ostruct_deep 0.1.2 → 0.1.3
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +34 -9
- data/lib/open_struct_extend/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1449c43755a27d4bd9b936540cb8ecabb94745a9
|
|
4
|
+
data.tar.gz: c398c1184a4dd1a6287eae9ec8af6e0879021f2f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4d46efbe0ca190d7549ba7b6aec829a2c8b28e8c555004d97d9088b5ba9270bd41bb26d9edb143d894e48f15379dfd6bac2fc97539373ab102913cfc6bacac4c
|
|
7
|
+
data.tar.gz: e66edf93297806731644e13c280aedba2de70a8b918d880f598746b424a795661d9db28a85a47089932b93f25c5e1a4a15fd46d575f28915b296a5029a69ebcd
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -20,8 +20,36 @@ Or install it yourself as:
|
|
|
20
20
|
$ gem install ostruct_deep
|
|
21
21
|
|
|
22
22
|
## Usage
|
|
23
|
+
```ruby
|
|
24
|
+
require 'open_struct_deep'
|
|
25
|
+
|
|
26
|
+
# Put your hash structure for the first parameter
|
|
27
|
+
hash = {name: "John Smith", age: 70, pension: 300}
|
|
28
|
+
person = OpenStructDeep.new(hash)
|
|
29
|
+
|
|
30
|
+
or
|
|
31
|
+
|
|
32
|
+
# It works also
|
|
33
|
+
person = OpenStructDeep.new(name: "John Smith", age: 70, pension: 300)
|
|
34
|
+
|
|
35
|
+
or
|
|
36
|
+
|
|
37
|
+
# Another way you can
|
|
38
|
+
person = OpenStructDeep.new
|
|
39
|
+
person.name = "John Smith"
|
|
40
|
+
person.age = 70
|
|
41
|
+
person.pension = 300
|
|
42
|
+
|
|
43
|
+
then
|
|
44
|
+
|
|
45
|
+
puts person.name # -> "John Smith"
|
|
46
|
+
puts person.age # -> 70
|
|
47
|
+
puts person.address # -> nil
|
|
48
|
+
```
|
|
23
49
|
|
|
24
|
-
|
|
50
|
+
## What's new?
|
|
51
|
+
### Originals Problem in (OpenStructure)
|
|
52
|
+
In original ostruct (rubysl-ostruct) do below:
|
|
25
53
|
|
|
26
54
|
```ruby
|
|
27
55
|
hash = { "country" => "Australia", :population => 20_000_000, :info => { from: 1392, to: 1910 } }
|
|
@@ -37,8 +65,10 @@ p data.info # -> {:from=>1392, :to=>1910}
|
|
|
37
65
|
p data.info.from # -> NoMethodError: undefined method `from' for {:from=>1392, :to=>1910}:Hash
|
|
38
66
|
```
|
|
39
67
|
|
|
68
|
+
### Solved in new one (OpenStructureDeep)
|
|
40
69
|
In ostruct_deep do below:
|
|
41
70
|
|
|
71
|
+
#### Sample Structure
|
|
42
72
|
The new hash has many stage and includes array.
|
|
43
73
|
```ruby
|
|
44
74
|
hash =
|
|
@@ -71,6 +101,7 @@ hash =
|
|
|
71
101
|
}
|
|
72
102
|
```
|
|
73
103
|
|
|
104
|
+
#### Works
|
|
74
105
|
OpenStructDeep works fine :
|
|
75
106
|
```ruby
|
|
76
107
|
data = OpenStructDeep.new(hash)
|
|
@@ -87,18 +118,12 @@ p data.kings.is_a?(Array) # -> true
|
|
|
87
118
|
|
|
88
119
|
```
|
|
89
120
|
|
|
90
|
-
## Development
|
|
91
|
-
|
|
92
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
93
|
-
|
|
94
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
95
|
-
|
|
96
121
|
## Contributing
|
|
97
122
|
|
|
98
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
123
|
+
Bug reports and pull requests are welcome on GitHub at [Repository](https://github.com/yhk1038/ostruct_deep). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
99
124
|
|
|
100
125
|
You can contribute in works below with opening issues or pull requests.
|
|
101
|
-
- Documentation
|
|
126
|
+
- Better Documentation
|
|
102
127
|
- Suggest features
|
|
103
128
|
- Modify code style
|
|
104
129
|
- And more better correct comments
|