flexirest 1.7.8 → 1.7.9
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/docs/root-elements.md +8 -0
- data/lib/flexirest/request.rb +6 -2
- data/lib/flexirest/version.rb +1 -1
- data/spec/lib/request_spec.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0a27d77149e8eeba7815235367970828643b622a0925425c0cd2f18a12740dc
|
4
|
+
data.tar.gz: 6c12446837777d3bef7f37d6def7be613eeb98c380406a16f4e4f41e47ae0443
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 722724ba195f14caa98a856beb93d527e1e69b8b16b247dc9bf4eabffb80f262ff930ba14bab9c01517bfcaf757e8c53f322f1efa454007ad3819d87214193e5
|
7
|
+
data.tar.gz: 779f448b1ed8c1f2f7244aa672b29e24496949088c3a4248c04a196336c79eeb8733691fd397521527b37ecdacc1368e6ae4345b6dfdeef374d4d56f6d9e58f3
|
data/CHANGELOG.md
CHANGED
data/docs/root-elements.md
CHANGED
@@ -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
|
data/lib/flexirest/request.rb
CHANGED
@@ -740,12 +740,16 @@ module Flexirest
|
|
740
740
|
end
|
741
741
|
|
742
742
|
if options[:ignore_root]
|
743
|
-
|
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
|
-
|
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]
|
data/lib/flexirest/version.rb
CHANGED
data/spec/lib/request_spec.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2019-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|