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 +4 -4
- data/README.md +11 -6
- data/lib/backport_dig.rb +1 -0
- data/lib/backport_dig/ostruct.rb +21 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c2cd469be19656c64c432426b10cf53186b0ac7
|
4
|
+
data.tar.gz: 461f848d23b43ebb5c168f6867e18d9c54ed5ee9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
data/lib/backport_dig.rb
CHANGED
@@ -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.
|
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-
|
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:
|