key_struct 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -0
- data/lib/key_struct/key_struct.rb +1 -1
- data/lib/key_struct/version.rb +1 -1
- data/spec/key_struct_spec.rb +4 -0
- metadata +8 -8
data/README.rdoc
CHANGED
@@ -126,6 +126,7 @@ Requires ruby >= 1.9.2. (Has been tested on MRI 1.9.2 and MRI 1.9.3)
|
|
126
126
|
|
127
127
|
Release Notes:
|
128
128
|
|
129
|
+
* 0.3.1 - Bug fix: to_hash when a value is an array. Was raising ArgumentError for Hash
|
129
130
|
* 0.3.0 - Introduced to_s and inspect
|
130
131
|
* 0.2.1 - Bug fix: return false for == with an incompatible object. Was raising NoMethodError
|
131
132
|
* 0.2.0 - Introduced <=> and to_hash
|
@@ -38,7 +38,7 @@ module KeyStruct
|
|
38
38
|
0
|
39
39
|
end
|
40
40
|
define_method(:to_hash) do
|
41
|
-
Hash[*keys.map{ |key| [key, self.send(key)]}.flatten(
|
41
|
+
Hash[*keys.map{ |key| [key, self.send(key)]}.flatten(1)]
|
42
42
|
end
|
43
43
|
define_method(:to_s) do
|
44
44
|
"[#{self.class.name} #{keys.map{|key| "#{key}:#{self.send(key)}"}.join(' ')}]"
|
data/lib/key_struct/version.rb
CHANGED
data/spec/key_struct_spec.rb
CHANGED
@@ -149,6 +149,10 @@ describe "KeyStruct" do
|
|
149
149
|
KeyStruct.accessor(:a => 3, :b => 4).new.to_hash.should == {:a => 3, :b => 4}
|
150
150
|
end
|
151
151
|
|
152
|
+
it "returns hash using to_hash when value is array" do
|
153
|
+
KeyStruct.accessor(:a => 3, :b => [[1,2], [3,4]]).new.to_hash.should == {:a => 3, :b => [[1,2],[3,4]]}
|
154
|
+
end
|
155
|
+
|
152
156
|
context "display as a string" do
|
153
157
|
PrintMe = KeyStruct[:a => 3, :b => "hello"]
|
154
158
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: key_struct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-01-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70145079063240 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70145079063240
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: simplecov
|
27
|
-
requirement: &
|
27
|
+
requirement: &70145079062540 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70145079062540
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: simplecov-gem-adapter
|
38
|
-
requirement: &
|
38
|
+
requirement: &70145079062020 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70145079062020
|
47
47
|
description: Defines KeyStruct analogous to Struct, but constructor takes keyword
|
48
48
|
arguments
|
49
49
|
email:
|