swirl 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -18,6 +18,14 @@ is `expand`ed to:
18
18
 
19
19
  { "InstanceId.0" => "i-123k2h1", "InstanceId.1" => "i-0234d3" }
20
20
 
21
+ in the case that `.n` isn't at the end of the key:
22
+
23
+ { "Foo.#.Bar" => ["a", "b"] }
24
+
25
+ is `expand`ed to:
26
+
27
+ { "Foo.0.Bar" => "a", "Foo.1.Bar" => "b" }
28
+
21
29
  and
22
30
 
23
31
  # Output
data/lib/swirl/helpers.rb CHANGED
@@ -66,8 +66,9 @@ module Swirl
66
66
 
67
67
  case value
68
68
  when Array
69
+ key = "#{key}.#" if key !~ /#/
69
70
  value.each_with_index do |val, n|
70
- exp["#{key}.#{n}"] = val
71
+ exp[key.gsub("#", n.to_s)] = val
71
72
  end
72
73
  when Range
73
74
  exp["From#{key}"] = value.min
@@ -29,6 +29,18 @@ class ExpanderTest < Test::Unit::TestCase
29
29
  assert_equal expected, Expander.expand(request)
30
30
  end
31
31
 
32
+ test "expands keys with # and Array values to .n. key-values" do
33
+ request = { "foo.#.bar" => ["foo", "bar", "baz"] }
34
+
35
+ expected = {
36
+ "foo.0.bar" => "foo",
37
+ "foo.1.bar" => "bar",
38
+ "foo.2.bar" => "baz"
39
+ }
40
+
41
+ assert_equal expected, Expander.expand(request)
42
+ end
43
+
32
44
  test "ignores empty Array values" do
33
45
  request = { "group" => [] }
34
46
  expected = {}
metadata CHANGED
@@ -1,7 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swirl
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.0"
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 1
8
+ version: "1.1"
5
9
  platform: ruby
6
10
  authors:
7
11
  - Blake Mizerany
@@ -14,34 +18,46 @@ default_executable:
14
18
  dependencies:
15
19
  - !ruby/object:Gem::Dependency
16
20
  name: crack
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
21
+ prerelease: false
22
+ requirement: &id001 !ruby/object:Gem::Requirement
20
23
  requirements:
21
24
  - - ">="
22
25
  - !ruby/object:Gem::Version
26
+ segments:
27
+ - 0
28
+ - 1
29
+ - 4
23
30
  version: 0.1.4
24
- version:
31
+ type: :runtime
32
+ version_requirements: *id001
25
33
  - !ruby/object:Gem::Dependency
26
34
  name: ruby-hmac
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
30
37
  requirements:
31
38
  - - ">="
32
39
  - !ruby/object:Gem::Version
40
+ segments:
41
+ - 0
42
+ - 3
43
+ - 2
33
44
  version: 0.3.2
34
- version:
45
+ type: :runtime
46
+ version_requirements: *id002
35
47
  - !ruby/object:Gem::Dependency
36
48
  name: contest
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
49
+ prerelease: false
50
+ requirement: &id003 !ruby/object:Gem::Requirement
40
51
  requirements:
41
52
  - - ">="
42
53
  - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
56
+ - 1
57
+ - 2
43
58
  version: 0.1.2
44
- version:
59
+ type: :development
60
+ version_requirements: *id003
45
61
  description: A version agnostic EC2 ruby driver
46
62
  email:
47
63
  executables:
@@ -80,18 +96,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
80
96
  requirements:
81
97
  - - ">="
82
98
  - !ruby/object:Gem::Version
99
+ segments:
100
+ - 0
83
101
  version: "0"
84
- version:
85
102
  required_rubygems_version: !ruby/object:Gem::Requirement
86
103
  requirements:
87
104
  - - ">="
88
105
  - !ruby/object:Gem::Version
106
+ segments:
107
+ - 0
89
108
  version: "0"
90
- version:
91
109
  requirements: []
92
110
 
93
111
  rubyforge_project: swirl
94
- rubygems_version: 1.3.5
112
+ rubygems_version: 1.3.6
95
113
  signing_key:
96
114
  specification_version: 2
97
115
  summary: A version agnostic EC2 ruby driver