hal-interpretation 1.6.0 → 1.7.0

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
  SHA1:
3
- metadata.gz: cea8a51625a140b91f33d23ff8cdce60d2748ebf
4
- data.tar.gz: fbcd0ddd428b0114b9e1bf5b506fa6843c8fcda6
3
+ metadata.gz: ee39c1fec5913e271d4fab7531f9ff40b6623dc9
4
+ data.tar.gz: 5c21413e4a4be9e30d16eb3cc8e6a00644154731
5
5
  SHA512:
6
- metadata.gz: ef35522580e2014518d56d1c7c5004d9724ccc026435c27a65fd06c1128ec4b162522c3daba84fc947ec4ddd58890775805203f584bec4b13f64dc5a254725b9
7
- data.tar.gz: efbe0228c3e4b8dbb22ed2a05adf28f6c0d7a80632f7d8d395b658d6f823b3f77c2e124c8ce431d6be5f362f860b0577ac0189a3eca8dc009fc96f6b126cfd9f
6
+ metadata.gz: 7cbe1d536193dd6f563c43823b7828ebe5975ba039201b5189960b033f12dfb72c04b767a95e8765c21736e661aee117b64fb95f769afc4f38fa7f626255ee01
7
+ data.tar.gz: eb3d579ce01aea81b727c59df2457c509765759ef0bc884492afe3adf57d746de99a43a639c2c44f0b95c6fcf5c998020189f8e0cb62552065c5ab4754ac5f8f
data/.travis.yml CHANGED
@@ -1,3 +1,5 @@
1
+ sudo: false
2
+ cache: bundler
1
3
  language: ruby
2
4
  rvm:
3
5
  - "1.9.3"
@@ -106,8 +106,16 @@ module HalInterpretation
106
106
  rel = opts.fetch(:rel) { attr_name }.to_s
107
107
  path = "/_links/" + json_path_escape(rel)
108
108
 
109
+ stringify_href = ->(string_or_uri_tmpl) {
110
+ if string_or_uri_tmpl.respond_to? :pattern
111
+ string_or_uri_tmpl.pattern
112
+ else
113
+ string_or_uri_tmpl.to_str
114
+ end
115
+ }
116
+
109
117
  extract attr_name, from: path,
110
- with: ->(r){ r.related_hrefs(rel){[]} },
118
+ with: ->(r){ r.raw_related_hrefs(rel){[]}.map &stringify_href },
111
119
  coercion: opts[:coercion]
112
120
  end
113
121
 
@@ -1,3 +1,3 @@
1
1
  module HalInterpretation
2
- VERSION = "1.6.0"
2
+ VERSION = "1.7.0"
3
3
  end
@@ -11,11 +11,12 @@ describe HalInterpretation do
11
11
  item_class test_item_class
12
12
  extract :name
13
13
  extract :latitude, from: "/geo/latitude"
14
+ extract :bday, coercion: ->(val){ Time.parse(val) }
15
+ extract :seq, with: ->(_) { next_seq_num }
14
16
  extract_link :up
15
17
  extract_links :friend_ids, rel: "http://xmlns.com/foaf/0.1/knows",
16
18
  coercion: ->(urls) { urls.map{|u| u.split("/").last } }
17
- extract :bday, coercion: ->(val){ Time.parse(val) }
18
- extract :seq, with: ->(_) { next_seq_num }
19
+ extract_link :archives_url_tmpl, rel: "archives"
19
20
 
20
21
  def initialize(*args)
21
22
  @cur_seq_num = 0
@@ -43,7 +44,11 @@ describe HalInterpretation do
43
44
  "http://xmlns.com/foaf/0.1/knows": [
44
45
  { "href": "http://example.com/bob" },
45
46
  { "href": "http://example.com/alice" }
46
- ]
47
+ ],
48
+ "archives": {
49
+ "href": "http://example.com/old{?since,until}",
50
+ "templated": true
51
+ }
47
52
  }
48
53
  }
49
54
  JSON
@@ -56,6 +61,8 @@ describe HalInterpretation do
56
61
  specify { expect(interpreter.item.bday).to eq Time.utc(2013,12,11,10,9,8) }
57
62
  specify { expect(interpreter.item.seq).to eq 1 }
58
63
  specify { expect(interpreter.item.friend_ids).to eq ["bob", "alice"] }
64
+ specify { expect(interpreter.item.archives_url_tmpl)
65
+ .to eq "http://example.com/old{?since,until}" }
59
66
 
60
67
  specify { expect(interpreter.problems).to be_empty }
61
68
 
@@ -271,7 +278,8 @@ describe HalInterpretation do
271
278
  let(:test_item_class) { Class.new do
272
279
  include ActiveModel::Validations
273
280
 
274
- attr_accessor :name, :latitude, :up, :bday, :seq, :hair, :friend_ids
281
+ attr_accessor :name, :latitude, :up, :bday, :seq, :hair, :friend_ids,
282
+ :archives_url_tmpl
275
283
 
276
284
  def initialize
277
285
  yield self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hal-interpretation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-06 00:00:00.000000000 Z
11
+ date: 2015-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hal-client