hal-client 3.17.0 → 3.17.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c738c6f35a8c627363d55bde0e10116bf46eb1b
4
- data.tar.gz: 32b562905f475064e94fbf2128222292dc44bc4c
3
+ metadata.gz: 5d2c194b53f031309d1fa2380dddfd3496543ae0
4
+ data.tar.gz: de974dcd0f45301ad37dda8122dac62a1321628f
5
5
  SHA512:
6
- metadata.gz: cf65e375001c9c167d557fe6345c58cdb07d5d70d63da052d7ce82392f9805002cbe6e91c703879fbe3f3c7cede65a2c88a74cf0943fa7fd4e825ad52541a263
7
- data.tar.gz: 6749283d49cc6f3aa0ae7f37e5aeda09c08ad875d4206a8250fbac21200ca7afc09e42a6388bdd392bb8e667b88b574751771f1d6275e92892d725a663b9a9c9
6
+ metadata.gz: c0aba01ccd2098a6f324c6054645a8af63555ed468f12c428e4a9da09e9b4c48956c4006828869deda0083a513c531579a6d3c0dab9b9ce061f1c541b71dd060
7
+ data.tar.gz: b43cd1474e4121bb48eeda832b3c8cd54c2f4d5b1049510cb758298d410457f616715879b0f94d44cfc4474cfee3a360ac9d1fe6f9dec2f13705c67ad8097192
@@ -56,6 +56,7 @@ class HalClient
56
56
 
57
57
  rel = hash_entry[:rel]
58
58
  hash_data = hash_entry[:data]
59
+ return nil unless hash_data['href']
59
60
  href = (base_url + hash_data['href']).to_s
60
61
 
61
62
  if hash_data['templated']
@@ -50,6 +50,7 @@ class HalClient
50
50
  def resolve_to_url(link)
51
51
  (fail HalClient::InvalidRepresentationError) unless link.respond_to? :fetch
52
52
 
53
+ return nil unless link.fetch("href")
53
54
  url = base_url + link.fetch("href")
54
55
  is_templated = link.fetch("templated", false)
55
56
 
@@ -367,7 +367,7 @@ class HalClient
367
367
  default_proc ||= NO_LINK_FOUND
368
368
 
369
369
  relations = links.hrefs(link_rel) { MISSING }
370
- return default_proc.call(link_rel, options) if relations == MISSING
370
+ return default_proc.call(link_rel, options) if relations == MISSING || relations.compact.empty?
371
371
 
372
372
  relations
373
373
  .map {|url_or_tmpl|
@@ -1,3 +1,3 @@
1
1
  class HalClient
2
- VERSION = "3.17.0"
2
+ VERSION = "3.17.1"
3
3
  end
@@ -49,6 +49,18 @@ RSpec.describe HalClient::Link do
49
49
  base_url: base_url)
50
50
  expect(my_link.raw_href).to eq((base_url + relative_href_1).to_s)
51
51
  end
52
+
53
+ it "handles hrefs with a nil value" do
54
+ input_hash = link_entry_hash(href: nil)
55
+ base_url = Addressable::URI.parse(href_1)
56
+
57
+ my_link = described_class.new_from_link_entry(hash_entry: input_hash,
58
+ hal_client: a_client,
59
+ curie_resolver: curie_resolver,
60
+ base_url: base_url)
61
+
62
+ expect(my_link.raw_href).to eq(base_url.to_s)
63
+ end
52
64
  end
53
65
 
54
66
  describe ".new_from_embedded_entry" do
@@ -30,6 +30,9 @@ RSpec.describe HalClient::LinksSection, "namespaces embedded" do
30
30
 
31
31
  specify { expect{section.hrefs("nonexistent")}.to raise_error KeyError }
32
32
 
33
+ specify { expect(section.hrefs("nil_href"))
34
+ .to contain_exactly nil }
35
+
33
36
  let(:fully_qualified_first_rel) { "http://rels.example.com/first" }
34
37
  let(:fully_qualified_second_rel) { "http://rels.example.com/2/second" }
35
38
 
@@ -45,6 +48,7 @@ RSpec.describe HalClient::LinksSection, "namespaces embedded" do
45
48
  "ns1:first" => {"href" => "http://example.com/foo"},
46
49
  "ns2:second" => [{"href" => "http://example.com/bar"},
47
50
  {"href" => "http://example.com/baz"}],
51
+ "nil_href" => {"href" => nil},
48
52
  "next" => {"href" => "/foo?p=2"}
49
53
  } }
50
54
 
@@ -11,6 +11,7 @@ RSpec.describe HalClient::Representation do
11
11
  ,"templated": true }
12
12
  ,"link3": [{ "href": "http://example.com/link3-a" }
13
13
  ,{ "href": "http://example.com/link3-b" }]
14
+ ,"nil_link": { "href": null }
14
15
  ,"dup": { "href": "http://example.com/dup" }
15
16
  }
16
17
  ,"_embedded": {
@@ -301,6 +302,7 @@ HAL
301
302
 
302
303
  specify { expect(subject.has_related? "no-such-link-or-embed").to be false }
303
304
  specify { expect(subject.related? "no-such-link-or-embed").to be false }
305
+ specify { expect(subject.related? "nil_link").to be false }
304
306
 
305
307
  specify { expect(subject.to_json).to be_equivalent_json_to raw_repr }
306
308
  specify { expect(subject.to_hal).to be_equivalent_json_to raw_repr }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hal-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.17.0
4
+ version: 3.17.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-08 00:00:00.000000000 Z
11
+ date: 2016-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http