darthjee-core_ext 3.0.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +10 -8
- data/.claude/agents/architect.md +41 -0
- data/.claude/agents/legacy.md +19 -0
- data/.claude/agents/ruby.md +31 -0
- data/.claude/agents/security.md +22 -0
- data/.claude/configuration/arcanum-repo-config.json +3 -0
- data/.claude/scripts/check_ruby.sh +8 -0
- data/.claude/settings.json +10 -0
- data/.github/commit_message_template-2.0.md +32 -0
- data/.github/commit_message_template.md +10 -0
- data/.github/copilot-instructions.md +1 -0
- data/.github/core_ext-usage.md +324 -0
- data/.github/pull_request_template.md +17 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +6 -5
- data/.rubocop_todo.yml +24 -11
- data/AGENTS.md +113 -0
- data/CLAUDE.md +1 -0
- data/Dockerfile +2 -2
- data/Gemfile +19 -12
- data/README.md +7 -8
- data/Rakefile +3 -0
- data/config/yardstick.yml +8 -36
- data/core_ext.gemspec +1 -1
- data/core_ext.jpg +0 -0
- data/docker-compose.yml +1 -1
- data/docs/agents/arcanum-split-issue.md +9 -0
- data/docs/agents/architecture.md +33 -0
- data/docs/agents/contributing.md +123 -0
- data/docs/agents/folder-structure.md +17 -0
- data/docs/agents/issue-enhancement.md +11 -0
- data/docs/agents/issues/.gitkeep +1 -0
- data/docs/agents/plans/.gitkeep +1 -0
- data/lib/darthjee/core_ext/array/hash_builder.rb +12 -0
- data/lib/darthjee/core_ext/hash/chain_fetcher.rb +22 -2
- data/lib/darthjee/core_ext/hash/deep_hash_constructor/setter.rb +12 -1
- data/lib/darthjee/core_ext/hash/deep_hash_constructor.rb +6 -1
- data/lib/darthjee/core_ext/hash/key_changer.rb +9 -0
- data/lib/darthjee/core_ext/hash/keys_sorter.rb +12 -0
- data/lib/darthjee/core_ext/hash/squasher.rb +8 -2
- data/lib/darthjee/core_ext/hash/transformable.rb +1 -0
- data/lib/darthjee/core_ext/hash/value_changer.rb +18 -0
- data/lib/darthjee/core_ext/numeric.rb +1 -1
- data/lib/darthjee/core_ext/time.rb +1 -0
- data/lib/darthjee/core_ext/version.rb +1 -1
- data/lib/darthjee/core_ext.rb +1 -0
- data/lib/darthjee.rb +1 -0
- data/scripts/bump_version.sh +62 -0
- data/spec/integration/readme/hash_spec.rb +2 -4
- data/spec/integration/yard/darthjee/core_ext/hash/changeable_spec.rb +2 -2
- data/spec/integration/yard/darthjee/core_ext/hash/value_changer_spec.rb +1 -1
- data/spec/integration/yard/darthjee/core_ext/object_spec.rb +1 -2
- data/spec/lib/darthjee/core_ext/hash/value_changer_spec.rb +8 -8
- data/spec/lib/object_spec.rb +1 -2
- data/spec/spec_helper.rb +6 -1
- metadata +27 -8
- data/mech.jpg +0 -0
|
@@ -124,6 +124,24 @@ module Darthjee
|
|
|
124
124
|
|
|
125
125
|
attr_reader :recursive, :skip_inner, :block
|
|
126
126
|
|
|
127
|
+
# @method recursive
|
|
128
|
+
# @api private
|
|
129
|
+
# @private
|
|
130
|
+
# Returns the flag telling to apply transformation recursively
|
|
131
|
+
# @return [::TrueClass,::FalseClass] flag telling to apply transformation recursively
|
|
132
|
+
|
|
133
|
+
# @method skip_inner
|
|
134
|
+
# @api private
|
|
135
|
+
# @private
|
|
136
|
+
# Returns the flag telling to not apply change block call to inner hashes
|
|
137
|
+
# @return [::TrueClass,::FalseClass] flag telling to not apply change block call to inner hashes
|
|
138
|
+
|
|
139
|
+
# @method block
|
|
140
|
+
# @api private
|
|
141
|
+
# @private
|
|
142
|
+
# Returns the block to be called when changing the values
|
|
143
|
+
# @return [::Proc] block to be called when changing the values
|
|
144
|
+
|
|
127
145
|
# @private
|
|
128
146
|
#
|
|
129
147
|
# Apply change logic to hash object
|
data/lib/darthjee/core_ext.rb
CHANGED
data/lib/darthjee.rb
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Usage: scripts/bump_version.sh [major|minor|patch|X.Y.Z]
|
|
3
|
+
# Without arguments, bumps the patch version of the current version.
|
|
4
|
+
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
ROOT="$(git rev-parse --show-toplevel)"
|
|
8
|
+
README="$ROOT/README.md"
|
|
9
|
+
VERSION_FILE="$ROOT/lib/darthjee/core_ext/version.rb"
|
|
10
|
+
LOCKFILE="$ROOT/Gemfile.lock"
|
|
11
|
+
GEM="darthjee-core_ext"
|
|
12
|
+
|
|
13
|
+
current=$(grep -oE "VERSION = '[0-9]+\.[0-9]+\.[0-9]+'" "$VERSION_FILE" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
|
|
14
|
+
IFS='.' read -r cmajor cminor cpatch <<< "$current"
|
|
15
|
+
|
|
16
|
+
arg="${1:-patch}"
|
|
17
|
+
|
|
18
|
+
case "$arg" in
|
|
19
|
+
major) new_version="$((cmajor + 1)).0.0" ;;
|
|
20
|
+
minor) new_version="${cmajor}.$((cminor + 1)).0" ;;
|
|
21
|
+
patch) new_version="${cmajor}.${cminor}.$((cpatch + 1))" ;;
|
|
22
|
+
*) new_version="$arg" ;;
|
|
23
|
+
esac
|
|
24
|
+
|
|
25
|
+
# Validate semver format
|
|
26
|
+
if ! echo "$new_version" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
|
|
27
|
+
echo "Error: version must be major, minor, patch or X.Y.Z" >&2
|
|
28
|
+
exit 1
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
# Next release: following minor
|
|
32
|
+
IFS='.' read -r major minor _patch <<< "$new_version"
|
|
33
|
+
next_release="${major}.$((minor + 1)).0"
|
|
34
|
+
|
|
35
|
+
echo "Current version: $current"
|
|
36
|
+
echo "New version: $new_version"
|
|
37
|
+
echo "Next release: $next_release"
|
|
38
|
+
|
|
39
|
+
# version.rb
|
|
40
|
+
sed -i '' "s|VERSION = '[0-9.]*'|VERSION = '${new_version}'|" "$VERSION_FILE"
|
|
41
|
+
|
|
42
|
+
# README: YARD docs link
|
|
43
|
+
sed -i '' \
|
|
44
|
+
"s|rubydoc.info/gems/${GEM}/[0-9.]*|rubydoc.info/gems/${GEM}/${new_version}|g" \
|
|
45
|
+
"$README"
|
|
46
|
+
|
|
47
|
+
# README: Current Release line
|
|
48
|
+
sed -i '' \
|
|
49
|
+
"s|\*\*Current Release\*\*: \[[0-9.]*\](https://github.com/darthjee/core_ext/tree/[0-9.]*)|**Current Release**: [${new_version}](https://github.com/darthjee/core_ext/tree/${new_version})|" \
|
|
50
|
+
"$README"
|
|
51
|
+
|
|
52
|
+
# README: Next release line
|
|
53
|
+
sed -i '' \
|
|
54
|
+
"s|\*\*Next release\*\*: \[[0-9.]*\](https://github.com/darthjee/core_ext/compare/[0-9.]*\.\.\.main)|**Next release**: [${next_release}](https://github.com/darthjee/core_ext/compare/${new_version}...main)|" \
|
|
55
|
+
"$README"
|
|
56
|
+
|
|
57
|
+
# Gemfile.lock
|
|
58
|
+
if [ -f "$LOCKFILE" ]; then
|
|
59
|
+
sed -i '' "s|^\( *${GEM} (\)[0-9.]*)|\1${new_version})|" "$LOCKFILE"
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
echo "Done."
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
|
-
# frozen_string_literal: true
|
|
6
|
-
|
|
7
5
|
describe Hash do
|
|
8
6
|
describe 'readme' do
|
|
9
7
|
describe '#chain_fetch' do
|
|
@@ -58,7 +56,7 @@ describe Hash do
|
|
|
58
56
|
end
|
|
59
57
|
|
|
60
58
|
it 'changes the values skipping inner' do
|
|
61
|
-
expect(result).to eq(a: '2', b: Array, d: '{:
|
|
59
|
+
expect(result).to eq(a: '2', b: Array, d: '{e: 3}')
|
|
62
60
|
end
|
|
63
61
|
end
|
|
64
62
|
end
|
|
@@ -101,7 +99,7 @@ describe Hash do
|
|
|
101
99
|
it 'changes the values skipping inner' do
|
|
102
100
|
expect { result }
|
|
103
101
|
.to change { hash }
|
|
104
|
-
.to(a: '2', b: Array, d: '{:
|
|
102
|
+
.to(a: '2', b: Array, d: '{e: 3}')
|
|
105
103
|
end
|
|
106
104
|
end
|
|
107
105
|
end
|
|
@@ -25,7 +25,7 @@ describe Darthjee::CoreExt::Hash::Changeable do
|
|
|
25
25
|
|
|
26
26
|
it 'changes the values' do
|
|
27
27
|
expect(hash.change_values(skip_inner: false, &:to_s))
|
|
28
|
-
.to eq(a: '1', b: '{:
|
|
28
|
+
.to eq(a: '1', b: '{c: 1}')
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
end
|
|
@@ -56,7 +56,7 @@ describe Darthjee::CoreExt::Hash::Changeable do
|
|
|
56
56
|
expect { hash.change_values!(skip_inner: false, &:to_s) }
|
|
57
57
|
.to change { hash }
|
|
58
58
|
.from(a: 1, b: { c: 2 })
|
|
59
|
-
.to(a: '1', b: '{:
|
|
59
|
+
.to(a: '1', b: '{c: 2}')
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
it 'changes the inner hash' do
|
|
@@ -24,7 +24,7 @@ describe Darthjee::CoreExt::Object do
|
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
# rubocop: disable RSpec/PredicateMatcher
|
|
27
|
+
# rubocop: disable-next RSpec/PredicateMatcher
|
|
28
28
|
describe '#trueful?' do
|
|
29
29
|
describe 'Calling on nil object' do
|
|
30
30
|
it { expect(nil.trueful?).not_to be_truthy }
|
|
@@ -42,6 +42,5 @@ describe Darthjee::CoreExt::Object do
|
|
|
42
42
|
it { expect(''.trueful?).to be_truthy }
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
|
-
# rubocop: enable RSpec/PredicateMatcher
|
|
46
45
|
end
|
|
47
46
|
end
|
|
@@ -73,7 +73,7 @@ describe Darthjee::CoreExt::Hash::ValueChanger do
|
|
|
73
73
|
let(:options) { { skip_inner: false } }
|
|
74
74
|
|
|
75
75
|
it 'apply change on inner hash' do
|
|
76
|
-
expect(changer.change(object)).to eq(a:
|
|
76
|
+
expect(changer.change(object)).to eq(a: 8)
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
79
|
|
|
@@ -81,7 +81,7 @@ describe Darthjee::CoreExt::Hash::ValueChanger do
|
|
|
81
81
|
let(:options) { { skip_inner: false, recursive: false } }
|
|
82
82
|
|
|
83
83
|
it 'applies the transformation before attempting recusrsive' do
|
|
84
|
-
expect(changer.change(object)).to eq(a:
|
|
84
|
+
expect(changer.change(object)).to eq(a: 8)
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
end
|
|
@@ -105,7 +105,7 @@ describe Darthjee::CoreExt::Hash::ValueChanger do
|
|
|
105
105
|
let(:options) { { skip_inner: false } }
|
|
106
106
|
|
|
107
107
|
it 'applies transformation over inner hash' do
|
|
108
|
-
expect(changer.change(object)).to eq(a:
|
|
108
|
+
expect(changer.change(object)).to eq(a: 10)
|
|
109
109
|
end
|
|
110
110
|
end
|
|
111
111
|
|
|
@@ -113,7 +113,7 @@ describe Darthjee::CoreExt::Hash::ValueChanger do
|
|
|
113
113
|
let(:options) { { skip_inner: false, recursive: false } }
|
|
114
114
|
|
|
115
115
|
it 'applies transformation before going recursive' do
|
|
116
|
-
expect(changer.change(object)).to eq(a:
|
|
116
|
+
expect(changer.change(object)).to eq(a: 10)
|
|
117
117
|
end
|
|
118
118
|
end
|
|
119
119
|
end
|
|
@@ -170,7 +170,7 @@ describe Darthjee::CoreExt::Hash::ValueChanger do
|
|
|
170
170
|
let(:options) { { skip_inner: false } }
|
|
171
171
|
|
|
172
172
|
it 'applies transformation on the first value of a hash' do
|
|
173
|
-
expect(changer.change(object)).to eq([[{ a: 3 }], [{ b:
|
|
173
|
+
expect(changer.change(object)).to eq([[{ a: 3 }], [{ b: 9 }]])
|
|
174
174
|
end
|
|
175
175
|
end
|
|
176
176
|
|
|
@@ -178,7 +178,7 @@ describe Darthjee::CoreExt::Hash::ValueChanger do
|
|
|
178
178
|
let(:options) { { skip_inner: false, recursive: false } }
|
|
179
179
|
|
|
180
180
|
it 'applies transformation before going recursive' do
|
|
181
|
-
expect(changer.change(object)).to eq([[{ a: 3 }], [{ b:
|
|
181
|
+
expect(changer.change(object)).to eq([[{ a: 3 }], [{ b: 9 }]])
|
|
182
182
|
end
|
|
183
183
|
end
|
|
184
184
|
end
|
|
@@ -193,7 +193,7 @@ describe Darthjee::CoreExt::Hash::ValueChanger do
|
|
|
193
193
|
end
|
|
194
194
|
|
|
195
195
|
it 'treat result of transformation as new hashes to be transformed' do
|
|
196
|
-
expected = { a: { size: 1 }, c:
|
|
196
|
+
expected = { a: { size: 1 }, c: 7, e: { size: 1 } }
|
|
197
197
|
expect(changer.change(object)).to eq(expected)
|
|
198
198
|
end
|
|
199
199
|
|
|
@@ -201,7 +201,7 @@ describe Darthjee::CoreExt::Hash::ValueChanger do
|
|
|
201
201
|
let(:options) { { skip_inner: false, recursive: false } }
|
|
202
202
|
|
|
203
203
|
it 'does not iterate over returned hash' do
|
|
204
|
-
expected = { a: { size: 1 }, c:
|
|
204
|
+
expected = { a: { size: 1 }, c: 7, e: { size: 0 } }
|
|
205
205
|
expect(changer.change(object)).to eq(expected)
|
|
206
206
|
end
|
|
207
207
|
end
|
data/spec/lib/object_spec.rb
CHANGED
|
@@ -35,7 +35,7 @@ describe Object do
|
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
# rubocop: disable RSpec/PredicateMatcher
|
|
38
|
+
# rubocop: disable-next RSpec/PredicateMatcher
|
|
39
39
|
describe '#trueful?' do
|
|
40
40
|
context 'when object is an empty array' do
|
|
41
41
|
it { expect([].trueful?).to be_truthy }
|
|
@@ -65,5 +65,4 @@ describe Object do
|
|
|
65
65
|
it { expect(false.trueful?).not_to be_truthy }
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
|
-
# rubocop: enable RSpec/PredicateMatcher
|
|
69
68
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'simplecov'
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
if ENV['CI']
|
|
6
|
+
require 'simplecov-lcov'
|
|
7
|
+
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
|
|
8
|
+
SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
|
|
9
|
+
end
|
|
5
10
|
|
|
6
11
|
SimpleCov.start do
|
|
7
12
|
add_filter '/spec/'
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: darthjee-core_ext
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Darthjee
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activesupport
|
|
@@ -32,13 +31,27 @@ extensions: []
|
|
|
32
31
|
extra_rdoc_files: []
|
|
33
32
|
files:
|
|
34
33
|
- ".circleci/config.yml"
|
|
34
|
+
- ".claude/agents/architect.md"
|
|
35
|
+
- ".claude/agents/legacy.md"
|
|
36
|
+
- ".claude/agents/ruby.md"
|
|
37
|
+
- ".claude/agents/security.md"
|
|
38
|
+
- ".claude/configuration/arcanum-repo-config.json"
|
|
39
|
+
- ".claude/scripts/check_ruby.sh"
|
|
40
|
+
- ".claude/settings.json"
|
|
41
|
+
- ".github/commit_message_template-2.0.md"
|
|
42
|
+
- ".github/commit_message_template.md"
|
|
43
|
+
- ".github/copilot-instructions.md"
|
|
44
|
+
- ".github/core_ext-usage.md"
|
|
45
|
+
- ".github/pull_request_template.md"
|
|
35
46
|
- ".gitignore"
|
|
36
47
|
- ".reek.yml"
|
|
37
48
|
- ".rspec"
|
|
38
49
|
- ".rubocop.yml"
|
|
39
50
|
- ".rubocop_todo.yml"
|
|
51
|
+
- AGENTS.md
|
|
40
52
|
- ARRAY_README.md
|
|
41
53
|
- CLASS_README.md
|
|
54
|
+
- CLAUDE.md
|
|
42
55
|
- DATE_README.md
|
|
43
56
|
- Dockerfile
|
|
44
57
|
- ENUMERABLE_README.md
|
|
@@ -56,7 +69,15 @@ files:
|
|
|
56
69
|
- config/yardstick.rb
|
|
57
70
|
- config/yardstick.yml
|
|
58
71
|
- core_ext.gemspec
|
|
72
|
+
- core_ext.jpg
|
|
59
73
|
- docker-compose.yml
|
|
74
|
+
- docs/agents/arcanum-split-issue.md
|
|
75
|
+
- docs/agents/architecture.md
|
|
76
|
+
- docs/agents/contributing.md
|
|
77
|
+
- docs/agents/folder-structure.md
|
|
78
|
+
- docs/agents/issue-enhancement.md
|
|
79
|
+
- docs/agents/issues/.gitkeep
|
|
80
|
+
- docs/agents/plans/.gitkeep
|
|
60
81
|
- lib/darthjee.rb
|
|
61
82
|
- lib/darthjee/core_ext.rb
|
|
62
83
|
- lib/darthjee/core_ext/array.rb
|
|
@@ -83,7 +104,7 @@ files:
|
|
|
83
104
|
- lib/darthjee/core_ext/symbol.rb
|
|
84
105
|
- lib/darthjee/core_ext/time.rb
|
|
85
106
|
- lib/darthjee/core_ext/version.rb
|
|
86
|
-
-
|
|
107
|
+
- scripts/bump_version.sh
|
|
87
108
|
- scripts/check_readme.sh
|
|
88
109
|
- scripts/rubycritic.sh
|
|
89
110
|
- spec/integration/readme/array_spec.rb
|
|
@@ -161,8 +182,7 @@ files:
|
|
|
161
182
|
homepage: https://github.com/darthjee/core_ext
|
|
162
183
|
licenses: []
|
|
163
184
|
metadata:
|
|
164
|
-
rubygems_mfa_required: '
|
|
165
|
-
post_install_message:
|
|
185
|
+
rubygems_mfa_required: 'false'
|
|
166
186
|
rdoc_options: []
|
|
167
187
|
require_paths:
|
|
168
188
|
- lib
|
|
@@ -177,8 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
177
197
|
- !ruby/object:Gem::Version
|
|
178
198
|
version: '0'
|
|
179
199
|
requirements: []
|
|
180
|
-
rubygems_version:
|
|
181
|
-
signing_key:
|
|
200
|
+
rubygems_version: 4.0.23
|
|
182
201
|
specification_version: 4
|
|
183
202
|
summary: Core Extensions
|
|
184
203
|
test_files: []
|
data/mech.jpg
DELETED
|
Binary file
|