pmp 0.3.0 → 0.3.1
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/README.md +5 -5
- data/lib/pmp/parser.rb +1 -3
- data/lib/pmp/version.rb +1 -1
- data/spec/collection_document_spec.rb +1 -1
- data/spec/parser_spec.rb +7 -1
- 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: 0b9a3cf98758bb112dbae4f1e223154c9cdb3c43
|
4
|
+
data.tar.gz: a83d94d1c25c7e65fb3e954a4a5908be9856140f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2aa7841f42db0ef4270c7b4e7ec1a03e3bd0019089c34e8feb4a74f96181a405eb79467ee74772e97524a8b061fd680dbf91d754a80b859bcd967c896277821c
|
7
|
+
data.tar.gz: 2d84a7b41dfeab0e23e8629bc1679db4b217ba2701f154e86d20404a4c33b250e74a15efcfa621fcbf66c2eea1d8f92c2c9df697a29965e1c915dd5934b9cc8f
|
data/README.md
CHANGED
@@ -78,17 +78,17 @@ puts root.links.keys.sort
|
|
78
78
|
puts pmp.links.keys.sort
|
79
79
|
> ["creator", "edit", "navigation", "query"]
|
80
80
|
|
81
|
-
# want to get the creator link?
|
82
|
-
puts pmp.links["creator"]
|
81
|
+
# want to get the creator link? (N.B. following a link always returns an Array, note use of `first`):
|
82
|
+
puts pmp.links["creator"].first
|
83
83
|
> #<PMP::Link href="https://api-sandbox.pmp.io/docs/af676335-21df-4486-ab43-e88c1b48f026">
|
84
84
|
|
85
85
|
# get the same thing as a method
|
86
|
-
puts pmp.creator
|
86
|
+
puts pmp.creator.first
|
87
87
|
> #<PMP::Link href="https://api-sandbox.pmp.io/docs/af676335-21df-4486-ab43-e88c1b48f026">
|
88
88
|
|
89
89
|
# like the root doc itself, this is lazy loaded
|
90
90
|
# but ask for an attribute on there, and you'll get the doc loaded up
|
91
|
-
puts pmp.creator.guid
|
91
|
+
puts pmp.creator.first.guid
|
92
92
|
|
93
93
|
#### http get request to link href occurs, loads info about the creator
|
94
94
|
> 'af676335-21df-4486-ab43-e88c1b48f026'
|
@@ -109,7 +109,7 @@ doc.save
|
|
109
109
|
guid = doc.guid
|
110
110
|
|
111
111
|
# how about the link to self
|
112
|
-
self_href = doc.self.href
|
112
|
+
self_href = doc.self.first.href
|
113
113
|
|
114
114
|
# get a new doc using self, could just have used the link, this is a bad example perhaps
|
115
115
|
doc = PMP::CollectionDocument.new(href: self_href)
|
data/lib/pmp/parser.rb
CHANGED
data/lib/pmp/version.rb
CHANGED
@@ -74,7 +74,7 @@ describe PMP::CollectionDocument do
|
|
74
74
|
|
75
75
|
it "should serialize to collection.doc+json" do
|
76
76
|
@doc = PMP::CollectionDocument.new(document: json_fixture(:collection_basic))
|
77
|
-
@doc.to_json.must_equal '{"version":"1.0","links":{"profile":[{"href":"http://api-sandbox.pmp.io/profiles/story"}],"self":[{"href":"http://api-sandbox.pmp.io/docs/f84e9018-5c21-4b32-93f8-d519308620f0"}],"collection":[{"href":"http://api-sandbox.pmp.io/docs/"}]},"attributes":{"guid":"f84e9018-5c21-4b32-93f8-d519308620f0","title":"Peers Find Less Pressure Borrowing From Each Other","published":"2013-05-10T15:17:00.598Z","valid":{"from":"2013-05-10T15:17:00.598Z","to":"2213-05-10T15:17:00.598Z"},"byline":"by SOME PERSON","hreflang":"en","description":"","contentencoded":"...","contenttemplated":"..."}}'
|
77
|
+
@doc.to_json.must_equal '{"version":"1.0","links":{"profile":[{"href":"http://api-sandbox.pmp.io/profiles/story"}],"self":[{"href":"http://api-sandbox.pmp.io/docs/f84e9018-5c21-4b32-93f8-d519308620f0"}],"collection":[{"href":"http://api-sandbox.pmp.io/docs/"}],"queries":[],"edit-form":[]},"attributes":{"guid":"f84e9018-5c21-4b32-93f8-d519308620f0","title":"Peers Find Less Pressure Borrowing From Each Other","published":"2013-05-10T15:17:00.598Z","valid":{"from":"2013-05-10T15:17:00.598Z","to":"2213-05-10T15:17:00.598Z"},"byline":"by SOME PERSON","hreflang":"en","description":"","contentencoded":"...","contenttemplated":"..."}}'
|
78
78
|
end
|
79
79
|
|
80
80
|
it "provides list of attributes (not links)" do
|
data/spec/parser_spec.rb
CHANGED
@@ -34,6 +34,12 @@ describe PMP::Parser do
|
|
34
34
|
tc.links['self'].href.must_equal "http://api-sandbox.pmp.io/docs/f84e9018-5c21-4b32-93f8-d519308620f0"
|
35
35
|
end
|
36
36
|
|
37
|
+
it "will parse empty arrays into empty arrays" do
|
38
|
+
tc = TestParser.new
|
39
|
+
tc.parse(json_fixture(:collection_links))
|
40
|
+
tc.links['edit-form'].must_equal Array.new
|
41
|
+
end
|
42
|
+
|
37
43
|
it "will un-parse to hash for json serialization" do
|
38
44
|
tc = TestParser.new
|
39
45
|
tc.parse(json_fixture(:collection_basic))
|
@@ -41,7 +47,7 @@ describe PMP::Parser do
|
|
41
47
|
# puts "basic as_json: #{hash}"
|
42
48
|
hash.keys.sort.must_equal ['attributes', 'links', 'version']
|
43
49
|
hash['attributes']['guid'].must_equal "f84e9018-5c21-4b32-93f8-d519308620f0"
|
44
|
-
hash['links'].keys.sort.must_equal ["collection", "profile", "self"]
|
50
|
+
hash['links'].keys.sort.must_equal ["collection", "edit-form", "profile", "queries", "self"]
|
45
51
|
end
|
46
52
|
|
47
53
|
it "parses query links into a hash based on rels" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pmp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kuklewicz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|