hal-client 3.5.1 → 3.6.0

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: 48fecd22d2b1db80b08257e47f4eabc59241b66b
4
- data.tar.gz: 1db19c11ab6e1b8916261b9092dcac95c09c6114
3
+ metadata.gz: 81cff13c5addef810f60d7f582893755f5c5002c
4
+ data.tar.gz: 50afe68ae72932b61422c8f0c784cbacc0058466
5
5
  SHA512:
6
- metadata.gz: 1520012e60a501afe54d0b8d03d46f16286ee7d0f5478408b52ffce06b7a8c3b8ca7ac7f6d22814f0a106a9ddd70deadc290f77d2e0895791f54a9dced948114
7
- data.tar.gz: 3ffd9b6ea7a6294f6edc12baaab6463a13ff1b439db55ac29c43efb4ead94789242ad2332a007c0ca5c6c7606083efefc1fe2b27a3e297ba5b34b83643792f18
6
+ metadata.gz: dd8b9912c0efaf36e53d58a0f36796df851d30ffd9ea3f78741d0c3c9cd20692f87f19163e21bbdd968cadb9bbb73a8a2ce1d0266ecb11aff990446d476afb77
7
+ data.tar.gz: d930ba6fc1f828b0120e296338c9e8386495531617d9a271212471c870d41470fb9f444ea14b6fdcf983b31e1bd9c15bf2ef601d96762ee08e009a592eee09d3
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.2"
@@ -238,6 +238,25 @@ class HalClient
238
238
  end
239
239
  alias_method :to_hal, :to_json
240
240
 
241
+ def hash
242
+ if href
243
+ href.hash
244
+ else
245
+ @raw.hash
246
+ end
247
+ end
248
+
249
+ def ==(other)
250
+ if href && other.respond_to?(:href)
251
+ href == other.href
252
+ elsif other.respond_to?(:raw)
253
+ @raw == other.raw
254
+ else
255
+ false
256
+ end
257
+ end
258
+ alias :eql? :==
259
+
241
260
  # Internal: Returns parsed json document
242
261
  def raw
243
262
  if @raw.nil? && @href
@@ -328,6 +347,5 @@ end
328
347
  end
329
348
 
330
349
  def_delegators :links, :namespaces
331
-
332
350
  end
333
351
  end
@@ -1,3 +1,3 @@
1
1
  class HalClient
2
- VERSION = "3.5.1"
2
+ VERSION = "3.6.0"
3
3
  end
@@ -112,6 +112,47 @@ HAL
112
112
  end
113
113
  end
114
114
 
115
+ context "equality and hash" do
116
+ let(:repr_same_href) { described_class.new(hal_client: a_client,
117
+ parsed_json: MultiJson.load(<<-HAL)) }
118
+ { "_links": { "self": { "href": "http://example.com/foo" } } }
119
+ HAL
120
+
121
+ let(:repr_diff_href) { described_class.new(hal_client: a_client,
122
+ parsed_json: MultiJson.load(<<-HAL)) }
123
+ { "_links": { "self": { "href": "http://DIFFERENT" } } }
124
+ HAL
125
+ let(:repr_no_href) { described_class.new(hal_client: a_client,
126
+ parsed_json: MultiJson.load(<<-HAL)) }
127
+ { }
128
+ HAL
129
+
130
+ describe "#==" do
131
+ specify { expect(repr == repr_same_href).to eq true }
132
+ specify { expect(repr == repr_diff_href).to eq false }
133
+ specify { expect(repr == repr_no_href).to eq false }
134
+ specify { expect(repr_no_href == repr).to eq false }
135
+ specify { expect(repr_no_href == repr_no_href).to eq true }
136
+ specify { expect(repr == Object.new).to eq false }
137
+ end
138
+
139
+ describe ".eql?" do
140
+ specify { expect(repr.eql? repr_same_href).to eq true }
141
+ specify { expect(repr.eql? repr_diff_href).to eq false }
142
+ specify { expect(repr.eql? repr_no_href).to eq false }
143
+ specify { expect(repr_no_href.eql? repr).to eq false }
144
+ specify { expect(repr_no_href.eql? repr_no_href).to eq true }
145
+ specify { expect(repr.eql? Object.new).to eq false }
146
+ end
147
+
148
+ describe "hash" do
149
+ specify{ expect(repr.hash).to eq repr.href.hash }
150
+ specify{ expect(repr_no_href.hash).to eq repr_no_href.raw.hash }
151
+ end
152
+ end
153
+
154
+
155
+
115
156
  specify { expect(repr.property "prop1").to eq 1 }
116
157
  specify { expect{repr.property "nonexistent-prop"}.to raise_exception KeyError }
117
158
 
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.5.1
4
+ version: 3.6.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: 2014-12-10 00:00:00.000000000 Z
11
+ date: 2015-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http