deep_fetch 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/{travis.yml → .travis.yml} +1 -1
- data/Gemfile +7 -0
- data/Gemfile.lock +35 -0
- data/deep_fetch.gemspec +0 -2
- data/lib/deep_fetch/core_ext.rb +5 -1
- data/lib/deep_fetch/version.rb +1 -1
- data/spec/deep_fetch_spec.rb +6 -2
- metadata +11 -28
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eab46da124d8b557aba990b551706b502c783ba2
|
4
|
+
data.tar.gz: 3f987b3c7df58d46b4706c7c065fa9f28039f9ec
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e2941168595f835f2f151cf7776443f758a46a42a04ee81c6fe28b50818ce69cb1acc551253dcdb58ebbdacd3fe74acc80e11d1fe6e2e81d85e6501a5235c5a1
|
7
|
+
data.tar.gz: 864af824911a22758af38807ec0d7f2881c241feda3f19ffab93f0f3f0f0b0ca0eabb55e65d399a06fc4667b53555b6425522f23f42bc9c04f68cd0a5dbf4ca9
|
data/{travis.yml → .travis.yml}
RENAMED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
deep_fetch (0.0.3)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
colorize (0.5.8)
|
10
|
+
coveralls (0.6.7)
|
11
|
+
colorize
|
12
|
+
multi_json (~> 1.3)
|
13
|
+
rest-client
|
14
|
+
simplecov (>= 0.7)
|
15
|
+
thor
|
16
|
+
mime-types (1.23)
|
17
|
+
minitest (4.7.0)
|
18
|
+
multi_json (1.7.2)
|
19
|
+
rake (10.0.4)
|
20
|
+
rest-client (1.6.7)
|
21
|
+
mime-types (>= 1.16)
|
22
|
+
simplecov (0.7.1)
|
23
|
+
multi_json (~> 1.0)
|
24
|
+
simplecov-html (~> 0.7.1)
|
25
|
+
simplecov-html (0.7.1)
|
26
|
+
thor (0.18.1)
|
27
|
+
|
28
|
+
PLATFORMS
|
29
|
+
ruby
|
30
|
+
|
31
|
+
DEPENDENCIES
|
32
|
+
coveralls
|
33
|
+
deep_fetch!
|
34
|
+
minitest
|
35
|
+
rake
|
data/deep_fetch.gemspec
CHANGED
data/lib/deep_fetch/core_ext.rb
CHANGED
@@ -7,7 +7,11 @@ class Hash
|
|
7
7
|
value.deep_fetch(*args, &block)
|
8
8
|
elsif value.kind_of?(Array) && args.size > 0
|
9
9
|
value = value[args.shift]
|
10
|
-
|
10
|
+
if args.size > 0
|
11
|
+
value.deep_fetch(*args, &block)
|
12
|
+
else
|
13
|
+
value
|
14
|
+
end
|
11
15
|
elsif args.size > 0
|
12
16
|
{}.fetch(args.shift, &block)
|
13
17
|
else
|
data/lib/deep_fetch/version.rb
CHANGED
data/spec/deep_fetch_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'minitest/spec'
|
2
2
|
require 'minitest/autorun'
|
3
3
|
|
4
|
-
|
4
|
+
require File.expand_path('../../lib/deep_fetch', __FILE__)
|
5
5
|
require 'coveralls'
|
6
6
|
|
7
7
|
Coveralls.wear!
|
@@ -40,6 +40,10 @@ describe Hash do
|
|
40
40
|
it "of hash from deeper hash" do
|
41
41
|
{:foo => {:bar => {:baz => :boo}}}.deep_fetch(:foo, :bar).must_equal({:baz => :boo})
|
42
42
|
end
|
43
|
+
|
44
|
+
it "from nested array" do
|
45
|
+
{:foo => {:bar => [:baz]}}.deep_fetch(:foo, :bar, 0).must_equal(:baz)
|
46
|
+
end
|
43
47
|
end
|
44
48
|
|
45
49
|
describe "must rise KeyError" do
|
@@ -71,7 +75,7 @@ describe Hash do
|
|
71
75
|
end
|
72
76
|
|
73
77
|
it "must not evaluate a default block when fetching from deep hash" do
|
74
|
-
bomb =
|
78
|
+
bomb = lambda { raise "BOOM" }
|
75
79
|
{:foo => {:bar => :baz}}.deep_fetch(:foo, :bar, &bomb).must_equal :baz
|
76
80
|
end
|
77
81
|
end
|
metadata
CHANGED
@@ -1,32 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deep_fetch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Tomasz Pewiński
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
13
|
-
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: coveralls
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :development
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
11
|
+
date: 2013-07-19 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
30
13
|
description: easily fetch values from nested ruby hashes
|
31
14
|
email:
|
32
15
|
- pewniak747@gmail.com
|
@@ -35,6 +18,9 @@ extensions: []
|
|
35
18
|
extra_rdoc_files: []
|
36
19
|
files:
|
37
20
|
- .gitignore
|
21
|
+
- .travis.yml
|
22
|
+
- Gemfile
|
23
|
+
- Gemfile.lock
|
38
24
|
- LICENSE.txt
|
39
25
|
- README.md
|
40
26
|
- Rakefile
|
@@ -43,31 +29,28 @@ files:
|
|
43
29
|
- lib/deep_fetch/core_ext.rb
|
44
30
|
- lib/deep_fetch/version.rb
|
45
31
|
- spec/deep_fetch_spec.rb
|
46
|
-
- travis.yml
|
47
32
|
homepage: https://github.com/pewniak747/deep_fetch
|
48
33
|
licenses: []
|
34
|
+
metadata: {}
|
49
35
|
post_install_message:
|
50
36
|
rdoc_options: []
|
51
37
|
require_paths:
|
52
38
|
- lib
|
53
39
|
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
40
|
requirements:
|
56
|
-
- -
|
41
|
+
- - '>='
|
57
42
|
- !ruby/object:Gem::Version
|
58
43
|
version: '0'
|
59
44
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
-
none: false
|
61
45
|
requirements:
|
62
|
-
- -
|
46
|
+
- - '>='
|
63
47
|
- !ruby/object:Gem::Version
|
64
48
|
version: '0'
|
65
49
|
requirements: []
|
66
50
|
rubyforge_project:
|
67
|
-
rubygems_version:
|
51
|
+
rubygems_version: 2.0.3
|
68
52
|
signing_key:
|
69
|
-
specification_version:
|
53
|
+
specification_version: 4
|
70
54
|
summary: easily fetch values from nested ruby hashes
|
71
55
|
test_files:
|
72
56
|
- spec/deep_fetch_spec.rb
|
73
|
-
has_rdoc:
|