zyra 1.2.0 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1729f498f526f9d3ad8308bf4d342832c54d3159793642b45c063196bc9946e0
4
- data.tar.gz: faf627cf21058bde26d0ae14e785b3fa9a200ba0db5e190b1308feae25d5f28f
3
+ metadata.gz: c840095927f9a1b4b8ff2b3b74251f54673eb8b17095c46695ac5fe1f8095729
4
+ data.tar.gz: 9b5f9c47cd321c3012df1e2d730a65c339edcbd013b3f04d64e52fa65bf9b501
5
5
  SHA512:
6
- metadata.gz: a95247d9bdc6ba44a72a302e1ae75c5df5d765df5677182212efb386286ddae78d08a46da070b5331e0475bc690f3e57856e36e9782c17468897125d303ec767
7
- data.tar.gz: 7340e55d077b958be1015d9636f33643e3817787467e357925173ae0d3cb42f2290383cb19d875981ae55437af2c43a0ebf91e9452124cc3e836c7ff0e4dc4f5
6
+ metadata.gz: 3fd0907f46f2d40623e3c909acc2409b4f7a968bd86ddafd678184e6a95564374c197402f60f88b20f8d02fa963fd2de130458acd6910f7f1b32a5c9c409b312
7
+ data.tar.gz: d5cf211e2bb5bd4d5dd51d3d8f451fad5105befc811479f6ee5af146df7d9a3463be6068658ebdfe9d3a97e3163c2fa8e6c09fd230ef298fe4af44fcfd269c36
data/.circleci/config.yml CHANGED
@@ -18,18 +18,15 @@ workflows:
18
18
  only: /\d+\.\d+\.\d+/
19
19
  branches:
20
20
  only:
21
- - master
21
+ - main
22
22
  jobs:
23
23
  test:
24
24
  docker:
25
- - image: darthjee/circleci_rails_gems:1.3.0
25
+ - image: darthjee/circleci_rails_gems:2.1.0
26
26
  environment:
27
27
  PROJECT: zyra
28
28
  steps:
29
29
  - checkout
30
- - run:
31
- name: Prepare Coverage Test Report
32
- command: cc-test-reporter before-build
33
30
  - run:
34
31
  name: Bundle Install
35
32
  command: bundle install
@@ -37,11 +34,11 @@ jobs:
37
34
  name: RSpec
38
35
  command: bundle exec rspec
39
36
  - run:
40
- name: Coverage Test Report
41
- command: cc-test-reporter after-build --exit-code $?
37
+ name: Upload coverage to Codacy
38
+ command: bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r coverage/lcov/project.lcov
42
39
  checks:
43
40
  docker:
44
- - image: darthjee/circleci_rails_gems:1.3.0
41
+ - image: darthjee/circleci_rails_gems:2.1.0
45
42
  environment:
46
43
  PROJECT: zyra
47
44
  steps:
@@ -66,7 +63,7 @@ jobs:
66
63
  command: check_specs
67
64
  build-and-release:
68
65
  docker:
69
- - image: darthjee/circleci_rails_gems:1.3.0
66
+ - image: darthjee/circleci_rails_gems:2.1.0
70
67
  environment:
71
68
  PROJECT: zyra
72
69
  steps:
@@ -0,0 +1,80 @@
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.
@@ -0,0 +1,289 @@
1
+ # `zyra` Gem — Integration Reference
2
+
3
+ > **Audience:** this document is intended for developers and GitHub Copilot in
4
+ > repositories that use (or plan to use) the `zyra` gem. It describes how to
5
+ > integrate and use the gem without having to inspect the original source code.
6
+
7
+ ## What is `zyra`?
8
+
9
+ `zyra` is a Ruby gem for **idempotent database seeding** in Rails projects. It
10
+ ensures that certain entities exist in the database without duplicating them on
11
+ every `rake db:seed` run.
12
+
13
+ The basic flow is:
14
+
15
+ 1. You **register** a model and define which attributes serve as lookup keys.
16
+ 2. When `find_or_create` is called, the gem searches for the record by those keys.
17
+ 3. If the record **does not exist**, it is created with all provided attributes.
18
+ 4. If the record **already exists**, it is simply returned (no duplication).
19
+ 5. Optional hooks allow extra logic to be executed at each step of the process.
20
+
21
+ ---
22
+
23
+ ## Installation
24
+
25
+ ### Via `Gemfile` (recommended for Rails applications)
26
+
27
+ Add to your `Gemfile`:
28
+
29
+ ```ruby
30
+ gem 'zyra'
31
+ ```
32
+
33
+ Then install the dependencies:
34
+
35
+ ```bash
36
+ bundle install
37
+ ```
38
+
39
+ ### Via `gemspec` (for gems that depend on `zyra`)
40
+
41
+ ```ruby
42
+ spec.add_dependency 'zyra', '>= 1.3.0'
43
+ ```
44
+
45
+ ### Direct installation
46
+
47
+ ```bash
48
+ gem install zyra
49
+ ```
50
+
51
+ ---
52
+
53
+ ## Requirements
54
+
55
+ | Requirement | Minimum version |
56
+ |---------------|-----------------|
57
+ | Ruby | 3.3.1 |
58
+ | ActiveSupport | 7.2.2 |
59
+ | jace | 0.2.0 |
60
+
61
+ `zyra` is compatible with any ORM framework that uses the `ActiveRecord`
62
+ interface (e.g. Rails with ActiveRecord).
63
+
64
+ ---
65
+
66
+ ## Initial setup
67
+
68
+ The gem requires no configuration files, environment variables, or separate
69
+ initializers. Simply include it in the seeding code:
70
+
71
+ ```ruby
72
+ require 'zyra'
73
+ ```
74
+
75
+ In Rails projects the gem is already loaded automatically via Bundler.
76
+
77
+ ---
78
+
79
+ ## Usage in Rails applications
80
+
81
+ The recommended place to use `zyra` is `db/seeds.rb`.
82
+
83
+ ### Step 1 — Register the model
84
+
85
+ Call `Zyra.register` passing the model class and the attribute (or list of
86
+ attributes) to use as the lookup key:
87
+
88
+ ```ruby
89
+ # db/seeds.rb
90
+
91
+ Zyra.register(User, find_by: :email)
92
+ ```
93
+
94
+ Multiple keys:
95
+
96
+ ```ruby
97
+ Zyra.register(Product, find_by: %i[sku store_id])
98
+ ```
99
+
100
+ Register with a custom symbolic key (useful when the same model needs more than
101
+ one registration):
102
+
103
+ ```ruby
104
+ Zyra.register(User, :admin_user, find_by: :email)
105
+ ```
106
+
107
+ > When no key is provided, it is automatically derived from the class name
108
+ > (e.g. `User` → `:user`, `Admin::User` → `:admin_user`).
109
+
110
+ ### Step 2 — Find or create the record
111
+
112
+ ```ruby
113
+ # db/seeds.rb
114
+
115
+ user = Zyra.find_or_create(
116
+ :user,
117
+ email: 'admin@example.com',
118
+ name: 'Administrator',
119
+ role: 'admin'
120
+ )
121
+ # => a persisted User instance
122
+ ```
123
+
124
+ On the **first run** the user is created with all provided attributes. On
125
+ **subsequent runs** the existing user is found by `email` and returned
126
+ unchanged (unless hooks are configured).
127
+
128
+ ### Step 3 — Use the block to always update certain fields
129
+
130
+ The block passed to `find_or_create` is executed both on creation and when an
131
+ existing record is found, making it useful to ensure certain fields are always
132
+ up-to-date:
133
+
134
+ ```ruby
135
+ attributes = {
136
+ email: 'admin@example.com',
137
+ name: 'Administrator',
138
+ password: 'secure_password'
139
+ }
140
+
141
+ Zyra.find_or_create(:user, attributes) do |user|
142
+ user.update(attributes)
143
+ end
144
+ ```
145
+
146
+ ---
147
+
148
+ ## Available hooks
149
+
150
+ Hooks are registered with `Zyra.on(key, event)` (or chained on the return value
151
+ of `register`). The four possible events are:
152
+
153
+ | Event | When it fires |
154
+ |-----------|-----------------------------------------------------------|
155
+ | `:build` | After the object is instantiated (before saving) |
156
+ | `:create` | After the object is saved for the first time |
157
+ | `:found` | When the object is found in the database |
158
+ | `:return` | Always, after `:build`/`:create`/`:found` (post-return) |
159
+
160
+ ### Example: generate a token only on creation
161
+
162
+ ```ruby
163
+ Zyra.register(User, find_by: :email)
164
+ .on(:build) do |user|
165
+ user.api_token = SecureRandom.hex(16)
166
+ end
167
+
168
+ Zyra.find_or_create(:user, email: 'usr@srv.com', name: 'John')
169
+ # api_token is generated only the first time
170
+ ```
171
+
172
+ ### Example: force an update on every run
173
+
174
+ ```ruby
175
+ Zyra.register(User, find_by: :email)
176
+
177
+ Zyra.on(:user, :return) do |user|
178
+ user.update(last_seeded_at: Time.current)
179
+ end
180
+
181
+ Zyra.find_or_create(:user, email: 'usr@srv.com')
182
+ # last_seeded_at is updated on every seed run
183
+ ```
184
+
185
+ ### Example: create associated records only on first creation
186
+
187
+ ```ruby
188
+ Zyra.register(User, find_by: :email)
189
+ .on(:build) do |user|
190
+ user.posts.build(title: 'Welcome', body: 'First post')
191
+ end
192
+
193
+ Zyra.find_or_create(:user, email: 'usr@srv.com', name: 'John').reload
194
+ # The post is created only when the user is created for the first time
195
+ ```
196
+
197
+ ---
198
+
199
+ ## Full example in `db/seeds.rb`
200
+
201
+ ```ruby
202
+ # db/seeds.rb
203
+
204
+ # 1. Register models
205
+ Zyra.register(Role, find_by: :name)
206
+ Zyra.register(User, find_by: :email)
207
+ .on(:build) { |u| u.api_token = SecureRandom.hex(16) }
208
+
209
+ # 2. Create roles
210
+ admin_role = Zyra.find_or_create(:role, name: 'admin')
211
+ _user_role = Zyra.find_or_create(:role, name: 'user')
212
+
213
+ # 3. Create the admin user and always keep the name up-to-date
214
+ Zyra.find_or_create(
215
+ :user,
216
+ email: 'admin@example.com',
217
+ name: 'Admin',
218
+ role: admin_role
219
+ ) do |user|
220
+ user.update(name: 'Admin')
221
+ end
222
+ ```
223
+
224
+ Run with:
225
+
226
+ ```bash
227
+ rails db:seed
228
+ # or, to start from scratch:
229
+ rails db:reset
230
+ ```
231
+
232
+ ---
233
+
234
+ ## Best practices and conventions
235
+
236
+ 1. **Register models before using them** — ideally at the top of `db/seeds.rb`
237
+ or in a separate file (`db/seeds/registrations.rb`) loaded at the start.
238
+
239
+ 2. **Use `find_by` with unique and stable attributes** — emails, slugs, internal
240
+ codes. Avoid attributes that change frequently.
241
+
242
+ 3. **Prefer the block for optional updates** — put in the block only what must
243
+ always be updated; attributes outside the block are used only on creation.
244
+
245
+ 4. **Use `:build` hooks for data that should be generated only once** — tokens,
246
+ unique references, etc.
247
+
248
+ 5. **Use `:return` hooks for data that should always be refreshed** — audit
249
+ timestamps, counters, etc.
250
+
251
+ 6. **One `Zyra.register` per model per key** — if you need to look up the same
252
+ model by different attributes, provide a distinct symbolic key:
253
+
254
+ ```ruby
255
+ Zyra.register(User, :user_by_email, find_by: :email)
256
+ Zyra.register(User, :user_by_name, find_by: :name)
257
+ ```
258
+
259
+ 7. **Avoid `Zyra.reset` in production code** — this method exists to facilitate
260
+ testing and clears all registered models.
261
+
262
+ ---
263
+
264
+ ## Relevant rake tasks
265
+
266
+ | Command | Description |
267
+ |-------------------|----------------------------------------------------------|
268
+ | `rails db:seed` | Runs `db/seeds.rb` (use `zyra` here) |
269
+ | `rails db:reset` | Recreates the database and runs the seeds |
270
+ | `rails db:setup` | Creates the database, runs migrations and seeds |
271
+
272
+ ---
273
+
274
+ ## Internal file reference for `darthjee/zyra`
275
+
276
+ | File | Responsibility |
277
+ |---------------------------------|----------------------------------------------------------|
278
+ | `lib/zyra.rb` | Main module; exposes `register`, `on`, `find_or_create` |
279
+ | `lib/zyra/registry.rb` | Keeps the map of registered models |
280
+ | `lib/zyra/finder_creator.rb` | Orchestrates the lookup and creation of a record |
281
+ | `lib/zyra/finder.rb` | Queries the database using the lookup key attributes |
282
+ | `lib/zyra/creator.rb` | Instantiates and persists a new record |
283
+ | `lib/zyra/exceptions.rb` | Gem exceptions (`NotRegistered`, etc.) |
284
+ | `lib/zyra/version.rb` | Version constant (`Zyra::VERSION`) |
285
+
286
+ Full YARD documentation: <https://www.rubydoc.info/gems/zyra>
287
+ (replace with the version installed in your project, e.g. `/gems/zyra/1.2.0`)
288
+
289
+ Repository: <https://github.com/darthjee/zyra>
data/.rubocop.yml CHANGED
@@ -1,8 +1,8 @@
1
- require: rubocop-rspec
1
+ plugins: rubocop-rspec
2
2
  inherit_from: .rubocop_todo.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.7
5
+ TargetRubyVersion: 3.3
6
6
  NewCops: enable
7
7
 
8
8
  Metrics/BlockLength:
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2023-06-02 22:47:39 UTC using RuboCop version 1.51.0.
3
+ # on 2026-03-10 01:29:02 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
@@ -10,3 +10,4 @@
10
10
  # Configuration parameters: AllowSubject.
11
11
  RSpec/MultipleMemoizedHelpers:
12
12
  Max: 7
13
+
data/Dockerfile CHANGED
@@ -1,6 +1,6 @@
1
- FROM darthjee/scripts:0.3.1 as scripts
1
+ FROM darthjee/scripts:0.6.0 as scripts
2
2
 
3
- FROM darthjee/rails_gems:1.3.0 as base
3
+ FROM darthjee/rails_gems:2.1.0 as base
4
4
 
5
5
  COPY --chown=app:app ./ /home/app/app/
6
6
 
data/Gemfile CHANGED
@@ -4,23 +4,25 @@ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
- gem 'activerecord', '7.0.4.3'
8
- gem 'bundler', '>= 2.3.20'
9
- gem 'database_cleaner', '2.0.2'
10
- gem 'factory_bot', '6.2.1'
7
+ gem 'activerecord', '7.2.2.1'
8
+ gem 'bundler', '>= 2.5.13'
9
+ gem 'database_cleaner', '2.1.0'
10
+ gem 'factory_bot', '6.5.6'
11
11
  gem 'pry', '0.14.2'
12
12
  gem 'pry-nav', '1.0.0'
13
- gem 'rake', '13.0.6'
14
- gem 'reek', '6.1.4'
15
- gem 'rspec', '3.12.0'
16
- gem 'rspec-core', '3.12.2'
17
- gem 'rspec-expectations', '3.12.3'
18
- gem 'rspec-mocks', '3.12.5'
19
- gem 'rspec-support', '3.12.0'
20
- gem 'rubocop', '1.51.0'
21
- gem 'rubocop-rspec', '2.22.0'
22
- gem 'rubycritic', '4.8.0'
13
+ gem 'rake', '13.2.1'
14
+ gem 'reek', '6.5.0'
15
+ gem 'rspec', '3.13.2'
16
+ gem 'rspec-core', '3.13.6'
17
+ gem 'rspec-expectations', '3.13.5'
18
+ gem 'rspec-mocks', '3.13.8'
19
+ gem 'rspec-support', '3.13.7'
20
+ gem 'rubocop', '1.85.1'
21
+ gem 'rubocop-rspec', '3.9.0'
22
+ gem 'rubycritic', '5.0.0'
23
23
  gem 'simplecov', '0.22.0'
24
+ gem 'simplecov-html', '0.13.2'
25
+ gem 'simplecov-lcov', '0.9.0'
24
26
  gem 'sqlite3', '1.4.2'
25
- gem 'yard', '0.9.27'
27
+ gem 'yard', '0.9.38'
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
- [![Code Climate](https://codeclimate.com/github/darthjee/zyra/badges/gpa.svg)](https://codeclimate.com/github/darthjee/zyra)
4
- [![Test Coverage](https://codeclimate.com/github/darthjee/zyra/badges/coverage.svg)](https://codeclimate.com/github/darthjee/zyra/coverage)
5
- [![Issue Count](https://codeclimate.com/github/darthjee/zyra/badges/issue_count.svg)](https://codeclimate.com/github/darthjee/zyra)
3
+ [![CircleCI](https://dl.circleci.com/status-badge/img/gh/darthjee/zyra/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/darthjee/zyra/tree/main)
6
4
  [![Gem Version](https://badge.fury.io/rb/zyra.svg)](https://badge.fury.io/rb/zyra)
7
- [![Codacy Badge](https://app.codacy.com/project/badge/Grade/fe2da1c4711d4774bd7c46acd578da05)](https://www.codacy.com/gh/darthjee/zyra/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=darthjee/zyra&amp;utm_campaign=Badge_Grade)
5
+ [![Codacy Badge](https://app.codacy.com/project/badge/Grade/fe2da1c4711d4774bd7c46acd578da05)](https://app.codacy.com/gh/darthjee/zyra/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
6
+ [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/fe2da1c4711d4774bd7c46acd578da05)](https://app.codacy.com/gh/darthjee/zyra/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)
8
7
  [![Inline docs](http://inch-ci.org/github/darthjee/zyra.svg?branch=master)](http://inch-ci.org/github/darthjee/zyra)
9
8
 
10
9
  ![zyra](https://raw.githubusercontent.com/darthjee/zyra/master/zyra.jpg)
@@ -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: [1.2.0](https://github.com/darthjee/zyra/tree/1.2.0)
17
+ **Current Release**: [1.3.0](https://github.com/darthjee/zyra/tree/1.3.0)
19
18
 
20
- [Next release](https://github.com/darthjee/zyra/compare/1.2.0...master)
19
+ **Next release**: [1.4.0](https://github.com/darthjee/zyra/compare/1.3.0...main)
21
20
 
22
21
  Yard Documentation
23
22
  -------------------
24
- [https://www.rubydoc.info/gems/zyra/1.2.0](https://www.rubydoc.info/gems/zyra/1.2.0)
23
+ [https://www.rubydoc.info/gems/zyra/1.3.0](https://www.rubydoc.info/gems/zyra/1.3.0)
25
24
 
26
25
  Installation
27
26
  ---------------
data/lib/zyra/finder.rb CHANGED
@@ -79,9 +79,7 @@ module Zyra
79
79
  #
80
80
  # @return [Hash]
81
81
  def query_from(attributes)
82
- attributes.symbolize_keys.select do |attribute, _value|
83
- keys.include?(attribute)
84
- end
82
+ attributes.symbolize_keys.slice(*keys)
85
83
  end
86
84
 
87
85
  # @private
@@ -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, &block)
40
- model = find(attributes, &block) || create(attributes, &block)
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, &block)
135
- finder_creator_for(key).on(event, &block)
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, &block)
172
- finder_creator_for(key).find_or_create(attributes, &block)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zyra
4
- VERSION = '1.2.0'
4
+ VERSION = '1.3.0'
5
5
  end
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].sort.each { |file| require file }
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 = '>= 2.7.0'
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.add_runtime_dependency 'activesupport', '>= 7.0.4'
22
- gem.add_runtime_dependency 'jace', '>= 0.1.1'
21
+ gem.add_dependency 'activesupport', '~> 7.2.x'
22
+ gem.add_dependency 'jace', '>= 0.1.2'
23
23
 
24
24
  gem.metadata['rubygems_mfa_required'] = 'true'
25
25
  end
data/zyra.jpg CHANGED
Binary file
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zyra
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DarthJee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-06 00:00:00.000000000 Z
11
+ date: 2026-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 7.0.4
19
+ version: 7.2.x
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 7.0.4
26
+ version: 7.2.x
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: jace
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.1
33
+ version: 0.1.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.1.1
40
+ version: 0.1.2
41
41
  description: Gem for seeding data in the database
42
42
  email:
43
43
  - darthjee@gmail.com
@@ -46,6 +46,8 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - ".circleci/config.yml"
49
+ - ".github/copilot-instructions.md"
50
+ - ".github/zyra-usage.md"
49
51
  - ".gitignore"
50
52
  - ".rspec"
51
53
  - ".rubocop.yml"
@@ -54,6 +56,7 @@ files:
54
56
  - Dockerfile.circleci
55
57
  - Gemfile
56
58
  - LICENSE
59
+ - Makefile
57
60
  - README.md
58
61
  - Rakefile
59
62
  - config/check_specs.yml
@@ -103,14 +106,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
106
  requirements:
104
107
  - - ">="
105
108
  - !ruby/object:Gem::Version
106
- version: 2.7.0
109
+ version: 3.3.1
107
110
  required_rubygems_version: !ruby/object:Gem::Requirement
108
111
  requirements:
109
112
  - - ">="
110
113
  - !ruby/object:Gem::Version
111
114
  version: '0'
112
115
  requirements: []
113
- rubygems_version: 3.1.2
116
+ rubygems_version: 3.5.9
114
117
  signing_key:
115
118
  specification_version: 4
116
119
  summary: Gem for seeding data in the database