ostruct_deep 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0106a8c28b7207d82c8969338763773d8292b9e6
4
- data.tar.gz: 05cce59c92911bb97e75bdbfa8fa9df068102283
3
+ metadata.gz: 66332d683068cf672c6975305257e916d7d95fb4
4
+ data.tar.gz: 46d2ffa07f2aa215810cb75a31d329505e699a4a
5
5
  SHA512:
6
- metadata.gz: 7354369d4c55e3a90af02bd8513ffd086910548004c9c3faef3ab4e967a98a2670656fcf42edcf5acd9d6d16505906fd8758d259b3653d30de00917bad357982
7
- data.tar.gz: a5055c436c7f9fc994c17ef547885aec10503624810a1e36cb11ee324b9de11cedffa61468d56414dd20fb34233772652fb18ff0cac955bd14696482146ae8f7
6
+ metadata.gz: 4755b41f8d649f781a067c91f77747bf3be5947cf6f9ed41052834d00a4c311bd0d737c51f7cc2a3c7e593d0d54782c7822a0bdefcb1237ab99e7389a2171608
7
+ data.tar.gz: 38e7eb225eef6921af3f2cddc3bb3f029861cfd9d15bba73e920ed817973f8f0e0c740e55edaac5be06124c4870675ef65cb521890eaf549271f8ba10c8ae06b
data/.gitignore CHANGED
@@ -6,3 +6,5 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ .idea/*
10
+ .idea
data/Gemfile.lock ADDED
@@ -0,0 +1,22 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ostruct_deep (0.1.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ minitest (5.11.3)
10
+ rake (10.5.0)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ bundler (~> 1.16)
17
+ minitest (~> 5.0)
18
+ ostruct_deep!
19
+ rake (~> 10.0)
20
+
21
+ BUNDLED WITH
22
+ 1.16.1
data/README.md CHANGED
@@ -1,15 +1,13 @@
1
- # OpenStructExtend
1
+ # OpenStructDeep
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/open_struct_extend`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Make deeper ostruct, such as method chain of javascript object
6
4
 
7
5
  ## Installation
8
6
 
9
7
  Add this line to your application's Gemfile:
10
8
 
11
9
  ```ruby
12
- gem 'open_struct_extend'
10
+ gem 'ostruct_deep'
13
11
  ```
14
12
 
15
13
  And then execute:
@@ -18,11 +16,75 @@ And then execute:
18
16
 
19
17
  Or install it yourself as:
20
18
 
21
- $ gem install open_struct_extend
19
+ $ gem install ostruct_deep
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ In original ostruct do below:
24
+
25
+ ```ruby
26
+ hash = { "country" => "Australia", :population => 20_000_000, :info => { from: 1392, to: 1910 } }
27
+ data = OpenStruct.new(hash)
28
+
29
+ p data # -> <OpenStruct country="Australia" population=20000000, info={:from=>1392, :to=>1910}>
30
+ p data.country # -> "Australia"
31
+ p data["country"] # -> "Australia" # still works.
32
+
33
+ p data.info # -> {:from=>1392, :to=>1910}
34
+
35
+ # Problem Case
36
+ p data.info.from # -> NoMethodError: undefined method `from' for {:from=>1392, :to=>1910}:Hash
37
+ ```
38
+
39
+ In ostruct_deep do below:
40
+
41
+ The new hash has many stage and includes array.
42
+ ```ruby
43
+ hash =
44
+ { "country" => "Joseon",
45
+ :population => 20000000,
46
+
47
+ :info => { # 2nd stage
48
+ :from => 1392,
49
+ :to => 1910,
50
+
51
+ :started_by => { # 3rd stage
52
+ name: "Lee Seong Gye"
53
+ }
54
+ },
55
+
56
+ # Array container
57
+ :kings => [
58
+ { :name => "SeJong",
59
+ :terms => { # 2nd stage in array element
60
+ :from => 1418,
61
+ :to => 1450
62
+ }
63
+ },
64
+ { :name => "JeongJo",
65
+ :info => {
66
+ :what => "ever"
67
+ }
68
+ }
69
+ ]
70
+ }
71
+ ```
72
+
73
+ OpenStructDeep works fine :
74
+ ```ruby
75
+ data = OpenStructDeep.new(hash)
76
+
77
+ p data # -> <OpenStructDeep country="Joseon", population=20000000, info=#<OpenStructDeep from=1392, to=1910, started_by=#<OpenStructDeep name="Lee Seong Gye">>, kings=[#<OpenStructDeep name="SeJong", terms=#<OpenStructDeep from=1418, to=1450>>, #<OpenStructDeep name="JeongJo", info=#<OpenStructDeep what="ever">>]>
78
+ p data.country # -> 'Joseon'
79
+ p data.info # -> <OpenStructDeep from=1392, to=1910, started_by=#<OpenStructDeep name="Lee Seong Gye">>
80
+ p data.info.started_by.name # -> 'Lee Seong Gye'
81
+
82
+ p data.kings # -> [#<OpenStructDeep name="SeJong", terms=#<OpenStructDeep from=1418, to=1450>>, #<OpenStructDeep name="JeongJo", info=#<OpenStructDeep what="ever">>]
83
+ p data.kings.is_a?(Array) # -> true
84
+
85
+ # ... you can parse structure whatever you want
86
+
87
+ ```
26
88
 
27
89
  ## Development
28
90
 
@@ -32,7 +94,13 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
94
 
33
95
  ## Contributing
34
96
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/open_struct_extend. 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.
97
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/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.
98
+
99
+ You can contribute in works below with opening issues or pull requests.
100
+ - Documentation
101
+ - Suggest features
102
+ - Modify code style
103
+ - And more better correct comments
36
104
 
37
105
  ## License
38
106
 
@@ -40,4 +108,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
40
108
 
41
109
  ## Code of Conduct
42
110
 
43
- Everyone interacting in the OpenStructExtend project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/open_struct_extend/blob/master/CODE_OF_CONDUCT.md).
111
+ Everyone interacting in the OpenStructExtend project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ostruct_deep/blob/master/CODE_OF_CONDUCT.md).
@@ -1,3 +1,3 @@
1
1
  module OpenStructExtend
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ostruct_deep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Kim
@@ -63,6 +63,7 @@ files:
63
63
  - ".travis.yml"
64
64
  - CODE_OF_CONDUCT.md
65
65
  - Gemfile
66
+ - Gemfile.lock
66
67
  - LICENSE.txt
67
68
  - README.md
68
69
  - Rakefile