couch_potato 0.3.1 → 0.3.2
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.
- data/VERSION.yml +2 -2
- data/lib/couch_potato/persistence/type_caster.rb +2 -2
- data/spec/unit/attributes_spec.rb +10 -0
- metadata +3 -9
data/VERSION.yml
CHANGED
@@ -24,9 +24,9 @@ module CouchPotato
|
|
24
24
|
def cast_native(value, type)
|
25
25
|
if type && !value.instance_of?(type)
|
26
26
|
if type == Fixnum
|
27
|
-
value.to_s.scan(
|
27
|
+
value.to_s.scan(/-?\d+/).join.to_i unless value.blank?
|
28
28
|
elsif type == Float
|
29
|
-
value.to_s.scan(
|
29
|
+
value.to_s.scan(/-?\d+\.?\d*/).join.to_f unless value.blank?
|
30
30
|
else
|
31
31
|
type.json_create value unless value.blank?
|
32
32
|
end
|
@@ -58,6 +58,11 @@ describe "attributes" do
|
|
58
58
|
@plant.typed_leaf_count.should == 4
|
59
59
|
end
|
60
60
|
|
61
|
+
it "should convert a string into a negative fixnum" do
|
62
|
+
@plant.typed_leaf_count = '-4'
|
63
|
+
@plant.typed_leaf_count.should == -4
|
64
|
+
end
|
65
|
+
|
61
66
|
it "should leave a fixnum as is" do
|
62
67
|
@plant.typed_leaf_count = 4
|
63
68
|
@plant.typed_leaf_count.should == 4
|
@@ -94,6 +99,11 @@ describe "attributes" do
|
|
94
99
|
@plant.typed_leaf_size = '5'
|
95
100
|
@plant.typed_leaf_size.should == 5.0
|
96
101
|
end
|
102
|
+
|
103
|
+
it "should convert a negative number in a string" do
|
104
|
+
@plant.typed_leaf_size = '-5.0'
|
105
|
+
@plant.typed_leaf_size.should == -5.0
|
106
|
+
end
|
97
107
|
|
98
108
|
it "should leave a float as it is" do
|
99
109
|
@plant.typed_leaf_size = 0.5
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: couch_potato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 17
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
8
|
+
- 2
|
9
|
+
version: 0.3.2
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Alexander Lang
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-11-03 00:00:00 +01:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,7 +25,6 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
28
|
segments:
|
31
29
|
- 0
|
32
30
|
version: "0"
|
@@ -40,7 +38,6 @@ dependencies:
|
|
40
38
|
requirements:
|
41
39
|
- - ">="
|
42
40
|
- !ruby/object:Gem::Version
|
43
|
-
hash: 21
|
44
41
|
segments:
|
45
42
|
- 1
|
46
43
|
- 0
|
@@ -56,7 +53,6 @@ dependencies:
|
|
56
53
|
requirements:
|
57
54
|
- - ">="
|
58
55
|
- !ruby/object:Gem::Version
|
59
|
-
hash: 3
|
60
56
|
segments:
|
61
57
|
- 0
|
62
58
|
version: "0"
|
@@ -165,7 +161,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
165
161
|
requirements:
|
166
162
|
- - ">="
|
167
163
|
- !ruby/object:Gem::Version
|
168
|
-
hash: 3
|
169
164
|
segments:
|
170
165
|
- 0
|
171
166
|
version: "0"
|
@@ -174,7 +169,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
169
|
requirements:
|
175
170
|
- - ">="
|
176
171
|
- !ruby/object:Gem::Version
|
177
|
-
hash: 3
|
178
172
|
segments:
|
179
173
|
- 0
|
180
174
|
version: "0"
|