active_rest_client 1.1.9 → 1.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +55 -0
- data/lib/active_rest_client/version.rb +1 -1
- data/spec/lib/xml_spec.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 766e4e62410954391fd9831d0094365c87a13fc8
|
4
|
+
data.tar.gz: fd72f55e816449ce6e09b530259f01b345ae99c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b770984b2b632d6b5bedf7169def7153c8208f416d6725da64386bcdcd74b485fbb89c97d070c9b208b5ebadc38af3d124ffd878176d9ab2392e531e943b5cdd
|
7
|
+
data.tar.gz: d71c3d0c69bdce2431e82323450d52bd18fcf6a22765bdfebc3b48208f9ef8640f2a2390250069c479a390257f498bc4ca268787c851674bd5a20ebdbab95de0
|
data/README.md
CHANGED
@@ -760,6 +760,61 @@ class Article < ActiveRestClient::Base
|
|
760
760
|
end
|
761
761
|
```
|
762
762
|
|
763
|
+
## Beta Features
|
764
|
+
|
765
|
+
### XML Responses
|
766
|
+
|
767
|
+
ActiveRestClient uses Crack to allow parsing of XML responses. For example, given an XML response of (with a content type of `application/xml` or `text/xml`):
|
768
|
+
|
769
|
+
```xml
|
770
|
+
<?xml version="1.0" encoding="utf-8"?>
|
771
|
+
<feed xmlns="http://www.w3.org/2005/Atom">
|
772
|
+
|
773
|
+
<title>Example Feed</title>
|
774
|
+
<link href="http://example.org/"/>
|
775
|
+
<updated>2003-12-13T18:30:02Z</updated>
|
776
|
+
<author>
|
777
|
+
<name>John Doe</name>
|
778
|
+
</author>
|
779
|
+
<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
|
780
|
+
|
781
|
+
<entry>
|
782
|
+
<title>Atom-Powered Robots Run Amok</title>
|
783
|
+
<link href="http://example.org/2003/12/13/atom03"/>
|
784
|
+
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
|
785
|
+
<updated>2003-12-13T18:30:02Z</updated>
|
786
|
+
<summary>Some text.</summary>
|
787
|
+
</entry>
|
788
|
+
|
789
|
+
<entry>
|
790
|
+
<title>Something else cool happened</title>
|
791
|
+
<link href="http://example.org/2015/08/11/andyjeffries"/>
|
792
|
+
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6b</id>
|
793
|
+
<updated>2015-08-11T18:30:02Z</updated>
|
794
|
+
<summary>Some other text.</summary>
|
795
|
+
</entry>
|
796
|
+
|
797
|
+
</feed>
|
798
|
+
```
|
799
|
+
|
800
|
+
You can use:
|
801
|
+
|
802
|
+
```ruby
|
803
|
+
class Feed < ActiveRestClient::Base
|
804
|
+
base_url "http://www.example.com/v1/"
|
805
|
+
get :atom, "/atom"
|
806
|
+
end
|
807
|
+
|
808
|
+
@atom = Feed.atom
|
809
|
+
|
810
|
+
puts @atom.feed.title
|
811
|
+
puts @atom.feed.link.href
|
812
|
+
@atom.feed.entry.each do |entry|
|
813
|
+
puts "#{entry.title} -> #{entry.link.href}"
|
814
|
+
end
|
815
|
+
```
|
816
|
+
|
817
|
+
For testing purposes, if you are using a `fake` content response when defining your endpoint, you should also provide `fake_content_type: "application/xml"` so that the parser knows to use XML parsing.
|
763
818
|
|
764
819
|
## Contributing
|
765
820
|
|
data/spec/lib/xml_spec.rb
CHANGED
@@ -45,6 +45,11 @@ describe XmlResponseExample do
|
|
45
45
|
expect(@atom.feed.title).to eq("Example Feed")
|
46
46
|
end
|
47
47
|
|
48
|
+
it "provides the link's href" do
|
49
|
+
@atom = XmlResponseExample.atom
|
50
|
+
expect(@atom.feed.link.href).to eq("http://example.org/")
|
51
|
+
end
|
52
|
+
|
48
53
|
it "each entry item has a title" do
|
49
54
|
@atom = XmlResponseExample.atom
|
50
55
|
expect(@atom.feed.entry.class).to eq(ActiveRestClient::ResultIterator)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_rest_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Which Ltd
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-08-
|
12
|
+
date: 2015-08-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|