awesome_spawn 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -57,20 +57,22 @@ module AwesomeSpawn
57
57
  sanitize_associative_array(params.to_a)
58
58
  end
59
59
 
60
- def sanitize_associative_array(array)
61
- array.collect { |a| sanitize_item(a) }
60
+ def sanitize_associative_array(assoc_array)
61
+ assoc_array.each.with_object([]) do |item, array|
62
+ array.concat(sanitize_item(item))
63
+ end
62
64
  end
63
65
 
64
66
  def sanitize_item(item)
65
67
  case item
66
68
  when Array then sanitize_key_values(item[0], item[1..-1])
67
69
  when Hash then sanitize_associative_array(item.to_a)
68
- else sanitize_item([item])
70
+ else sanitize_key_values(item, [])
69
71
  end
70
72
  end
71
73
 
72
74
  def sanitize_key_values(key, values)
73
- [sanitize_key(key), *sanitize_value(values)]
75
+ [[sanitize_key(key), *sanitize_value(values)]]
74
76
  end
75
77
 
76
78
  KEY_REGEX = /^((?:--?)?)(.+?)(=?)$/
@@ -1,3 +1,3 @@
1
1
  module AwesomeSpawn
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -165,26 +165,30 @@ describe AwesomeSpawn::CommandLineBuilder do
165
165
  assert_params([["--", nil]], "--")
166
166
  end
167
167
 
168
- it "key alone" do
168
+ it "with key alone" do
169
169
  assert_params([["--abc"]], "--abc")
170
170
  end
171
171
 
172
- it "key as Symbol alone" do
172
+ it "with key as Symbol alone" do
173
173
  assert_params([[:abc]], "--abc")
174
174
  end
175
175
 
176
- it "key as a bareword" do
176
+ it "with key as a bareword" do
177
177
  assert_params(["--abc"], "--abc")
178
178
  end
179
179
 
180
- it "key as bareword Symbol" do
180
+ it "with key as bareword Symbol" do
181
181
  assert_params([:abc], "--abc")
182
182
  end
183
183
 
184
- it "value as a bareword" do
184
+ it "with value as a bareword" do
185
185
  assert_params(["abc"], "abc")
186
186
  end
187
187
 
188
+ it "with entry as a nested Hash" do
189
+ assert_params([{:abc_def= => "ghi"}], "--abc-def=ghi")
190
+ end
191
+
188
192
  it "with value as Symbol" do
189
193
  assert_params([["--abc" => :def]], "--abc def")
190
194
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awesome_spawn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-07-09 00:00:00.000000000 Z
15
+ date: 2014-07-17 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: bundler
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  version: '0'
125
125
  requirements: []
126
126
  rubyforge_project:
127
- rubygems_version: 1.8.23
127
+ rubygems_version: 1.8.23.2
128
128
  signing_key:
129
129
  specification_version: 3
130
130
  summary: AwesomeSpawn is a module that provides some useful features over Ruby's Kernel.spawn.
@@ -134,4 +134,3 @@ test_files:
134
134
  - spec/command_result_spec.rb
135
135
  - spec/spec_helper.rb
136
136
  - .rspec
137
- has_rdoc: