ulid-rails 2.0.0 → 2.1.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: fc4f8ec7576322c1c26b53c0c488cbd268e1dded71b500c2ee6f76461a3b37f2
4
- data.tar.gz: 3c5980e176f56ccebd808abeb2cbd7dd33dc387179f3287a19dbd35f9c2cbd4b
3
+ metadata.gz: 68a14806c3289d3d6df925f84d498397db548eb23001772055ca287901de4439
4
+ data.tar.gz: c945755a7ce0accec78102f7e2f77743c7af016d9914679b42d8812be6efd315
5
5
  SHA512:
6
- metadata.gz: 5c4da8824fe1b0719da0e9a8762e1e5df9d15cb019d9a36d4732dac7ddf1423c034f90f88931b10d23a0ee1ac02b1ad31783872e622dd3e5b9ffa7a47fe87ae1
7
- data.tar.gz: 8e75e3053c04bc75b6248263439737d6a51e2dbaa16cc7954c919cda0fa3e496623fca9663818f2378f4a77bb3eb4db0ab4ac4e5a6c101b5a75f1acf1827bc43
6
+ metadata.gz: f5a91f4489c8d7c52c498e47f84abe4aaf79d2c7047d686bd84001601ce59548843e2df25e33f0926def71941d5a0139b67728b8c422b5025083d0e7a5571840
7
+ data.tar.gz: 665f1d233db7086447e626f96136139d5b86729f552327cb8e163092ea2590b769269d15a3e480fceebff68610da2f8c11973ce8bad46337dfa551d94a5744d1
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 2.1.0
6
+
7
+ - Make `ULID::Rails::Type::Data.valid_ulid?` more strict in what is accepted as valid and not.
8
+
5
9
  ## 2.0.0
6
10
 
7
11
  - Ensure compatibility with the Trilogy database adapter.
data/README.md CHANGED
@@ -31,7 +31,7 @@ Specify `id: false` to `create_table` and add `id` column as 16-byte binary type
31
31
  ```ruby
32
32
  def change
33
33
  create_table :users, id: false do |t|
34
- t.binary :id, limit: 16, auto_generate: true
34
+ t.binary :id, limit: 16, primary_key: true
35
35
  # ...
36
36
  end
37
37
  end
@@ -77,7 +77,7 @@ A virtual column is useful if you want to add index on the timestamp column or w
77
77
 
78
78
  ```ruby
79
79
  create_table :users, id: false do |t|
80
- t.binary :id, limit: 16, auto_generate: true
80
+ t.binary :id, limit: 16, primary_key: true
81
81
  t.datetime :updated_at
82
82
  t.virtual_ulid_timestamp :created_at, :id
83
83
  end
@@ -44,6 +44,9 @@ module ULID
44
44
  end
45
45
 
46
46
  class Data < ActiveModel::Type::Binary::Data
47
+ INVALID_CHARACTERS_REGEX = /[ilou]/i.freeze
48
+ VALID_INITIAL_CHARACTER_REGEX = /^[0-7]/i.freeze
49
+
47
50
  def self.from_serialized(data)
48
51
  deserialized = Base32::Crockford.encode(data.hex).rjust(26, "0")
49
52
  new(deserialized)
@@ -51,8 +54,11 @@ module ULID
51
54
 
52
55
  def self.valid_ulid?(str)
53
56
  return true if str.nil?
57
+ return false unless str.length == 26
58
+ return false if INVALID_CHARACTERS_REGEX.match?(str)
59
+ return false unless VALID_INITIAL_CHARACTER_REGEX.match?(str)
54
60
 
55
- str.length == 26 && Base32::Crockford.valid?(str)
61
+ Base32::Crockford.valid?(str)
56
62
  end
57
63
 
58
64
  def initialize(value)
@@ -1,5 +1,5 @@
1
1
  module ULID
2
2
  module Rails
3
- VERSION = "2.0.0"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
data/ulid-rails.gemspec CHANGED
@@ -5,7 +5,7 @@ require "ulid/rails/version"
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "ulid-rails"
7
7
  spec.version = ULID::Rails::VERSION
8
- spec.required_ruby_version = ">= 2.5.0"
8
+ spec.required_ruby_version = ">= 2.6.0"
9
9
  spec.authors = ["Kazunori Kajihiro", "Zendesk"]
10
10
  spec.email = ["kazunori.kajihiro@gmail.com", "ruby-core@zendesk.com"]
11
11
 
@@ -47,5 +47,5 @@ Gem::Specification.new do |spec|
47
47
  spec.add_development_dependency "rake"
48
48
  spec.add_development_dependency "minitest", "~> 5.0"
49
49
  spec.add_development_dependency "rubocop-minitest"
50
- spec.add_development_dependency "standard", "~> 1.16.0"
50
+ spec.add_development_dependency "standard", "~> 1.32.0"
51
51
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ulid-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazunori Kajihiro
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-11-15 00:00:00.000000000 Z
12
+ date: 2023-12-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ulid
@@ -157,14 +157,14 @@ dependencies:
157
157
  requirements:
158
158
  - - "~>"
159
159
  - !ruby/object:Gem::Version
160
- version: 1.16.0
160
+ version: 1.32.0
161
161
  type: :development
162
162
  prerelease: false
163
163
  version_requirements: !ruby/object:Gem::Requirement
164
164
  requirements:
165
165
  - - "~>"
166
166
  - !ruby/object:Gem::Version
167
- version: 1.16.0
167
+ version: 1.32.0
168
168
  description: ULID for Rails
169
169
  email:
170
170
  - kazunori.kajihiro@gmail.com
@@ -200,14 +200,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
200
  requirements:
201
201
  - - ">="
202
202
  - !ruby/object:Gem::Version
203
- version: 2.5.0
203
+ version: 2.6.0
204
204
  required_rubygems_version: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - ">="
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
209
  requirements: []
210
- rubygems_version: 3.4.12
210
+ rubygems_version: 3.4.22
211
211
  signing_key:
212
212
  specification_version: 4
213
213
  summary: ULID for Rails