backport_dig 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a4dde83bd36c3f7fdfd4e389d0b2484277d3bb5
4
- data.tar.gz: d3a7ff89a6858e0a2b716ac2fd6f3bd87d0d43b5
3
+ metadata.gz: 0c2cd469be19656c64c432426b10cf53186b0ac7
4
+ data.tar.gz: 461f848d23b43ebb5c168f6867e18d9c54ed5ee9
5
5
  SHA512:
6
- metadata.gz: 3f111c6a90ab86cb36164d8b5e28c814d31900f468e4d02b505d6960eafe9610142011741022bd64e33eea93e6f3ae863f6ad3b841519da14df88a76372d15db
7
- data.tar.gz: 9ebb36d8b31583a19d22726b3c716076f322c0443e260f13f42ed28ec3eac554fc990afe98382884829bb7785e0d94d2bfe212ad21cd54048479329face18f1a
6
+ metadata.gz: 9ff5fbecba2247d21c94581ec6122b93d2bc775628ef794d0b1779687e27a07cf0910ca783faaef3c90ca7f1b2a7a0d7eb310a7bdd80a10782a914815516ea95
7
+ data.tar.gz: 7d329c028973e27a8c942ae7fcdc0095529f20a6d355fc1d0c53b6bb7ee6c2fcacd59ff629933d6680e5bcacf7d3e4dd57e57341cd1e787614b007fcecb2a802
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # backport_dig [![Build Status](https://travis-ci.org/koic/backport_dig.svg)](https://travis-ci.org/koic/backport_dig)
1
+ # backport_dig [![Build Status](https://travis-ci.org/koic/backport_dig.svg)](https://travis-ci.org/koic/backport_dig) [![Gem Version](https://badge.fury.io/rb/backport_dig.svg)](http://badge.fury.io/rb/backport_dig)
2
2
 
3
3
  backport_dig is the backport of Hash#dig and Array#dig in Ruby 2.3.0 to older Ruby versions.
4
4
 
@@ -50,11 +50,6 @@ And require it as:
50
50
  require 'backport_dig'
51
51
  ```
52
52
 
53
- ## Special Thanks
54
-
55
- * Ruby Development Team
56
- * Pay homage to [ruby_dig](https://rubygems.org/gems/ruby_dig)
57
-
58
53
  ## Contributing
59
54
 
60
55
  1. Fork it
@@ -66,3 +61,13 @@ require 'backport_dig'
66
61
  ## License
67
62
 
68
63
  backport_dig is released under the [MIT License](http://www.opensource.org/licenses/MIT).
64
+
65
+ ### Get the original codes
66
+
67
+ * Hash#dig and Array#dig [https://github.com/ruby/ruby/commit/2986268](https://github.com/ruby/ruby/commit/29862685c0acf3a40c6b1f9e8780cbbd86cba658#diff-24411fb2a634ee46e29925b04767d15e)
68
+ * OpenStruct#dig [https://github.com/ruby/ruby/commit/4825306](https://github.com/ruby/ruby/commit/482530680c18ea2e44c3300c6f323fabc3bd55f7#diff-f0ac5119f74bfda273347c9925e910d7)
69
+
70
+ ## Special Thanks
71
+
72
+ * Ruby Development Team
73
+ * Pay homage to [ruby_dig](https://rubygems.org/gems/ruby_dig)
@@ -1 +1,2 @@
1
1
  require 'backport_dig/backport_dig'
2
+ require 'backport_dig/ostruct'
@@ -0,0 +1,21 @@
1
+ require 'ostruct'
2
+
3
+ class OpenStruct
4
+ #
5
+ # Retrieves the value object corresponding to the each +name+
6
+ # objects repeatedly.
7
+ #
8
+ # address = OpenStruct.new('city' => "Anytown NC", 'zip' => 12345)
9
+ # person = OpenStruct.new('name' => 'John Smith', 'address' => address)
10
+ # person.dig(:address, 'zip') # => 12345
11
+ # person.dig(:business_address, 'zip') # => nil
12
+ #
13
+ def dig(name, *names)
14
+ begin
15
+ name = name.to_sym
16
+ rescue NoMethodError
17
+ return
18
+ end
19
+ @table.dig(name, *names)
20
+ end
21
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backport_dig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koichi ITO
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-26 00:00:00.000000000 Z
11
+ date: 2016-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hoe
@@ -66,15 +66,14 @@ files:
66
66
  - ext/backport_dig/backport_dig.c
67
67
  - ext/backport_dig/extconf.rb
68
68
  - lib/backport_dig.rb
69
+ - lib/backport_dig/ostruct.rb
69
70
  homepage: https://github.com/koic/backport_dig
70
71
  licenses:
71
72
  - MIT
72
73
  metadata: {}
73
74
  post_install_message: |
74
75
  backport_dig is the backport of Hash#dig and Array#dig in Ruby 2.3.0 to older Ruby versions.
75
-
76
76
  The best way is to use Ruby 2.3.0 or later.
77
-
78
77
  Thanks.
79
78
  rdoc_options: []
80
79
  require_paths: