bury 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/gem-push.yml +30 -0
- data/.github/workflows/test.yml +26 -0
- data/Gemfile.lock +2 -7
- data/README.md +2 -0
- data/bury.gemspec +2 -3
- data/lib/bury/version.rb +1 -1
- data/lib/bury.rb +3 -13
- metadata +9 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84d91bcfe1d6d643a532c60ab9858f7914297e933b1acd47d850e2133af57d5a
|
4
|
+
data.tar.gz: 4cdd52a55a4808fde527578f7a87babd7fd60c11e4cc164bb14b83ab21739d42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b51c37a562338d21cc59950b0f4b0509515a6deec409a40292feea1e4b6a8865001acfa6d4d963cbf4bb9c28bcaffde125993cec2551de0257a53e14bb4e58be
|
7
|
+
data.tar.gz: 8825978c730f2b5e062b673d718bee49949f22f42f63fdf5c9c64df866a8f3addc1579640810e19da04ba81de0cef0811fe994cf0add30c667f5990fdb2e88e8
|
@@ -0,0 +1,30 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_dispatch:
|
5
|
+
|
6
|
+
jobs:
|
7
|
+
build:
|
8
|
+
name: Build + Publish
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
permissions:
|
11
|
+
contents: read
|
12
|
+
packages: write
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
- name: Set up Ruby 2.6
|
17
|
+
uses: actions/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: 2.6.x
|
20
|
+
|
21
|
+
- name: Publish to RubyGems
|
22
|
+
run: |
|
23
|
+
mkdir -p $HOME/.gem
|
24
|
+
touch $HOME/.gem/credentials
|
25
|
+
chmod 0600 $HOME/.gem/credentials
|
26
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
27
|
+
gem build *.gemspec
|
28
|
+
gem push *.gem
|
29
|
+
env:
|
30
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ main ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1']
|
15
|
+
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- name: Set up Ruby
|
19
|
+
uses: ruby/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: ${{ matrix.ruby }}
|
22
|
+
bundler-cache: true
|
23
|
+
- name: Update RubyGems
|
24
|
+
run: gem update --system 3.2.3
|
25
|
+
- name: Run tests
|
26
|
+
run: bundle exec rake
|
data/Gemfile.lock
CHANGED
@@ -1,16 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bury (1.
|
4
|
+
bury (1.1.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
minitest (5.15.0)
|
10
|
-
minitest-power_assert (0.3.1)
|
11
|
-
minitest
|
12
|
-
power_assert (>= 1.1)
|
13
|
-
power_assert (2.0.1)
|
14
10
|
rake (12.3.3)
|
15
11
|
|
16
12
|
PLATFORMS
|
@@ -19,8 +15,7 @@ PLATFORMS
|
|
19
15
|
DEPENDENCIES
|
20
16
|
bury!
|
21
17
|
minitest (~> 5.0)
|
22
|
-
minitest-power_assert (~> 0.3)
|
23
18
|
rake (~> 12.0)
|
24
19
|
|
25
20
|
BUNDLED WITH
|
26
|
-
2.
|
21
|
+
2.3.5
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Bury
|
2
2
|
|
3
|
+
[![Test](https://github.com/patorash/bury/actions/workflows/test.yml/badge.svg)](https://github.com/patorash/bury/actions/workflows/test.yml)
|
4
|
+
|
3
5
|
Bury is a library for extending the Hash class. `Hash#bury` method is the opposite of the `Hash#dig` method.
|
4
6
|
|
5
7
|
## Installation
|
data/bury.gemspec
CHANGED
@@ -6,8 +6,8 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.authors = ["Toyoaki Oko"]
|
7
7
|
spec.email = ["chariderpato@gmail.com"]
|
8
8
|
|
9
|
-
spec.summary = %q{Bury
|
10
|
-
spec.description = %q{Bury
|
9
|
+
spec.summary = %q{Bury is a library for extending the Hash class. Hash#bury method is the opposite of the Hash#dig method.}
|
10
|
+
spec.description = %q{Bury is a library for extending the Hash class. Hash#bury method is the opposite of the Hash#dig method.}
|
11
11
|
spec.homepage = "https://github.com/patorash/bury"
|
12
12
|
spec.license = "MIT"
|
13
13
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
@@ -27,5 +27,4 @@ Gem::Specification.new do |spec|
|
|
27
27
|
|
28
28
|
spec.add_development_dependency 'rake', '~> 12.0'
|
29
29
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
30
|
-
spec.add_development_dependency 'minitest-power_assert', '~> 0.3'
|
31
30
|
end
|
data/lib/bury/version.rb
CHANGED
data/lib/bury.rb
CHANGED
@@ -5,21 +5,14 @@ module Bury
|
|
5
5
|
# Merge Hash according to the array of keys passed to Hash
|
6
6
|
# @param [Array<String|Symbol>] keys
|
7
7
|
# @param [Object] value
|
8
|
-
# @option [Integer] index
|
9
8
|
# @return [Hash]
|
10
9
|
# @example example
|
11
10
|
# {}.bury([:a,:b,:c], 1) # => {a:{b:{c: 1}}}
|
12
11
|
# {a: {d: 2}}.bury([:a,:b,:c], 1) # => {a:{b:{c:1},d:2}}
|
13
12
|
def bury(keys, value)
|
14
|
-
|
15
|
-
|
16
|
-
if hash.has_key?(key) && hash[key].is_a?(Hash)
|
17
|
-
merge_for_burying.call(hash[key], _keys, target_hash, index + 1)
|
18
|
-
else
|
19
|
-
hash.merge!(index.zero? ? target_hash : target_hash.dig(*_keys.take(index)))
|
20
|
-
end
|
13
|
+
merge_proc = lambda do |_key, old_value, new_value|
|
14
|
+
[old_value, new_value].all? { |v| v.is_a? Hash } ? old_value.merge!(new_value, &merge_proc) : new_value
|
21
15
|
end
|
22
|
-
|
23
16
|
create_hash_recursively = lambda do |_keys, _value, index = 0|
|
24
17
|
if _keys.size - 1 == index
|
25
18
|
{ _keys[index] => _value }
|
@@ -27,10 +20,7 @@ module Bury
|
|
27
20
|
{ _keys[index] => create_hash_recursively.call(_keys, _value, index + 1)}
|
28
21
|
end
|
29
22
|
end
|
30
|
-
|
31
|
-
merge_for_burying.call(self, keys, create_hash_recursively.call(keys, value))
|
32
|
-
|
33
|
-
self
|
23
|
+
merge!(create_hash_recursively.call(keys, value), &merge_proc)
|
34
24
|
end
|
35
25
|
|
36
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bury
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toyoaki Oko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,27 +38,16 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '5.0'
|
41
|
-
|
42
|
-
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0.3'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0.3'
|
55
|
-
description: Bury defines Hash#bury method.
|
41
|
+
description: Bury is a library for extending the Hash class. Hash#bury method is the
|
42
|
+
opposite of the Hash#dig method.
|
56
43
|
email:
|
57
44
|
- chariderpato@gmail.com
|
58
45
|
executables: []
|
59
46
|
extensions: []
|
60
47
|
extra_rdoc_files: []
|
61
48
|
files:
|
49
|
+
- ".github/workflows/gem-push.yml"
|
50
|
+
- ".github/workflows/test.yml"
|
62
51
|
- ".gitignore"
|
63
52
|
- CODE_OF_CONDUCT.md
|
64
53
|
- Gemfile
|
@@ -92,9 +81,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
requirements: []
|
95
|
-
|
96
|
-
rubygems_version: 2.7.3
|
84
|
+
rubygems_version: 3.2.3
|
97
85
|
signing_key:
|
98
86
|
specification_version: 4
|
99
|
-
summary: Bury
|
87
|
+
summary: Bury is a library for extending the Hash class. Hash#bury method is the opposite
|
88
|
+
of the Hash#dig method.
|
100
89
|
test_files: []
|