parameters 0.4.3 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,8 @@
1
+ ### 0.4.4 / 2012-06-16
2
+
3
+ * {Parameters::Options} now correctly parses escaped `\:` characters for Hash
4
+ parameters.
5
+
1
6
  ### 0.4.3 / 2012-06-11
2
7
 
3
8
  * Allow defaulting Boolean parameters to `false`.
@@ -209,9 +209,13 @@ module Parameters
209
209
  end
210
210
 
211
211
  # accept pattern for Hashes
212
- OptionParser.accept(Hash, /[^\s:]*:[^\s:]*(\s+[^\s:]*:[^\s:])*/) do |s,|
212
+ OptionParser.accept(Hash, /((?:\\.|[^\\:])*):((?:\\.|[^\\:])*)/) do |s,k,v|
213
213
  if s
214
- Hash[s.split.map { |key_value| key_value.split(':',2) }]
214
+ unescape = lambda { |string|
215
+ string.gsub(/\\./) { |match| match[1,1] }
216
+ }
217
+
218
+ {unescape[k] => unescape[v]}
215
219
  end
216
220
  end
217
221
 
@@ -1,4 +1,4 @@
1
1
  module Parameters
2
2
  # The version of parameters
3
- VERSION = '0.4.3'
3
+ VERSION = '0.4.4'
4
4
  end
@@ -123,6 +123,14 @@ describe Parameters::Options do
123
123
 
124
124
  object.mapping.should == hash
125
125
  end
126
+
127
+ it "should accept 'foo\\:bar:baz pairs" do
128
+ hash = {:"foo:bar" => 1}
129
+
130
+ subject.parse(['--mapping', "foo\\:bar:1"])
131
+
132
+ object.mapping.should == hash
133
+ end
126
134
 
127
135
  it "should reject non 'key:value' pairs" do
128
136
  lambda {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parameters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-12 00:00:00.000000000 Z
12
+ date: 2012-06-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubygems-tasks