hal-client 3.7.0 → 3.8.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa71061de205b5ea4b0a5eabe170f105eec8f0fc
|
4
|
+
data.tar.gz: 5ad722a314c80c75e840709f96daccc1f644e902
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bf075feeccb75b8f3b09a2c3ce9f42167f2519d5207f34c13e36b618ab410092b9a0874d2fb1f56f33dc336284f24db1064620b77f57732860ab1d3aeee4dba
|
7
|
+
data.tar.gz: 9c03d6184f359e014d3a354012b07220b436ad717159366db0d066d0ff9aa3b3f0f0140c2bd3a45416281ac224144fa8ab81d406ba69e4fb796e3bd091332ae5
|
@@ -90,7 +90,7 @@ class HalClient
|
|
90
90
|
# :templated - is this link templated? Default: false
|
91
91
|
def add_link(rel, target, opts={})
|
92
92
|
templated = opts.fetch(:templated, false)
|
93
|
-
|
93
|
+
|
94
94
|
link_obj = { "href" => target.to_s }
|
95
95
|
link_obj = link_obj.merge("templated" => true) if templated
|
96
96
|
|
@@ -100,6 +100,15 @@ class HalClient
|
|
100
100
|
self.class.new(orig_repr, raw.merge("_links" => updated_links_section))
|
101
101
|
end
|
102
102
|
|
103
|
+
# Returns a RepresentationEditor exactly like this one except that
|
104
|
+
# is has an new or overwritten property value
|
105
|
+
#
|
106
|
+
# key - The name of the property
|
107
|
+
# value - Value to place in the property
|
108
|
+
def set_property(key, value)
|
109
|
+
self.class.new(orig_repr, raw.merge(key => value))
|
110
|
+
end
|
111
|
+
|
103
112
|
protected
|
104
113
|
|
105
114
|
attr_reader :orig_repr, :raw
|
data/lib/hal_client/version.rb
CHANGED
@@ -82,6 +82,18 @@ RSpec.describe HalClient::RepresentationEditor do
|
|
82
82
|
|
83
83
|
end
|
84
84
|
|
85
|
+
describe "#set_property" do
|
86
|
+
it "adds brand new property" do
|
87
|
+
expect(subject.set_property("name", "new-name"))
|
88
|
+
.to have_property("name", "new-name")
|
89
|
+
end
|
90
|
+
|
91
|
+
it "overwrites any previous value in the property" do
|
92
|
+
expect(subject).to have_property("age", 10)
|
93
|
+
expect(subject.set_property("age", 20)).to have_property("age", 20)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
85
97
|
describe "#add_link" do
|
86
98
|
it "adds brand new link rel" do
|
87
99
|
expect(subject.add_link("related", "http://example.com/third"))
|
@@ -108,7 +120,8 @@ RSpec.describe HalClient::RepresentationEditor do
|
|
108
120
|
.new(parsed_json: MultiJson.load(raw_hal)) }
|
109
121
|
|
110
122
|
let(:raw_hal) { <<-HAL }
|
111
|
-
{ "
|
123
|
+
{ "age": 10
|
124
|
+
,"_links": {
|
112
125
|
"self" : { "href": "http://example.com/a_repr" }
|
113
126
|
,"up" : [{ "href": "http://example.com/c1" },
|
114
127
|
{ "href": "http://example.com/c2" }]
|
@@ -152,6 +165,13 @@ RSpec.describe HalClient::RepresentationEditor do
|
|
152
165
|
end
|
153
166
|
end
|
154
167
|
|
168
|
+
matcher :have_property do |key, value|
|
169
|
+
match do |actual_json|
|
170
|
+
parsed = MultiJson.load(actual_json.to_hal)
|
171
|
+
expect(parsed[key]).to eq value
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
155
175
|
matcher :have_embedded do |expected_rel, expected_target=ANYTHING|
|
156
176
|
match do |actual_json|
|
157
177
|
parsed = MultiJson.load(actual_json.to_hal)
|
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.
|
4
|
+
version: 3.8.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-
|
11
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|