enumbler 0.11.0 → 0.12.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: e565cc926b8cca7f06e64cc90503f5965003a3e5c60d1c2a5cd689ea690c8215
4
- data.tar.gz: e2cfef7c22ed8ce2d51d706802c79ce1fc0b4abe8b3268aa634400051f9970b1
3
+ metadata.gz: 8976fda559de218589436c6fba7fe3e31d2f43ecefdb989d1ac30e54581973f0
4
+ data.tar.gz: b592b99299c6c6656d5f4914c0a487d82ba9b56589b8c0d57deb03b206b1a057
5
5
  SHA512:
6
- metadata.gz: 77c6de7fc4fbebc329e77ccee8ead1998a71e6539d45a218a1f018424a4a6e087869e0c04fc51d074f006fddfa32cf7e047e417e3b1c5706be822003029b432c
7
- data.tar.gz: 8e30d49be482fc9fa3da561c134c93c8db1b8362f05c7dd83300e5e6db16b001c399382ed5c9fa3d96291ab232d4a28ac1d147bf8d7833294ece0ed98b3135e6
6
+ metadata.gz: 374808a1e72ad4bf6104cacf52ea5e00e8eecfd341395f667083caa0469f57a2e39630cf2601583274c36de71da4a978b2e7c45bec4e35e4043559736d4e3c13
7
+ data.tar.gz: 2b5e72f8985aaf052d24997c6285b71c4a2d323b30f9a99e2b287116d94c39e9a9f2be90d7d06effbc3c05662fda0020748299670724590030d32148986aed81
data/CHANGELOG.md ADDED
@@ -0,0 +1,40 @@
1
+ # Changelog
2
+
3
+ All notable changes to this gem are recorded here. Versions follow the bare
4
+ git tags on `main` (no `v` prefix).
5
+
6
+ ## 0.12.0
7
+
8
+ ### Added
9
+
10
+ - `enumbler_allow_duplicate_labels`: a per-model opt-in, declared before the
11
+ first `enumble`, that lets enumbles share a label. Duplicates are then
12
+ rejected only on id or enum, and Enumbles that share only a label are no
13
+ longer `==`/`eql?`. On such a model a String lookup that matches an enum
14
+ name resolves to it; one that matches more than one label raises the new
15
+ `Enumbler::AmbiguousLabelError` (an `Enumbler::Error`), even without
16
+ `raise_error`, and `find_by_enumble` passes it through rather than raising
17
+ `ActiveRecord::RecordNotFound`. Exact-case matches rank above case-insensitive
18
+ ones, and within each an enum name ranks above a label. Models that do not
19
+ opt in are unchanged.
20
+
21
+ ### Changed
22
+
23
+ - **Minimum Ruby is now 3.2** (was 3.1). Ruby 3.1 is end-of-life, and the
24
+ patched `sqlite3` the test suite needs no longer installs on it.
25
+ ActiveRecord/ActiveSupport support is unchanged (>= 6.0, < 9).
26
+ - Rails 8.1 is now in the CI matrix, as is Ruby 4.0 (with Rails 7.1+).
27
+ - Gem metadata points at `github.com/octoopi/enumbler` and this changelog,
28
+ and the packaged gem ships only `lib/`, the README, the changelog and the
29
+ license.
30
+
31
+ ## 0.11.0
32
+
33
+ - Added `Enumbler.suppress_database_warnings` (and the
34
+ `ENUMBLER_SUPPRESS_DATABASE_WARNINGS` environment variable) to silence the
35
+ boot-time `[Enumbler Warning]` messages.
36
+ - Releases publish through RubyGems trusted publishing from CI.
37
+
38
+ ## 0.10.0
39
+
40
+ - Support for Rails 7.x and 8.0.
data/README.md CHANGED
@@ -149,6 +149,44 @@ Feeling.verklempt.enumble.label # => 'overcome with emotion'
149
149
  Feeling.verklempt.emotion # => 'overcome with emotion'
150
150
  ```
151
151
 
152
+ ### Allow duplicate labels
153
+
154
+ Every enumble in a model normally needs a unique id, enum, **and** label: a second `enumble` that repeats any of the three raises `You cannot add the same Enumble twice!`. When labels genuinely repeat, say a `Topic` table where "Classroom" appears under two different parents, opt the model in with `enumbler_allow_duplicate_labels` before its first `enumble`:
155
+
156
+ ```ruby
157
+ ActiveRecord::Schema.define do
158
+ create_table :topics, force: true do |t|
159
+ t.string :label, null: false # no unique index: labels repeat
160
+ end
161
+ end
162
+
163
+ class Topic < ApplicationRecord
164
+ include Enumbler::Enabler
165
+
166
+ enumbler_allow_duplicate_labels
167
+
168
+ enumble :k12_classroom, 17, label: "Classroom"
169
+ enumble :higher_ed_classroom, 34, label: "Classroom"
170
+ enumble :science, 20, label: "Science"
171
+ end
172
+ ```
173
+
174
+ With it on, an enumble is a duplicate only when its **id or enum** is already taken. Enum names are still unique, so constants (`Topic::K12_CLASSROOM`), class shortcuts (`Topic.k12_classroom`), predicates (`topic.k12_classroom?`), `graphql_enum`, and lookups by id, symbol, Enumble, or record all work as before. Two Enumbles that share only a label are no longer `==`.
175
+
176
+ String lookups (`find_enumble(s)`, `find_by_enumble`, `ids_from_enumbler`, the `enumbled_to` scopes, and their bang versions) become stricter:
177
+
178
+ ```ruby
179
+ Topic.find_enumble("higher_ed_classroom") # => Enumbler::Enumble<:higher_ed_classroom>, by enum name
180
+ Topic.find_enumble("Science") # => Enumbler::Enumble<:science>, one label match resolves
181
+ Topic.find_enumble("Art") # => nil, as before
182
+ Topic.find_enumble("Classroom") # => raises Enumbler::AmbiguousLabelError
183
+ Lesson.topic("Classroom") # => raises Enumbler::AmbiguousLabelError (Lesson `enumbled_to :topic`)
184
+ ```
185
+
186
+ A String that matches more than one label raises `Enumbler::AmbiguousLabelError` (a subclass of `Enumbler::Error`) **whether or not** you asked for an error on a missing value, rather than silently returning whichever enumble was defined first. `find_by_enumble` lets it through instead of turning it into `ActiveRecord::RecordNotFound`. Matching follows `case_sensitive:` as usual, so `"classroom"` is ambiguous too unless you pass `case_sensitive: true`. Exact-case matches rank above case-insensitive ones, and within each an enum name ranks above a label. So with an enum `:classroom` labeled "Classroom" and a second "Classroom" label, `"classroom"` resolves to `:classroom` but `"Classroom"` raises: it matches two labels exactly, and resolving it to an enum that only matches ignoring case would be a guess. Likewise `"Classroom"` still resolves when the only other label is `"classroom"`.
187
+
188
+ Models that do not call `enumbler_allow_duplicate_labels` behave exactly as they always have.
189
+
152
190
  ## Core ext
153
191
 
154
192
  Adds case equality power to the `Symbol` class allowing you to use case methods directly against an enabled instance:
@@ -199,7 +237,7 @@ Two things to know before tagging:
199
237
 
200
238
  Steps:
201
239
 
202
- 1. Bump `Enumbler::VERSION` in `lib/enumbler/version.rb` (and run `bundle install` so the lockfiles pick it up) on a `release/x.y.z` branch off `develop` (or `hotfix/x.y.z` off `main`).
240
+ 1. Bump `Enumbler::VERSION` in `lib/enumbler/version.rb` and add its section to `CHANGELOG.md`, then refresh every lockfile so it records the new version (`for g in Gemfile Gemfile.rails*[0-9]; do BUNDLE_GEMFILE=$g bundle lock; done`) on a `release/x.y.z` branch off `develop` (or `hotfix/x.y.z` off `main`).
203
241
  2. Merge the branch into `main`, then tag the release commit:
204
242
 
205
243
  ```bash
@@ -213,7 +251,7 @@ Steps:
213
251
 
214
252
  ### Matrix testing
215
253
 
216
- This gem supporst different versions of Ruby and Rails. To test against all supported versions, run:
254
+ The gem supports Ruby >= 3.2 and ActiveRecord/ActiveSupport >= 6.0, < 9. CI runs the rspec matrix across those using one `Gemfile.rails*` per Rails minor (6.0 through 8.1); the main `Gemfile` tracks the newest Rails. To test against one of them locally, run:
217
255
 
218
256
  ```bash
219
257
  BUNDLE_GEMFILE=Gemfile.rails7.2 bundle install
@@ -226,7 +264,7 @@ BUNDLE_GEMFILE=Gemfile.rails7.2 bundle exec rspec
226
264
 
227
265
  ## Contributing
228
266
 
229
- Bug reports and pull requests are welcome on GitHub at https://github.com/linguabee/enumbler.
267
+ Bug reports and pull requests are welcome on GitHub at https://github.com/octoopi/enumbler.
230
268
 
231
269
  ## License
232
270
 
@@ -99,6 +99,7 @@ module Enumbler
99
99
  @enumbler_label_column_name ||= :label
100
100
 
101
101
  enumble = Enumble.new(enum, id, label: label, label_column_name: @enumbler_label_column_name, **attributes)
102
+ enumble.allow_duplicate_labels! if enumbler_allow_duplicate_labels?
102
103
 
103
104
  if @enumbles.include?(enumble)
104
105
  raise Error, "You cannot add the same Enumble twice! Attempted to add: #{enum}, #{id}."
@@ -133,6 +134,49 @@ module Enumbler
133
134
  @enumbler_label_column_name = label_column_name
134
135
  end
135
136
 
137
+ # By default every enumble in a model needs a unique id, enum, and
138
+ # label. Call this before your first `enumble` to let labels repeat:
139
+ # an enumble is then rejected as a duplicate only when its id or enum is
140
+ # already taken. Enum names stay unique, so constants, class
141
+ # shortcuts, predicates, and `graphql_enum` are unaffected.
142
+ #
143
+ # class Topic < ApplicationRecord
144
+ # include Enumbler::Enabler
145
+ #
146
+ # enumbler_allow_duplicate_labels
147
+ #
148
+ # enumble :k12_classroom, 17, label: "Classroom"
149
+ # enumble :higher_ed_classroom, 34, label: "Classroom"
150
+ # end
151
+ #
152
+ # A String lookup (`find_enumble`, `find_by_enumble`, `ids_from_enumbler`
153
+ # and friends) that matches an enum name still resolves to that enumble.
154
+ # One that matches no enum name but more than one label raises
155
+ # {Enumbler::AmbiguousLabelError}, even without `raise_error`, rather
156
+ # than return whichever was defined first. Exact-case matches beat
157
+ # case-insensitive ones; within each, an enum name beats a label. So
158
+ # with `:classroom` labeled "Classroom" and a second "Classroom" label,
159
+ # "classroom" resolves to `:classroom` but "Classroom" raises.
160
+ #
161
+ # Remember to drop any unique index on the label column.
162
+ #
163
+ # @param allow [Boolean] (default: true)
164
+ # @raise [Error] when called after the model has defined an enumble
165
+ def enumbler_allow_duplicate_labels(allow = true) # rubocop:disable Style/OptionalBooleanParameter
166
+ if @enumbles.present?
167
+ raise Error, "Call `enumbler_allow_duplicate_labels` on #{self} before its first `enumble`."
168
+ end
169
+
170
+ @enumbler_allow_duplicate_labels = allow ? true : false
171
+ end
172
+
173
+ # Whether this model lets enumbles share a label. See
174
+ # {.enumbler_allow_duplicate_labels}.
175
+ # @return [Boolean]
176
+ def enumbler_allow_duplicate_labels?
177
+ @enumbler_allow_duplicate_labels || false
178
+ end
179
+
136
180
  # Like `ActiveRecord#find_by`, will try and return an instance of this
137
181
  # model that matches any of our enumble attributes (instance, id, string,
138
182
  # or symbol).
@@ -155,6 +199,8 @@ module Enumbler
155
199
 
156
200
  find_by = raise_error ? :find_by! : :find_by
157
201
  @enumbled_model.public_send(find_by, id: id)
202
+ rescue Enumbler::AmbiguousLabelError
203
+ raise
158
204
  rescue Enumbler::Error
159
205
  raise ActiveRecord::RecordNotFound.new("Couldn't find #{@enumbled_model}", @enumbled_model)
160
206
  end
@@ -182,6 +228,9 @@ module Enumbler
182
228
  # want one argument to be found and not returned in an array.
183
229
  # @raise [Error] when there is no [Enumbler::Enumble] to be found and
184
230
  # `raise_error: true`
231
+ # @raise [AmbiguousLabelError] on a model with
232
+ # {.enumbler_allow_duplicate_labels}, when a String matches more than
233
+ # one label (regardless of `raise_error`)
185
234
  # @param args [Integer, String, Symbol]
186
235
  # @param case_sensitive [Boolean] should a String search be case sensitive
187
236
  # (default: false)
@@ -197,6 +246,9 @@ module Enumbler
197
246
  # if none found.
198
247
  # @raise [Error] when there is no [Enumbler::Enumble] to be found and
199
248
  # `raise_error: true`
249
+ # @raise [AmbiguousLabelError] on a model with
250
+ # {.enumbler_allow_duplicate_labels}, when a String matches more than
251
+ # one label (regardless of `raise_error`)
200
252
  # @param args [Integer, String, Symbol]
201
253
  # @param case_sensitive [Boolean] should a String search be case sensitive
202
254
  # (default: false)
@@ -217,6 +269,9 @@ module Enumbler
217
269
  #
218
270
  # @raise [Error] when there is no [Enumbler::Enumble] to be found and
219
271
  # `raise_error: true`
272
+ # @raise [AmbiguousLabelError] on a model with
273
+ # {.enumbler_allow_duplicate_labels}, when a String matches more than
274
+ # one label (regardless of `raise_error`)
220
275
  # @param args [Integer, String, Symbol]
221
276
  # @param case_sensitive [Boolean] should a String search be case sensitive
222
277
  # (default: false)
@@ -236,6 +291,8 @@ module Enumbler
236
291
  @enumbled_model.enumbles.find { |e| e.enum == arg }
237
292
  elsif arg.is_a?(Enumbler::Enumble)
238
293
  @enumbled_model.enumbles.find { |e| e.enum == arg.enum }
294
+ elsif arg.is_a?(String) && @enumbled_model.enumbler_allow_duplicate_labels?
295
+ find_enumble_by_string_allowing_duplicate_labels(arg, case_sensitive: case_sensitive)
239
296
  elsif arg.is_a?(String)
240
297
  @enumbled_model.enumbles.find do |e|
241
298
  if case_sensitive
@@ -256,6 +313,8 @@ module Enumbler
256
313
 
257
314
  nil
258
315
  end
316
+ rescue AmbiguousLabelError
317
+ raise
259
318
  rescue Error
260
319
  raise Error, err
261
320
  end
@@ -263,6 +322,8 @@ module Enumbler
263
322
 
264
323
  # See {.find_enumbles}. Same method, only raises error when none found.
265
324
  # @raise [Error] when there is no [Enumbler::Enumble] to be found
325
+ # @raise [AmbiguousLabelError] when a String matches more than one label
326
+ # (see {.enumbler_allow_duplicate_labels})
266
327
  # @param args [Integer, String, Symbol]
267
328
  # @param case_sensitive [Boolean] should a String search be case sensitive
268
329
  # (default: false)
@@ -280,6 +341,8 @@ module Enumbler
280
341
  # Color.id_from_enumbler(Color.black) # => 1
281
342
  #
282
343
  # @raise [Error] when there is no enumble to be found
344
+ # @raise [AmbiguousLabelError] when a String matches more than one label
345
+ # (see {.enumbler_allow_duplicate_labels})
283
346
  # @param arg [Integer, Symbol, Class]
284
347
  # @param case_sensitive [Boolean] should a string search be performed with
285
348
  # case sensitivity (default: false)
@@ -292,6 +355,8 @@ module Enumbler
292
355
 
293
356
  # See {.ids_from_enumbler}. Raises error if none found.
294
357
  # @raise [Error] when there is no enumble to be found
358
+ # @raise [AmbiguousLabelError] when a String matches more than one label
359
+ # (see {.enumbler_allow_duplicate_labels})
295
360
  # @param arg [Integer, Symbol, Class]
296
361
  # @param case_sensitive [Boolean] should a string search be performed with
297
362
  # case sensitivity (default: false)
@@ -312,6 +377,8 @@ module Enumbler
312
377
  # Color.ids_from_enumbler(Color.black, Color.white) # => [1, 2]
313
378
  #
314
379
  # @raise [Error] when there is no enumble to be found
380
+ # @raise [AmbiguousLabelError] when a String matches more than one label
381
+ # (see {.enumbler_allow_duplicate_labels})
315
382
  # @param *args [Integer, Symbol, Class]
316
383
  # @param case_sensitive [Boolean] should a string search be performed with
317
384
  # case sensitivity (default: false)
@@ -325,6 +392,8 @@ module Enumbler
325
392
 
326
393
  # See {.ids_from_enumbler}. Raises error when none found.
327
394
  # @raise [Error] when there is no enumble to be found
395
+ # @raise [AmbiguousLabelError] when a String matches more than one label
396
+ # (see {.enumbler_allow_duplicate_labels})
328
397
  # @param *args [Integer, Symbol, Class]
329
398
  # @param case_sensitive [Boolean] should a string search be performed with
330
399
  # case sensitivity (default: false)
@@ -380,6 +449,32 @@ module Enumbler
380
449
 
381
450
  private
382
451
 
452
+ # The String branch of {.find_enumbles} for a model that allows
453
+ # duplicate labels. Matching runs in tiers: exact case first, then
454
+ # (unless `case_sensitive`) ignoring case. Within a tier an enum name
455
+ # wins, then a single label match resolves and more than one raises.
456
+ # So an exact-case label shared by two enumbles raises even when some
457
+ # enum name matches it ignoring case: better than guessing.
458
+ def find_enumble_by_string_allowing_duplicate_labels(arg, case_sensitive:)
459
+ tiers = [->(value) { arg == value }]
460
+ tiers << ->(value) { arg.casecmp?(value) } unless case_sensitive
461
+
462
+ tiers.each do |matches|
463
+ by_enum = @enumbled_model.enumbles.find { |e| matches.call(e.enum.to_s) }
464
+ return by_enum if by_enum
465
+
466
+ by_label = @enumbled_model.enumbles.select { |e| matches.call(e.label) }
467
+ next if by_label.empty?
468
+ return by_label.first if by_label.one?
469
+
470
+ raise AmbiguousLabelError,
471
+ "#{@enumbled_model} has more than one enumble labeled #{arg.inspect} " \
472
+ "(#{by_label.map { |e| ":#{e.enum}" }.join(', ')}); look it up by enum or id instead."
473
+ end
474
+
475
+ nil
476
+ end
477
+
383
478
  def define_dynamic_methods_and_constants_for_enumbled_model(enumble)
384
479
  method_name = "#{enumble.enum}?"
385
480
  not_method_name = "not_#{enumble.enum}?"
@@ -9,14 +9,17 @@ module Enumbler
9
9
  @id = id
10
10
  @enum = enum
11
11
  @label_column_name = label_column_name
12
+ @allow_duplicate_labels = false
12
13
  @label = (label_col_specified? ? attributes[label_column_name] : label) || enum.to_s.dasherize
13
14
  @additional_attributes = attributes || {}
14
15
  @additional_attributes.merge!({ label: label }) unless label.nil?
15
16
  end
16
17
 
18
+ # Equal when the id or enum match, or the label matches and neither side
19
+ # allows duplicate labels.
17
20
  def ==(other)
18
21
  other.class == self.class &&
19
- (other.id == id || other.enum == enum || other.label == label)
22
+ (other.id == id || other.enum == enum || same_label_as?(other))
20
23
  end
21
24
 
22
25
  def attributes
@@ -34,9 +37,24 @@ module Enumbler
34
37
  self
35
38
  end
36
39
 
37
- def eql?(other)
38
- other.class == self.class &&
39
- (other.id == id || other.enum == enum || other.label == label)
40
+ alias eql? ==
41
+
42
+ # Whether this Enumble may share its label with another in its model.
43
+ # @return [Boolean]
44
+ def allow_duplicate_labels?
45
+ @allow_duplicate_labels
46
+ end
47
+
48
+ # Lets this Enumble share its label: a shared label no longer makes two
49
+ # Enumbles equal, only id or enum do. Called by `enumble` on a model that
50
+ # uses {Enumbler::Enabler::ClassMethods#enumbler_allow_duplicate_labels};
51
+ # it is not a constructor keyword so it cannot collide with a column name
52
+ # passed through `**attributes`.
53
+ # @api private
54
+ # @return [self]
55
+ def allow_duplicate_labels!
56
+ @allow_duplicate_labels = true
57
+ self
40
58
  end
41
59
 
42
60
  # Standardizing the enum for a GraphQL schema with an uppercase string
@@ -52,6 +70,12 @@ module Enumbler
52
70
 
53
71
  private
54
72
 
73
+ def same_label_as?(other)
74
+ return false if allow_duplicate_labels? || other.allow_duplicate_labels?
75
+
76
+ other.label == label
77
+ end
78
+
55
79
  def label_col_specified?
56
80
  label_column_name != :label
57
81
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Enumbler
4
- VERSION = "0.11.0"
4
+ VERSION = "0.12.0"
5
5
  end
data/lib/enumbler.rb CHANGED
@@ -17,6 +17,12 @@ module Enumbler
17
17
  # An error raised by the Enumbler.
18
18
  class Error < StandardError; end
19
19
 
20
+ # Raised when a String lookup matches the labels of more than one enumble,
21
+ # which can only happen on a model that calls
22
+ # `enumbler_allow_duplicate_labels`. Raised whether or not the lookup was
23
+ # asked to raise on a missing value: a guess is worse than no answer.
24
+ class AmbiguousLabelError < Error; end
25
+
20
26
  class << self
21
27
  attr_writer :suppress_database_warnings
22
28
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enumbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damon Timm
@@ -49,57 +49,32 @@ dependencies:
49
49
  - - "<"
50
50
  - !ruby/object:Gem::Version
51
51
  version: '9'
52
- description: A more complete description is forthcoming.
52
+ description: 'Database-backed enums for ActiveRecord: real foreign-key lookup tables
53
+ that behave like enums, with constants, predicates, scopes, and seeding generated
54
+ from one definition.'
53
55
  email:
54
56
  - damon@linguabee.com
55
57
  executables: []
56
58
  extensions: []
57
59
  extra_rdoc_files: []
58
60
  files:
59
- - ".github/workflows/ruby.yml"
60
- - ".gitignore"
61
- - ".rspec"
62
- - ".rubocop.yml"
63
- - ".ruby-version"
64
- - ".solargraph.yml"
65
- - AGENTS.md
66
- - CLAUDE.md
67
- - Gemfile
68
- - Gemfile.lock
69
- - Gemfile.rails6.0
70
- - Gemfile.rails6.0.lock
71
- - Gemfile.rails6.1
72
- - Gemfile.rails6.1.lock
73
- - Gemfile.rails7.0
74
- - Gemfile.rails7.0.lock
75
- - Gemfile.rails7.1
76
- - Gemfile.rails7.1.lock
77
- - Gemfile.rails7.2
78
- - Gemfile.rails7.2.lock
79
- - Gemfile.rails8.0
80
- - Gemfile.rails8.0.lock
61
+ - CHANGELOG.md
81
62
  - LICENSE.txt
82
63
  - README.md
83
- - Rakefile
84
- - bin/console
85
- - bin/pre_commit_rubocop.rb
86
- - bin/setup
87
- - enumbler.gemspec
88
- - lefthook.yml
89
64
  - lib/enumbler.rb
90
65
  - lib/enumbler/collection.rb
91
66
  - lib/enumbler/core_ext/symbol/case_equality_operator.rb
92
67
  - lib/enumbler/enabler.rb
93
68
  - lib/enumbler/enumble.rb
94
69
  - lib/enumbler/version.rb
95
- homepage: https://github.com/linguabee/enumbler
70
+ homepage: https://github.com/octoopi/enumbler
96
71
  licenses:
97
72
  - MIT
98
73
  metadata:
99
74
  allowed_push_host: https://rubygems.org
100
- homepage_uri: https://github.com/linguabee/enumbler
101
- source_code_uri: https://github.com/linguabee/enumbler
102
- changelog_uri: https://github.com/linguabee/enumbler
75
+ homepage_uri: https://github.com/octoopi/enumbler
76
+ source_code_uri: https://github.com/octoopi/enumbler
77
+ changelog_uri: https://github.com/octoopi/enumbler/blob/main/CHANGELOG.md
103
78
  rubygems_mfa_required: 'true'
104
79
  rdoc_options: []
105
80
  require_paths:
@@ -108,7 +83,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
83
  requirements:
109
84
  - - ">="
110
85
  - !ruby/object:Gem::Version
111
- version: '3.1'
86
+ version: '3.2'
112
87
  required_rubygems_version: !ruby/object:Gem::Requirement
113
88
  requirements:
114
89
  - - ">="
@@ -1,93 +0,0 @@
1
- name: CI Matrix Testing
2
-
3
- on:
4
- push:
5
- branches: [ main ]
6
- tags: ["*"]
7
- pull_request:
8
-
9
- # A new push to the same ref supersedes any in-flight run; cancel the stale
10
- # one rather than paying for both.
11
- concurrency:
12
- group: ci-${{ github.workflow }}-${{ github.ref }}
13
- cancel-in-progress: true
14
-
15
- jobs:
16
- rspec:
17
- runs-on: ubuntu-latest
18
- # Typical matrix job is under 2 minutes; a hung job otherwise runs to
19
- # GitHub's 6-hour default.
20
- timeout-minutes: 10
21
- strategy:
22
- fail-fast: false
23
- matrix:
24
- ruby: [3.1, 3.2, 3.3, 3.4]
25
- rails_version: ["6.0", "6.1", "7.0", "7.1", "7.2", "8.0"]
26
- exclude:
27
- - ruby: 3.1
28
- rails_version: "8.0"
29
- - ruby: 3.4
30
- rails_version: "6.0"
31
- - ruby: 3.4
32
- rails_version: "6.1"
33
- - ruby: 3.4
34
- rails_version: "7.0"
35
-
36
- steps:
37
- - uses: actions/checkout@v4
38
-
39
- - name: Set up Ruby
40
- uses: ruby/setup-ruby@v1
41
- with:
42
- ruby-version: ${{ matrix.ruby }}
43
-
44
- - name: Install sqlite3
45
- run: sudo apt-get update && sudo apt-get install -y libsqlite3-dev
46
-
47
- - name: Install dependencies
48
- env:
49
- BUNDLE_GEMFILE: Gemfile.rails${{ matrix.rails_version }}
50
- run: |
51
- bundle install --jobs 4 --retry 3
52
-
53
- - name: Run specs
54
- env:
55
- BUNDLE_GEMFILE: Gemfile.rails${{ matrix.rails_version }}
56
- run: bundle exec rspec
57
-
58
- build:
59
- needs: rspec
60
-
61
- name: Publish Gem
62
- runs-on: ubuntu-latest
63
- timeout-minutes: 10
64
-
65
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
66
-
67
- # Publishes via RubyGems trusted publishing (OIDC) — no API key, and
68
- # exempt from the account's OTP requirement. The trusted publisher on
69
- # rubygems.org is registered for this repo + this workflow filename.
70
- # Uses configure-rubygems-credentials + a plain `gem push` rather than
71
- # the release-gem action: that action runs `rake release`, which wants
72
- # to git-push and create its own v-prefixed tag — this repo tags
73
- # manually (bare version numbers) and this job runs on a detached HEAD.
74
- permissions:
75
- id-token: write
76
-
77
- steps:
78
- - uses: actions/checkout@v4
79
- with:
80
- persist-credentials: false
81
-
82
- - name: Set up Ruby
83
- uses: ruby/setup-ruby@v1
84
- with:
85
- ruby-version: 3.4
86
-
87
- - uses: rubygems/configure-rubygems-credentials@v2.1.0
88
-
89
- - name: Build and push gem
90
- run: |
91
- gem build *.gemspec
92
- gem push *.gem
93
-
data/.gitignore DELETED
@@ -1,14 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
12
- .byebug_history
13
-
14
- tags*
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,76 +0,0 @@
1
- AllCops:
2
- NewCops: enable
3
- TargetRubyVersion: 3.4
4
- Exclude:
5
- - 'bin/**/*'
6
-
7
- Gemspec/RequiredRubyVersion:
8
- Enabled: false
9
-
10
- Layout/ArgumentAlignment:
11
- Enabled: true
12
- EnforcedStyle: with_fixed_indentation
13
-
14
- Layout/FirstHashElementIndentation:
15
- Enabled: true
16
- EnforcedStyle: consistent
17
-
18
- Layout/HashAlignment:
19
- Enabled: true
20
- # This allows "implicit" hash arguments (without curly braces) to be aligned
21
- # differently.
22
- EnforcedLastArgumentHashStyle: ignore_implicit
23
-
24
- Layout/LineLength:
25
- AllowURI: true
26
- Max: 119
27
-
28
- Layout/MultilineMethodCallIndentation:
29
- Enabled: true
30
- EnforcedStyle: indented
31
-
32
- Lint/RaiseException:
33
- Enabled: true
34
-
35
- Lint/StructNewOverride:
36
- Enabled: true
37
-
38
- Metrics:
39
- Enabled: false
40
-
41
- Naming/MethodParameterName:
42
- Enabled: true
43
- AllowedNames: [at, by, db, id, in, ip, of, on, to, tz]
44
-
45
- Naming/PredicateName:
46
- Enabled: true
47
-
48
- # Works in 3.4 only
49
- Style/ArgumentsForwarding:
50
- Enabled: false
51
-
52
- Style/Documentation:
53
- Enabled: false
54
-
55
- Style/HashEachMethods:
56
- Enabled: true
57
-
58
- Style/HashTransformKeys:
59
- Enabled: true
60
-
61
- Style/HashTransformValues:
62
- Enabled: true
63
-
64
- Style/StringLiterals:
65
- EnforcedStyle: double_quotes
66
-
67
- Style/TrailingCommaInHashLiteral:
68
- Enabled: true
69
- EnforcedStyleForMultiline: consistent_comma
70
-
71
- Style/TrailingCommaInArrayLiteral:
72
- Enabled: true
73
- EnforcedStyleForMultiline: consistent_comma
74
-
75
- Style/TrailingCommaInArguments:
76
- EnforcedStyleForMultiline: consistent_comma
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.4.4