flexirest 1.7.8 → 1.7.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 392084cff2b3134307881a8e998b561ff49c8f5f3db22f5e6af4df495a8f8790
4
- data.tar.gz: cd6928e4802e733483ea04de70765f2d069181b1f445ccb1ba188a3d247d8908
3
+ metadata.gz: b0a27d77149e8eeba7815235367970828643b622a0925425c0cd2f18a12740dc
4
+ data.tar.gz: 6c12446837777d3bef7f37d6def7be613eeb98c380406a16f4e4f41e47ae0443
5
5
  SHA512:
6
- metadata.gz: 65c520be2d605b87e665599e9bcc0d5d59752c86aa5cf68d17273ec894832296b37058fa13c700a57214c3a8255edd306f789c679a203c2daad35c375bf9b55a
7
- data.tar.gz: f2dfcf7aa20f178d9dff64232577dc4a3810f77877d089ef85222ae78aa4c17df7ddc213691f8d104c8f8ff91a6f9e63e63097217ac56bc8e3f63da8b1ab9c82
6
+ metadata.gz: 722724ba195f14caa98a856beb93d527e1e69b8b16b247dc9bf4eabffb80f262ff930ba14bab9c01517bfcaf757e8c53f322f1efa454007ad3819d87214193e5
7
+ data.tar.gz: 779f448b1ed8c1f2f7244aa672b29e24496949088c3a4248c04a196336c79eeb8733691fd397521527b37ecdacc1368e6ae4345b6dfdeef374d4d56f6d9e58f3
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.7.9
4
+
5
+ Features:
6
+
7
+ - The `ignore_root` method now can ignore a tree of labels, rather than just one top level (thanks to gkosmr for the issue and pull request)
8
+
3
9
  ## 1.7.8
4
10
 
5
11
  Fix:
@@ -8,6 +8,14 @@ class Feed < Flexirest::Base
8
8
  end
9
9
  ```
10
10
 
11
+ This also works if you'd want to remove a tree of root nodes:
12
+
13
+ ```ruby
14
+ class Feed < Flexirest::Base
15
+ post :list, "/feed", ignore_root: ["feed", "items"]
16
+ end
17
+ ```
18
+
11
19
  Alternatively if you want to wrap your JSON request body in a root element, e.g.:
12
20
 
13
21
  ```json
@@ -740,12 +740,16 @@ module Flexirest
740
740
  end
741
741
 
742
742
  if options[:ignore_root]
743
- body = body[options[:ignore_root].to_s]
743
+ [options[:ignore_root]].flatten.each do |key|
744
+ body = body[key.to_s]
745
+ end
744
746
  end
745
747
  elsif is_xml_response?
746
748
  body = @response.body.blank? ? {} : Crack::XML.parse(@response.body)
747
749
  if options[:ignore_root]
748
- body = body[options[:ignore_root].to_s]
750
+ [options[:ignore_root]].flatten.each do |key|
751
+ body = body[key.to_s]
752
+ end
749
753
  elsif options[:ignore_xml_root]
750
754
  Flexirest::Logger.warn("Using `ignore_xml_root` is deprecated, please switch to `ignore_root`")
751
755
  body = body[options[:ignore_xml_root].to_s]
@@ -1,3 +1,3 @@
1
1
  module Flexirest
2
- VERSION = "1.7.8"
2
+ VERSION = "1.7.9"
3
3
  end
@@ -164,6 +164,20 @@ describe Flexirest::Request do
164
164
  }
165
165
  end
166
166
 
167
+ class IgnoredMultiLevelRootExampleClient < ExampleClient
168
+ get :multi_level_root, "/multi-level-root", ignore_root: [:response, "data", "object"], fake: %Q{
169
+ {
170
+ "response": {
171
+ "data": {
172
+ "object": {
173
+ "title": "Example Multi Level Feed"
174
+ }
175
+ }
176
+ }
177
+ }
178
+ }
179
+ end
180
+
167
181
  class WhitelistedDateClient < Flexirest::Base
168
182
  base_url "http://www.example.com"
169
183
  put :conversion, "/put/:id"
@@ -1123,6 +1137,10 @@ describe Flexirest::Request do
1123
1137
  it "should ignore a specified root element" do
1124
1138
  expect(IgnoredRootExampleClient.root.title).to eq("Example Feed")
1125
1139
  end
1140
+
1141
+ it "should ignore a specified multi-level root element" do
1142
+ expect(IgnoredMultiLevelRootExampleClient.multi_level_root.title).to eq("Example Multi Level Feed")
1143
+ end
1126
1144
 
1127
1145
  context "Parameter preparation" do
1128
1146
  method = {url: "http://www.example.com", method: :get}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flexirest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.8
4
+ version: 1.7.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jeffries
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-07 00:00:00.000000000 Z
11
+ date: 2019-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler