recursive_struct 0.0.3 → 0.0.4
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.
- checksums.yaml +8 -8
- data/README.md +15 -2
- data/lib/recursive_struct/version.rb +1 -1
- data/recursive_struct.gemspec +1 -1
- data/spec/recursive_struct_spec.rb +6 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTg4ZDBlM2U1ZjhhZGFhNDU1MTY0YTc2YmRhYjM1YWIxMmNiYTI5Yg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2ViNDY2ZTE0YTcyNDUwZDhlMzk2ZjYzMzc2NjlmYmM0YjRmMDY3NQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmQzNjJhODlmMTg4NDJiZDc1YjEzOWJhODdiMGFmNjk0Y2U4ZTUzOGUyMzBm
|
10
|
+
OTM0NDlkNWNiZjY5NzcxM2NkYjU1ZDM1MWYyMmYyYThmNzcyZDE1ZDhkMGMz
|
11
|
+
MDI2MjJlYzZhOTFmNWZmOTk4YTkzMzJlYTkyNjQ0Y2I5YTA3NmM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTM1ZDIxZGEwZmViZjA0NmU3Nzc4M2YxZTFhZTg4MGQ5MzU3MGM4YzI0Y2Y0
|
14
|
+
OTUzYzM1NzRkNzQ3YmFjZDM0ZGEwZDg2MmM1YjUzMWEyZjBkOGJjODZkNTUy
|
15
|
+
ZWY1MjFiZDFjYWQyZTE4YjdkYmJkNjdkNjE4ZjE3ZjM4NWM0ZWQ=
|
data/README.md
CHANGED
@@ -21,15 +21,28 @@ Or install it yourself as:
|
|
21
21
|
## Usage
|
22
22
|
|
23
23
|
Passing a hash into the initializer will create an open struct that has all nested getter and setter methods.
|
24
|
-
|
25
24
|
```
|
26
25
|
hash = { a: { b: true }, c: false }
|
27
26
|
struct = RecursiveStruct.new(hash}
|
28
|
-
struct.a # #<RecursiveStruct b
|
27
|
+
struct.a # #<RecursiveStruct @data={:b=>true}>
|
29
28
|
struct.a.b # true
|
30
29
|
struct.c # false
|
31
30
|
```
|
32
31
|
|
32
|
+
You can also create set any value on any method and it will automatically create the getter and setter.
|
33
|
+
```
|
34
|
+
struct = RecursiveStruct.new
|
35
|
+
struct.a = true
|
36
|
+
struct.a # true
|
37
|
+
```
|
38
|
+
|
39
|
+
If this value happens to be a hash, it will wrap it in a RecursiveStruct
|
40
|
+
```
|
41
|
+
struct = RecursiveStruct.new
|
42
|
+
struct.a = { b: true }
|
43
|
+
struct a # #<RecursiveStruct @data={:b=>true}>
|
44
|
+
```
|
45
|
+
|
33
46
|
## Contributing
|
34
47
|
|
35
48
|
1. Fork it ( https://github.com/pboksz/recursive_struct/fork )
|
data/recursive_struct.gemspec
CHANGED
@@ -22,5 +22,5 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.7"
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
24
|
spec.add_development_dependency "pry", "~> 0"
|
25
|
-
spec.add_development_dependency "rspec", "~>
|
25
|
+
spec.add_development_dependency "rspec", "~> 3"
|
26
26
|
end
|
@@ -10,12 +10,12 @@ describe RecursiveStruct do
|
|
10
10
|
|
11
11
|
describe 'hash exists' do
|
12
12
|
let(:hash) { { one: true } }
|
13
|
-
it { expect(subject.one).to
|
13
|
+
it { expect(subject.one).to be true }
|
14
14
|
end
|
15
15
|
|
16
16
|
describe 'nested hash' do
|
17
17
|
let(:hash) { { one: { two: true } } }
|
18
|
-
it { expect(subject.one.two).to
|
18
|
+
it { expect(subject.one.two).to be true }
|
19
19
|
end
|
20
20
|
|
21
21
|
describe 'hash with array' do
|
@@ -28,12 +28,12 @@ describe RecursiveStruct do
|
|
28
28
|
|
29
29
|
describe 'nested setter' do
|
30
30
|
before { subject.one.two = false }
|
31
|
-
it { expect(subject.one.two).to
|
31
|
+
it { expect(subject.one.two).to be false }
|
32
32
|
end
|
33
33
|
|
34
34
|
describe 'top level setter' do
|
35
35
|
before { subject.one = false }
|
36
|
-
it { expect(subject.one).to
|
36
|
+
it { expect(subject.one).to be false }
|
37
37
|
end
|
38
38
|
|
39
39
|
describe 'setting a hash' do
|
@@ -51,7 +51,7 @@ describe RecursiveStruct do
|
|
51
51
|
describe 'valid setter' do
|
52
52
|
describe 'single value' do
|
53
53
|
before { subject.one = true }
|
54
|
-
it { expect(subject.one).to
|
54
|
+
it { expect(subject.one).to be true }
|
55
55
|
end
|
56
56
|
|
57
57
|
describe 'array value' do
|
@@ -61,7 +61,7 @@ describe RecursiveStruct do
|
|
61
61
|
|
62
62
|
describe 'hash value' do
|
63
63
|
before { subject.one = { two: true } }
|
64
|
-
it { expect(subject.one.two).to
|
64
|
+
it { expect(subject.one.two).to eq true }
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recursive_struct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phillip Boksz
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '3'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '3'
|
69
69
|
description: A gem to create recursive structs similar to open struct.
|
70
70
|
email:
|
71
71
|
- pboksz@gmail.com
|