darthjee-active_ext 1.3.2 → 2.0.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 (50) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +77 -9
  3. data/.claude/agents/architect.md +46 -0
  4. data/.claude/agents/ruby.md +49 -0
  5. data/.claude/configuration/arcanum-repo-config.json +8 -0
  6. data/.claude/scripts/check_ruby.sh +7 -0
  7. data/.claude/settings.json +10 -0
  8. data/.github/active_ext-usage.md +137 -0
  9. data/.github/commit_message_template-2.0.md +32 -0
  10. data/.github/commit_message_template.md +10 -0
  11. data/.github/copilot-instructions.md +1 -0
  12. data/.github/pull_request_template.md +17 -0
  13. data/.gitignore +6 -0
  14. data/.rubocop.yml +12 -0
  15. data/.rubocop_todo.yml +8 -0
  16. data/AGENTS.md +139 -0
  17. data/CLAUDE.md +1 -0
  18. data/Dockerfile +21 -0
  19. data/Gemfile +25 -0
  20. data/Makefile +6 -0
  21. data/README.md +15 -3
  22. data/Rakefile +8 -0
  23. data/active_ext.gemspec +7 -14
  24. data/active_ext.jpg +0 -0
  25. data/config/check_specs.yml +6 -0
  26. data/config/rubycritc.rb +12 -0
  27. data/config/yardstick.rb +13 -0
  28. data/config/yardstick.yml +39 -0
  29. data/docker-compose.yml +14 -9
  30. data/docs/agents/arcanum-split-issue.md +9 -0
  31. data/docs/agents/architecture.md +59 -0
  32. data/docs/agents/contributing.md +182 -0
  33. data/docs/agents/flow.md +5 -0
  34. data/docs/agents/folder-structure.md +18 -0
  35. data/docs/agents/issue-enhancement.md +13 -0
  36. data/docs/agents/issues/.gitkeep +1 -0
  37. data/docs/agents/plans/.gitkeep +1 -0
  38. data/lib/active_record/base_ext.rb +39 -2
  39. data/lib/active_record/relation_ext.rb +108 -10
  40. data/lib/darthjee/active_ext/version.rb +3 -1
  41. data/lib/darthjee/active_ext.rb +3 -0
  42. data/lib/darthjee.rb +3 -1
  43. data/scripts/bump_version.sh +62 -0
  44. data/spec/lib/active_record/relation_spec.rb +5 -3
  45. data/spec/spec_helper.rb +12 -8
  46. data/spec/support/models/document.rb +2 -0
  47. data/spec/support/schema.rb +3 -1
  48. data/spec/support/shared_examples/active_relation.rb +4 -2
  49. metadata +43 -121
  50. data/spec/lib/active_record/base_spec.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fb91b628ca83024e054c1739dea5c23e3086c99c
4
- data.tar.gz: 7c95c17e1a61c92d9819bb9c4c206a4958d34d6b
2
+ SHA256:
3
+ metadata.gz: 519372f970cd7269217941e0195cbe7ae07e8efd832be66b81294425b4afecdf
4
+ data.tar.gz: 20f465f2aa808ce6c8b3d8884672c2a568ec10ce73d8c8c91ccb22cf1750a622
5
5
  SHA512:
6
- metadata.gz: e7dad17a96b13c41e2d24185166006e1892c11ad2fb5a8bf9ccac364c8eb1f7a286a3cbbfd2adf147baaf3704d3c7fd1c574826158774b95743dcd13616e0b1f
7
- data.tar.gz: 83ad3e5604468f5ab2128d572fc4f4ffc510ee503d284bf3ba8150c179711b252502b19e8df976bf6207d24e3c1eb1a70bbe3a0a6cbd66f75e3c1b8225f07f97
6
+ metadata.gz: b2d1d141abfac80b8b0a436e04a15bd2768e957047e726b402fd5fe5689ec1b56eae640878c5732b5cbde63b84f1504a8fd9c1041e180ed0b9c340a67bb79dd1
7
+ data.tar.gz: 768c0b01bd9150083923a4f3801810d1b96132db431bcad29f5c0f1339c6034c302441a6b9cc2b8d4bcb179cfd4e4cc8409fd21a9281f12756909517dc66a9b7
data/.circleci/config.yml CHANGED
@@ -1,13 +1,81 @@
1
- version: 2
1
+ version: 2.1
2
+ workflows:
3
+ test-and-build:
4
+ jobs:
5
+ - test:
6
+ filters:
7
+ tags:
8
+ only: /.*/
9
+ - checks:
10
+ filters:
11
+ tags:
12
+ only: /.*/
13
+ - build-and-release:
14
+ requires: [test, checks]
15
+ filters:
16
+ tags:
17
+ only: /\d+\.\d+\.\d+/
18
+ branches:
19
+ only:
20
+ - main
2
21
  jobs:
3
- build:
22
+ test:
4
23
  docker:
5
- - image: circleci/ruby:2.4.1
24
+ - image: darthjee/circleci_rails_gems:3.0.0
25
+ environment:
26
+ PROJECT: active_ext
6
27
  steps:
7
28
  - checkout
8
- - run: curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
9
- - run: chmod +x ./cc-test-reporter
10
- - run: ./cc-test-reporter before-build
11
- - run: bundle install
12
- - run: bundle exec rspec
13
- - run: ./cc-test-reporter after-build --exit-code $?
29
+ - run:
30
+ name: Bundle Install
31
+ command: bundle install
32
+ - run:
33
+ name: 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
38
+ checks:
39
+ docker:
40
+ - image: darthjee/circleci_rails_gems:3.0.0
41
+ environment:
42
+ PROJECT: active_ext
43
+ steps:
44
+ - checkout
45
+ - run:
46
+ name: Bundle Install
47
+ command: bundle install
48
+ - run:
49
+ name: Rubocop
50
+ command: rubocop
51
+ - run:
52
+ name: Yardstick coverage check
53
+ command: bundle exec rake verify_measurements
54
+ - run:
55
+ name: Check version documentation
56
+ command: PROJECT=darthjee-active_ext check_readme.sh
57
+ - run:
58
+ name: Rubycritcs check
59
+ command: rubycritic.sh
60
+ - run:
61
+ name: Check unit tests
62
+ command: check_specs
63
+ build-and-release:
64
+ docker:
65
+ - image: darthjee/circleci_rails_gems:3.0.0
66
+ environment:
67
+ PROJECT: active_ext
68
+ steps:
69
+ - checkout
70
+ - run:
71
+ name: Bundle Install
72
+ command: bundle install
73
+ - run:
74
+ name: Signin
75
+ command: build_gem.sh signin
76
+ - run:
77
+ name: Build Gem
78
+ command: PROJECT=darthjee-active_ext build_gem.sh build
79
+ - run:
80
+ name: Push Gem
81
+ command: PROJECT=darthjee-active_ext build_gem.sh push
@@ -0,0 +1,46 @@
1
+ ---
2
+ name: architect
3
+ description: active_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 the active_ext project — a Ruby gem (`darthjee-active_ext`) that adds query helpers to ActiveRecord::Relation and ActiveRecord::Base.
8
+
9
+ ## Your scope
10
+
11
+ - `docs/agents/` — all project documentation
12
+ - Root-level files: `README.md`, `AGENTS.md`, `CLAUDE.md`, `LICENSE`, `Dockerfile`, `docker-compose.yml`, `Makefile`
13
+ - `.github/` and `.circleci/`
14
+ - Cross-cutting decisions that span multiple layers
15
+ - Coordination of the other specialist agents
16
+
17
+ ## Specialist agents
18
+
19
+ Delegate implementation, exploration, and planning work to the right agent. Never implement, explore, or plan what belongs to a specialist yourself.
20
+
21
+ | Agent | Scope |
22
+ |-------|-------|
23
+ | `ruby` | `lib/`, `spec/`, `config/` and the Ruby tooling files: gem code, specs, YARD, RuboCop |
24
+
25
+ ## How to coordinate
26
+
27
+ When a task spans multiple agents:
28
+
29
+ 1. **Break it down** — identify which parts belong to which agent.
30
+ 2. **Delegate exploration first** — before proposing an approach, dispatch the specialist(s) whose scope covers the relevant area to investigate, rather than reading the code yourself.
31
+ 3. **Sequence or parallelize** — if agents' outputs are independent, run them in parallel; if one depends on the other, sequence them.
32
+ 4. **Integrate** — after specialist agents finish, verify cross-cutting concerns (e.g. README usage examples and the version line in `README.md` match the code).
33
+ 5. **Update docs** — reflect any architectural change in `docs/agents/`.
34
+
35
+ ## Documentation (`docs/agents/`)
36
+
37
+ | File | Contents |
38
+ |------|----------|
39
+ | [Folder Structure](../../docs/agents/folder-structure.md) | Top-level directory layout and the role of each folder. |
40
+ | [Architecture](../../docs/agents/architecture.md) | Source layout, modules, code style, and implementation guidelines. |
41
+ | [Flow](../../docs/agents/flow.md) | Main runtime flow of the application. |
42
+ | [Contributing](../../docs/agents/contributing.md) | Commit guidelines, PR standards, code organization, and refactoring rules. |
43
+ | [Plans](../../docs/agents/plans/) | Implementation plans for ongoing or upcoming features. |
44
+ | [Issues](../../docs/agents/issues/) | Detailed specs for open issues. |
45
+
46
+ Keep documentation up to date after any architectural change. When a new agent is created or its scope changes, update this file and `AGENTS.md`.
@@ -0,0 +1,49 @@
1
+ ---
2
+ name: ruby
3
+ description: active_ext Ruby specialist. Use for any task involving Ruby code, ActiveRecord/ActiveSupport extensions, RSpec specs, YARD docs, RuboCop, or files under lib/, spec/, config/.
4
+ tools: Read, Edit, Write, Bash
5
+ ---
6
+
7
+ You are the ruby specialist for the active_ext project — a Ruby gem (`darthjee-active_ext`) that adds query helpers to ActiveRecord::Relation and ActiveRecord::Base.
8
+
9
+ ## Your scope
10
+
11
+ You own:
12
+
13
+ - `lib/` — gem source (`darthjee/` entry point and version, `active_record/` extensions)
14
+ - `spec/` — RSpec suite (`spec/lib/` mirrors `lib/`; `spec/support/` has the schema, models, shared examples)
15
+ - `config/` — check_specs, yardstick and rubycritic config
16
+ - `Gemfile`, `active_ext.gemspec`, `Rakefile`, `.rubocop.yml`, `.rubocop_todo.yml`, `.rspec`
17
+
18
+ Do NOT touch `docs/agents/`, `README.md`, `AGENTS.md`, `CLAUDE.md`, `.github/`, `.circleci/` or Docker files. Those belong to `architect`.
19
+
20
+ ## Stack
21
+
22
+ - Ruby >= 3.3.1, ActiveRecord / ActiveSupport 7.2, `darthjee-core_ext`
23
+ - RSpec with in-memory SQLite, SimpleCov
24
+ - RuboCop (+ rubocop-rspec, rubocop-rake), YARD + yardstick, RubyCritic, reek
25
+
26
+ ## Commands
27
+
28
+ ```bash
29
+ .claude/scripts/check_ruby.sh
30
+ ```
31
+
32
+ which runs:
33
+
34
+ ```bash
35
+ bundle exec rspec
36
+ bundle exec rubocop
37
+ bundle exec rake verify_measurements
38
+ ```
39
+
40
+ CI also runs `check_specs`, `rubycritic.sh` and `check_readme.sh` from the `darthjee/circleci_rails_gems` image. `docker-compose run test_all` runs specs and the YARD checks in the dev container.
41
+
42
+ ## Conventions
43
+
44
+ - Follow `docs/agents/contributing.md` and `docs/agents/architecture.md`.
45
+ - Every change needs specs. Every `lib/` file needs a spec, or an entry in `config/check_specs.yml` if it cannot have one.
46
+ - Every public class, module and method needs a YARD docstring with `@param`, `@return` and `@example`.
47
+ - Put behaviour on `ActiveRecord::Relation`, and expose it on `ActiveRecord::Base` by delegating to `all`.
48
+ - Keep methods small and chainable, in line with Rails conventions. Avoid patching core Ruby classes.
49
+ - `# frozen_string_literal: true` in every Ruby file. Public methods come before private ones.
@@ -0,0 +1,8 @@
1
+ {
2
+ "auto-fix-all": {
3
+ "ignored_check_patterns": [
4
+ "Codacy"
5
+ ]
6
+ },
7
+ "version": "2.4.0"
8
+ }
@@ -0,0 +1,7 @@
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
@@ -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,137 @@
1
+ # Using `darthjee-active_ext` in This Project
2
+
3
+ This project uses the [`darthjee-active_ext`](https://github.com/darthjee/active_ext) gem,
4
+ which adds utility methods to `ActiveRecord::Relation` and `ActiveRecord::Base`.
5
+
6
+ ---
7
+
8
+ ## Installation
9
+
10
+ Add to your `Gemfile`:
11
+
12
+ ```ruby
13
+ gem 'darthjee-active_ext'
14
+ ```
15
+
16
+ Then run:
17
+
18
+ ```console
19
+ bundle install
20
+ ```
21
+
22
+ ---
23
+
24
+ ## Methods Added
25
+
26
+ The gem adds the following methods to **`ActiveRecord::Relation`** and, by delegation,
27
+ to every **`ActiveRecord::Base`** subclass (i.e., every model):
28
+
29
+ | Method | Returns | Purpose |
30
+ |---|---|---|
31
+ | `#percentage(*filters)` | `Float` (0.0 – 1.0) | Fraction of records matching a condition within the current scope |
32
+ | `#pluck_as_json(*keys)` | `Array<Hash>` | Like `pluck`, but returns an array of hashes instead of an array of arrays |
33
+
34
+ ---
35
+
36
+ ## `#percentage`
37
+
38
+ Returns the fraction of records within the current relation that match the
39
+ given condition. The result is a `Float` between `0.0` and `1.0`.
40
+ Returns `0` (integer) when the relation is empty, to avoid division by zero.
41
+
42
+ ### Accepted filter forms
43
+
44
+ | Form | Example argument |
45
+ |---|---|
46
+ | Named scope (Symbol) | `:with_error` |
47
+ | Multiple chained scopes (Symbols) | `:active, :with_error` |
48
+ | Hash condition | `status: :error` |
49
+ | Raw SQL string | `"status = 'error'"` |
50
+
51
+ ### Examples
52
+
53
+ ```ruby
54
+ # Given a model and some data:
55
+ class Document < ActiveRecord::Base
56
+ scope :with_error, -> { where(status: :error) }
57
+ scope :with_success, -> { where(status: :success) }
58
+ scope :active, -> { where(active: true) }
59
+ end
60
+
61
+ # 3 error documents, 1 success document (4 total)
62
+ Document.percentage(:with_error) #=> 0.75
63
+ Document.percentage(status: :error) #=> 0.75
64
+ Document.percentage("status = 'error'") #=> 0.75
65
+
66
+ # Nested scope: among active documents only
67
+ Document.active.percentage(:with_error) #=> 0.5
68
+
69
+ # Multiple scope filters chained together
70
+ Document.percentage(:active, :with_error) #=> 0.25
71
+
72
+ # Empty relation → returns 0, not a float, to avoid division by zero
73
+ Document.where(id: nil).percentage(:with_error) #=> 0
74
+ ```
75
+
76
+ ### When to use `percentage`
77
+
78
+ - Displaying statistics or progress indicators (e.g., "75% of tasks completed").
79
+ - Feature-flag rollout checks across a filtered user base.
80
+ - Any situation where you need a ratio of one subset to its parent scope.
81
+
82
+ ---
83
+
84
+ ## `#pluck_as_json`
85
+
86
+ Works like `ActiveRecord`'s built-in `pluck`, but returns an **array of hashes**
87
+ instead of an array of arrays. Each hash maps column name (as a Symbol) to its
88
+ value.
89
+
90
+ When called **with no arguments**, it returns the full `as_json` representation
91
+ of every record in the relation (equivalent to `map(&:as_json)`).
92
+
93
+ ### Examples
94
+
95
+ ```ruby
96
+ # Standard pluck returns nested arrays — column order matters
97
+ Document.pluck(:id, :status)
98
+ #=> [[1, "error"], [2, "success"], [3, "success"]]
99
+
100
+ # pluck_as_json returns hashes — keys make meaning explicit
101
+ Document.pluck_as_json(:id, :status)
102
+ #=> [
103
+ # { id: 1, status: "error" },
104
+ # { id: 2, status: "success" },
105
+ # { id: 3, status: "success" }
106
+ # ]
107
+
108
+ # Works with any ActiveRecord scope chain
109
+ Document.active.pluck_as_json(:id, :status)
110
+ #=> [{ id: 3, status: "success" }]
111
+
112
+ # No arguments — returns all columns for every record as JSON hashes
113
+ Document.pluck_as_json
114
+ #=> [
115
+ # { id: 1, status: "error", active: false, created_at: ..., updated_at: ... },
116
+ # { id: 2, status: "success", active: false, created_at: ..., updated_at: ... },
117
+ # { id: 3, status: "success", active: true, created_at: ..., updated_at: ... }
118
+ # ]
119
+ ```
120
+
121
+ ### When to use `pluck_as_json`
122
+
123
+ - Building JSON API responses without loading full ActiveRecord objects.
124
+ - Feeding data into serializers or view helpers that expect hashes.
125
+ - Any scenario where column position in a plain array would be fragile or unclear.
126
+
127
+ ---
128
+
129
+ ## Notes
130
+
131
+ - Both methods are available directly on model classes (`Document.percentage(...)`)
132
+ **and** on any `ActiveRecord::Relation` (`Document.active.percentage(...)`),
133
+ because the class-level methods are delegated to `Model.all`.
134
+ - `percentage` with Symbol arguments chains named scopes; with a Hash or String it
135
+ uses `where`. Do **not** mix Symbols with Hashes/Strings in a single call.
136
+ - The gem requires `darthjee-core_ext` (pulled in automatically as a dependency),
137
+ which provides the `Array#as_hash` helper used internally by `pluck_as_json`.
@@ -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,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
@@ -1,3 +1,9 @@
1
1
  coverage
2
2
  Gemfile.lock
3
3
  pkg
4
+
5
+ .yardoc/
6
+ doc/
7
+ rubycritic/
8
+ measurement
9
+ .claude/state/
data/.rubocop.yml ADDED
@@ -0,0 +1,12 @@
1
+ plugins:
2
+ - rubocop-rspec
3
+ - rubocop-rake
4
+
5
+ inherit_from: .rubocop_todo.yml
6
+
7
+ AllCops:
8
+ TargetRubyVersion: 3.3
9
+ NewCops: enable
10
+
11
+ Gemspec/RequireMFA:
12
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,8 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2026-03-10 23:25:07 UTC using RuboCop version 1.85.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
data/AGENTS.md ADDED
@@ -0,0 +1,139 @@
1
+ # GitHub Copilot Instructions for `darthjee/active_ext`
2
+
3
+ ## Project Overview
4
+
5
+ `active_ext` is a Ruby gem that provides extension methods to be used with
6
+ **ActiveRecord** and **ActiveSupport** (Ruby on Rails components). It enriches
7
+ `ActiveRecord::Relation` and related classes with additional query helpers and
8
+ utilities, keeping the extensions idiomatic, lightweight, and Rails-friendly.
9
+
10
+ ---
11
+
12
+ ## Language
13
+
14
+ All contributions must be in **English**:
15
+
16
+ - Pull request titles and descriptions
17
+ - Code comments and inline documentation
18
+ - YARD docstrings and examples
19
+ - Commit messages
20
+ - Identifiers (class names, method names, variable names, etc.)
21
+
22
+ ---
23
+
24
+ ## Testing
25
+
26
+ - **Always add tests** for every change, bug fix, or new feature.
27
+ - Tests live under `spec/` and use **RSpec**.
28
+ - Follow the existing spec structure: place specs next to the corresponding
29
+ `lib/` file (e.g., `lib/active_record/my_extension.rb` →
30
+ `spec/lib/active_record/my_extension_spec.rb`).
31
+ - If a source file genuinely cannot have a spec (e.g., it only re-exports
32
+ constants or requires other files), list it in **`check_specs.yml`** so it
33
+ is explicitly acknowledged as exempt from the coverage requirement.
34
+
35
+ ---
36
+
37
+ ## Code Documentation (YARD)
38
+
39
+ - Provide documentation compatible with **YARD**.
40
+ - Every **public** class, module, and method must include a YARD docstring.
41
+ - Include `@param`, `@return`, and `@example` tags where appropriate.
42
+ - Example:
43
+
44
+ ```ruby
45
+ # Returns the percentage of records matching +scope+ within the current
46
+ # relation.
47
+ #
48
+ # @param scope [Symbol, Hash, String] the scope or condition to evaluate
49
+ # @return [Float] percentage as a decimal between 0.0 and 1.0
50
+ #
51
+ # @example Using a named scope
52
+ # Document.percentage(:with_error) #=> 0.75
53
+ #
54
+ # @example Using a hash condition
55
+ # Document.percentage(status: :error) #=> 0.75
56
+ #
57
+ # @example Within a nested scope
58
+ # Document.active.percentage(:with_error) #=> 0.5
59
+ def percentage(scope)
60
+ # ...
61
+ end
62
+ ```
63
+
64
+ ---
65
+
66
+ ## Design & Quality
67
+
68
+ Follow the principles championed by **Sandi Metz** (as described in
69
+ *99 Bottles of OOP* and *Practical Object-Oriented Design*):
70
+
71
+ - **Small classes and methods** — each should have a single, well-defined
72
+ responsibility.
73
+ - **Limit method length** — prefer short, readable methods over long ones.
74
+ - **Prefer composition over inheritance** when extending behavior.
75
+ - **Avoid Law of Demeter violations** — an object should only talk to its
76
+ immediate collaborators; avoid long method-chain calls like
77
+ `a.b.c.do_something`.
78
+ - **Favor clear, explicit boundaries** — modules and classes should expose
79
+ minimal public APIs and hide implementation details.
80
+
81
+ ---
82
+
83
+ ## Rails & ActiveRecord Compatibility
84
+
85
+ - Extensions must remain **Rails-friendly**: follow Rails conventions and
86
+ naming patterns.
87
+ - New methods added to `ActiveRecord::Relation` or `ActiveSupport` classes
88
+ should integrate naturally with existing Rails query interfaces (scopes,
89
+ chainability, etc.).
90
+ - Avoid monkey-patching core Ruby classes unless absolutely necessary; prefer
91
+ extending the appropriate Rails base classes or using `ActiveSupport::Concern`.
92
+ - Ensure compatibility with the Ruby and Rails versions declared in
93
+ `active_ext.gemspec` and `Gemfile`.
94
+
95
+ ---
96
+
97
+ ## Pull Request Guidelines
98
+
99
+ - Keep PRs focused and small — one logical change per PR.
100
+ - Include a clear description of *what* changed and *why*.
101
+ - Reference any related issues.
102
+ - Ensure all existing and new specs pass before requesting review.
103
+
104
+ ## Documentation
105
+
106
+ All project documentation lives under [`docs/agents/`](docs/agents/):
107
+
108
+ | File | Contents |
109
+ |------|----------|
110
+ | [Folder Structure](docs/agents/folder-structure.md) | Top-level directory layout and the role of each folder. |
111
+ | [Architecture](docs/agents/architecture.md) | Source layout, modules, code style, and implementation guidelines. |
112
+ | [Flow](docs/agents/flow.md) | Main runtime flow of the application. |
113
+ | [Contributing](docs/agents/contributing.md) | Commit guidelines, PR standards, code organization, and refactoring rules. |
114
+ | [Plans](docs/agents/plans/) | Implementation plans for ongoing or upcoming features. |
115
+ | [Issues](docs/agents/issues/) | Detailed specs for open issues. |
116
+
117
+ ### Issues (`docs/agents/issues/`)
118
+
119
+ Each file documents an issue in detail. Naming convention:
120
+
121
+ ```
122
+ docs/agents/issues/<issue_id>_<issue_name>.md
123
+ ```
124
+
125
+ Example: `docs/agents/issues/5_release_docker_image.md` for issue #5.
126
+
127
+ ### Plans (`docs/agents/plans/`)
128
+
129
+ Each plan is a directory named after the issue ID and topic, containing one or more related files:
130
+
131
+ ```
132
+ docs/agents/plans/<issue_id>_<topic>/<related_files>.md
133
+ ```
134
+
135
+ Example: `docs/agents/plans/12_add-auth/plan.md` for issue #12.
136
+
137
+ ## Commit Attribution
138
+
139
+ Commit co-author trailers follow arcanum's resolved `git.omit_model_coauthor` and `git.remove_coauthors` config (check them with `/arcanum-check-config`); this overrides Claude Code's own attribution reminder for every commit, including ones written by hand.
data/CLAUDE.md ADDED
@@ -0,0 +1 @@
1
+ See [AGENTS.md](AGENTS.md) for project instructions.
data/Dockerfile ADDED
@@ -0,0 +1,21 @@
1
+ FROM darthjee/scripts:0.15.0 as scripts
2
+
3
+ FROM darthjee/rails_gems:3.0.0 as base
4
+
5
+ COPY --chown=app:app ./ /home/app/app/
6
+
7
+ ######################################
8
+
9
+ FROM base as builder
10
+
11
+ COPY --chown=app:app --from=scripts /home/scripts/builder/bundle_builder.sh /usr/local/sbin/bundle_builder.sh
12
+
13
+ ENV HOME_DIR /home/app
14
+ RUN bundle_builder.sh
15
+
16
+ #######################
17
+ #FINAL IMAGE
18
+ FROM base
19
+
20
+ COPY --chown=app:app --from=builder /home/app/bundle/ /usr/local/bundle/
21
+ RUN bundle install
data/Gemfile CHANGED
@@ -1,5 +1,30 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in credential_builder.gemspec
4
6
  gemspec
5
7
 
8
+ gem 'activerecord', '7.2.4'
9
+ gem 'bundler', '>= 4.0.24'
10
+ gem 'pry', '0.14.2'
11
+ gem 'pry-nav', '1.0.0'
12
+ gem 'rake', '13.4.2'
13
+ gem 'reek', '6.5.0'
14
+ gem 'rspec', '3.13.2'
15
+ gem 'rspec-collection_matchers'
16
+ gem 'rspec-core', '3.13.7'
17
+ gem 'rspec-expectations', '3.13.6'
18
+ gem 'rspec-mocks', '3.13.9'
19
+ gem 'rspec-rails', '8.1.0'
20
+ gem 'rspec-support', '3.13.8'
21
+ gem 'rubocop', '1.92.2'
22
+ gem 'rubocop-rake', '0.7.1'
23
+ gem 'rubocop-rspec', '3.10.2'
24
+ gem 'rubycritic', '5.0.0'
25
+ gem 'simplecov', '0.22.0'
26
+ gem 'simplecov-html', '0.13.2'
27
+ gem 'simplecov-lcov', '0.9.0'
28
+ gem 'sqlite3', '2.10.2'
29
+ gem 'yard', '0.9.45'
30
+ gem 'yardstick', '0.9.9'
data/Makefile ADDED
@@ -0,0 +1,6 @@
1
+ .PHONY: dev
2
+
3
+ PROJECT?=active_ext
4
+
5
+ dev:
6
+ docker-compose run $(PROJECT) /bin/bash