hash_ext 0.5.0 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +26 -0
- data/README.md +1 -2
- data/hash_ext.gemspec +0 -7
- data/lib/hash_ext/builder.rb +1 -1
- data/lib/hash_ext/nested.rb +1 -1
- data/lib/hash_ext/normalized.rb +11 -2
- data/lib/hash_ext/sorted.rb +4 -4
- data/lib/hash_ext/version.rb +1 -1
- data/lib/hash_ext.rb +1 -0
- metadata +4 -19
- data/.travis.yml +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bca61daa08eec133fde975f36da8db37331be48173d1041ac8fb610a11d187fb
|
4
|
+
data.tar.gz: 88ebe2cc65aea9c9696c9900d65889b2b6cc723835d447ce733b3db1172d0595
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e7c9bd2a09115f29bc3af858a8e0070de1402710ef2b8933ec28a8ba941aa7d42428638113c08b4309ccd5ca2efa38265acce306b222d373ebf42dfad519ad5
|
7
|
+
data.tar.gz: 7d3d096de1d2f4a33c33f30102bc8a64d3813c3f0f62b4d08740cfd25e65c13eeff576453230ecfd03c4d72973a67fca71be2cfcb74328a6941f6cf569e1917d
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ '**' ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ '**' ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
|
12
|
+
name: Tests
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
ruby-version: ['2.0', '2.1', '2.2', '2.3', '2.4', '2.5', '2.6', '2.7', '3.0', 'jruby-9.2.9.0']
|
17
|
+
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v3
|
20
|
+
- name: Set up Ruby
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby-version }}
|
24
|
+
bundler-cache: true
|
25
|
+
- name: Run tests
|
26
|
+
run: bundle exec rake
|
data/README.md
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# HashExt
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/hash_ext.svg)](https://rubygems.org/gems/hash_ext)
|
4
|
-
[![
|
4
|
+
[![CI](https://github.com/gabynaiman/hash_ext/actions/workflows/ci.yml/badge.svg)](https://github.com/gabynaiman/hash_ext/actions/workflows/ci.yml)
|
5
5
|
[![Coverage Status](https://coveralls.io/repos/gabynaiman/hash_ext/badge.svg?branch=master)](https://coveralls.io/r/gabynaiman/hash_ext?branch=master)
|
6
6
|
[![Code Climate](https://codeclimate.com/github/gabynaiman/hash_ext.svg)](https://codeclimate.com/github/gabynaiman/hash_ext)
|
7
|
-
[![Dependency Status](https://gemnasium.com/gabynaiman/hash_ext.svg)](https://gemnasium.com/gabynaiman/hash_ext)
|
8
7
|
|
9
8
|
Hash extensions without monkey patching
|
10
9
|
|
data/hash_ext.gemspec
CHANGED
@@ -19,7 +19,6 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
|
-
spec.add_development_dependency 'bundler', '~> 1.12'
|
23
22
|
spec.add_development_dependency 'rake', '~> 11.0'
|
24
23
|
spec.add_development_dependency 'minitest', '~> 5.0', '< 5.11'
|
25
24
|
spec.add_development_dependency 'minitest-colorin', '~> 0.1'
|
@@ -27,10 +26,4 @@ Gem::Specification.new do |spec|
|
|
27
26
|
spec.add_development_dependency 'simplecov', '~> 0.14'
|
28
27
|
spec.add_development_dependency 'coveralls', '~> 0.8'
|
29
28
|
spec.add_development_dependency 'pry-nav', '~> 0.2'
|
30
|
-
|
31
|
-
if RUBY_VERSION < '2'
|
32
|
-
spec.add_development_dependency 'term-ansicolor', '~> 1.3.0'
|
33
|
-
spec.add_development_dependency 'tins', '~> 1.6.0'
|
34
|
-
spec.add_development_dependency 'json', '~> 1.8'
|
35
|
-
end
|
36
29
|
end
|
data/lib/hash_ext/builder.rb
CHANGED
data/lib/hash_ext/nested.rb
CHANGED
data/lib/hash_ext/normalized.rb
CHANGED
@@ -53,6 +53,13 @@ class Hash
|
|
53
53
|
super normalize_key(key), *args, &block
|
54
54
|
end
|
55
55
|
|
56
|
+
def dig(*keys)
|
57
|
+
normalized_keys = keys.map { |k| normalize_key(k) }
|
58
|
+
normalized_keys.inject(self) do |target, key|
|
59
|
+
target ? target[key] : nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
56
63
|
def to_h
|
57
64
|
each_with_object({}) do |(key, value), hash|
|
58
65
|
hash[key] = value_to_h value
|
@@ -66,8 +73,10 @@ class Hash
|
|
66
73
|
end
|
67
74
|
|
68
75
|
def normalize_value(value)
|
69
|
-
if value.
|
70
|
-
|
76
|
+
if value.is_a? self.class
|
77
|
+
value
|
78
|
+
elsif value.kind_of? Hash
|
79
|
+
self.class.new value, &@normalization_block
|
71
80
|
elsif value.kind_of? Array
|
72
81
|
value.map { |v| normalize_value v }
|
73
82
|
else
|
data/lib/hash_ext/sorted.rb
CHANGED
@@ -7,12 +7,12 @@ class Hash
|
|
7
7
|
|
8
8
|
def_delegators :@hash, :[], :[]=, :value?, :fetch, :values_at,
|
9
9
|
:key?, :include?, :empty?,
|
10
|
-
:delete, :delete_if, :clear,
|
10
|
+
:delete, :delete_if, :clear,
|
11
11
|
:merge, :merge!, :update, :store, :replace,
|
12
12
|
:count, :size, :length,
|
13
13
|
:==, :eql, :hash
|
14
|
-
|
15
|
-
def_delegators :to_h, :to_a, :to_s, :inspect,
|
14
|
+
|
15
|
+
def_delegators :to_h, :to_a, :to_s, :inspect,
|
16
16
|
:select, :reject, :flatten,
|
17
17
|
:as_json, :to_json
|
18
18
|
|
@@ -56,7 +56,7 @@ class Hash
|
|
56
56
|
attr_reader :direction, :sort_criteria
|
57
57
|
|
58
58
|
class << self
|
59
|
-
|
59
|
+
|
60
60
|
def ascending(hash={}, &sort_criteria)
|
61
61
|
new hash, :asc, &sort_criteria
|
62
62
|
end
|
data/lib/hash_ext/version.rb
CHANGED
data/lib/hash_ext.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash_ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Naiman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.12'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.12'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rake
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,10 +122,10 @@ extensions: []
|
|
136
122
|
extra_rdoc_files: []
|
137
123
|
files:
|
138
124
|
- ".coveralls.yml"
|
125
|
+
- ".github/workflows/ci.yml"
|
139
126
|
- ".gitignore"
|
140
127
|
- ".ruby-gemset"
|
141
128
|
- ".ruby-version"
|
142
|
-
- ".travis.yml"
|
143
129
|
- Gemfile
|
144
130
|
- LICENSE.txt
|
145
131
|
- README.md
|
@@ -173,8 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
159
|
- !ruby/object:Gem::Version
|
174
160
|
version: '0'
|
175
161
|
requirements: []
|
176
|
-
|
177
|
-
rubygems_version: 2.7.3
|
162
|
+
rubygems_version: 3.0.8
|
178
163
|
signing_key:
|
179
164
|
specification_version: 4
|
180
165
|
summary: Hash extensions without monkey patching
|
data/.travis.yml
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
rvm:
|
4
|
-
- 1.9.3
|
5
|
-
- 2.0
|
6
|
-
- 2.1
|
7
|
-
- 2.2
|
8
|
-
- 2.3.0
|
9
|
-
- 2.4.0
|
10
|
-
- 2.5.0
|
11
|
-
- 2.6.0
|
12
|
-
- jruby-1.7.25
|
13
|
-
- jruby-9.1.7.0
|
14
|
-
- ruby-head
|
15
|
-
- jruby-head
|
16
|
-
|
17
|
-
matrix:
|
18
|
-
fast_finish: true
|
19
|
-
allow_failures:
|
20
|
-
- rvm: ruby-head
|
21
|
-
- rvm: jruby-head
|
22
|
-
|
23
|
-
before_install:
|
24
|
-
- rvm all-gemsets do gem uninstall bundler -ax || true
|
25
|
-
- gem install bundler -v "< 2"
|