sqlite_crypto 2.0.0 → 2.0.1

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: 628653b7be79d3206b90f05b059a29c2d38912101019bd70355804859e4f9c0a
4
- data.tar.gz: dfd43d1ec8f3b34e1326923ca3da3e3137c9f78a3ebe54916726753e47d7e1fc
3
+ metadata.gz: f7728bff2a398f6ed1fe0ce0888055586b7619d45954728240ef32ba33cd1650
4
+ data.tar.gz: fb5715411594706283fd93969b4f97709f468870f428105c1cb5ebdefb8d5c56
5
5
  SHA512:
6
- metadata.gz: 17bdceabe86c7d75a54013a330f9dde6017bb80373e70242831d7fed8880ad7a5c46196fbbf0c9d5b54443a839d359dd1a7fbac690e099e29c13f49e7c2fa548
7
- data.tar.gz: 8c67565b5f8644e6d42d1a15e3347ad40006e8c2631222d9d3878697647e4e1c0f7e91f05905528941da569629c1dd0be39eaf3484702b2ae0871fdd93c07f1a
6
+ metadata.gz: 7d0efcd9f607384d1e33ee2c55643408cae5d4a0382885dee40ef6bc0dc142f62d4085cc85f529fd2e76694ffc624651aa7802f85bc0de789716a0b3d7c1aa27
7
+ data.tar.gz: 9954abb7f5068e1b85f9e636ce1abe0d921baa94b9b7394711745bba9bf349655611dcbd925b6ba0fe1c4d1405f2ae434bf863c7234ed864de17b5748b3efadd
data/CHANGELOG.md CHANGED
@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.0.1] - 2026-01-14
9
+
10
+ ### Security
11
+ - **CRITICAL:**
12
+ - Fixed regex anchor vulnerability in UUID/ULID validators
13
+ - Fixed action_text-trix XSS vulnerability by updating the version to '>= 2.1.16'
14
+
15
+ ### Changed
16
+ - **Eager configuration validation**: Setting `uuid_version = :v7` on Ruby < 3.3 now fails at boot time with clear error message instead of runtime failure
17
+ - **Namespace cleanup**: `uuid` and `ulid` schema helpers now scoped to `ActiveRecord::Schema` instead of global `Object`
18
+ - **Performance**: Cached Ruby version check in `V7_AVAILABLE` constant (eliminates repeated `Gem::Version` comparisons)
19
+ - **Boot time**: Added lazy loading with `ActiveSupport.on_load(:active_record)` hook for faster Rails initialization
20
+ - **Migration performance**: Memoized primary key type detection to avoid redundant database queries
21
+
22
+ ### Removed
23
+ - Unused `SqliteCrypto::Error` class
24
+ - Unused `SqliteCrypto.load_extensions` placeholder method
25
+
26
+ ### Internal
27
+ - Simplified configuration defaults to reuse `Generators::Uuid.v7_available?` logic
28
+ - Improved code organization and removed dead code
29
+
8
30
  ## [2.0.0] - 2026-01-08
9
31
 
10
32
  ### Added
data/README.md CHANGED
@@ -4,88 +4,80 @@
4
4
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.txt)
5
5
  [![types supported](https://img.shields.io/badge/types-ULID,_UUIDv7/v4-brightgreen.svg)](https://github.com/bart-oz/sqlite_crypto)
6
6
  [![Tests](https://img.shields.io/badge/tests-passing-brightgreen.svg)](https://github.com/bart-oz/sqlite_crypto/actions)
7
- [![Coverage](https://img.shields.io/badge/coverage-98.59%25-brightgreen.svg)](https://github.com/bart-oz/sqlite_crypto/actions)
7
+ [![Coverage](https://img.shields.io/badge/coverage-98.06%25-brightgreen.svg)](https://github.com/bart-oz/sqlite_crypto/actions)
8
8
  [![Status](https://img.shields.io/badge/status-active-success.svg)](https://github.com/bart-oz/sqlite_crypto)
9
9
 
10
- **Drop-in UUID and ULID primary keys for Rails + SQLite3**
10
+ ## Overview
11
+
12
+ Seamless UUID and ULID primary key support for Rails applications using SQLite3. Handles type registration, validation, foreign key detection, and schema generation automatically.
11
13
 
12
14
  ```ruby
13
- # Just use :uuid or :ulid instead of default integer IDs
14
15
  create_table :users, id: :uuid do |t|
15
16
  t.string :email
17
+ t.timestamps
16
18
  end
17
19
  ```
18
20
 
19
- ## What You Get
21
+ **Key capabilities:**
22
+ - UUID primary keys (v4 random or v7 time-ordered)
23
+ - ULID primary keys (time-sortable, compact)
24
+ - Automatic foreign key type detection
25
+ - Model-level ID generation
26
+ - Clean schema.rb output
27
+ - Zero external dependencies
20
28
 
21
- **UUID primary keys** (v4 random or v7 time-sortable)<br/>
22
- ✅ **ULID primary keys** (time-sortable, 26 characters)<br/>
23
- ✅ **Automatic foreign key detection** - `t.references` just works<br/>
24
- ✅ **Model generators** - `generates_uuid :token`<br/>
25
- ✅ **Clean schema.rb** - No verbose type definitions<br/>
26
- ✅ **Zero dependencies** - Uses Ruby's built-in SecureRandom<br/>
29
+ ## Compatibility
27
30
 
28
- ## Quick Start
31
+ **Ruby & Rails:**
29
32
 
30
- ```bash
31
- bundle add sqlite_crypto
32
- rails generate sqlite_crypto:install
33
- ```
33
+ | | Rails 7.1 | Rails 7.2 | Rails 8.0 | Rails 8.1 |
34
+ |-------|-----------|-----------|-----------|-----------|
35
+ | Ruby 3.1 | ✓ | ✓ | - | - |
36
+ | Ruby 3.2 | ✓ | ✓ | ✓ | ✓ |
37
+ | Ruby 3.3 | ✓ | ✓ | ✓ | ✓ |
38
+ | Ruby 3.4 | ✓ | ✓ | ✓ | ✓ |
39
+ | Ruby 4.0 | ✓ | ✓ | ✓ | ✓ |
34
40
 
35
- ## ID Type Comparison
41
+ **UUID Versions:**
36
42
 
37
- | Type | Format | Performance | Use Case |
38
- |------|--------|-------------|----------|
39
- | **Integer** | `1, 2, 3...` | Baseline | Simple apps, no distribution |
40
- | **UUIDv7** | `018d3f91-...` (36 chars) | ~1-3% slower inserts | **Recommended** - Time-sortable + fast |
41
- | **UUIDv4** | `550e8400-e29b-...` (36 chars) | ~2-5% slower inserts | Random IDs, legacy compatibility |
42
- | **ULID** | `01ARZ3NDEK...` (26 chars) | ~3-7% slower inserts | Time-sortable, compact format |
43
+ | Version | Ruby 3.1/3.2 | Ruby 3.3+ |
44
+ |---------|--------------|-----------|
45
+ | v4 (random) | | |
46
+ | v7 (time-ordered) | - | |
43
47
 
44
- ### Why UUIDv7 is Recommended
48
+ **Database:** SQLite3
45
49
 
46
- UUIDv7 embeds a timestamp in the first 48 bits, making IDs naturally sortable by creation time:
50
+ ## Installation
47
51
 
48
- ```
49
- UUIDv7: 018d3f91-8f4a-7000-9e7b-4a5c8d2e1f3a ← Time-based (inserts cluster at end)
50
- UUIDv4: 6ba7b810-9dad-11d1-80b4-00c04fd430c8 ← Random (causes index fragmentation)
52
+ ```ruby
53
+ # Gemfile
54
+ gem "sqlite_crypto"
51
55
  ```
52
56
 
53
- **Performance Impact:**
54
- - New records insert at the **end of B-tree index** (not random positions)
55
- - Reduces page splits and fragmentation
56
- - ~40% faster index writes vs UUIDv4 at scale (10k+ records)
57
+ ```bash
58
+ bundle install
59
+ rails generate sqlite_crypto:install
60
+ ```
57
61
 
58
- **Requirements:** Ruby 3.3+ (falls back to v4 on older versions)
62
+ The generator creates `config/initializers/sqlite_crypto.rb` for configuration.
59
63
 
60
64
  ## Configuration
61
65
 
62
- ### Choose UUID Version (v4 or v7)
63
-
64
- After running `rails generate sqlite_crypto:install`:
66
+ **1. Configure UUID Version**
65
67
 
66
68
  ```ruby
67
69
  # config/initializers/sqlite_crypto.rb
68
70
  SqliteCrypto.configure do |config|
69
- config.uuid_version = :v7 # Recommended (requires Ruby 3.3+)
70
- # config.uuid_version = :v4 # Use this for Ruby 3.1/3.2
71
+ config.uuid_version = :v7 # or :v4
71
72
  end
72
73
  ```
73
74
 
74
- **Ruby Version Support:**
75
- - Ruby 3.3+ → v4 and v7
76
- - Ruby 3.1/3.2 → v4 only
75
+ The gem automatically selects a default based on your Ruby version (v7 for Ruby 3.3+, v4 otherwise).
77
76
 
78
- Check programmatically:
79
- ```ruby
80
- SqliteCrypto::Generators::Uuid.v7_available? # => true/false
81
- ```
82
-
83
- ## Usage Examples
84
-
85
- ### UUID Primary Keys
77
+ **2. Create Tables with UUID/ULID**
86
78
 
87
79
  ```ruby
88
- class CreateUsers < ActiveRecord::Migration[8.1]
80
+ class CreateUsers < ActiveRecord::Migration[8.0]
89
81
  def change
90
82
  create_table :users, id: :uuid do |t|
91
83
  t.string :email
@@ -95,106 +87,96 @@ class CreateUsers < ActiveRecord::Migration[8.1]
95
87
  end
96
88
  ```
97
89
 
98
- Result:
99
- ```ruby
100
- user = User.create!(email: "alice@example.com")
101
- user.id # => "018d3f91-8f4a-7000-9e7b-4a5c8d2e1f3a" (UUIDv7)
102
- ```
103
-
104
- ### ULID Primary Keys
90
+ **3. Use Your Models**
105
91
 
106
92
  ```ruby
107
- class CreatePosts < ActiveRecord::Migration[8.1]
108
- def change
109
- create_table :posts, id: :ulid do |t|
110
- t.string :title
111
- t.timestamps
112
- end
113
- end
114
- end
93
+ user = User.create!(email: "test@example.com")
94
+ user.id # => "018d3f91-8f4a-7000-9e7b-4a5c8d2e1f3a"
115
95
  ```
116
96
 
117
- Result:
118
- ```ruby
119
- post = Post.create!(title: "Hello World")
120
- post.id # => "01ARZ3NDEKTSV4RRFFQ69G5FAV" (26 chars, time-sortable)
121
- ```
97
+ ## Usage
122
98
 
123
- ### Automatic Foreign Keys
99
+ **Primary Keys**
124
100
 
125
- The gem **automatically detects** parent table ID types:
101
+ Create tables with UUID or ULID primary keys:
126
102
 
127
103
  ```ruby
128
- # Users have UUID primary keys
104
+ # UUID
129
105
  create_table :users, id: :uuid do |t|
130
- t.string :name
106
+ t.string :email
131
107
  end
132
108
 
133
- # Posts automatically get varchar(36) foreign keys
134
- create_table :posts do |t|
135
- t.references :user # Auto-detected as varchar(36)!
109
+ # ULID
110
+ create_table :posts, id: :ulid do |t|
136
111
  t.string :title
137
112
  end
138
113
  ```
139
114
 
140
- Works with ULID too:
115
+ **Foreign Keys**
116
+
117
+ Foreign key types are automatically detected from parent tables:
118
+
141
119
  ```ruby
142
- create_table :categories, id: :ulid do |t|
120
+ create_table :users, id: :uuid do |t|
143
121
  t.string :name
144
122
  end
145
123
 
146
- create_table :articles do |t|
147
- t.references :category # Auto-detected as varchar(26)!
124
+ create_table :posts do |t|
125
+ t.references :user # Automatically varchar(36)
126
+ t.string :title
148
127
  end
149
128
  ```
150
129
 
151
- ### Generate UUIDs/ULIDs for Any Column
130
+ **Model-Level Generation**
131
+
132
+ Generate UUIDs or ULIDs for any column:
152
133
 
153
134
  ```ruby
154
135
  class User < ApplicationRecord
155
- generates_uuid :token # Auto-generate on create
156
- generates_ulid :reference, unique: true # With uniqueness validation
136
+ generates_uuid :api_token
137
+ generates_ulid :tracking_id, unique: true
157
138
  end
158
139
 
159
- user = User.create!(email: "test@example.com")
160
- user.token # => "018d3f91-..." (auto-generated)
161
- user.reference # => "01ARZ3NDEK..." (auto-generated + validated)
140
+ user = User.create!
141
+ user.api_token # => "550e8400-e29b-41d4-a716-446655440000"
142
+ user.tracking_id # => "01ARZ3NDEKTSV4RRFFQ69G5FAV"
162
143
  ```
163
144
 
164
- ## Requirements
145
+ ## ID Types
165
146
 
166
- - **Ruby**: 3.1+ (3.3+ for UUIDv7)
167
- - **Rails**: 7.1, 7.2, 8.0, 8.1
168
- - **Database**: SQLite3
147
+ **Characteristics**
169
148
 
170
- ## Performance Benchmarks
149
+ | Type | Length | Format | Ordering | Ruby Version |
150
+ |------|--------|--------|----------|--------------|
151
+ | Integer | 8 bytes | Sequential numbers | Sequential | Any |
152
+ | UUIDv4 | 36 chars | `xxxxxxxx-xxxx-4xxx-...` | Random | 3.1+ |
153
+ | UUIDv7 | 36 chars | `xxxxxxxx-xxxx-7xxx-...` | Time-based | 3.3+ |
154
+ | ULID | 26 chars | `01ARZ3NDEK...` | Time-based | 3.1+ |
171
155
 
172
- Run your own benchmarks: `bundle exec rspec --tag performance`
156
+ **Performance**
173
157
 
174
- **Typical results (M1 Mac, SQLite3, 10k records):**
158
+ Benchmarks with 10,000 records on SQLite3:
175
159
 
176
- | Operation | Integer (baseline) | UUIDv4 | UUIDv7 | ULID |
177
- |-----------|-------------------|--------|--------|------|
178
- | Insert (10k) | 1.00x | 1.02x | 1.01x | 1.05x |
179
- | Query by ID | 1.00x | 1.03x | 1.03x | 1.04x |
180
- | Index size | 100% | 145% | 145% | 130% |
160
+ | Type | Insert | Query | Index Size |
161
+ |------|--------|-------|------------|
162
+ | Integer | 1.00x | 1.00x | 100% |
163
+ | UUIDv4 | 1.02x | 1.03x | 145% |
164
+ | UUIDv7 | 1.01x | 1.03x | 145% |
165
+ | ULID | 1.05x | 1.04x | 130% |
181
166
 
182
- **Key takeaway:** UUIDv7 has nearly identical performance to v4, with better write scaling.
183
- ## Advanced Usage
167
+ Run your own: `bundle exec rspec --tag performance`
184
168
 
185
- ### Custom Table Names
169
+ ## Advanced Usage
186
170
 
187
- Use `:to_table` for non-standard associations:
171
+ **Non-Standard Table Names**
188
172
 
189
173
  ```ruby
190
174
  create_table :posts do |t|
191
- t.references :author, to_table: :users # Uses users table's ID type
175
+ t.references :author, to_table: :users
192
176
  end
193
177
  ```
194
178
 
195
- ### Mixing ID Types
196
-
197
- Different tables can use different ID types:
179
+ **Mixed ID Types**
198
180
 
199
181
  ```ruby
200
182
  create_table :users, id: :uuid do |t|
@@ -202,65 +184,38 @@ create_table :users, id: :uuid do |t|
202
184
  end
203
185
 
204
186
  create_table :sessions, id: :ulid do |t|
205
- t.references :user # Auto-detected as varchar(36)
206
- end
207
-
208
- create_table :logs do |t| # Integer ID (default)
209
- t.string :message
187
+ t.references :user
210
188
  end
211
- ```
212
-
213
- ### ID Prefixes (Stripe-style)
214
189
 
215
- ```ruby
216
- class Invoice < ApplicationRecord
217
- before_create :add_prefix
218
-
219
- private
220
- def add_prefix
221
- self.id = "inv_#{SecureRandom.uuid}" if id.nil?
222
- end
190
+ create_table :logs do |t| # Integer ID
191
+ t.text :message
223
192
  end
224
193
  ```
225
194
 
226
195
  ## Migrating Existing Apps
227
196
 
228
- Use UUID/ULID only for **new tables**:
197
+ Add UUID/ULID to new tables while keeping integer IDs on existing tables:
229
198
 
230
199
  ```ruby
231
- # Keep existing integer IDs
232
- # users: id (integer)
233
- # posts: id (integer), user_id (integer)
234
-
235
- # New tables use UUID/ULID
200
+ # Existing tables unchanged
236
201
  create_table :invoices, id: :uuid do |t|
237
- t.references :user # Still integer (auto-detected)
202
+ t.references :user # Detects integer from users table
238
203
  t.decimal :amount
239
204
  end
240
205
  ```
241
206
 
242
- ## How It Works
243
-
244
- 1. **Type Registration** - Registers `:uuid` and `:ulid` with ActiveRecord's SQLite3 adapter
245
- 2. **Validation** - UUIDs: 36-char format, ULIDs: 26-char format
246
- 3. **Migration Helpers** - `t.uuid()` and `t.ulid()` in migrations
247
- 4. **Smart References** - `t.references` detects parent table ID type
248
- 5. **Model Extensions** - `generates_uuid`/`generates_ulid` for auto-generation
249
- 6. **Schema Dumper** - Clean output: `id: :uuid` instead of verbose definitions
250
-
251
207
  ## Development
252
208
 
253
209
  ```bash
254
210
  bundle install
255
- bundle exec rspec # Run tests
256
- bundle exec standardrb # Lint
257
- bundle exec rspec --tag performance # Benchmarks
211
+ bundle exec rspec
212
+ bundle exec standardrb
258
213
  ```
259
214
 
260
215
  ## Contributing
261
216
 
262
- See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
217
+ Bug reports and pull requests are welcome on GitHub at https://github.com/bart-oz/sqlite_crypto.
263
218
 
264
219
  ## License
265
220
 
266
- MIT License - see [LICENSE.txt](LICENSE.txt)
221
+ The gem is available as open source under the terms of the [MIT License](LICENSE.txt).
@@ -2,11 +2,31 @@
2
2
 
3
3
  module SqliteCrypto
4
4
  class Configuration
5
- attr_accessor :uuid_version
5
+ attr_reader :uuid_version
6
6
 
7
7
  def initialize
8
8
  # Default to v7 on Ruby 3.3+, v4 on older versions
9
- @uuid_version = (Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.3.0")) ? :v7 : :v4
9
+ @uuid_version = Generators::Uuid.v7_available? ? :v7 : :v4
10
+ end
11
+
12
+ def uuid_version=(version)
13
+ validate_uuid_version!(version)
14
+ @uuid_version = version
15
+ end
16
+
17
+ private
18
+
19
+ def validate_uuid_version!(version)
20
+ valid_versions = [:v4, :v7]
21
+ unless valid_versions.include?(version)
22
+ raise ArgumentError, "Invalid UUID version: #{version}. Must be one of #{valid_versions.join(", ")}"
23
+ end
24
+
25
+ if version == :v7 && !Generators::Uuid.v7_available?
26
+ raise ArgumentError,
27
+ "UUIDv7 requires Ruby 3.3+. Current: #{RUBY_VERSION}. " \
28
+ "Use config.uuid_version = :v4 or upgrade Ruby."
29
+ end
10
30
  end
11
31
  end
12
32
  end
@@ -6,7 +6,7 @@ module SqliteCrypto
6
6
  module Generators
7
7
  class Uuid
8
8
  MINIMUM_RUBY_FOR_V7 = Gem::Version.new("3.3.0")
9
- CURRENT_RUBY = Gem::Version.new(RUBY_VERSION)
9
+ V7_AVAILABLE = (Gem::Version.new(RUBY_VERSION) >= MINIMUM_RUBY_FOR_V7)
10
10
 
11
11
  class << self
12
12
  def generate(version: SqliteCrypto.config.uuid_version)
@@ -21,7 +21,7 @@ module SqliteCrypto
21
21
  end
22
22
 
23
23
  def v7_available?
24
- CURRENT_RUBY >= MINIMUM_RUBY_FOR_V7
24
+ V7_AVAILABLE
25
25
  end
26
26
 
27
27
  private
@@ -32,6 +32,11 @@ module SqliteCrypto
32
32
  private
33
33
 
34
34
  def detect_primary_key_type(table_name)
35
+ @pk_type_cache ||= {}
36
+ @pk_type_cache[table_name] ||= fetch_primary_key_type(table_name)
37
+ end
38
+
39
+ def fetch_primary_key_type(table_name)
35
40
  conn = @conn || @base || (respond_to?(:connection) ? connection : nil)
36
41
  return nil unless conn&.table_exists?(table_name)
37
42
 
@@ -10,13 +10,17 @@ module SqliteCrypto
10
10
  config.sqlite_crypto = ActiveSupport::OrderedOptions.new
11
11
 
12
12
  initializer "sqlite_crypto.register_types" do
13
- ActiveRecord::Type.register(:uuid, SqliteCrypto::Type::Uuid, adapter: :sqlite3)
14
- ActiveRecord::Type.register(:ulid, SqliteCrypto::Type::ULID, adapter: :sqlite3)
13
+ ActiveSupport.on_load(:active_record) do
14
+ ActiveRecord::Type.register(:uuid, SqliteCrypto::Type::Uuid, adapter: :sqlite3)
15
+ ActiveRecord::Type.register(:ulid, SqliteCrypto::Type::ULID, adapter: :sqlite3)
16
+ end
15
17
  end
16
18
 
17
19
  initializer "sqlite_crypto.native_types" do
18
- require "active_record/connection_adapters/sqlite3_adapter"
19
- ActiveRecord::ConnectionAdapters::SQLite3Adapter.prepend(SqliteCrypto::Sqlite3AdapterExtension)
20
+ ActiveSupport.on_load(:active_record) do
21
+ require "active_record/connection_adapters/sqlite3_adapter"
22
+ ActiveRecord::ConnectionAdapters::SQLite3Adapter.prepend(SqliteCrypto::Sqlite3AdapterExtension)
23
+ end
20
24
  end
21
25
 
22
26
  initializer "sqlite_crypto.schema_dumper", after: "active_record.initialize_database" do
@@ -13,5 +13,7 @@ module SqliteCrypto
13
13
  end
14
14
  end
15
15
 
16
- # Extend the main object context for schema.rb loading
17
- Object.include(SqliteCrypto::SchemaDefinitions)
16
+ # Extend ActiveRecord::Schema context for schema.rb loading (not global Object)
17
+ if defined?(ActiveRecord::Schema)
18
+ ActiveRecord::Schema.include(SqliteCrypto::SchemaDefinitions)
19
+ end
@@ -5,6 +5,8 @@ require "sqlite_crypto/type/base"
5
5
  module SqliteCrypto
6
6
  module Type
7
7
  class ULID < Base
8
+ ULID_PATTERN = /\A[0-7][0-9A-Z]{25}\z/i
9
+
8
10
  def type
9
11
  :ulid
10
12
  end
@@ -12,7 +14,7 @@ module SqliteCrypto
12
14
  private
13
15
 
14
16
  def valid?(value)
15
- value.match?(/^[0-7][0-9A-Z]{25}$/i)
17
+ ULID_PATTERN.match?(value)
16
18
  end
17
19
  end
18
20
  end
@@ -5,6 +5,8 @@ require "sqlite_crypto/type/base"
5
5
  module SqliteCrypto
6
6
  module Type
7
7
  class Uuid < Base
8
+ UUID_PATTERN = /\A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\z/i
9
+
8
10
  def type
9
11
  :uuid
10
12
  end
@@ -12,7 +14,7 @@ module SqliteCrypto
12
14
  private
13
15
 
14
16
  def valid?(value)
15
- value.match?(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i)
17
+ UUID_PATTERN.match?(value)
16
18
  end
17
19
  end
18
20
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SqliteCrypto
4
- VERSION = "2.0.0"
4
+ VERSION = "2.0.1"
5
5
  RUBY_MINIMUM_VERSION = "3.1.0"
6
6
  RAILS_MINIMUM_VERSION = "7.1.0"
7
7
  end
data/lib/sqlite_crypto.rb CHANGED
@@ -8,8 +8,6 @@ require "sqlite_crypto/schema_definitions"
8
8
  require "sqlite_crypto/generators/uuid"
9
9
 
10
10
  module SqliteCrypto
11
- class Error < StandardError; end
12
-
13
11
  class << self
14
12
  def configuration
15
13
  @configuration ||= Configuration.new
@@ -24,8 +22,4 @@ module SqliteCrypto
24
22
  @configuration = Configuration.new
25
23
  end
26
24
  end
27
-
28
- def self.load_extensions
29
- # Placeholder for future extension loading logic
30
- end
31
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqlite_crypto
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - BartOz
@@ -51,8 +51,10 @@ dependencies:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '1.0'
54
- description: A lightweight, modular gem providing transparent UUID/ULID primary key
55
- configuration for Rails applications using SQLite.
54
+ description: UUID and ULID primary key support for Rails with SQLite3. Provides automatic
55
+ type registration, validation, foreign key detection, and clean schema generation.
56
+ Supports UUIDv4 (random), UUIDv7 (time-ordered), and ULID (compact, time-sortable)
57
+ with zero external dependencies.
56
58
  email:
57
59
  - bartek.ozdoba@gmail.com
58
60
  executables: []
@@ -98,5 +100,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
100
  requirements: []
99
101
  rubygems_version: 4.0.3
100
102
  specification_version: 4
101
- summary: Seamless UUID/ULID support for Rails 8 with SQLite
103
+ summary: UUID (v4/v7) and ULID primary keys for Rails + SQLite3
102
104
  test_files: []