hashtostruct 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -1
- data/lib/hashtostruct.rb +8 -1
- data/spec/hashtostruct_spec.rb +6 -1
- metadata +3 -3
data/History.txt
CHANGED
data/lib/hashtostruct.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
require 'date'
|
2
2
|
|
3
3
|
module Hashtostruct
|
4
|
-
VERSION = '0.9.
|
4
|
+
VERSION = '0.9.1'
|
5
|
+
|
6
|
+
module ToObject
|
7
|
+
def to_obj
|
8
|
+
self
|
9
|
+
end
|
10
|
+
end
|
5
11
|
|
6
12
|
module StringToObject
|
7
13
|
# Attempt to parse the string into a native Ruby object using standard formats
|
@@ -78,6 +84,7 @@ module Hashtostruct
|
|
78
84
|
end
|
79
85
|
end
|
80
86
|
|
87
|
+
Object.send :include, ToObject
|
81
88
|
Array.send :include, ArrayToObject
|
82
89
|
String.send :include, StringToObject
|
83
90
|
Hash.send :include, HashToStruct
|
data/spec/hashtostruct_spec.rb
CHANGED
@@ -32,7 +32,8 @@ describe Hashtostruct do
|
|
32
32
|
"nested" => {
|
33
33
|
"int" => "32",
|
34
34
|
"string" => "textie"
|
35
|
-
}
|
35
|
+
},
|
36
|
+
"already_int" => 89
|
36
37
|
}.to_struct
|
37
38
|
end
|
38
39
|
|
@@ -194,4 +195,8 @@ describe Hashtostruct do
|
|
194
195
|
@obj.array.should be_an_instance_of(Array)
|
195
196
|
@obj.array.should eql(["item_1", 45.2, 1230.0])
|
196
197
|
end
|
198
|
+
|
199
|
+
it "should properly parse non-strings" do
|
200
|
+
@obj.already_int.should eql(89)
|
201
|
+
end
|
197
202
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hashtostruct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timothy Caraballo
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-12-03 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements: []
|
80
80
|
|
81
81
|
rubyforge_project: hashtostruct
|
82
|
-
rubygems_version: 1.3.
|
82
|
+
rubygems_version: 1.3.1
|
83
83
|
signing_key:
|
84
84
|
specification_version: 2
|
85
85
|
summary: Takes a Hash and converts it into a Struct with each key as a property and each value converted into a native object if possible.
|