-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add simplified syntax for hash and array #875
Conversation
* to specify values with very simple comma (and colon for key-value separator) * to re-format values because comma-separated values doesn't have type information It looks to satisfy various use-cases of 3rd party plugins, and this change is just additional change to allow format which is currently denied as ConfigError.
This change is exclusive with #874 |
I prefer this than #874 |
@@ -124,10 +124,33 @@ class TestConfigTypes < ::Test::Unit::TestCase | |||
|
|||
test 'hash' do | |||
assert_equal({"x"=>"v","k"=>1}, Config::HASH_TYPE.call('{"x":"v","k":1}', {})) | |||
assert_equal({"x"=>"v","k"=>"1"}, Config::HASH_TYPE.call('x:v,k:1', {})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test a hash with , surrounded by spaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -80,19 +80,58 @@ def self.bool_value(str) | |||
SIZE_TYPE = Proc.new { |val, opts| Config.size_value(val) } | |||
BOOL_TYPE = Proc.new { |val, opts| Config.bool_value(val) } | |||
TIME_TYPE = Proc.new { |val, opts| Config.time_value(val) } | |||
|
|||
REFORMAT_VALUES = ->(type, value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why REFORMAT_VALUES
? REFORMAT_VALUE
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed to REFORMAT_VALUE
Merged. |
It looks to satisfy various use-cases of 3rd party plugins, and this change is just additional
change to allow format which is currently denied as ConfigError.