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 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
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.8.7
4
3
  - 1.9.2
5
4
  - 1.9.3
5
+ - 2.0.0
6
6
  notifications:
7
7
  email:
8
8
  recipients:
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'minitest'
6
+ gem 'coveralls'
7
+ gem 'rake'
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
@@ -16,6 +16,4 @@ Gem::Specification.new do |gem|
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
-
20
- gem.add_development_dependency "coveralls"
21
19
  end
@@ -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
- value.deep_fetch(*args, &block)
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
@@ -1,3 +1,3 @@
1
1
  module DeepFetch
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  require 'minitest/spec'
2
2
  require 'minitest/autorun'
3
3
 
4
- require_relative '../lib/deep_fetch'
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 = ->() { raise "BOOM" }
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.3
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-04-28 00:00:00.000000000 Z
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: 1.8.23
51
+ rubygems_version: 2.0.3
68
52
  signing_key:
69
- specification_version: 3
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: