active_attr 0.11.0 → 0.12.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.

Potentially problematic release.


This version of active_attr might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f072a053dc7854c420523d4dcea77f3c06181021
4
- data.tar.gz: 5ea51b5d4fd81a140484c1d725a12c16ed8adbd8
3
+ metadata.gz: 02c6c69fe8a87196740e45c3e827e832b09a8eca
4
+ data.tar.gz: ce44bea22a9b8d2dbc753bc9a81cee7f51b4c6da
5
5
  SHA512:
6
- metadata.gz: 19f0b7b8289d633be65d8f7f6a519d3769d34b6812f6483de5d485274496dae7b1f27aed5199829d9113b44fd11fbbc3a8030d2e884f28b2ea4d795a0f287455
7
- data.tar.gz: 526b81fa479ee21f79d5df4e4bb9fafec8413aef334a75daa3c2ea4baee4dce732eaeecb4d03355c2dadae9b7166e1258a5ae30e4ddcc9b9bb78d3f9954f57f9
6
+ metadata.gz: 9a13a61893450f32efa41744f7187e0cf4988359db4cf556de5175098fa9e357dd6744319e8fd43b786bcf4c9b156ea92aff74f9d26ccb1100c1821272e8a9b2
7
+ data.tar.gz: 605675def174c8cd4d83d2b2b7bc9c99a57c625409cc6124f3bf163d234441c96f93cd71d78e542d4eccc52824dec4c3fae94e0d154573c088623af147797ce1
@@ -6,10 +6,10 @@ rvm:
6
6
  - 1.9.3
7
7
  - 2.0.0
8
8
  - 2.1.10
9
- - 2.2.9
10
- - 2.3.6
11
- - 2.4.3
12
- - 2.5.0
9
+ - 2.2.10
10
+ - 2.3.7
11
+ - 2.4.4
12
+ - 2.5.1
13
13
  before_install: gem install bundler
14
14
  bundler_args: --without development
15
15
  gemfile:
@@ -27,7 +27,7 @@ matrix:
27
27
  allow_failures:
28
28
  - gemfile: gemfiles/rails_head.gemfile
29
29
  exclude:
30
- - rvm: 2.5.0
30
+ - rvm: 2.5.1
31
31
  gemfile: gemfiles/rails_3_0.gemfile
32
32
  - rvm: ree
33
33
  gemfile: gemfiles/rails_4_0.gemfile
@@ -1,3 +1,10 @@
1
+ # ActiveAttr 0.12.0 (August 6, 2018) #
2
+
3
+ * #167 Changed Typecasting::BooleanTypecaster to cast strings starting
4
+ with a zero character to cast to true (Artin Boghosian)
5
+ * Changed Typecasting::BooleanTypecaster to cast more numeric strings
6
+ to true
7
+
1
8
  # ActiveAttr 0.11.0 (May 29, 2018) #
2
9
 
3
10
  * #166 Changed Typecasting::DateTimeTypecaster to not raise on invalid
@@ -34,7 +34,7 @@ module ActiveAttr
34
34
  def call(value)
35
35
  case value
36
36
  when *FALSE_VALUES then false
37
- when Numeric, /^\-?[0-9]/ then !value.to_f.zero?
37
+ when Numeric, /\A[-+]?(0+\.?0*|0*\.?0+)\z/ then !value.to_f.zero?
38
38
  else value.present?
39
39
  end
40
40
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveAttr
2
2
  # Complete version string
3
3
  # @since 0.1.0
4
- VERSION = "0.11.0"
4
+ VERSION = "0.12.0"
5
5
  end
@@ -33,6 +33,14 @@ module ActiveAttr
33
33
  typecaster.call("abc").should equal true
34
34
  end
35
35
 
36
+ it "casts a non-empty String starting with number 0 to true" do
37
+ typecaster.call("0c2").should equal true
38
+ end
39
+
40
+ it "casts a non-empty String starting with number > 0 to true" do
41
+ typecaster.call("1c2").should equal true
42
+ end
43
+
36
44
  {
37
45
  "t" => true,
38
46
  "f" => false,
@@ -119,6 +127,10 @@ module ActiveAttr
119
127
  typecaster.call("0").should equal false
120
128
  end
121
129
 
130
+ it "casts '0\\nx' to true" do
131
+ typecaster.call("0\nx").should equal true
132
+ end
133
+
122
134
  it "casts '1' to true" do
123
135
  typecaster.call("1").should equal true
124
136
  end
@@ -127,6 +139,14 @@ module ActiveAttr
127
139
  typecaster.call("0.0").should equal false
128
140
  end
129
141
 
142
+ it "casts '.0' to false" do
143
+ typecaster.call(".0").should equal false
144
+ end
145
+
146
+ it "casts '0.' to false" do
147
+ typecaster.call("0.").should equal false
148
+ end
149
+
130
150
  it "casts '0.1' to true" do
131
151
  typecaster.call("0.1").should equal true
132
152
  end
@@ -135,13 +155,25 @@ module ActiveAttr
135
155
  typecaster.call("-1").should equal true
136
156
  end
137
157
 
158
+ it "casts '+1' to true" do
159
+ typecaster.call("+1").should equal true
160
+ end
161
+
138
162
  it "casts '-0.0' to false" do
139
163
  typecaster.call("-0.0").should equal false
140
164
  end
141
165
 
166
+ it "casts '+0.0' to false" do
167
+ typecaster.call("+0.0").should equal false
168
+ end
169
+
142
170
  it "casts '-0.1' to true" do
143
171
  typecaster.call("-0.1").should equal true
144
172
  end
173
+
174
+ it "casts '+0.1' to true" do
175
+ typecaster.call("+0.1").should equal true
176
+ end
145
177
  end
146
178
  end
147
179
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_attr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Griego
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-05-29 00:00:00.000000000 Z
12
+ date: 2018-08-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel