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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +10 -8
  3. data/.claude/agents/architect.md +41 -0
  4. data/.claude/agents/legacy.md +19 -0
  5. data/.claude/agents/ruby.md +31 -0
  6. data/.claude/agents/security.md +22 -0
  7. data/.claude/configuration/arcanum-repo-config.json +3 -0
  8. data/.claude/scripts/check_ruby.sh +8 -0
  9. data/.claude/settings.json +10 -0
  10. data/.github/commit_message_template-2.0.md +32 -0
  11. data/.github/commit_message_template.md +10 -0
  12. data/.github/copilot-instructions.md +1 -0
  13. data/.github/core_ext-usage.md +324 -0
  14. data/.github/pull_request_template.md +17 -0
  15. data/.gitignore +1 -0
  16. data/.rubocop.yml +6 -5
  17. data/.rubocop_todo.yml +24 -11
  18. data/AGENTS.md +113 -0
  19. data/CLAUDE.md +1 -0
  20. data/Dockerfile +2 -2
  21. data/Gemfile +19 -12
  22. data/README.md +7 -8
  23. data/Rakefile +3 -0
  24. data/config/yardstick.yml +8 -36
  25. data/core_ext.gemspec +1 -1
  26. data/core_ext.jpg +0 -0
  27. data/docker-compose.yml +1 -1
  28. data/docs/agents/arcanum-split-issue.md +9 -0
  29. data/docs/agents/architecture.md +33 -0
  30. data/docs/agents/contributing.md +123 -0
  31. data/docs/agents/folder-structure.md +17 -0
  32. data/docs/agents/issue-enhancement.md +11 -0
  33. data/docs/agents/issues/.gitkeep +1 -0
  34. data/docs/agents/plans/.gitkeep +1 -0
  35. data/lib/darthjee/core_ext/array/hash_builder.rb +12 -0
  36. data/lib/darthjee/core_ext/hash/chain_fetcher.rb +22 -2
  37. data/lib/darthjee/core_ext/hash/deep_hash_constructor/setter.rb +12 -1
  38. data/lib/darthjee/core_ext/hash/deep_hash_constructor.rb +6 -1
  39. data/lib/darthjee/core_ext/hash/key_changer.rb +9 -0
  40. data/lib/darthjee/core_ext/hash/keys_sorter.rb +12 -0
  41. data/lib/darthjee/core_ext/hash/squasher.rb +8 -2
  42. data/lib/darthjee/core_ext/hash/transformable.rb +1 -0
  43. data/lib/darthjee/core_ext/hash/value_changer.rb +18 -0
  44. data/lib/darthjee/core_ext/numeric.rb +1 -1
  45. data/lib/darthjee/core_ext/time.rb +1 -0
  46. data/lib/darthjee/core_ext/version.rb +1 -1
  47. data/lib/darthjee/core_ext.rb +1 -0
  48. data/lib/darthjee.rb +1 -0
  49. data/scripts/bump_version.sh +62 -0
  50. data/spec/integration/readme/hash_spec.rb +2 -4
  51. data/spec/integration/yard/darthjee/core_ext/hash/changeable_spec.rb +2 -2
  52. data/spec/integration/yard/darthjee/core_ext/hash/value_changer_spec.rb +1 -1
  53. data/spec/integration/yard/darthjee/core_ext/object_spec.rb +1 -2
  54. data/spec/lib/darthjee/core_ext/hash/value_changer_spec.rb +8 -8
  55. data/spec/lib/object_spec.rb +1 -2
  56. data/spec/spec_helper.rb +6 -1
  57. metadata +27 -8
  58. data/mech.jpg +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 488d3a9ef14a0b2369f3d281bc0ab6433eeb29ef9696cda0bb77886b6a0528ca
4
- data.tar.gz: 78a996784bc1dda49f0a2349ec25d8b131576967e4262f3523ded5a25ca52e74
3
+ metadata.gz: 2be51d5f98eb56eb38bbe096f1df08ddf10b32eead8c106a4bdf3f565705f54c
4
+ data.tar.gz: 8f01466a2c6e5bddc66b3a0a3e1f0faf5bd843da49e93bf1da099fc11eae2219
5
5
  SHA512:
6
- metadata.gz: a76d650ce4908f61c4e9fd88cb8ae6e1ba8712a05e4d5ce07eea7a048f91bf78e1926cbafa1695eaca167a57645832977546e53a8eac8309424fdbf4e077174f
7
- data.tar.gz: 523348bc447c0299531540dd1308b7ff202d2e7a2da59c84b292a85c4883ee1b20cd16637b6cd51ec51b0241180f5917059dc3639c74f8eca98feff854c9dd65
6
+ metadata.gz: 91f1ff57e0908357695e5e4cadd69cc3f49711d39df0971e4c7b61144efebad69f423221093ecea4d9c4821a333481e6229bf80939d39a6c0a5ac7c904411c1b
7
+ data.tar.gz: 95ce069229e486ba050b54e9239201ebf43a045fee4f197482cce5008cce900f7f63a74d8cf4005a1341ac9f8fc0117dc958ad9b02c1b49cbcff3de97abbb08b
data/.circleci/config.yml CHANGED
@@ -1,6 +1,5 @@
1
- version: 2
1
+ version: 2.1
2
2
  workflows:
3
- version: 2
4
3
  test-and-build:
5
4
  jobs:
6
5
  - test:
@@ -22,7 +21,7 @@ workflows:
22
21
  jobs:
23
22
  test:
24
23
  docker:
25
- - image: darthjee/circleci_ruby_331:1.0.2
24
+ - image: darthjee/circleci_ruby_3412:1.0.0
26
25
  environment:
27
26
  PROJECT: core_ext
28
27
  steps:
@@ -32,10 +31,13 @@ jobs:
32
31
  command: bundle install
33
32
  - run:
34
33
  name: RSpec
35
- command: COVERAGE_JSON=true bundle exec rspec
34
+ command: bundle exec rspec
35
+ - run:
36
+ name: Upload coverage to Codacy
37
+ command: bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r coverage/lcov/project.lcov
36
38
  checks:
37
39
  docker:
38
- - image: darthjee/circleci_ruby_331:1.0.2
40
+ - image: darthjee/circleci_ruby_3412:1.0.0
39
41
  environment:
40
42
  PROJECT: core_ext
41
43
  steps:
@@ -60,7 +62,7 @@ jobs:
60
62
  command: check_specs
61
63
  build-and-release:
62
64
  docker:
63
- - image: darthjee/circleci_ruby_331:1.0.2
65
+ - image: darthjee/circleci_ruby_3412:1.0.0
64
66
  environment:
65
67
  PROJECT: core_ext
66
68
  steps:
@@ -73,7 +75,7 @@ jobs:
73
75
  command: build_gem.sh signin
74
76
  - run:
75
77
  name: Build Gem
76
- command: build_gem.sh build
78
+ command: PROJECT=darthjee-core_ext build_gem.sh build
77
79
  - run:
78
80
  name: Push Gem
79
- command: build_gem.sh push
81
+ command: PROJECT=darthjee-core_ext build_gem.sh push
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: architect
3
+ description: core_ext architect and coordinator. Use for cross-cutting tasks, multi-agent coordination, documentation, root-level files, or any task that spans more than one agent's scope.
4
+ tools: Read, Edit, Write, Bash, Agent
5
+ ---
6
+
7
+ You are the architect and coordinator for core_ext, a Ruby gem (`darthjee-core_ext`) that adds methods to Ruby core classes.
8
+
9
+ ## Your scope
10
+
11
+ - `docs/agents/`
12
+ - Root-level files: README.md, *_README.md, AGENTS.md, CLAUDE.md, gemspec, Gemfile, Dockerfile, docker-compose.yml, Makefile
13
+ - Cross-cutting decisions and coordination of the specialists
14
+
15
+ ## Specialist agents
16
+
17
+ Delegate implementation, exploration and review to the right agent.
18
+
19
+ | Agent | Scope |
20
+ |-------|-------|
21
+ | `ruby` | `lib/`, `spec/`, `config/`, `scripts/`: implementation, tests, YARD docs |
22
+ | `security` | Read-only review of `lib/` for exploitable code |
23
+ | `legacy` | Read-only review of `lib/` for extensions that Ruby already provides |
24
+
25
+ ## How to coordinate
26
+
27
+ 1. Break the task down by agent.
28
+ 2. Delegate exploration first.
29
+ 3. Run independent agents in parallel, dependent ones in sequence.
30
+ 4. For new or changed extensions, dispatch `security` and `legacy` to review after `ruby` implements.
31
+ 5. Update `docs/agents/` after any architectural change.
32
+
33
+ ## Documentation (`docs/agents/`)
34
+
35
+ | Document | Description |
36
+ |----------|-------------|
37
+ | `folder-structure.md` | Top-level directory layout |
38
+ | `architecture.md` | Source layout and design |
39
+ | `contributing.md` | Commit, PR and code-organization rules |
40
+
41
+ Keep them and AGENTS.md in sync when scopes change.
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: legacy
3
+ description: core_ext legacy reviewer. Use to find extensions that are deprecated or redundant because Ruby (or the stdlib) already provides an equivalent.
4
+ tools: Read, Grep, Glob, Bash
5
+ ---
6
+
7
+ You are the legacy reviewer for core_ext. You are read-only: report findings, never edit files.
8
+
9
+ ## Your scope
10
+
11
+ Compare every method in `lib/darthjee/core_ext/` with the Ruby versions the gem supports (see gemspec and CI image) and look for:
12
+
13
+ - Methods now built in (`Hash#transform_keys`, `Hash#to_h` with a block, `Array#sum`, `Enumerable#each_with_object`/`tally`/`filter_map`, `Hash#dig`, and similar)
14
+ - Methods that only wrap a single built-in call
15
+ - Extensions whose behaviour differs from the built-in, which is a compatibility risk
16
+
17
+ ## Report format
18
+
19
+ Per method: file:line, the Ruby equivalent and since which version, whether behaviour is identical (note differences), and a recommendation (deprecate, keep as alias, or keep). Test with `ruby -e` where unsure.
@@ -0,0 +1,31 @@
1
+ ---
2
+ name: ruby
3
+ description: core_ext Ruby specialist. Use for any task involving Ruby code, RSpec specs, YARD docs, Rubocop, or gem tooling under lib/, spec/, config/ and scripts/.
4
+ tools: Read, Edit, Write, Bash
5
+ ---
6
+
7
+ You are the Ruby specialist for core_ext, a gem that adds methods to Ruby core classes.
8
+
9
+ ## Your scope
10
+
11
+ You own `lib/`, `spec/`, `config/` and `scripts/`. Do NOT touch `docs/agents/` or root-level docs and packaging files.
12
+
13
+ ## Stack
14
+
15
+ Ruby 3.3, RSpec, Rubocop, Yardstick/YARD, RubyCritic, Reek.
16
+
17
+ ## Commands
18
+
19
+ ```bash
20
+ bundle exec rspec
21
+ bundle exec rubocop
22
+ bundle exec rake verify_measurements
23
+ check_specs
24
+ ```
25
+
26
+ ## Conventions
27
+
28
+ - English everywhere; every public method has YARD docs with an @example
29
+ - Every feature or fix has specs mirroring `lib/` under `spec/lib/`
30
+ - Single responsibility, small methods, Law of Demeter; collaborators go in `lib/darthjee/core_ext/<class>/`
31
+ - Never add files to `config/check_specs.yml` just to skip tests
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: security
3
+ description: core_ext security reviewer. Use to check new or changed code for possible exploitation (code injection, unsafe metaprogramming, ReDoS, unsafe deserialization, unsafe core overrides).
4
+ tools: Read, Grep, Glob, Bash
5
+ ---
6
+
7
+ You are the security reviewer for core_ext. You are read-only: report findings, never edit files.
8
+
9
+ ## Your scope
10
+
11
+ Review `lib/` (and `spec/` only for context). Look for:
12
+
13
+ - `eval`, `instance_eval`/`class_eval` on strings, `send`/`public_send`/`const_get` with caller-controlled input
14
+ - Shell or file access (`system`, backticks, `open`, `File`) and unsafe deserialization (`Marshal.load`, `YAML.load`)
15
+ - Regexes prone to ReDoS
16
+ - Monkey-patches that change the semantics or visibility of existing core methods, or leak state
17
+ - Unbounded recursion or memory growth on hostile input (deep or huge hashes and arrays)
18
+ - Vulnerable dependencies (`bundle exec bundler-audit` if available)
19
+
20
+ ## Report format
21
+
22
+ Per finding: file:line, severity, exploit scenario, suggested fix. Say explicitly when nothing was found.
@@ -0,0 +1,3 @@
1
+ {
2
+ "version": "2.4.0"
3
+ }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ set -x
4
+
5
+ bundle exec rspec
6
+ bundle exec rubocop
7
+ bundle exec rake verify_measurements
8
+ check_specs
@@ -0,0 +1,10 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(auto-fix-all/scripts/wait_ci_and_merge.sh *)",
5
+ "Bash(auto-fix-issue/scripts/commit_change.sh *)",
6
+ "Bash(auto-fix-issue/scripts/run_checks.sh *)",
7
+ "Bash(git add *)"
8
+ ]
9
+ }
10
+ }
@@ -0,0 +1,32 @@
1
+ ```text
2
+ <type>(<scope>): <subject> (issue #<id>)
3
+
4
+ <optional body: what was done and why, if not obvious>
5
+
6
+ Addresses-Comment: <optional: URL of the PR comment this commit addresses>
7
+
8
+ Co-Authored-By: <AI model name> <AI model email>
9
+ Co-Authored-By: <agent> agent <agent email>
10
+ ```
11
+
12
+ Note: unlike the model line above (always the running AI model's own
13
+ canonical noreply address), the agent line's email is independently
14
+ configurable per agent via the "git.email" key (a template such as
15
+ "you+{agent}@example.com", with "{agent}" substituted for the actual
16
+ agent name, e.g. "architect" or "backend") in
17
+ .claude/state/arcanum-config.json (local) or
18
+ .claude/configuration/arcanum-repo-config.json (repo) — see
19
+ docs/guides/arcanum-repo-config.md. When "git.email" is unset, the agent
20
+ line falls back to the same address as the model line, reproducing the
21
+ old, single-shared-email template's output.
22
+
23
+ The model line above can be omitted entirely by setting the
24
+ "git.omit_model_coauthor" key to "true" in the same three locations
25
+ (local state, repo config, or global config — see
26
+ docs/guides/arcanum-repo-config.md) — the agent line is always still
27
+ emitted regardless of this setting.
28
+
29
+ This file's mere presence (as "commit_message_template-2.0.md", not its
30
+ content) is what switches the commit scripts onto this new, two-distinct-
31
+ email behavior — the content itself is never parsed at runtime, it is
32
+ purely human-facing documentation of the shape above.
@@ -0,0 +1,10 @@
1
+ ```text
2
+ <type>(<scope>): <subject> (issue #<id>)
3
+
4
+ <optional body: what was done and why, if not obvious>
5
+
6
+ Addresses-Comment: <optional: URL of the PR comment this commit addresses>
7
+
8
+ Co-Authored-By: <AI model name> <AI model email>
9
+ Co-Authored-By: <agent> agent <AI model email>
10
+ ```
@@ -0,0 +1 @@
1
+ See [AGENTS.md](../AGENTS.md) for project instructions.
@@ -0,0 +1,324 @@
1
+ # Using `darthjee-core_ext` in Your Project
2
+
3
+ This file is intended to be copied into the `.github/` folder of other projects.
4
+ It provides GitHub Copilot (and developers) with a clear, actionable guide on how
5
+ to use the [`darthjee-core_ext`](https://github.com/darthjee/core_ext) Ruby gem.
6
+
7
+ ---
8
+
9
+ ## What Is `core_ext`?
10
+
11
+ `darthjee-core_ext` is a Ruby gem that extends Ruby's built-in (core) classes with
12
+ additional utility methods. It follows the convention of "core extensions" — monkey-patching
13
+ standard objects such as `Array`, `Hash`, `Symbol`, `Enumerable`, `Date`, `Object`,
14
+ `Numeric`, and `Math` with useful helpers, while maintaining predictable behavior.
15
+
16
+ - **Gem name**: `darthjee-core_ext`
17
+ - **Source**: <https://github.com/darthjee/core_ext>
18
+ - **YARD docs**: <https://www.rubydoc.info/gems/darthjee-core_ext>
19
+ - **Current stable release**: 3.0.0
20
+
21
+ ---
22
+
23
+ ## Adding the Gem to Your Project
24
+
25
+ ### Via RubyGems (recommended)
26
+
27
+ Add to your `Gemfile`:
28
+
29
+ ```ruby
30
+ gem 'darthjee-core_ext'
31
+ ```
32
+
33
+ Or pin a specific version for reproducible builds:
34
+
35
+ ```ruby
36
+ gem 'darthjee-core_ext', '~> 3.0'
37
+ ```
38
+
39
+ ### Via GitHub (source)
40
+
41
+ ```ruby
42
+ gem 'darthjee-core_ext',
43
+ github: 'darthjee/core_ext',
44
+ branch: 'main'
45
+ ```
46
+
47
+ ---
48
+
49
+ ## Installing
50
+
51
+ After adding the gem to your `Gemfile`, run:
52
+
53
+ ```shell
54
+ bundle install
55
+ ```
56
+
57
+ Or install it system-wide:
58
+
59
+ ```shell
60
+ gem install darthjee-core_ext
61
+ ```
62
+
63
+ ---
64
+
65
+ ## Loading the Gem
66
+
67
+ When using Bundler (Rails, typical Ruby apps), the gem is loaded automatically via
68
+ `Bundler.require`. No explicit `require` is needed.
69
+
70
+ In plain Ruby scripts or when Bundler auto-require is disabled, add:
71
+
72
+ ```ruby
73
+ require 'darthjee/core_ext'
74
+ ```
75
+
76
+ ---
77
+
78
+ ## Extensions Provided
79
+
80
+ ### `Hash`
81
+
82
+ | Method | Description |
83
+ |---|---|
84
+ | `#append_to_keys` | Appends a string to every key |
85
+ | `#prepend_to_keys` | Prepends a string to every key |
86
+ | `#camelize_keys` / `#camelize_keys!` | Converts keys to CamelCase |
87
+ | `#lower_camelize_keys` / `#lower_camelize_keys!` | Converts keys to lowerCamelCase |
88
+ | `#underscore_keys` / `#underscore_keys!` | Converts keys to snake_case |
89
+ | `#change_keys` / `#change_keys!` | Transforms keys with a block |
90
+ | `#chain_change_keys` / `#chain_change_keys!` | Transforms keys by chaining method calls |
91
+ | `#change_values` / `#change_values!` | Transforms values with a block (optionally recursive) |
92
+ | `#chain_fetch` | Fetches nested keys in a chain |
93
+ | `#exclusive_merge` / `#exclusive_merge!` | Merges only existing keys |
94
+ | `#remap_keys` / `#remap_keys!` | Renames keys based on a mapping hash |
95
+ | `#sort_keys` / `#sort_keys!` | Sorts the hash by its keys |
96
+ | `#squash` / `#squash!` | Flattens a deep hash into a single-level hash |
97
+ | `#to_deep_hash` / `#to_deep_hash!` | Expands a squashed hash back into a deep hash |
98
+ | `#map_to_hash` | Maps values keeping original keys |
99
+ | `#transpose` / `#transpose!` | Swaps keys with values |
100
+
101
+ ### `Array`
102
+
103
+ | Method | Description |
104
+ |---|---|
105
+ | `#as_hash` | Zips the array with a keys array into a Hash |
106
+ | `#average` | Returns the arithmetic average of the elements |
107
+ | `#chain_map` | Applies `.map` in a chain of method calls |
108
+ | `#mapk` | Maps by fetching nested keys from hashes inside the array |
109
+ | `#procedural_join` | Joins elements with a dynamically computed separator |
110
+ | `#random` | Returns a random element |
111
+ | `#random!` | Removes and returns a random element |
112
+
113
+ ### `Symbol`
114
+
115
+ | Method | Description |
116
+ |---|---|
117
+ | `#camelize` | Camelizes the symbol (`:my_sym` → `:MySym`) |
118
+ | `#underscore` | Underscores a camelized symbol (`:MySym` → `:my_sym`) |
119
+
120
+ ### `Enumerable` (available on `Array`, `Hash`, and any `Enumerable`)
121
+
122
+ | Method | Description |
123
+ |---|---|
124
+ | `#clean` | Returns a copy with empty values removed |
125
+ | `#clean!` | Removes empty values in place (recursive) |
126
+ | `#map_and_find` | Maps and stops at the first truthy result |
127
+ | `#map_and_select` | Maps and returns only truthy results |
128
+ | `#map_to_hash` | Maps values, using original elements as keys |
129
+
130
+ ### `Object` (available on every Ruby object)
131
+
132
+ | Method | Description |
133
+ |---|---|
134
+ | `#is_any?` | Returns `true` if the object is an instance of any of the given classes |
135
+ | `#trueful?` | Returns `true` only when the object is not `nil` (unlike `#present?`, `[]` and `{}` are trueful) |
136
+
137
+ ### `Date`
138
+
139
+ | Method | Description |
140
+ |---|---|
141
+ | `#days_between` | Returns the absolute number of days between two dates |
142
+
143
+ ### `Math`
144
+
145
+ | Method | Description |
146
+ |---|---|
147
+ | `.average` | Calculates the (optionally weighted) average of values |
148
+
149
+ ### `Class`
150
+
151
+ | Method | Description |
152
+ |---|---|
153
+ | `.default_value` | Adds a reader that returns the same default instance every time |
154
+ | `.default_values` | Adds multiple readers sharing the same default instance |
155
+ | `.default_reader` | Adds a reader that returns a default value only when the instance variable was never set |
156
+ | `.default_readers` | Adds multiple default readers sharing the same default value |
157
+
158
+ ---
159
+
160
+ ## Code Examples
161
+
162
+ ### Hash key transformations
163
+
164
+ ```ruby
165
+ # Converting API responses from camelCase to snake_case
166
+ response = { 'userId' => 1, 'firstName' => 'Alice' }
167
+ response.underscore_keys # => { 'user_id' => 1, 'first_name' => 'Alice' }
168
+
169
+ # Preparing a payload for a camelCase API
170
+ params = { user_id: 1, first_name: 'Alice' }
171
+ params.lower_camelize_keys
172
+ # => { userId: 1, firstName: 'Alice' }
173
+
174
+ # Equivalent long form with explicit option
175
+ params.camelize_keys(uppercase_first_letter: false)
176
+ # => { userId: 1, firstName: 'Alice' }
177
+ ```
178
+
179
+ ### Fetching nested values safely
180
+
181
+ ```ruby
182
+ config = { database: { primary: { host: 'localhost' } } }
183
+
184
+ config.chain_fetch(:database, :primary, :host) # => 'localhost'
185
+ config.chain_fetch(:database, :replica, :host) { |key, _rest| "default-#{key}" }
186
+ # => 'default-replica'
187
+ ```
188
+
189
+ ### Flattening and restoring deep hashes
190
+
191
+ ```ruby
192
+ deep = { a: { b: [1, 2] } }
193
+ flat = deep.squash # => { 'a.b[0]' => 1, 'a.b[1]' => 2 }
194
+ flat.to_deep_hash # => { 'a' => { 'b' => [1, 2] } }
195
+ ```
196
+
197
+ ### Exclusive merge (update only existing keys)
198
+
199
+ ```ruby
200
+ defaults = { timeout: 30, retries: 3 }
201
+ overrides = { retries: 5, unknown_key: 'ignored' }
202
+
203
+ defaults.exclusive_merge(overrides) # => { timeout: 30, retries: 5 }
204
+ ```
205
+
206
+ ### Array utilities
207
+
208
+ ```ruby
209
+ # Zip an array with keys into a Hash
210
+ values = [10, 20, 30]
211
+ values.as_hash(%i[x y z]) # => { x: 10, y: 20, z: 30 }
212
+
213
+ # Chain map calls
214
+ [:hello, :world].chain_map(:to_s, :upcase) # => ['HELLO', 'WORLD']
215
+
216
+ # Fetch nested keys from an array of hashes
217
+ records = [{ user: { id: 1 } }, { user: { id: 2 } }]
218
+ records.mapk(:user, :id) # => [1, 2]
219
+ ```
220
+
221
+ ### Symbol utilities
222
+
223
+ ```ruby
224
+ :my_method_name.camelize # => :MyMethodName
225
+ :my_method_name.camelize(:lower) # => :myMethodName
226
+ :MyMethodName.underscore # => :my_method_name
227
+ ```
228
+
229
+ ### Enumerable cleaning
230
+
231
+ ```ruby
232
+ data = { name: 'Alice', nickname: nil, tags: [], meta: {} }
233
+ data.clean # => { name: 'Alice' }
234
+
235
+ mixed = [1, nil, '', [], {}, 'hello']
236
+ mixed.clean # => [1, 'hello']
237
+ ```
238
+
239
+ ### Object helpers
240
+
241
+ ```ruby
242
+ value = 42
243
+ value.is_any?(String, Symbol) # => false
244
+ value.is_any?(String, Symbol, Integer) # => true
245
+
246
+ nil.trueful? # => false
247
+ [].trueful? # => true (unlike blank?/present?)
248
+ ''.trueful? # => true
249
+ ```
250
+
251
+ ### Class default readers
252
+
253
+ ```ruby
254
+ class Report
255
+ attr_writer :title
256
+ default_reader :title, 'Untitled Report'
257
+ end
258
+
259
+ r = Report.new
260
+ r.title # => 'Untitled Report'
261
+ r.title = 'Q1'
262
+ r.title # => 'Q1'
263
+ r.title = nil
264
+ r.title # => nil (nil is respected; differs from default_value)
265
+ ```
266
+
267
+ ### Math weighted average
268
+
269
+ ```ruby
270
+ # Simple average
271
+ Math.average([10, 20, 30]) # => 20.0
272
+
273
+ # Weighted average (value => weight)
274
+ Math.average(10 => 1, 20 => 2, 30 => 1) # => 20.0
275
+ ```
276
+
277
+ ---
278
+
279
+ ## Best Practices and Caveats
280
+
281
+ ### Monkey-patching awareness
282
+
283
+ `core_ext` extends Ruby's built-in classes globally. This means:
284
+
285
+ - All objects of the extended classes gain the new methods **throughout your entire application**, including third-party gems.
286
+ - **Name collision risk**: if another gem or your application already defines a method with the same name on the same class, the last `require`/`load` wins. Review the method list above before adoption and check for conflicts.
287
+ - In libraries (gems) intended for wide reuse, prefer not requiring `core_ext` at the top level unless you own all consumers.
288
+
289
+ ### Recursive options
290
+
291
+ Several `Hash` methods (`change_keys`, `camelize_keys`, `underscore_keys`, `change_values`, `clean!`) operate recursively by default, descending into nested arrays and hashes. Pass `recursive: false` when you only need shallow transformation to avoid unintended side-effects on nested structures.
292
+
293
+ ### Bang (`!`) methods vs. non-bang methods
294
+
295
+ Methods ending with `!` mutate the receiver **in place**. Use them when you are sure you do not need the original structure. Use the non-bang variants to return a transformed copy.
296
+
297
+ ### Versioning
298
+
299
+ Pin to a minor version to avoid unexpected breaking changes:
300
+
301
+ ```ruby
302
+ gem 'darthjee-core_ext', '~> 3.0'
303
+ ```
304
+
305
+ Check the [CHANGELOG / releases page](https://github.com/darthjee/core_ext/releases) before upgrading.
306
+
307
+ ---
308
+
309
+ ## Running the Test Suite / Contributing
310
+
311
+ If you are contributing to `core_ext` itself or want to verify its behavior locally:
312
+
313
+ ```shell
314
+ # Install dependencies
315
+ bundle install
316
+
317
+ # Run the full test suite
318
+ bundle exec rspec
319
+
320
+ # Run a single spec file
321
+ bundle exec rspec spec/lib/darthjee/core_ext/hash_spec.rb
322
+ ```
323
+
324
+ Tests live under `spec/` and mirror the structure of `lib/`. Every public method must have a corresponding spec. See the [README](https://github.com/darthjee/core_ext/blob/main/README.md) and the repository's Copilot instructions (`.github/copilot-instructions.md`) for more details.
@@ -0,0 +1,17 @@
1
+ ## Summary
2
+
3
+ <!-- One sentence describing what this PR does -->
4
+
5
+ ## Problem
6
+
7
+ <!-- What problem does this solve? Why is this change needed? -->
8
+
9
+ ## Solution
10
+
11
+ <!-- How was the problem solved? What approach was taken? -->
12
+
13
+ ## Details
14
+
15
+ <!-- Optional: implementation notes, migration steps, caveats. Remove this section if not needed. -->
16
+
17
+ Fixes #
data/.gitignore CHANGED
@@ -6,3 +6,4 @@ doc
6
6
  measurement
7
7
  rubycritic
8
8
  **/.*.swp
9
+ .claude/state/
data/.rubocop.yml CHANGED
@@ -1,4 +1,6 @@
1
- require: rubocop-rspec
1
+ plugins:
2
+ - rubocop-rspec
3
+ - rubocop-rake
2
4
  inherit_from: .rubocop_todo.yml
3
5
 
4
6
  AllCops:
@@ -9,10 +11,6 @@ RSpec/MultipleExpectations:
9
11
  Exclude:
10
12
  - 'spec/integration/**/*_spec.rb'
11
13
 
12
- Naming/PredicateName:
13
- Exclude:
14
- - 'lib/darthjee/core_ext/object.rb'
15
-
16
14
  Metrics/BlockLength:
17
15
  Exclude:
18
16
  - 'spec/**/*_spec.rb'
@@ -35,3 +33,6 @@ Style/HashEachMethods:
35
33
  Exclude:
36
34
  - 'lib/darthjee/core_ext/hash/deep_hash_constructor.rb'
37
35
  - 'lib/darthjee/core_ext/hash/squasher.rb'
36
+
37
+ Gemspec/RequireMFA:
38
+ Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -1,23 +1,36 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2025-02-24 21:33:57 UTC using RuboCop version 1.59.0.
3
+ # on 2026-03-11 13:23:23 UTC using RuboCop version 1.85.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
- # versionsuof RuboCop, may require this file to be generated again.
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
11
+ # NamePrefix: is_, has_, have_, does_
12
+ # ForbiddenPrefixes: is_, has_, have_, does_
13
+ # AllowedMethods: is_a?
14
+ # MethodDefinitionMacros: define_method, define_singleton_method
15
+ Naming/PredicatePrefix:
16
+ Exclude:
17
+ - 'spec/**/*'
18
+ - 'lib/darthjee/core_ext/object.rb'
8
19
 
9
20
  # Offense count: 4
10
21
  # Configuration parameters: AllowSubject.
11
22
  RSpec/MultipleMemoizedHelpers:
12
23
  Max: 6
13
24
 
14
- # Offense count: 4
15
- # Configuration parameters: AllowedConstants.
16
- Style/Documentation:
25
+ # Offense count: 8
26
+ # Configuration parameters: AllowedClasses.
27
+ Style/OneClassPerFile:
17
28
  Exclude:
18
- - 'spec/**/*'
19
- - 'test/**/*'
20
- - 'lib/darthjee.rb'
21
- - 'lib/darthjee/core_ext.rb'
22
- - 'lib/darthjee/core_ext/hash/transformable.rb'
23
- - 'lib/darthjee/core_ext/time.rb'
29
+ - 'lib/darthjee/core_ext/array.rb'
30
+ - 'lib/darthjee/core_ext/class.rb'
31
+ - 'lib/darthjee/core_ext/date.rb'
32
+ - 'lib/darthjee/core_ext/hash.rb'
33
+ - 'lib/darthjee/core_ext/math.rb'
34
+ - 'lib/darthjee/core_ext/numeric.rb'
35
+ - 'lib/darthjee/core_ext/object.rb'
36
+ - 'lib/darthjee/core_ext/symbol.rb'