zyra 1.2.0 → 1.4.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 +21 -13
- data/.claude/agents/architect.md +44 -0
- data/.claude/agents/ruby.md +42 -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/pull_request_template.md +17 -0
- data/.github/zyra-usage.md +289 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +2 -2
- data/.rubocop_todo.yml +2 -1
- data/AGENTS.md +121 -0
- data/CLAUDE.md +1 -0
- data/Dockerfile +2 -2
- data/Gemfile +18 -16
- data/Makefile +21 -0
- data/README.md +6 -7
- data/docs/agents/arcanum-split-issue.md +9 -0
- data/docs/agents/architecture.md +31 -0
- data/docs/agents/contributing.md +141 -0
- data/docs/agents/flow.md +5 -0
- data/docs/agents/folder-structure.md +33 -0
- data/docs/agents/issue-enhancement.md +10 -0
- data/docs/agents/issues/.gitkeep +1 -0
- data/docs/agents/plans/.gitkeep +1 -0
- data/lib/zyra/finder.rb +1 -3
- data/lib/zyra/finder_creator.rb +2 -2
- data/lib/zyra/registry.rb +4 -4
- data/lib/zyra/version.rb +1 -1
- data/scripts/bump_version.sh +62 -0
- data/spec/spec_helper.rb +7 -1
- data/zyra.gemspec +3 -3
- data/zyra.jpg +0 -0
- metadata +32 -13
data/AGENTS.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Copilot Instructions for `zyra`
|
|
2
|
+
|
|
3
|
+
## About This Project
|
|
4
|
+
|
|
5
|
+
`zyra` is a Ruby gem designed to be used from `db/seeds.rb` in Rails projects.
|
|
6
|
+
You define how an entity is **found** (via lookup keys/attributes), and Zyra
|
|
7
|
+
locates those entities using those keys. If the entity is not found, Zyra
|
|
8
|
+
creates it with the additional attributes provided.
|
|
9
|
+
|
|
10
|
+
This makes seeding **idempotent**: running `rake db:seed` repeatedly does not
|
|
11
|
+
duplicate records, and it guarantees that required entities are always present
|
|
12
|
+
in the database.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Language
|
|
17
|
+
|
|
18
|
+
- All PRs, PR descriptions, commit messages, review comments, documentation,
|
|
19
|
+
and code **must be written in English**.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Tests
|
|
24
|
+
|
|
25
|
+
- **Always add tests** for new behaviour and for any change to existing
|
|
26
|
+
behaviour.
|
|
27
|
+
- Tests live in the `spec/` directory and use RSpec.
|
|
28
|
+
- Files that cannot reasonably be tested (e.g. version constants, exception
|
|
29
|
+
class definitions) must be listed in `config/check_specs.yml` under the
|
|
30
|
+
`ignore:` key with a brief comment explaining why tests are not applicable.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Documentation (YARD)
|
|
35
|
+
|
|
36
|
+
- All **public APIs** must have YARD-compatible docstrings (`@param`, `@return`,
|
|
37
|
+
`@example`, etc.).
|
|
38
|
+
- Update `README.md` and any relevant usage docs whenever public behaviour
|
|
39
|
+
changes.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## `config/check_specs.yml`
|
|
44
|
+
|
|
45
|
+
Any file that is intentionally excluded from test coverage must be added to
|
|
46
|
+
`config/check_specs.yml`:
|
|
47
|
+
|
|
48
|
+
```yaml
|
|
49
|
+
ignore:
|
|
50
|
+
- lib/zyra/version.rb # version constant only, no logic to test
|
|
51
|
+
- lib/zyra/exceptions.rb # plain exception class definitions
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
If you add a new file without tests, add its path here with a comment
|
|
55
|
+
justifying the omission.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Code Style — Small Classes & Single Responsibilities
|
|
60
|
+
|
|
61
|
+
Follow the principles described by Sandi Metz (including those in
|
|
62
|
+
*99 Bottles of OOP*):
|
|
63
|
+
|
|
64
|
+
- Keep **methods short** and intention-revealing; a method should do one thing.
|
|
65
|
+
- Prefer **extracting new objects** over adding conditionals to existing ones.
|
|
66
|
+
- Favour **composition over inheritance**.
|
|
67
|
+
- Name things after what they *do* or *represent*, not after implementation
|
|
68
|
+
details.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Law of Demeter
|
|
73
|
+
|
|
74
|
+
Avoid Demeter violations (chained message sends across object boundaries):
|
|
75
|
+
|
|
76
|
+
- **Pass collaborators** as arguments rather than reaching through objects.
|
|
77
|
+
- **Wrap** external calls in intention-revealing methods so callers do not need
|
|
78
|
+
to know the internal structure of their dependencies.
|
|
79
|
+
- A method should only call methods on: `self`, objects passed as arguments,
|
|
80
|
+
objects it creates, or direct component objects.
|
|
81
|
+
|
|
82
|
+
## Documentation
|
|
83
|
+
|
|
84
|
+
All project documentation lives under [`docs/agents/`](docs/agents/):
|
|
85
|
+
|
|
86
|
+
| File | Contents |
|
|
87
|
+
|------|----------|
|
|
88
|
+
| [Folder Structure](docs/agents/folder-structure.md) | Top-level directory layout and the role of each folder. |
|
|
89
|
+
| [Architecture](docs/agents/architecture.md) | Source layout, modules, code style, and implementation guidelines. |
|
|
90
|
+
| [Contributing](docs/agents/contributing.md) | Commit guidelines, PR standards, code organization, and refactoring rules. |
|
|
91
|
+
| [Flow](docs/agents/flow.md) | Main runtime flow of the application. |
|
|
92
|
+
| [Plans](docs/agents/plans/) | Implementation plans for ongoing or upcoming features. |
|
|
93
|
+
| [Issues](docs/agents/issues/) | Detailed specs for open issues. |
|
|
94
|
+
|
|
95
|
+
### Issues (`docs/agents/issues/`)
|
|
96
|
+
|
|
97
|
+
Each file documents an issue in detail. Naming convention:
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
docs/agents/issues/<issue_id>_<issue_name>.md
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Example: `docs/agents/issues/5_release_docker_image.md` for issue #5.
|
|
104
|
+
|
|
105
|
+
### Plans (`docs/agents/plans/`)
|
|
106
|
+
|
|
107
|
+
Each plan is a directory named after the issue ID and topic, containing one or more related files:
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
docs/agents/plans/<issue_id>_<topic>/<related_files>.md
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Example: `docs/agents/plans/12_add-auth/plan.md` for issue #12.
|
|
114
|
+
|
|
115
|
+
## Running commands
|
|
116
|
+
|
|
117
|
+
All commands (tests, lint, docs checks) **must be run through `docker-compose`**, never directly on the host. See `.claude/agents/ruby.md` for the exact commands.
|
|
118
|
+
|
|
119
|
+
## Commit Attribution
|
|
120
|
+
|
|
121
|
+
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
CHANGED
data/Gemfile
CHANGED
|
@@ -4,23 +4,25 @@ source 'https://rubygems.org'
|
|
|
4
4
|
|
|
5
5
|
gemspec
|
|
6
6
|
|
|
7
|
-
gem 'activerecord', '7.
|
|
8
|
-
gem 'bundler', '>=
|
|
9
|
-
gem 'database_cleaner', '2.0
|
|
10
|
-
gem 'factory_bot', '6.
|
|
7
|
+
gem 'activerecord', '7.2.4'
|
|
8
|
+
gem 'bundler', '>= 4.0.24'
|
|
9
|
+
gem 'database_cleaner', '2.1.0'
|
|
10
|
+
gem 'factory_bot', '6.6.0'
|
|
11
11
|
gem 'pry', '0.14.2'
|
|
12
12
|
gem 'pry-nav', '1.0.0'
|
|
13
|
-
gem 'rake', '13.
|
|
14
|
-
gem 'reek', '6.
|
|
15
|
-
gem 'rspec', '3.
|
|
16
|
-
gem 'rspec-core', '3.
|
|
17
|
-
gem 'rspec-expectations', '3.
|
|
18
|
-
gem 'rspec-mocks', '3.
|
|
19
|
-
gem 'rspec-support', '3.
|
|
20
|
-
gem 'rubocop', '1.
|
|
21
|
-
gem 'rubocop-rspec', '
|
|
22
|
-
gem 'rubycritic', '
|
|
13
|
+
gem 'rake', '13.4.2'
|
|
14
|
+
gem 'reek', '6.5.0'
|
|
15
|
+
gem 'rspec', '3.13.2'
|
|
16
|
+
gem 'rspec-core', '3.13.7'
|
|
17
|
+
gem 'rspec-expectations', '3.13.6'
|
|
18
|
+
gem 'rspec-mocks', '3.13.9'
|
|
19
|
+
gem 'rspec-support', '3.13.8'
|
|
20
|
+
gem 'rubocop', '1.92.2'
|
|
21
|
+
gem 'rubocop-rspec', '3.10.2'
|
|
22
|
+
gem 'rubycritic', '5.0.0'
|
|
23
23
|
gem 'simplecov', '0.22.0'
|
|
24
|
-
gem '
|
|
25
|
-
gem '
|
|
24
|
+
gem 'simplecov-html', '0.13.2'
|
|
25
|
+
gem 'simplecov-lcov', '0.9.0'
|
|
26
|
+
gem 'sqlite3', '2.10.2'
|
|
27
|
+
gem 'yard', '0.9.45'
|
|
26
28
|
gem 'yardstick', '0.9.9'
|
data/Makefile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.PHONY: build dev tests
|
|
2
|
+
|
|
3
|
+
PROJECT?=zyra
|
|
4
|
+
IMAGE?=$(PROJECT)
|
|
5
|
+
BASE_IMAGE?=$(DOCKER_ID_USER)/$(PROJECT)-base
|
|
6
|
+
DOCKER_FILE_BASE=Dockerfile.$(PROJECT)-base
|
|
7
|
+
|
|
8
|
+
all:
|
|
9
|
+
@echo "Usage:"
|
|
10
|
+
@echo " make build\n Build docker image for $(PROJECT)"
|
|
11
|
+
@echo " make dev\n Run development environment for $(PROJECT)"
|
|
12
|
+
@echo " make tests\n Run tests for $(PROJECT)"
|
|
13
|
+
|
|
14
|
+
build:
|
|
15
|
+
docker build -f Dockerfile.$(PROJECT) . -t $(IMAGE) -t $(PUSH_IMAGE):latest
|
|
16
|
+
|
|
17
|
+
tests:
|
|
18
|
+
docker-compose run $(PROJECT)_tests /bin/bash
|
|
19
|
+
|
|
20
|
+
dev:
|
|
21
|
+
docker-compose run $(PROJECT) /bin/bash
|
data/README.md
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
Zyra
|
|
2
2
|
====
|
|
3
|
-
[](https://codeclimate.com/github/darthjee/zyra/coverage)
|
|
5
|
-
[](https://codeclimate.com/github/darthjee/zyra)
|
|
3
|
+
[](https://dl.circleci.com/status-badge/redirect/gh/darthjee/zyra/tree/main)
|
|
6
4
|
[](https://badge.fury.io/rb/zyra)
|
|
7
|
-
[](https://
|
|
5
|
+
[](https://app.codacy.com/gh/darthjee/zyra/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
|
6
|
+
[](https://app.codacy.com/gh/darthjee/zyra/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)
|
|
8
7
|
[](http://inch-ci.org/github/darthjee/zyra)
|
|
9
8
|
|
|
10
9
|

|
|
@@ -15,13 +14,13 @@ entity exists without having to reinsert it every time in the database
|
|
|
15
14
|
The process is done by registering a model class, then performing
|
|
16
15
|
a creation in case of missing the entry
|
|
17
16
|
|
|
18
|
-
Current Release
|
|
17
|
+
**Current Release**: [1.4.0](https://github.com/darthjee/zyra/tree/1.4.0)
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
**Next release**: [1.5.0](https://github.com/darthjee/zyra/compare/1.4.0...main)
|
|
21
20
|
|
|
22
21
|
Yard Documentation
|
|
23
22
|
-------------------
|
|
24
|
-
[https://www.rubydoc.info/gems/zyra/1.
|
|
23
|
+
[https://www.rubydoc.info/gems/zyra/1.4.0](https://www.rubydoc.info/gems/zyra/1.4.0)
|
|
25
24
|
|
|
26
25
|
Installation
|
|
27
26
|
---------------
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Arcanum Split Issue
|
|
2
|
+
|
|
3
|
+
A checklist of concerns to consider when splitting a broad issue into sub-issues via `/arcanum-split-issue`. Not exhaustive — adjust or extend the list for this project's needs.
|
|
4
|
+
|
|
5
|
+
- **Sub-issue granularity** — is each sub-issue independently workable, or does it still depend on another sub-issue landing first?
|
|
6
|
+
- **Standalone clarity** — does each sub-issue stand on its own, without requiring the reader to have the parent issue open to understand it?
|
|
7
|
+
- **Shared contracts** — interfaces, schemas, or config keys touched by more than one sub-issue, and who owns getting them right first.
|
|
8
|
+
- **Sequencing** — is there a natural order sub-issues should be implemented/merged in, or can they proceed in parallel?
|
|
9
|
+
- **Responsible agents** — which specialist agent(s) each sub-issue is likely to fall to.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Zyra is a Ruby gem for idempotent seeding. A model class is registered with
|
|
6
|
+
lookup keys; `find_or_create` looks the record up by those keys and creates it
|
|
7
|
+
(with the remaining attributes) only if it is missing. Lifecycle hooks are
|
|
8
|
+
supported through `Jace` events (e.g. `:build`).
|
|
9
|
+
|
|
10
|
+
## Source Code Layout
|
|
11
|
+
|
|
12
|
+
All application source code lives under `lib/`.
|
|
13
|
+
|
|
14
|
+
### `lib/zyra.rb`
|
|
15
|
+
|
|
16
|
+
Entry point. Declares autoloads and exposes the public API (`Zyra.register`,
|
|
17
|
+
`Zyra.find_or_create`, etc.) delegating to a registry.
|
|
18
|
+
|
|
19
|
+
### `lib/zyra/`
|
|
20
|
+
|
|
21
|
+
- `registry.rb` — Public. Stores registered `FinderCreator`s by key.
|
|
22
|
+
- `finder_creator.rb` — Ensures an entry exists: finds via `Finder`, else builds via `Creator`.
|
|
23
|
+
- `finder.rb` — Looks a model up in the DB using only the configured keys; triggers events.
|
|
24
|
+
- `creator.rb` — Builds and saves a model from attributes, running the block and events.
|
|
25
|
+
- `exceptions.rb` — Exception classes.
|
|
26
|
+
- `version.rb` — Version constant.
|
|
27
|
+
|
|
28
|
+
## Guidelines
|
|
29
|
+
|
|
30
|
+
Small single-responsibility classes, composition over inheritance, Law of
|
|
31
|
+
Demeter, YARD docs on public APIs, specs for all behaviour (see `AGENTS.md`).
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Commit Guidelines
|
|
4
|
+
|
|
5
|
+
- **Atomic and Unitary:** Each commit must represent a single logical change.
|
|
6
|
+
*Example:*
|
|
7
|
+
- Good: `Add Finder#find_by_keys method`
|
|
8
|
+
- Bad: `Add Finder#find_by_keys and refactor Registry logic`
|
|
9
|
+
- **No Unrelated Changes:** Do not mix unrelated changes in the same commit.
|
|
10
|
+
- **Separate Refactoring:** Whenever possible, separate refactoring commits from new feature or bugfix commits.
|
|
11
|
+
|
|
12
|
+
## Pull Requests
|
|
13
|
+
|
|
14
|
+
- **Descriptive Summary:** Every PR must include a clear and descriptive summary of its purpose and changes.
|
|
15
|
+
- **PR Description Files:** If a description cannot be provided directly in the PR, generate a file with the PR description (e.g., `docs/issues/<pr_number>_description.md`), but do not commit this file.
|
|
16
|
+
|
|
17
|
+
## Definition of Done for PRs
|
|
18
|
+
|
|
19
|
+
A PR is considered complete when:
|
|
20
|
+
|
|
21
|
+
- The stated objective has been achieved.
|
|
22
|
+
- All tests are passing.
|
|
23
|
+
- Linting passes without errors.
|
|
24
|
+
- Code coverage is as high as reasonably possible.
|
|
25
|
+
- Public APIs have YARD docs; README/usage docs are updated for public behaviour changes.
|
|
26
|
+
- Code is not overly complex:
|
|
27
|
+
- Classes and methods should have clear, focused responsibilities.
|
|
28
|
+
- Methods should be small and do exactly one thing. If a method is growing, extract private helpers or separate classes.
|
|
29
|
+
- *Example:*
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
# Good: each method does one thing
|
|
33
|
+
class Worker
|
|
34
|
+
def fetch_job; end
|
|
35
|
+
def process_job(job); end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Bad: method does too much
|
|
39
|
+
class Worker
|
|
40
|
+
def run
|
|
41
|
+
fetch_job
|
|
42
|
+
process_job
|
|
43
|
+
send_metrics
|
|
44
|
+
cleanup
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- This applies primarily to source code. For specs, refactor only if there is excessive duplication.
|
|
50
|
+
|
|
51
|
+
### CI Checks
|
|
52
|
+
|
|
53
|
+
Before a PR is considered complete, all CI checks relevant to the modified parts of the project must pass locally. The project is a single gem, so CircleCI runs these jobs on every change:
|
|
54
|
+
|
|
55
|
+
| Modified area | CircleCI job | Local commands |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| `lib/`, `spec/` | `test` | `bundle exec rspec` |
|
|
58
|
+
| any | `checks` | `rubocop`, `bundle exec rake verify_measurements`, `check_readme.sh`, `rubycritic.sh`, `check_specs` |
|
|
59
|
+
|
|
60
|
+
Locally, run inside Docker: `make tests` (opens a shell), then e.g. `rspec && yard && rake yardstick_measure && rake verify_measurements`.
|
|
61
|
+
|
|
62
|
+
When **planning how to resolve an issue**, include a final step listing the CI commands to run before opening a PR.
|
|
63
|
+
|
|
64
|
+
## Code Organization
|
|
65
|
+
|
|
66
|
+
### File Responsibility: Class Declarers vs Scripts
|
|
67
|
+
|
|
68
|
+
Every source file (excluding specs) must act as a **class declarer** — define one or more classes or modules, and not execute logic or side effects at load time. The only entrypoint is `lib/zyra.rb`, which declares autoloads and the public API.
|
|
69
|
+
|
|
70
|
+
```ruby
|
|
71
|
+
# Good: class declarer
|
|
72
|
+
class Router
|
|
73
|
+
def register(app); end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Bad: script — executes logic at load time
|
|
77
|
+
router = Router.new
|
|
78
|
+
router.register(app)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Specs are exempt.
|
|
82
|
+
|
|
83
|
+
### File Naming: snake_case for Class Files
|
|
84
|
+
|
|
85
|
+
Files defining a class use **snake_case** matching the class name, and live under the module path (e.g. `Zyra::FinderCreator` → `lib/zyra/finder_creator.rb`). Specs mirror this: `spec/lib/zyra/finder_creator_spec.rb`.
|
|
86
|
+
|
|
87
|
+
### Method Order: Public Before Private
|
|
88
|
+
|
|
89
|
+
Public methods are declared before private methods; private helpers go at the end of the class body.
|
|
90
|
+
|
|
91
|
+
```ruby
|
|
92
|
+
# Good
|
|
93
|
+
class Worker
|
|
94
|
+
def run
|
|
95
|
+
prepare
|
|
96
|
+
execute
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
private
|
|
100
|
+
|
|
101
|
+
def prepare; end
|
|
102
|
+
def execute; end
|
|
103
|
+
end
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Dependency Injection
|
|
107
|
+
|
|
108
|
+
Classes must receive their dependencies (data, configuration, collaborators) as constructor arguments. A class must never read files or environment variables on its own; the entry point loads configuration and passes it down. This keeps every class independently testable (as `Finder` and `Creator` do with `event_registry:`).
|
|
109
|
+
|
|
110
|
+
```ruby
|
|
111
|
+
# Good
|
|
112
|
+
class Router
|
|
113
|
+
def initialize(data)
|
|
114
|
+
@data = data
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Bad: loads its own config
|
|
119
|
+
class Router
|
|
120
|
+
def build
|
|
121
|
+
data = YAML.load_file('./data.yml')
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Refactoring Guidelines
|
|
127
|
+
|
|
128
|
+
When refactoring, aim to:
|
|
129
|
+
|
|
130
|
+
- **Reduce Code Duplication:** e.g. move repeated spec setup into factories (`spec/support/factories`).
|
|
131
|
+
|
|
132
|
+
```ruby
|
|
133
|
+
# Good
|
|
134
|
+
create(:category, id: 2)
|
|
135
|
+
# Bad: the same hash repeated in many specs
|
|
136
|
+
Category.new(id: 2, name: 'Books')
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
- **Prefer Extracting Objects** over adding conditionals (Sandi Metz).
|
|
140
|
+
- **Avoid Demeter violations:** wrap chained calls in intention-revealing methods.
|
|
141
|
+
- **Keep behaviour unchanged** and covered by passing specs throughout.
|
data/docs/agents/flow.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Folder Structure
|
|
2
|
+
|
|
3
|
+
## Project Root
|
|
4
|
+
|
|
5
|
+
| Directory / File | Description |
|
|
6
|
+
|---|---|
|
|
7
|
+
| `lib/` | Gem source code (`zyra.rb` entry point and `zyra/` namespace). |
|
|
8
|
+
| `spec/` | RSpec suite: unit specs, integration specs, and shared support. |
|
|
9
|
+
| `config/` | Tooling configuration (spec-coverage check, yardstick, rubycritic). |
|
|
10
|
+
| `docs/agents/` | Documentation for agents: architecture, flow, issues, plans. |
|
|
11
|
+
| `.circleci/` | CI pipeline and release configuration. |
|
|
12
|
+
| `.github/` | PR/commit templates and Copilot instructions. |
|
|
13
|
+
| `Dockerfile`, `Dockerfile.circleci`, `docker-compose.yml`, `Makefile` | Docker-based dev/test environment. |
|
|
14
|
+
| `zyra.gemspec`, `Gemfile`, `Rakefile` | Gem packaging, dependencies and tasks. |
|
|
15
|
+
| `.rubocop.yml`, `.rubocop_todo.yml`, `.rspec` | Lint and test runner configuration. |
|
|
16
|
+
| `README.md`, `zyra.jpg`, `LICENSE` | Public docs, logo, license. |
|
|
17
|
+
| `AGENTS.md`, `CLAUDE.md` | Shared agent instructions (CLAUDE.md points to AGENTS.md). |
|
|
18
|
+
|
|
19
|
+
## spec/
|
|
20
|
+
|
|
21
|
+
| Subdirectory | Description |
|
|
22
|
+
|---|---|
|
|
23
|
+
| `lib/` | Unit specs mirroring `lib/`. |
|
|
24
|
+
| `integration/` | Specs validating README and YARD examples. |
|
|
25
|
+
| `support/` | Factories, models, schema and shared examples. |
|
|
26
|
+
|
|
27
|
+
## config/
|
|
28
|
+
|
|
29
|
+
| File | Description |
|
|
30
|
+
|---|---|
|
|
31
|
+
| `check_specs.yml` | Files ignored by the "every file has a spec" check. |
|
|
32
|
+
| `yardstick.rb`, `yardstick.yml` | YARD documentation coverage checks. |
|
|
33
|
+
| `rubycritc.rb` | Rubycritic config. |
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Issue Enhancement
|
|
2
|
+
|
|
3
|
+
A checklist of concerns to consider when fleshing out a vague issue idea (tagged `Idea`/`Writting`) before it reaches the `Created` stage. Not exhaustive — adjust or extend the list for this project's needs.
|
|
4
|
+
|
|
5
|
+
- **Scope boundaries** — what's explicitly in scope and what's explicitly out.
|
|
6
|
+
- **Alternative solutions** — other ways to solve the same problem, and why this one was chosen.
|
|
7
|
+
- **Edge cases** — inputs, states, or timing the happy path doesn't cover.
|
|
8
|
+
- **Backward compatibility** — whether this breaks existing behavior, data, or integrations.
|
|
9
|
+
- **Testing strategy** — how the change will be verified.
|
|
10
|
+
- **Performance & security considerations** — anything relevant to load, latency, or attack surface.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
data/lib/zyra/finder.rb
CHANGED
data/lib/zyra/finder_creator.rb
CHANGED
|
@@ -36,8 +36,8 @@ module Zyra
|
|
|
36
36
|
#
|
|
37
37
|
# @see Zyra::Finder#find
|
|
38
38
|
# @see Zyra::Creator#create
|
|
39
|
-
def find_or_create(attributes, &
|
|
40
|
-
model = find(attributes, &
|
|
39
|
+
def find_or_create(attributes, &)
|
|
40
|
+
model = find(attributes, &) || create(attributes, &)
|
|
41
41
|
|
|
42
42
|
event_registry.trigger(:return, model) { model }
|
|
43
43
|
end
|
data/lib/zyra/registry.rb
CHANGED
|
@@ -131,8 +131,8 @@ module Zyra
|
|
|
131
131
|
#
|
|
132
132
|
# user = registry.find_or_create(:user, email: email)
|
|
133
133
|
# # returns a User with name 'some other name'
|
|
134
|
-
def on(key, event, &
|
|
135
|
-
finder_creator_for(key).on(event, &
|
|
134
|
+
def on(key, event, &)
|
|
135
|
+
finder_creator_for(key).on(event, &)
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
# Builds an instance of the registered model class
|
|
@@ -168,8 +168,8 @@ module Zyra
|
|
|
168
168
|
# email: email, name: 'final name'
|
|
169
169
|
# )
|
|
170
170
|
# # returns a User with name 'initial name'
|
|
171
|
-
def find_or_create(key, attributes, &
|
|
172
|
-
finder_creator_for(key).find_or_create(attributes, &
|
|
171
|
+
def find_or_create(key, attributes, &)
|
|
172
|
+
finder_creator_for(key).find_or_create(attributes, &)
|
|
173
173
|
end
|
|
174
174
|
|
|
175
175
|
private
|
data/lib/zyra/version.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/zyra/version.rb"
|
|
10
|
+
LOCKFILE="$ROOT/Gemfile.lock"
|
|
11
|
+
GEM="zyra"
|
|
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/zyra/tree/[0-9.]*)|**Current Release**: [${new_version}](https://github.com/darthjee/zyra/tree/${new_version})|" \
|
|
50
|
+
"$README"
|
|
51
|
+
|
|
52
|
+
# README: Next release line
|
|
53
|
+
sed -i '' \
|
|
54
|
+
"s|\*\*Next release\*\*: \[[0-9.]*\](https://github.com/darthjee/zyra/compare/[0-9.]*\.\.\.main)|**Next release**: [${next_release}](https://github.com/darthjee/zyra/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."
|
data/spec/spec_helper.rb
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
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
|
|
10
|
+
|
|
5
11
|
SimpleCov.profiles.define 'gem' do
|
|
6
12
|
add_filter '/spec/'
|
|
7
13
|
end
|
|
@@ -20,7 +26,7 @@ ActiveRecord::Base.establish_connection(
|
|
|
20
26
|
|
|
21
27
|
support_files = File.expand_path('spec/support/**/*.rb')
|
|
22
28
|
|
|
23
|
-
Dir[support_files].
|
|
29
|
+
Dir[support_files].each { |file| require file }
|
|
24
30
|
|
|
25
31
|
RSpec.configure do |config|
|
|
26
32
|
config.run_all_when_everything_filtered = true
|
data/zyra.gemspec
CHANGED
|
@@ -12,14 +12,14 @@ Gem::Specification.new do |gem|
|
|
|
12
12
|
gem.homepage = 'https://github.com/darthjee/zyra'
|
|
13
13
|
gem.description = 'Gem for seeding data in the database'
|
|
14
14
|
gem.summary = gem.description
|
|
15
|
-
gem.required_ruby_version = '>=
|
|
15
|
+
gem.required_ruby_version = '>= 3.3.1'
|
|
16
16
|
|
|
17
17
|
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
|
18
18
|
gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
19
19
|
gem.require_paths = ['lib']
|
|
20
20
|
|
|
21
|
-
gem.
|
|
22
|
-
gem.
|
|
21
|
+
gem.add_dependency 'activesupport', '~> 7.2.x'
|
|
22
|
+
gem.add_dependency 'jace', '>= 1.0.0'
|
|
23
23
|
|
|
24
24
|
gem.metadata['rubygems_mfa_required'] = 'true'
|
|
25
25
|
end
|
data/zyra.jpg
CHANGED
|
Binary file
|