cool_id 0.1.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07011e094fb16385d448b80b4461b0e579d29efc0b4273fff4b41dd1df350a64
4
- data.tar.gz: 11d8a83f95a7fce11598df98d1b7175c26b00f8a0d19d6af18ebaa35b8ddfa0b
3
+ metadata.gz: bc42cbe218faf0128cc6e5c4f35c1b5eb2726dc0f1fcdf28cf5815593b34f5dd
4
+ data.tar.gz: df7b2bafa9b1981727109d9eed23041c32e010df7e6a578f90594727606d45be
5
5
  SHA512:
6
- metadata.gz: f98ab9a494119599b383cc41bc9fdb797f68e793f626b07759899fee06ded282b6b8fe4f98d8ab82425127c64f4daac2511b8645f61458625e8356c8a428efe0
7
- data.tar.gz: 6002ff50f083a330ad2fcdb582df9e12d9aea31d26e1d7f737dcd20650c0fa7454e2eb43a7f88c84e47bcdb5f9965557433d97acfca13b0afa854032c4de28fa
6
+ metadata.gz: 3d0fc47f2c3d94877fc3c79480e674b2c57a585623c0ed9d6fecb8d72cb3b3770062304055c794ccb012e34c00aef2a9bd9f7941ff8031198fd73eaaa9949a4c
7
+ data.tar.gz: 071f5e82664f7915b95f1be643da9dd10b89c81830d71a41d31bc302e4e156482ab38595c69ca9f0d53632987024a91a715423ec54eb2c4bbb3fc407893c98eb
data/.yardopts ADDED
@@ -0,0 +1,5 @@
1
+ --no-private
2
+ --markup=markdown
3
+ --readme=README.md
4
+ --title='cool_id api documentation'
5
+ 'lib/**/*.rb' - '*.md' LICENSE
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # cool id
2
2
 
3
- gem for rails apps to generates string ids with a prefix, followed by a [nanoid](https://zelark.github.io/nano-id-cc/). similar to the ids you see in stripe's api. also able to lookup any record by id, similar to rails' globalid.
3
+ gem for rails apps to generate string ids with a prefix, followed by a [nanoid](https://zelark.github.io/nano-id-cc/). similar to the ids you see in stripe's api. also able to lookup any record by id, similar to rails' globalid. there's an [introductory blog post](https://schpet.com/note/cool-id) explaining why i made this.
4
+
5
+ ## usage
6
+
7
+ ### basic id generation
4
8
 
5
9
  ```ruby
6
10
  class User < ActiveRecord::Base
@@ -12,48 +16,33 @@ User.create!(name: "...").id
12
16
  # => "usr_vktd1b5v84lr"
13
17
  ```
14
18
 
15
- lookup any record by its id
19
+ ### locate records
16
20
 
17
21
  ```ruby
18
22
  CoolId.locate("usr_vktd1b5v84lr")
19
23
  # => #<User id: "usr_vktd1b5v84lr", name: "John Doe">
20
24
  ```
21
25
 
22
- and parse ids
26
+ ### generate ids
23
27
 
24
- ```ruby
25
- parsed = CoolId.parse("usr_vktd1b5v84lr")
26
- # => #<struct CoolId::Id key="vktd1b5v84lr", prefix="usr", id="usr_vktd1b5v84lr", model_class=User>
27
-
28
- parsed.model_class
29
- # => User
30
- ```
31
-
32
- and generate ids without creating a record
28
+ e.g. for batch inserts or upserts
33
29
 
34
30
  ```ruby
35
- # generate an id, e.g. for batch inserts or upserts
36
31
  User.generate_cool_id
37
32
  # => "usr_vktd1b5v84lr"
38
33
  ```
39
34
 
40
- you can use cool_id with a separate field, keeping the default primary key:
35
+ ### parsing ids
41
36
 
42
37
  ```ruby
43
- class Product < ActiveRecord::Base
44
- include CoolId::Model
45
- cool_id prefix: "prd", id_field: :public_id
46
- end
47
-
48
- product = Product.create!(name: "Cool Product")
49
- product.id # => 1 (or another integer)
50
- product.public_id # => "prd_vktd1b5v84lr"
38
+ parsed = CoolId.parse("usr_vktd1b5v84lr")
39
+ # => #<struct CoolId::Id key="vktd1b5v84lr", prefix="usr", id="usr_vktd1b5v84lr", model_class=User>
51
40
 
52
- # You can still use CoolId.locate with the public_id
53
- CoolId.locate("prd_vktd1b5v84lr") # => #<Product id: 1, public_id: "prd_vktd1b5v84lr", name: "Cool Product">
41
+ parsed.model_class
42
+ # => User
54
43
  ```
55
44
 
56
- this approach allows you to keep your primary key as an auto-incrementing integer while still benefiting from CoolId's functionality. it's particularly useful when you want to expose a public identifier that's separate from your internal primary key.
45
+ ### configuration options
57
46
 
58
47
  it takes parameters to change the alphabet or length
59
48
 
@@ -77,6 +66,27 @@ CoolId.configure do |config|
77
66
  end
78
67
  ```
79
68
 
69
+ #### using a different id field
70
+
71
+ you can use cool_id with a separate field, keeping the default primary key:
72
+
73
+ ```ruby
74
+ class Product < ActiveRecord::Base
75
+ include CoolId::Model
76
+ cool_id prefix: "prd", id_field: :public_id
77
+ end
78
+
79
+ product = Product.create!(name: "Cool Product")
80
+ product.id # => 1 (or a uuid or whatever primary key you like)
81
+ product.public_id # => "prd_vktd1b5v84lr"
82
+
83
+ # locate will find this
84
+ CoolId.locate("prd_vktd1b5v84lr") # => #<Product id: 1, public_id: "prd_vktd1b5v84lr", ...>
85
+ ```
86
+
87
+ this approach allows you to avoid exposing your primary keys, read David Bryant Copeland's [Create public-facing unique keys alongside your primary keys](https://naildrivin5.com/blog/2024/08/26/create-public-facing-unique-keys-alongside-your-primary-keys.html) to learn why you might want to do this. it also allows you to adopt cool_id more easily in a project that already has some data.
88
+
89
+
80
90
  ## installation
81
91
 
82
92
  add cool_id to your Gemfile:
@@ -89,6 +99,13 @@ bundle add cool_id
89
99
  gem "cool_id"
90
100
  ```
91
101
 
102
+ don't want to deal with a dependency? copy it into your project:
103
+
104
+ ```
105
+ mkdir -p app/lib
106
+ curl https://raw.githubusercontent.com/schpet/cool_id/main/lib/cool_id.rb -o app/lib/cool_id.rb
107
+ ```
108
+
92
109
  ### adding cool_id to a single model
93
110
 
94
111
  use string ids when creating a table
@@ -108,6 +125,8 @@ class User < ActiveRecord::Base
108
125
  end
109
126
  ```
110
127
 
128
+ note: if you prefer more traditional primary keys (like bigints or uuids) you can use the `id_field` on a different column.
129
+
111
130
  ### using cool_id on all models
112
131
 
113
132
  you have drank the coolaid. setup rails to use string ids on all new generated migrations
@@ -134,7 +153,6 @@ end
134
153
 
135
154
  if you use the graphql ruby node interface, you can implement [object identification](https://graphql-ruby.org/schema/object_identification)
136
155
 
137
-
138
156
  ```ruby
139
157
  # app/graphql/app_schema.rb
140
158
  class AppSchema < GraphQL::Schema
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CoolId
4
- VERSION = "0.1.9"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/cool_id.rb CHANGED
@@ -1,29 +1,59 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "cool_id/version"
4
- require "nanoid"
4
+ require "securerandom"
5
5
  require "active_support/concern"
6
6
 
7
+ # The CoolId module provides functionality for generating and managing unique identifiers.
7
8
  module CoolId
9
+ # Error raised when CoolId is not configured for a model.
8
10
  class NotConfiguredError < StandardError; end
9
11
 
12
+ # Error raised when the maximum number of retries is exceeded while generating a unique ID.
10
13
  class MaxRetriesExceededError < StandardError; end
11
14
 
12
- # defaults based on https://planetscale.com/blog/why-we-chose-nanoids-for-planetscales-api
15
+ # Default separator used in generated IDs.
13
16
  DEFAULT_SEPARATOR = "_"
17
+
18
+ # Default alphabet used for generating IDs.
14
19
  DEFAULT_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz"
20
+
21
+ # Default length of the generated ID (excluding prefix and separator).
15
22
  DEFAULT_LENGTH = 12
23
+
24
+ # Default maximum number of retries when generating a unique ID.
16
25
  DEFAULT_MAX_RETRIES = 1000
17
26
 
27
+ # Struct representing a parsed CoolId.
28
+ # @attr [String] key The unique part of the ID (excluding prefix and separator).
29
+ # @attr [String] prefix The prefix of the ID.
30
+ # @attr [String] id The full ID (prefix + separator + key).
31
+ # @attr [Class] model_class The ActiveRecord model class associated with this ID.
32
+ # @attr [Symbol] id_field The field in the model used to store the ID.
18
33
  Id = Struct.new(:key, :prefix, :id, :model_class, :id_field)
19
34
 
20
35
  class << self
36
+ # @!attribute [rw] separator
37
+ # @return [String] The separator used in generated IDs.
38
+ # @!attribute [rw] alphabet
39
+ # @return [String] The alphabet used for generating IDs.
40
+ # @!attribute [rw] length
41
+ # @return [Integer] The length of the generated ID (excluding prefix and separator).
42
+ # @!attribute [rw] max_retries
43
+ # @return [Integer] The maximum number of retries when generating a unique ID.
44
+ # @!attribute [rw] id_field
45
+ # @return [Symbol, nil] The default field to use for storing the ID in models.
21
46
  attr_accessor :separator, :alphabet, :length, :max_retries, :id_field
22
47
 
48
+ # Configures the CoolId module.
49
+ # @yield [self] Gives itself to the block.
50
+ # @return [void]
23
51
  def configure
24
52
  yield self
25
53
  end
26
54
 
55
+ # Resets the configuration to default values.
56
+ # @return [void]
27
57
  def reset_configuration
28
58
  self.separator = DEFAULT_SEPARATOR
29
59
  self.alphabet = DEFAULT_ALPHABET
@@ -32,10 +62,15 @@ module CoolId
32
62
  self.id_field = nil
33
63
  end
34
64
 
65
+ # @return [Registry] The default registry that keeps track of which prefixes are associated with which model classes.
35
66
  def registry
36
67
  @prefix_map ||= Registry.new
37
68
  end
38
69
 
70
+ # Generates a unique ID based on the given configuration.
71
+ # @param config [Config] The configuration for ID generation.
72
+ # @return [String] A unique ID.
73
+ # @raise [MaxRetriesExceededError] If unable to generate a unique ID within the maximum number of retries.
39
74
  def generate_id(config)
40
75
  alphabet = config.alphabet || @alphabet
41
76
  length = config.length || @length
@@ -43,7 +78,7 @@ module CoolId
43
78
 
44
79
  retries = 0
45
80
  loop do
46
- nano_id = Nanoid.generate(size: length, alphabet: alphabet)
81
+ nano_id = SecureRandom.alphanumeric(length, chars: alphabet.chars)
47
82
  full_id = "#{config.prefix}#{separator}#{nano_id}"
48
83
  if !config.model_class.exists?(id: full_id)
49
84
  return full_id
@@ -56,6 +91,9 @@ module CoolId
56
91
  end
57
92
  end
58
93
 
94
+ # Resolves the field (column) to use for storing the CoolId in a model.
95
+ # @param model_class [Class] The ActiveRecord model class.
96
+ # @return [Symbol] The field to use for storing the CoolId.
59
97
  def resolve_cool_id_field(model_class)
60
98
  model_class.cool_id_config&.id_field || CoolId.id_field || model_class.primary_key
61
99
  end
@@ -66,15 +104,23 @@ module CoolId
66
104
  self.length = DEFAULT_LENGTH
67
105
  self.max_retries = DEFAULT_MAX_RETRIES
68
106
 
107
+ # Registry for managing prefixes and model classes.
69
108
  class Registry
70
109
  def initialize
71
110
  @prefix_map = {}
72
111
  end
73
112
 
113
+ # Registers a prefix with a model class.
114
+ # @param prefix [String] The prefix to register.
115
+ # @param model_class [Class] The ActiveRecord model class to associate with the prefix.
116
+ # @return [void]
74
117
  def register(prefix, model_class)
75
118
  @prefix_map[prefix] = model_class
76
119
  end
77
120
 
121
+ # Locates a record by its CoolId.
122
+ # @param id [String] The CoolId to look up.
123
+ # @return [ActiveRecord::Base, nil] The found record, or nil if not found.
78
124
  def locate(id)
79
125
  parsed = parse(id)
80
126
  return nil unless parsed
@@ -83,6 +129,9 @@ module CoolId
83
129
  parsed.model_class.find_by(id_field => id)
84
130
  end
85
131
 
132
+ # Parses a CoolId into its components.
133
+ # @param id [String] The CoolId to parse.
134
+ # @return [Id, nil] The parsed Id object, or nil if parsing fails.
86
135
  def parse(id)
87
136
  prefix, key = id.split(CoolId.separator, 2)
88
137
  model_class = @prefix_map[prefix]
@@ -92,12 +141,36 @@ module CoolId
92
141
  end
93
142
  end
94
143
 
144
+ # Configuration class for CoolId generation.
95
145
  class Config
96
- attr_reader :prefix, :length, :alphabet, :max_retries, :model_class, :id_field
146
+ # @return [String] The prefix for generated IDs.
147
+ attr_reader :prefix
148
+
149
+ # @return [Integer, nil] The length of the generated ID (excluding prefix and separator).
150
+ attr_reader :length
151
+
152
+ # @return [String, nil] The alphabet to use for generating IDs.
153
+ attr_reader :alphabet
97
154
 
155
+ # @return [Integer, nil] The maximum number of retries when generating a unique ID.
156
+ attr_reader :max_retries
157
+
158
+ # @return [Class] The ActiveRecord model class associated with this configuration.
159
+ attr_reader :model_class
160
+
161
+ # @return [Symbol, nil] The field to use for storing the ID in the model.
162
+ attr_reader :id_field
163
+
164
+ # Initializes a new Config instance.
165
+ # @param prefix [String] The prefix for generated IDs.
166
+ # @param model_class [Class] The ActiveRecord model class.
167
+ # @param length [Integer, nil] The length of the generated ID (excluding prefix and separator).
168
+ # @param alphabet [String, nil] The alphabet to use for generating IDs.
169
+ # @param max_retries [Integer, nil] The maximum number of retries when generating a unique ID.
170
+ # @param id_field [Symbol, nil] The field to use for storing the ID in the model.
98
171
  def initialize(prefix:, model_class:, length: nil, alphabet: nil, max_retries: nil, id_field: nil)
99
- @length = length
100
172
  @prefix = validate_prefix(prefix)
173
+ @length = length
101
174
  @alphabet = validate_alphabet(alphabet)
102
175
  @max_retries = max_retries
103
176
  @model_class = model_class
@@ -106,12 +179,20 @@ module CoolId
106
179
 
107
180
  private
108
181
 
182
+ # Validates the prefix.
183
+ # @param value [String] The prefix to validate.
184
+ # @return [String] The validated prefix.
185
+ # @raise [ArgumentError] If the prefix is nil or empty.
109
186
  def validate_prefix(value)
110
187
  raise ArgumentError, "Prefix cannot be nil" if value.nil?
111
188
  raise ArgumentError, "Prefix cannot be empty" if value.empty?
112
189
  value
113
190
  end
114
191
 
192
+ # Validates the alphabet.
193
+ # @param value [String, nil] The alphabet to validate.
194
+ # @return [String, nil] The validated alphabet.
195
+ # @raise [ArgumentError] If the alphabet includes the separator.
115
196
  def validate_alphabet(value)
116
197
  return nil if value.nil?
117
198
  raise ArgumentError, "Alphabet cannot include the separator '#{CoolId.separator}'" if value.include?(CoolId.separator)
@@ -119,30 +200,52 @@ module CoolId
119
200
  end
120
201
  end
121
202
 
203
+ # Module to be included in ActiveRecord models for CoolId functionality.
122
204
  module Model
123
205
  extend ActiveSupport::Concern
124
206
 
125
207
  class_methods do
208
+ # @!attribute [rw] cool_id_config
209
+ # @return [Config] The CoolId configuration for this model.
210
+ # @!attribute [rw] cool_id_setup_required
211
+ # @return [Boolean] Whether CoolId setup is required for this model.
126
212
  attr_accessor :cool_id_config
127
213
  attr_accessor :cool_id_setup_required
128
214
 
215
+ # Configures CoolId for this model.
216
+ # @param options [Hash] Options for configuring CoolId.
217
+ # @option options [String] :prefix The prefix for generated IDs.
218
+ # @option options [Integer] :length The length of the generated ID (excluding prefix and separator).
219
+ # @option options [String] :alphabet The alphabet to use for generating IDs.
220
+ # @option options [Integer] :max_retries The maximum number of retries when generating a unique ID.
221
+ # @option options [Symbol] :id_field The field to use for storing the ID in the model.
222
+ # @return [void]
129
223
  def cool_id(options)
130
224
  @cool_id_config = Config.new(**options, model_class: self)
131
225
  CoolId.registry.register(options[:prefix], self)
132
226
  end
133
227
 
228
+ # Generates a new CoolId for this model.
229
+ # @return [String] A new CoolId.
134
230
  def generate_cool_id
135
231
  CoolId.generate_id(@cool_id_config)
136
232
  end
137
233
 
234
+ # Enforces CoolId setup for all descendants of this model.
235
+ # @return [void]
138
236
  def enforce_cool_id_for_descendants
139
237
  @cool_id_setup_required = true
140
238
  end
141
239
 
240
+ # Skips enforcing CoolId setup for this model.
241
+ # @return [void]
142
242
  def skip_enforce_cool_id
143
243
  @cool_id_setup_required = false
144
244
  end
145
245
 
246
+ # Inherits CoolId setup requirements to subclasses.
247
+ # @param subclass [Class] The subclass inheriting from this model.
248
+ # @return [void]
146
249
  def inherited(subclass)
147
250
  super
148
251
  if @cool_id_setup_required && !subclass.instance_variable_defined?(:@cool_id_setup_required)
@@ -157,11 +260,16 @@ module CoolId
157
260
 
158
261
  private
159
262
 
263
+ # Sets the CoolId for the model instance before creation.
264
+ # @return [void]
160
265
  def set_cool_id
161
266
  id_field = CoolId.resolve_cool_id_field(self.class)
162
267
  self[id_field] = self.class.generate_cool_id if self[id_field].blank?
163
268
  end
164
269
 
270
+ # Ensures that CoolId is configured for the model.
271
+ # @raise [NotConfiguredError] If CoolId is not configured and setup is required.
272
+ # @return [void]
165
273
  def ensure_cool_id_configured
166
274
  if self.class.cool_id_setup_required && self.class.cool_id_config.nil?
167
275
  suggested_prefix = self.class.name.downcase[0..2]
@@ -171,10 +279,16 @@ module CoolId
171
279
  end
172
280
  end
173
281
 
282
+ # Locates a record by its CoolId.
283
+ # @param id [String] The CoolId to look up.
284
+ # @return [ActiveRecord::Base, nil] The found record, or nil if not found.
174
285
  def self.locate(id)
175
286
  registry.locate(id)
176
287
  end
177
288
 
289
+ # Parses a CoolId into its components.
290
+ # @param id [String] The CoolId to parse.
291
+ # @return [Id, nil] The parsed Id object, or nil if parsing fails.
178
292
  def self.parse(id)
179
293
  registry.parse(id)
180
294
  end
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cool_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Schilling
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-26 00:00:00.000000000 Z
11
+ date: 2025-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: nanoid
14
+ name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '6.0'
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: '2.0'
26
+ version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: activerecord
28
+ name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,19 +39,75 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '6.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: activesupport
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '13.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '13.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: standard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.9.28
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.9.28
97
+ - !ruby/object:Gem::Dependency
98
+ name: webrick
43
99
  requirement: !ruby/object:Gem::Requirement
44
100
  requirements:
45
101
  - - ">="
46
102
  - !ruby/object:Gem::Version
47
- version: '6.0'
48
- type: :runtime
103
+ version: '0'
104
+ type: :development
49
105
  prerelease: false
50
106
  version_requirements: !ruby/object:Gem::Requirement
51
107
  requirements:
52
108
  - - ">="
53
109
  - !ruby/object:Gem::Version
54
- version: '6.0'
110
+ version: '0'
55
111
  - !ruby/object:Gem::Dependency
56
112
  name: sqlite3
57
113
  requirement: !ruby/object:Gem::Requirement
@@ -66,30 +122,27 @@ dependencies:
66
122
  - - "~>"
67
123
  - !ruby/object:Gem::Version
68
124
  version: '1.4'
69
- description: generates primary keys using prefixed nanoids for ActiveRecord models
125
+ description: CoolId generates primary keys using prefixed nanoids for ActiveRecord
126
+ models, providing unique and readable identifiers.
70
127
  email:
71
128
  - git@schpet.com
72
129
  executables: []
73
130
  extensions: []
74
131
  extra_rdoc_files: []
75
132
  files:
76
- - ".aider.conf.yml"
77
- - ".rspec"
78
- - ".standard.yml"
133
+ - ".yardopts"
79
134
  - CHANGELOG.md
80
135
  - LICENSE
81
136
  - README.md
82
- - Rakefile
83
137
  - lib/cool_id.rb
84
138
  - lib/cool_id/version.rb
85
- - sig/cool_id.rbs
86
139
  homepage: https://github.com/schpet/cool_id
87
140
  licenses:
88
141
  - ISC
89
142
  metadata:
90
143
  homepage_uri: https://github.com/schpet/cool_id
91
144
  source_code_uri: https://github.com/schpet/cool_id
92
- changelog_uri: https://github.com/schpet/cool_id/tree/main/CHANGELOG.md
145
+ changelog_uri: https://github.com/schpet/cool_id/blob/main/CHANGELOG.md
93
146
  post_install_message:
94
147
  rdoc_options: []
95
148
  require_paths:
@@ -98,15 +151,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
151
  requirements:
99
152
  - - ">="
100
153
  - !ruby/object:Gem::Version
101
- version: 3.0.0
154
+ version: 3.1.0
102
155
  required_rubygems_version: !ruby/object:Gem::Requirement
103
156
  requirements:
104
157
  - - ">="
105
158
  - !ruby/object:Gem::Version
106
159
  version: '0'
107
160
  requirements: []
108
- rubygems_version: 3.5.11
161
+ rubygems_version: 3.5.22
109
162
  signing_key:
110
163
  specification_version: 4
111
- summary: generates cool ids
164
+ summary: Generates cool ids for ActiveRecord models
112
165
  test_files: []
data/.aider.conf.yml DELETED
@@ -1,9 +0,0 @@
1
- # https://aider.chat/docs/config/aider_conf.html
2
-
3
- lint-cmd: bundle exec standardrb --fix
4
- auto-lint: true
5
-
6
- test-cmd: bundle exec rspec --format progress --no-profile --no-color --fail-fast
7
- auto-test: true
8
-
9
- read: cool_id.gemspec
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.standard.yml DELETED
@@ -1,3 +0,0 @@
1
- # For available configuration options, see:
2
- # https://github.com/standardrb/standard
3
- ruby_version: 3.0
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- require "standard/rake"
9
-
10
- task default: %i[spec standard]
data/sig/cool_id.rbs DELETED
@@ -1,4 +0,0 @@
1
- module CoolId
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end