active_attr 0.12.0 → 0.15.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.
Potentially problematic release.
This version of active_attr might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/.github/workflows/test.yaml +160 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +33 -0
- data/Gemfile +5 -8
- data/README.md +142 -117
- data/active_attr.gemspec +13 -6
- data/gemfiles/rails_3_0.gemfile +0 -4
- data/gemfiles/rails_3_1.gemfile +1 -8
- data/gemfiles/rails_3_2.gemfile +1 -12
- data/gemfiles/rails_4_0.gemfile +1 -1
- data/gemfiles/rails_4_1.gemfile +1 -1
- data/gemfiles/rails_4_2.gemfile +1 -1
- data/gemfiles/rails_5_0.gemfile +1 -1
- data/gemfiles/rails_5_1.gemfile +1 -1
- data/gemfiles/rails_5_2.gemfile +9 -0
- data/gemfiles/rails_6_0.gemfile +9 -0
- data/gemfiles/rails_head.gemfile +1 -1
- data/lib/active_attr.rb +1 -1
- data/lib/active_attr/attributes.rb +63 -9
- data/lib/active_attr/chainable_initialization.rb +2 -6
- data/lib/active_attr/logger.rb +1 -1
- data/lib/active_attr/mass_assignment.rb +2 -2
- data/lib/active_attr/matchers/have_attribute_matcher.rb +1 -1
- data/lib/active_attr/model.rb +1 -0
- data/lib/active_attr/query_attributes.rb +1 -1
- data/lib/active_attr/railtie.rb +5 -0
- data/lib/active_attr/typecasting/big_decimal_typecaster.rb +5 -2
- data/lib/active_attr/typecasting/boolean_typecaster.rb +8 -0
- data/lib/active_attr/typecasting/float_typecaster.rb +3 -1
- data/lib/active_attr/typecasting/integer_typecaster.rb +3 -1
- data/lib/active_attr/version.rb +1 -1
- data/spec/functional/active_attr/attributes_spec.rb +8 -40
- data/spec/functional/active_attr/mass_assignment_spec.rb +2 -2
- data/spec/functional/active_attr/matchers/have_attribute_matcher_spec.rb +48 -0
- data/spec/functional/active_attr/model_spec.rb +47 -0
- data/spec/functional/active_attr/typecasted_attributes_spec.rb +1 -1
- data/spec/unit/active_attr/attribute_defaults_spec.rb +8 -0
- data/spec/unit/active_attr/attributes_spec.rb +91 -0
- data/spec/unit/active_attr/query_attributes_spec.rb +4 -4
- data/spec/unit/active_attr/typecasting/big_decimal_typecaster_spec.rb +17 -9
- data/spec/unit/active_attr/typecasting/boolean_typecaster_spec.rb +7 -7
- data/spec/unit/active_attr/typecasting/float_typecaster_spec.rb +10 -2
- data/spec/unit/active_attr/typecasting/integer_typecaster_spec.rb +10 -2
- metadata +44 -29
- data/.ruby-version +0 -1
- data/.travis.yml +0 -83
@@ -16,8 +16,8 @@ module ActiveAttr
|
|
16
16
|
typecaster.call(false).should equal false
|
17
17
|
end
|
18
18
|
|
19
|
-
it "casts nil to
|
20
|
-
typecaster.call(nil).should equal
|
19
|
+
it "casts nil to nil" do
|
20
|
+
typecaster.call(nil).should equal nil
|
21
21
|
end
|
22
22
|
|
23
23
|
it "casts an Object to true" do
|
@@ -26,7 +26,7 @@ module ActiveAttr
|
|
26
26
|
|
27
27
|
context "when the value is a String" do
|
28
28
|
it "casts an empty String to false" do
|
29
|
-
typecaster.call("").should equal
|
29
|
+
typecaster.call("").should equal nil
|
30
30
|
end
|
31
31
|
|
32
32
|
it "casts a non-empty String to true" do
|
@@ -94,11 +94,11 @@ module ActiveAttr
|
|
94
94
|
end
|
95
95
|
|
96
96
|
it "casts a zero BigDecimal to false" do
|
97
|
-
typecaster.call(BigDecimal
|
97
|
+
typecaster.call(BigDecimal("0.0")).should equal false
|
98
98
|
end
|
99
99
|
|
100
100
|
it "casts a non-zero BigDecimal to true" do
|
101
|
-
typecaster.call(BigDecimal
|
101
|
+
typecaster.call(BigDecimal("0.1")).should equal true
|
102
102
|
end
|
103
103
|
|
104
104
|
it "casts -1 to true" do
|
@@ -114,11 +114,11 @@ module ActiveAttr
|
|
114
114
|
end
|
115
115
|
|
116
116
|
it "casts a negative zero BigDecimal to false" do
|
117
|
-
typecaster.call(BigDecimal
|
117
|
+
typecaster.call(BigDecimal("-0.0")).should equal false
|
118
118
|
end
|
119
119
|
|
120
120
|
it "casts a negative BigDecimal to true" do
|
121
|
-
typecaster.call(BigDecimal
|
121
|
+
typecaster.call(BigDecimal("-0.1")).should equal true
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
@@ -12,14 +12,22 @@ module ActiveAttr
|
|
12
12
|
typecaster.call(value).should equal value
|
13
13
|
end
|
14
14
|
|
15
|
-
it "casts nil to
|
16
|
-
typecaster.call(nil).should eql
|
15
|
+
it "casts nil to nil" do
|
16
|
+
typecaster.call(nil).should eql nil
|
17
17
|
end
|
18
18
|
|
19
19
|
it "returns the float version of a String" do
|
20
20
|
typecaster.call("2").should eql 2.0
|
21
21
|
end
|
22
22
|
|
23
|
+
it "casts an empty String to nil" do
|
24
|
+
typecaster.call("").should eql nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it "casts an alpha String to a zero Float" do
|
28
|
+
typecaster.call("bob").should eql 0.0
|
29
|
+
end
|
30
|
+
|
23
31
|
it "returns nil for an object that does not respond to #to_f" do
|
24
32
|
typecaster.call(Object.new).should be_nil
|
25
33
|
end
|
@@ -12,14 +12,22 @@ module ActiveAttr
|
|
12
12
|
typecaster.call(value).should equal value
|
13
13
|
end
|
14
14
|
|
15
|
-
it "casts nil to
|
16
|
-
typecaster.call(nil).should eql
|
15
|
+
it "casts nil to nil" do
|
16
|
+
typecaster.call(nil).should eql nil
|
17
17
|
end
|
18
18
|
|
19
19
|
it "returns the integer version of a String" do
|
20
20
|
typecaster.call("2").should eql 2
|
21
21
|
end
|
22
22
|
|
23
|
+
it "casts an empty String to nil" do
|
24
|
+
typecaster.call("").should eql nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it "casts an alpha String to a zero Integer" do
|
28
|
+
typecaster.call("bob").should eql 0
|
29
|
+
end
|
30
|
+
|
23
31
|
it "returns nil for an object that does not respond to #to_i" do
|
24
32
|
typecaster.call(Object.new).should be_nil
|
25
33
|
end
|
metadata
CHANGED
@@ -1,16 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_attr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Griego
|
8
8
|
- Ben Poweski
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-12-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: actionpack
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 3.0.2
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '6.2'
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 3.0.2
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '6.2'
|
14
34
|
- !ruby/object:Gem::Dependency
|
15
35
|
name: activemodel
|
16
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -20,7 +40,7 @@ dependencies:
|
|
20
40
|
version: 3.0.2
|
21
41
|
- - "<"
|
22
42
|
- !ruby/object:Gem::Version
|
23
|
-
version: '6.
|
43
|
+
version: '6.2'
|
24
44
|
type: :runtime
|
25
45
|
prerelease: false
|
26
46
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -30,7 +50,7 @@ dependencies:
|
|
30
50
|
version: 3.0.2
|
31
51
|
- - "<"
|
32
52
|
- !ruby/object:Gem::Version
|
33
|
-
version: '6.
|
53
|
+
version: '6.2'
|
34
54
|
- !ruby/object:Gem::Dependency
|
35
55
|
name: activesupport
|
36
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -40,7 +60,7 @@ dependencies:
|
|
40
60
|
version: 3.0.2
|
41
61
|
- - "<"
|
42
62
|
- !ruby/object:Gem::Version
|
43
|
-
version: '6.
|
63
|
+
version: '6.2'
|
44
64
|
type: :runtime
|
45
65
|
prerelease: false
|
46
66
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -50,28 +70,25 @@ dependencies:
|
|
50
70
|
version: 3.0.2
|
51
71
|
- - "<"
|
52
72
|
- !ruby/object:Gem::Version
|
53
|
-
version: '6.
|
73
|
+
version: '6.2'
|
54
74
|
- !ruby/object:Gem::Dependency
|
55
75
|
name: bundler
|
56
76
|
requirement: !ruby/object:Gem::Requirement
|
57
77
|
requirements:
|
58
|
-
- - "
|
78
|
+
- - ">="
|
59
79
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
80
|
+
version: '0'
|
61
81
|
type: :development
|
62
82
|
prerelease: false
|
63
83
|
version_requirements: !ruby/object:Gem::Requirement
|
64
84
|
requirements:
|
65
|
-
- - "
|
85
|
+
- - ">="
|
66
86
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
87
|
+
version: '0'
|
68
88
|
- !ruby/object:Gem::Dependency
|
69
|
-
name:
|
89
|
+
name: factory_bot
|
70
90
|
requirement: !ruby/object:Gem::Requirement
|
71
91
|
requirements:
|
72
|
-
- - ">="
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '2.2'
|
75
92
|
- - "<"
|
76
93
|
- !ruby/object:Gem::Version
|
77
94
|
version: '5.0'
|
@@ -79,9 +96,6 @@ dependencies:
|
|
79
96
|
prerelease: false
|
80
97
|
version_requirements: !ruby/object:Gem::Requirement
|
81
98
|
requirements:
|
82
|
-
- - ">="
|
83
|
-
- !ruby/object:Gem::Version
|
84
|
-
version: '2.2'
|
85
99
|
- - "<"
|
86
100
|
- !ruby/object:Gem::Version
|
87
101
|
version: '5.0'
|
@@ -108,7 +122,7 @@ dependencies:
|
|
108
122
|
version: 0.9.0
|
109
123
|
- - "<"
|
110
124
|
- !ruby/object:Gem::Version
|
111
|
-
version: '
|
125
|
+
version: '13.1'
|
112
126
|
type: :development
|
113
127
|
prerelease: false
|
114
128
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -118,7 +132,7 @@ dependencies:
|
|
118
132
|
version: 0.9.0
|
119
133
|
- - "<"
|
120
134
|
- !ruby/object:Gem::Version
|
121
|
-
version: '
|
135
|
+
version: '13.1'
|
122
136
|
- !ruby/object:Gem::Dependency
|
123
137
|
name: rspec
|
124
138
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,7 +161,7 @@ dependencies:
|
|
147
161
|
- - ">="
|
148
162
|
- !ruby/object:Gem::Version
|
149
163
|
version: '0'
|
150
|
-
description: Create plain old
|
164
|
+
description: Create plain old Ruby models without reinventing the wheel.
|
151
165
|
email:
|
152
166
|
- cgriego@gmail.com
|
153
167
|
- bpoweski@gmail.com
|
@@ -155,10 +169,9 @@ executables: []
|
|
155
169
|
extensions: []
|
156
170
|
extra_rdoc_files: []
|
157
171
|
files:
|
172
|
+
- ".github/workflows/test.yaml"
|
158
173
|
- ".gitignore"
|
159
174
|
- ".rspec"
|
160
|
-
- ".ruby-version"
|
161
|
-
- ".travis.yml"
|
162
175
|
- ".yardopts"
|
163
176
|
- CHANGELOG.md
|
164
177
|
- Gemfile
|
@@ -175,6 +188,8 @@ files:
|
|
175
188
|
- gemfiles/rails_4_2.gemfile
|
176
189
|
- gemfiles/rails_5_0.gemfile
|
177
190
|
- gemfiles/rails_5_1.gemfile
|
191
|
+
- gemfiles/rails_5_2.gemfile
|
192
|
+
- gemfiles/rails_6_0.gemfile
|
178
193
|
- gemfiles/rails_head.gemfile
|
179
194
|
- lib/active_attr.rb
|
180
195
|
- lib/active_attr/attribute_defaults.rb
|
@@ -251,8 +266,9 @@ files:
|
|
251
266
|
homepage: https://github.com/cgriego/active_attr
|
252
267
|
licenses:
|
253
268
|
- MIT
|
254
|
-
metadata:
|
255
|
-
|
269
|
+
metadata:
|
270
|
+
changelog_uri: https://github.com/cgriego/active_attr/blob/master/CHANGELOG.md
|
271
|
+
post_install_message:
|
256
272
|
rdoc_options: []
|
257
273
|
require_paths:
|
258
274
|
- lib
|
@@ -260,16 +276,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
260
276
|
requirements:
|
261
277
|
- - ">="
|
262
278
|
- !ruby/object:Gem::Version
|
263
|
-
version:
|
279
|
+
version: 2.1.0
|
264
280
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
265
281
|
requirements:
|
266
282
|
- - ">="
|
267
283
|
- !ruby/object:Gem::Version
|
268
284
|
version: '0'
|
269
285
|
requirements: []
|
270
|
-
|
271
|
-
|
272
|
-
signing_key:
|
286
|
+
rubygems_version: 3.1.2
|
287
|
+
signing_key:
|
273
288
|
specification_version: 4
|
274
289
|
summary: What ActiveModel left out
|
275
290
|
test_files:
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.4.1
|
data/.travis.yml
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
sudo: false
|
3
|
-
rvm:
|
4
|
-
- ree
|
5
|
-
- 1.9.2
|
6
|
-
- 1.9.3
|
7
|
-
- 2.0.0
|
8
|
-
- 2.1.10
|
9
|
-
- 2.2.10
|
10
|
-
- 2.3.7
|
11
|
-
- 2.4.4
|
12
|
-
- 2.5.1
|
13
|
-
before_install: gem install bundler
|
14
|
-
bundler_args: --without development
|
15
|
-
gemfile:
|
16
|
-
- gemfiles/rails_3_0.gemfile
|
17
|
-
- gemfiles/rails_3_1.gemfile
|
18
|
-
- gemfiles/rails_3_2.gemfile
|
19
|
-
- gemfiles/rails_4_0.gemfile
|
20
|
-
- gemfiles/rails_4_1.gemfile
|
21
|
-
- gemfiles/rails_4_2.gemfile
|
22
|
-
- gemfiles/rails_5_0.gemfile
|
23
|
-
- gemfiles/rails_5_1.gemfile
|
24
|
-
- Gemfile
|
25
|
-
- gemfiles/rails_head.gemfile
|
26
|
-
matrix:
|
27
|
-
allow_failures:
|
28
|
-
- gemfile: gemfiles/rails_head.gemfile
|
29
|
-
exclude:
|
30
|
-
- rvm: 2.5.1
|
31
|
-
gemfile: gemfiles/rails_3_0.gemfile
|
32
|
-
- rvm: ree
|
33
|
-
gemfile: gemfiles/rails_4_0.gemfile
|
34
|
-
- rvm: 1.9.2
|
35
|
-
gemfile: gemfiles/rails_4_0.gemfile
|
36
|
-
- rvm: ree
|
37
|
-
gemfile: gemfiles/rails_4_1.gemfile
|
38
|
-
- rvm: 1.9.2
|
39
|
-
gemfile: gemfiles/rails_4_1.gemfile
|
40
|
-
- rvm: ree
|
41
|
-
gemfile: gemfiles/rails_4_2.gemfile
|
42
|
-
- rvm: 1.9.2
|
43
|
-
gemfile: gemfiles/rails_4_2.gemfile
|
44
|
-
- rvm: ree
|
45
|
-
gemfile: gemfiles/rails_5_0.gemfile
|
46
|
-
- rvm: 1.9.2
|
47
|
-
gemfile: gemfiles/rails_5_0.gemfile
|
48
|
-
- rvm: 1.9.3
|
49
|
-
gemfile: gemfiles/rails_5_0.gemfile
|
50
|
-
- rvm: 2.0.0
|
51
|
-
gemfile: gemfiles/rails_5_0.gemfile
|
52
|
-
- rvm: 2.1.10
|
53
|
-
gemfile: gemfiles/rails_5_0.gemfile
|
54
|
-
- rvm: ree
|
55
|
-
gemfile: gemfiles/rails_5_1.gemfile
|
56
|
-
- rvm: 1.9.2
|
57
|
-
gemfile: gemfiles/rails_5_1.gemfile
|
58
|
-
- rvm: 1.9.3
|
59
|
-
gemfile: gemfiles/rails_5_1.gemfile
|
60
|
-
- rvm: 2.0.0
|
61
|
-
gemfile: gemfiles/rails_5_1.gemfile
|
62
|
-
- rvm: 2.1.10
|
63
|
-
gemfile: gemfiles/rails_5_1.gemfile
|
64
|
-
- rvm: ree
|
65
|
-
gemfile: Gemfile
|
66
|
-
- rvm: 1.9.2
|
67
|
-
gemfile: Gemfile
|
68
|
-
- rvm: 1.9.3
|
69
|
-
gemfile: Gemfile
|
70
|
-
- rvm: 2.0.0
|
71
|
-
gemfile: Gemfile
|
72
|
-
- rvm: 2.1.10
|
73
|
-
gemfile: Gemfile
|
74
|
-
- rvm: ree
|
75
|
-
gemfile: gemfiles/rails_head.gemfile
|
76
|
-
- rvm: 1.9.2
|
77
|
-
gemfile: gemfiles/rails_head.gemfile
|
78
|
-
- rvm: 1.9.3
|
79
|
-
gemfile: gemfiles/rails_head.gemfile
|
80
|
-
- rvm: 2.0.0
|
81
|
-
gemfile: gemfiles/rails_head.gemfile
|
82
|
-
- rvm: 2.1.10
|
83
|
-
gemfile: gemfiles/rails_head.gemfile
|