bound 2.1.2 → 2.2.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 +4 -4
- data/README.md +9 -0
- data/lib/bound.rb +3 -2
- data/lib/bound/errors.rb +5 -0
- data/lib/bound/version.rb +1 -1
- data/spec/bound_spec.rb +5 -5
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e611bbeb3b6f8b649efc18a6ef08e37acf5f088
|
4
|
+
data.tar.gz: ed887777475b4e99ece4bc304c1c95478ef4060b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04725dd9df62aa9ae9a4044831ed2edf41c77c6e7249377f9ecc2441085f5492ff7e3ff89bf77589d903c42dc271604229301bf95af43452b7d0d832fa9c1c8e
|
7
|
+
data.tar.gz: cb08fd0d64f330182f3b964445b237cccd759d27bc6c792b8791c33a3a53be82e7cd34082cac5038331b996bc9be8dfcae7ea6af7d441de49fe333c1ed051c39
|
data/README.md
CHANGED
@@ -150,3 +150,12 @@ Because of legacy software we also support some older versions:
|
|
150
150
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
151
151
|
4. Push to the branch (`git push origin my-new-feature`)
|
152
152
|
5. Create new Pull Request
|
153
|
+
|
154
|
+
## Release
|
155
|
+
|
156
|
+
```
|
157
|
+
# Bump version
|
158
|
+
edit lib/bound/version.rb
|
159
|
+
git commit -am "Bump to version X.Y.Z"
|
160
|
+
rake release
|
161
|
+
```
|
data/lib/bound.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "bound/version"
|
2
2
|
require "bound/caller"
|
3
|
+
require "bound/errors"
|
3
4
|
|
4
5
|
class Bound
|
5
6
|
def self.new(*args)
|
@@ -58,7 +59,7 @@ class Bound
|
|
58
59
|
a.each do |attr|
|
59
60
|
unless b.include? attr
|
60
61
|
message = "Unknown attribute: #{attr.inspect} in #{b}"
|
61
|
-
raise
|
62
|
+
raise UnknownAttributeError, message
|
62
63
|
end
|
63
64
|
end
|
64
65
|
end
|
@@ -66,7 +67,7 @@ class Bound
|
|
66
67
|
def ensure_present!(attribute)
|
67
68
|
if !overwritten?(attribute) && !target_has?(attribute)
|
68
69
|
message = "Missing attribute: #{attribute}"
|
69
|
-
raise
|
70
|
+
raise MissingAttributeError, message
|
70
71
|
end
|
71
72
|
end
|
72
73
|
|
data/lib/bound/errors.rb
ADDED
data/lib/bound/version.rb
CHANGED
data/spec/bound_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe Bound do
|
|
29
29
|
the_hash.delete :age
|
30
30
|
|
31
31
|
[the_hash, object].each do |subject|
|
32
|
-
exception = assert_raises
|
32
|
+
exception = assert_raises MissingAttributeError, subject.inspect do
|
33
33
|
User.new(subject)
|
34
34
|
end
|
35
35
|
|
@@ -49,7 +49,7 @@ describe Bound do
|
|
49
49
|
the_hash[:gender] = "M"
|
50
50
|
subject = the_hash
|
51
51
|
|
52
|
-
exception = assert_raises
|
52
|
+
exception = assert_raises UnknownAttributeError, subject.inspect do
|
53
53
|
User.new(subject)
|
54
54
|
end
|
55
55
|
|
@@ -172,7 +172,7 @@ describe Bound do
|
|
172
172
|
it 'fails if argument of optional nested bound is missing' do
|
173
173
|
the_hash[:profile].delete(:age)
|
174
174
|
[the_hash, object].each do |subject|
|
175
|
-
error = assert_raises
|
175
|
+
error = assert_raises MissingAttributeError do
|
176
176
|
UserWithProfile.new(subject)
|
177
177
|
end
|
178
178
|
assert_match(/missing/i, error.message)
|
@@ -213,7 +213,7 @@ describe Bound do
|
|
213
213
|
it 'fails if nested attributes are missing' do
|
214
214
|
the_hash[:company].delete(:name)
|
215
215
|
[the_hash, object].each do |subject|
|
216
|
-
error = assert_raises
|
216
|
+
error = assert_raises MissingAttributeError do
|
217
217
|
EmployedUser.new(subject)
|
218
218
|
end
|
219
219
|
assert_match(/missing/i, error.message)
|
@@ -257,7 +257,7 @@ describe Bound do
|
|
257
257
|
it 'fails if nested bound is missing an attribute' do
|
258
258
|
the_hash[:posts][1].delete(:title)
|
259
259
|
[the_hash, object].each do |subject|
|
260
|
-
error = assert_raises
|
260
|
+
error = assert_raises MissingAttributeError do
|
261
261
|
BloggingUser.new(subject)
|
262
262
|
end
|
263
263
|
assert_match(/missing/i, error.message)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bound
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakob Holderbaum
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-03-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- bound.gemspec
|
86
86
|
- lib/bound.rb
|
87
87
|
- lib/bound/caller.rb
|
88
|
+
- lib/bound/errors.rb
|
88
89
|
- lib/bound/version.rb
|
89
90
|
- spec/bound_spec.rb
|
90
91
|
- spec/caller_spec.rb
|