swirl 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,30 +4,6 @@ module Swirl
4
4
 
5
5
  module Compactor
6
6
 
7
- Lists = [
8
- "keySet",
9
- "groupSet",
10
- "blockDeviceMapping",
11
- "instancesSet",
12
- "reservationSet",
13
- "imagesSet",
14
- "ownersSet",
15
- "executableBySet",
16
- "securityGroupSet",
17
- "ipPermissions",
18
- "ipRanges",
19
- "groups",
20
- "securityGroupInfo",
21
- "add",
22
- "remove",
23
- "launchPermission",
24
- "productCodes",
25
- "availabilityZoneSet",
26
- "availabilityZoneInfo",
27
- "publicIpsSet",
28
- "addressesSet"
29
- ]
30
-
31
7
  def compact(response)
32
8
  root_key = response.keys.first
33
9
  base = response[root_key]
@@ -38,8 +14,8 @@ module Swirl
38
14
  def compact!(data)
39
15
  data.inject({}) do |com, (key, value)|
40
16
  if value.is_a?(Hash)
41
- converted = if value.has_key?("item")
42
- items = value["item"]
17
+ converted = if value.has_key?("item") || value.has_key?("member")
18
+ items = value["item"] || value ["member"]
43
19
  items ||= []
44
20
  items = items.is_a?(Array) ? items : [items]
45
21
  items.map {|item| compact!(item) }
@@ -25,6 +25,13 @@ class CompactorTest < Test::Unit::TestCase
25
25
  assert_equal expected, Compactor.compact(response)
26
26
  end
27
27
 
28
+ test "pivots list keys on member" do
29
+ response = { "Foo" => { "groupSet" => { "member" => [{ "foo" => "bar" }] } } }
30
+ expected = { "groupSet" => [ { "foo" => "bar" } ] }
31
+
32
+ assert_equal expected, Compactor.compact(response)
33
+ end
34
+
28
35
  test "pivots list keys item and converts to Array not already an Array" do
29
36
  response = { "Foo" => { "groupSet" => { "item" => { "foo" => "bar" } } } }
30
37
  expected = { "groupSet" => [ { "foo" => "bar" } ] }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swirl
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 7
9
- - 0
10
- version: 1.7.0
9
+ - 1
10
+ version: 1.7.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Blake Mizerany