ulid-rails 1.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/README.md +45 -5
- data/lib/ulid/rails/postgresql_type.rb +39 -0
- data/lib/ulid/rails/sqlite_type.rb +21 -0
- data/lib/ulid/rails/type.rb +55 -28
- data/lib/ulid/rails/version.rb +1 -1
- data/lib/ulid/rails.rb +8 -3
- data/ulid-rails.gemspec +22 -13
- metadata +45 -33
- data/.env +0 -1
- data/.github/workflows/lint.yml +0 -15
- data/.github/workflows/test.yml +0 -21
- data/.gitignore +0 -10
- data/.standard.yml +0 -4
- data/Gemfile +0 -9
- data/Rakefile +0 -10
- data/bin/console +0 -14
- data/bin/run_tests +0 -18
- data/bin/setup +0 -8
- data/docker-compose.yml +0 -49
- data/gemfiles/5.0.gemfile +0 -6
- data/gemfiles/5.1.gemfile +0 -6
- data/gemfiles/5.2.gemfile +0 -8
- data/gemfiles/6.0.gemfile +0 -8
- data/gemfiles/6.1.gemfile +0 -8
- data/lib/ulid/rails/formatter.rb +0 -16
- data/lib/ulid/rails/validator.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68a14806c3289d3d6df925f84d498397db548eb23001772055ca287901de4439
|
4
|
+
data.tar.gz: c945755a7ce0accec78102f7e2f77743c7af016d9914679b42d8812be6efd315
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5a91f4489c8d7c52c498e47f84abe4aaf79d2c7047d686bd84001601ce59548843e2df25e33f0926def71941d5a0139b67728b8c422b5025083d0e7a5571840
|
7
|
+
data.tar.gz: 665f1d233db7086447e626f96136139d5b86729f552327cb8e163092ea2590b769269d15a3e480fceebff68610da2f8c11973ce8bad46337dfa551d94a5744d1
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,34 @@
|
|
1
1
|
# ulid-rails CHANGELOG
|
2
2
|
|
3
|
+
## Unreleased
|
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
|
+
|
9
|
+
## 2.0.0
|
10
|
+
|
11
|
+
- Ensure compatibility with the Trilogy database adapter.
|
12
|
+
- Drop support for Rails 5.0 and Rails 5.1.
|
13
|
+
- Ensure compatibility with Rails 7.1.
|
14
|
+
- Fix various issues when calling `#where` with non-String values, or multiple ULID values.
|
15
|
+
- The following modules/classes have been removed:
|
16
|
+
- `ULID::Rails::Formatter`
|
17
|
+
- `ULID::Rails::Validator`
|
18
|
+
- `ULID::Rails::Patch::FinderMethods`
|
19
|
+
- `ULID::Rails::Patch::SchemaStatements`
|
20
|
+
|
21
|
+
## 1.1.1
|
22
|
+
|
23
|
+
- Drop support for ruby 2.6.
|
24
|
+
- Fix compatibility with ActiveRecord 7.0.5+.
|
25
|
+
|
26
|
+
## 1.1.0
|
27
|
+
|
28
|
+
- Fix eager loading with limit/offset on models that have ulid primary key. The fix only applies to ActiveRecord 5.2, 6 and 7 (#38).
|
29
|
+
- Add support for Ruby 3.1.
|
30
|
+
- Add support for ActiveRecord 7.
|
31
|
+
|
3
32
|
## 1.0.0
|
4
33
|
|
5
34
|
- Drop support for Rails 4.2.
|
@@ -11,6 +40,7 @@
|
|
11
40
|
## 0.6.0
|
12
41
|
|
13
42
|
- Add support for Rails 4.2, 5.0 and 5.1.
|
43
|
+
- Known Issue: AREL expressions incorrectly serialize ULID values in Rails 4.2 (#27).
|
14
44
|
|
15
45
|
## 0.5.0
|
16
46
|
|
data/README.md
CHANGED
@@ -2,24 +2,28 @@
|
|
2
2
|
|
3
3
|
This gem makes it possible to use [ULID](https://github.com/ulid/spec) for DB in a Ruby on Rails app.
|
4
4
|
|
5
|
-
|
6
5
|
## Installation
|
7
6
|
|
8
|
-
|
9
7
|
```ruby
|
10
8
|
gem 'ulid-rails'
|
11
9
|
```
|
12
10
|
|
13
11
|
And then execute:
|
14
12
|
|
15
|
-
|
13
|
+
```
|
14
|
+
$ bundle
|
15
|
+
```
|
16
16
|
|
17
17
|
Or install it yourself as:
|
18
18
|
|
19
|
-
|
19
|
+
```
|
20
|
+
$ gem install ulid-rails
|
21
|
+
```
|
20
22
|
|
21
23
|
## Usage
|
22
24
|
|
25
|
+
First, load up the gem with `require 'ulid/rails'`.
|
26
|
+
|
23
27
|
### Migrations
|
24
28
|
|
25
29
|
Specify `id: false` to `create_table` and add `id` column as 16-byte binary type.
|
@@ -33,6 +37,7 @@ Specify `id: false` to `create_table` and add `id` column as 16-byte binary type
|
|
33
37
|
end
|
34
38
|
```
|
35
39
|
|
40
|
+
**MySQL note:** You can also declare the `id` column as `t.column :id, 'binary(16)'` when using MySQL, given that the syntax in the example will generate a SQL that makes the id as `VARBINARY(16)` instead of `BINARY(16)`.
|
36
41
|
|
37
42
|
### Model Changes
|
38
43
|
|
@@ -103,6 +108,41 @@ You need to specicfy `type` option
|
|
103
108
|
end
|
104
109
|
```
|
105
110
|
|
111
|
+
### Many to many associations
|
112
|
+
|
113
|
+
Please note that this library doesn't work properly with `has_and_belongs_to_many` associations.
|
114
|
+
|
115
|
+
Our recommendation is to be explicit and instead use the `has_many, through: join_class` association.
|
116
|
+
Notice that for it to work properly you must specify the `has_many` to the join class in the main classes of the association,
|
117
|
+
and your join class must have `belongs_to` main classes defined as shown in the example below:
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
class User < ActiveRecord::Base
|
121
|
+
include ULID::Rails
|
122
|
+
ulid :id, auto_generate: true
|
123
|
+
|
124
|
+
has_many :user_articles
|
125
|
+
has_many :articles, through: :user_articles
|
126
|
+
end
|
127
|
+
|
128
|
+
class UserArticle < ActiveRecord::Base
|
129
|
+
include ULID::Rails
|
130
|
+
ulid :id, auto_generate: true
|
131
|
+
ulid :user_id
|
132
|
+
ulid :article_id
|
133
|
+
|
134
|
+
belongs_to :user
|
135
|
+
belongs_to :article
|
136
|
+
end
|
137
|
+
|
138
|
+
class Article < ActiveRecord::Base
|
139
|
+
include ULID::Rails
|
140
|
+
ulid :id, auto_generate: true
|
141
|
+
|
142
|
+
has_many :user_articles
|
143
|
+
end
|
144
|
+
```
|
145
|
+
|
106
146
|
## Development
|
107
147
|
|
108
148
|
### Run tests
|
@@ -122,7 +162,7 @@ $ docker-compose run -e AR_VERSION=6.1 test
|
|
122
162
|
Or run tests locally, without docker-compose
|
123
163
|
|
124
164
|
```
|
125
|
-
$ AR_VERSION=
|
165
|
+
$ AR_VERSION=6.1 bundle update && AR_VERSION=6.1 bundle exec rake test
|
126
166
|
```
|
127
167
|
|
128
168
|
## License
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative "type"
|
2
|
+
|
3
|
+
module ULID
|
4
|
+
module Rails
|
5
|
+
class PostgresqlType < Type
|
6
|
+
class Data < ULID::Rails::Type::Data
|
7
|
+
def hex
|
8
|
+
hexed = super
|
9
|
+
return nil if hexed.nil?
|
10
|
+
[hexed].pack("H*")
|
11
|
+
end
|
12
|
+
|
13
|
+
alias_method :to_s, :hex
|
14
|
+
end
|
15
|
+
|
16
|
+
# Inspired by active_record/connection_adapters/postgresql/oid/bytea
|
17
|
+
def deserialize(value)
|
18
|
+
case value
|
19
|
+
when nil
|
20
|
+
nil
|
21
|
+
when ULID::Rails::Type::Data
|
22
|
+
super(value.value)
|
23
|
+
else
|
24
|
+
super(PG::Connection.unescape_bytea(value))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def cast_string_to_ulid(value)
|
31
|
+
if value.is_a?(String) && value.length == 34 && value.start_with?("\\x")
|
32
|
+
Data.from_serialized(value[2..])
|
33
|
+
else
|
34
|
+
super(value, data_class: PostgresqlType::Data)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative "type"
|
2
|
+
|
3
|
+
module ULID
|
4
|
+
module Rails
|
5
|
+
class SqliteType < Type
|
6
|
+
class Data < ULID::Rails::Type::Data
|
7
|
+
alias_method :to_s, :hex
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def cast_string_to_ulid(value)
|
13
|
+
if value.is_a?(String) && value.length == 32
|
14
|
+
Data.from_serialized(value)
|
15
|
+
else
|
16
|
+
super(value, data_class: SqliteType::Data)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/ulid/rails/type.rb
CHANGED
@@ -1,53 +1,80 @@
|
|
1
1
|
require "active_model/type"
|
2
|
-
require "
|
3
|
-
require "ulid/rails/validator"
|
2
|
+
require "base32/crockford"
|
4
3
|
require "ulid/rails/errors"
|
5
4
|
|
6
5
|
module ULID
|
7
6
|
module Rails
|
8
7
|
class Type < ActiveModel::Type::Binary
|
9
|
-
|
10
|
-
|
8
|
+
def assert_valid_value(value)
|
9
|
+
raise ArgumentError, "`#{value}` is not a ULID format" unless Data.valid_ulid?(value)
|
11
10
|
end
|
12
11
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
def cast(value)
|
13
|
+
return nil if value.nil?
|
14
|
+
|
15
|
+
str = value.is_a?(Data) ? value.value : value
|
16
|
+
|
17
|
+
cast_string_to_ulid(str).value
|
17
18
|
end
|
18
19
|
|
19
|
-
def
|
20
|
-
|
20
|
+
def serialize(value)
|
21
|
+
return value if value.is_a?(Data)
|
22
|
+
return nil unless value.is_a?(String)
|
23
|
+
|
24
|
+
cast_string_to_ulid(value)
|
21
25
|
end
|
22
26
|
|
23
27
|
def deserialize(value)
|
24
28
|
return nil if value.nil?
|
25
29
|
|
26
|
-
|
27
|
-
value = value.unpack1("H*") if value.encoding == Encoding::ASCII_8BIT
|
28
|
-
value = value[2..-1] if value.start_with?("\\x")
|
29
|
-
|
30
|
-
value.length == 32 ? @formatter.format(value) : super
|
30
|
+
super
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
|
33
|
+
private
|
34
|
+
|
35
|
+
def cast_string_to_ulid(value, data_class: Data)
|
36
|
+
raise ArgumentError if !value.is_a?(String)
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
if data_class.valid_ulid?(value)
|
39
|
+
data_class.new(value)
|
40
|
+
else
|
41
|
+
data = value.unpack1("H*")
|
42
|
+
data_class.from_serialized(data)
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
|
-
|
46
|
+
class Data < ActiveModel::Type::Binary::Data
|
47
|
+
INVALID_CHARACTERS_REGEX = /[ilou]/i.freeze
|
48
|
+
VALID_INITIAL_CHARACTER_REGEX = /^[0-7]/i.freeze
|
45
49
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
50
|
+
def self.from_serialized(data)
|
51
|
+
deserialized = Base32::Crockford.encode(data.hex).rjust(26, "0")
|
52
|
+
new(deserialized)
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.valid_ulid?(str)
|
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)
|
60
|
+
|
61
|
+
Base32::Crockford.valid?(str)
|
62
|
+
end
|
63
|
+
|
64
|
+
def initialize(value)
|
65
|
+
@value = nil
|
66
|
+
super if self.class.valid_ulid?(value)
|
67
|
+
end
|
68
|
+
|
69
|
+
attr_reader :value
|
70
|
+
|
71
|
+
def hex
|
72
|
+
return nil if @value.nil?
|
73
|
+
|
74
|
+
hexed = Base32::Crockford.decode(@value).to_s(16).rjust(32, "0")
|
75
|
+
raise ArgumentError if hexed.length > 32
|
76
|
+
|
77
|
+
hexed
|
51
78
|
end
|
52
79
|
end
|
53
80
|
end
|
data/lib/ulid/rails/version.rb
CHANGED
data/lib/ulid/rails.rb
CHANGED
@@ -5,6 +5,8 @@ require "ulid"
|
|
5
5
|
require "base32/crockford"
|
6
6
|
require "ulid/rails/version"
|
7
7
|
require "ulid/rails/type"
|
8
|
+
require "ulid/rails/postgresql_type"
|
9
|
+
require "ulid/rails/sqlite_type"
|
8
10
|
require "ulid/rails/patch"
|
9
11
|
|
10
12
|
module ULID
|
@@ -13,7 +15,7 @@ module ULID
|
|
13
15
|
|
14
16
|
class_methods do
|
15
17
|
def ulid(column_name, auto_generate: false)
|
16
|
-
attribute column_name,
|
18
|
+
attribute column_name, :ulid
|
17
19
|
|
18
20
|
if auto_generate
|
19
21
|
before_create do
|
@@ -44,7 +46,10 @@ module ULID
|
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
47
|
-
|
48
|
-
ActiveRecord::
|
49
|
+
ActiveRecord::Type.register(:ulid, ULID::Rails::Type, override: false)
|
50
|
+
ActiveRecord::Type.register(:ulid, ULID::Rails::PostgresqlType, adapter: :postgresql)
|
51
|
+
ActiveRecord::Type.register(:ulid, ULID::Rails::SqliteType, adapter: :sqlite)
|
52
|
+
ActiveRecord::Type.register(:ulid, ULID::Rails::SqliteType, adapter: :sqlite3)
|
53
|
+
ActiveRecord::ConnectionAdapters::TableDefinition.include(Patch::Migrations)
|
49
54
|
end
|
50
55
|
end
|
data/ulid-rails.gemspec
CHANGED
@@ -5,12 +5,12 @@ 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.
|
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
|
|
12
|
-
spec.summary = "ULID for
|
13
|
-
spec.description = "ULID for
|
12
|
+
spec.summary = "ULID for Rails"
|
13
|
+
spec.description = "ULID for Rails"
|
14
14
|
spec.homepage = "https://github.com/k2nr/ulid-rails/"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
@@ -22,21 +22,30 @@ Gem::Specification.new do |spec|
|
|
22
22
|
}
|
23
23
|
|
24
24
|
# Specify which files should be added to the gem when it is released.
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
spec.files = %w[
|
26
|
+
CHANGELOG.md
|
27
|
+
LICENSE.txt
|
28
|
+
README.md
|
29
|
+
lib/ulid/rails.rb
|
30
|
+
lib/ulid/rails/errors.rb
|
31
|
+
lib/ulid/rails/patch.rb
|
32
|
+
lib/ulid/rails/postgresql_type.rb
|
33
|
+
lib/ulid/rails/sqlite_type.rb
|
34
|
+
lib/ulid/rails/type.rb
|
35
|
+
lib/ulid/rails/version.rb
|
36
|
+
ulid-rails.gemspec
|
37
|
+
]
|
31
38
|
spec.require_paths = ["lib"]
|
32
39
|
|
33
40
|
spec.add_dependency "ulid", "~> 1.0"
|
34
41
|
spec.add_dependency "base32-crockford", "~> 0.1"
|
35
|
-
spec.add_dependency "activesupport", ">= 5.
|
36
|
-
spec.add_dependency "activemodel", ">= 5.
|
37
|
-
spec.add_dependency "activerecord", ">= 5.
|
42
|
+
spec.add_dependency "activesupport", ">= 5.2"
|
43
|
+
spec.add_dependency "activemodel", ">= 5.2"
|
44
|
+
spec.add_dependency "activerecord", ">= 5.2"
|
38
45
|
spec.add_development_dependency "bundler"
|
46
|
+
spec.add_development_dependency "pry-byebug"
|
39
47
|
spec.add_development_dependency "rake"
|
40
48
|
spec.add_development_dependency "minitest", "~> 5.0"
|
41
|
-
spec.add_development_dependency "
|
49
|
+
spec.add_development_dependency "rubocop-minitest"
|
50
|
+
spec.add_development_dependency "standard", "~> 1.32.0"
|
42
51
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ulid-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazunori Kajihiro
|
8
8
|
- Zendesk
|
9
9
|
autorequire:
|
10
|
-
bindir:
|
10
|
+
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-12-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ulid
|
@@ -45,42 +45,42 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '5.
|
48
|
+
version: '5.2'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '5.
|
55
|
+
version: '5.2'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: activemodel
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '5.
|
62
|
+
version: '5.2'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '5.
|
69
|
+
version: '5.2'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: activerecord
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '5.
|
76
|
+
version: '5.2'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '5.
|
83
|
+
version: '5.2'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: bundler
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,6 +95,20 @@ dependencies:
|
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: pry-byebug
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
98
112
|
- !ruby/object:Gem::Dependency
|
99
113
|
name: rake
|
100
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,21 +137,35 @@ dependencies:
|
|
123
137
|
- - "~>"
|
124
138
|
- !ruby/object:Gem::Version
|
125
139
|
version: '5.0'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: rubocop-minitest
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
126
154
|
- !ruby/object:Gem::Dependency
|
127
155
|
name: standard
|
128
156
|
requirement: !ruby/object:Gem::Requirement
|
129
157
|
requirements:
|
130
158
|
- - "~>"
|
131
159
|
- !ruby/object:Gem::Version
|
132
|
-
version: 1.
|
160
|
+
version: 1.32.0
|
133
161
|
type: :development
|
134
162
|
prerelease: false
|
135
163
|
version_requirements: !ruby/object:Gem::Requirement
|
136
164
|
requirements:
|
137
165
|
- - "~>"
|
138
166
|
- !ruby/object:Gem::Version
|
139
|
-
version: 1.
|
140
|
-
description: ULID for
|
167
|
+
version: 1.32.0
|
168
|
+
description: ULID for Rails
|
141
169
|
email:
|
142
170
|
- kazunori.kajihiro@gmail.com
|
143
171
|
- ruby-core@zendesk.com
|
@@ -145,31 +173,15 @@ executables: []
|
|
145
173
|
extensions: []
|
146
174
|
extra_rdoc_files: []
|
147
175
|
files:
|
148
|
-
- ".env"
|
149
|
-
- ".github/workflows/lint.yml"
|
150
|
-
- ".github/workflows/test.yml"
|
151
|
-
- ".gitignore"
|
152
|
-
- ".standard.yml"
|
153
176
|
- CHANGELOG.md
|
154
|
-
- Gemfile
|
155
177
|
- LICENSE.txt
|
156
178
|
- README.md
|
157
|
-
- Rakefile
|
158
|
-
- bin/console
|
159
|
-
- bin/run_tests
|
160
|
-
- bin/setup
|
161
|
-
- docker-compose.yml
|
162
|
-
- gemfiles/5.0.gemfile
|
163
|
-
- gemfiles/5.1.gemfile
|
164
|
-
- gemfiles/5.2.gemfile
|
165
|
-
- gemfiles/6.0.gemfile
|
166
|
-
- gemfiles/6.1.gemfile
|
167
179
|
- lib/ulid/rails.rb
|
168
180
|
- lib/ulid/rails/errors.rb
|
169
|
-
- lib/ulid/rails/formatter.rb
|
170
181
|
- lib/ulid/rails/patch.rb
|
182
|
+
- lib/ulid/rails/postgresql_type.rb
|
183
|
+
- lib/ulid/rails/sqlite_type.rb
|
171
184
|
- lib/ulid/rails/type.rb
|
172
|
-
- lib/ulid/rails/validator.rb
|
173
185
|
- lib/ulid/rails/version.rb
|
174
186
|
- ulid-rails.gemspec
|
175
187
|
homepage: https://github.com/k2nr/ulid-rails/
|
@@ -188,15 +200,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
188
200
|
requirements:
|
189
201
|
- - ">="
|
190
202
|
- !ruby/object:Gem::Version
|
191
|
-
version: 2.
|
203
|
+
version: 2.6.0
|
192
204
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
205
|
requirements:
|
194
206
|
- - ">="
|
195
207
|
- !ruby/object:Gem::Version
|
196
208
|
version: '0'
|
197
209
|
requirements: []
|
198
|
-
rubygems_version: 3.
|
210
|
+
rubygems_version: 3.4.22
|
199
211
|
signing_key:
|
200
212
|
specification_version: 4
|
201
|
-
summary: ULID for
|
213
|
+
summary: ULID for Rails
|
202
214
|
test_files: []
|
data/.github/workflows/lint.yml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: Linting
|
3
|
-
on: [push, pull_request]
|
4
|
-
jobs:
|
5
|
-
standardrb:
|
6
|
-
env:
|
7
|
-
AR_VERSION: "5.2"
|
8
|
-
runs-on: ubuntu-latest
|
9
|
-
steps:
|
10
|
-
- uses: actions/checkout@v2
|
11
|
-
- uses: ruby/setup-ruby@v1
|
12
|
-
with:
|
13
|
-
ruby-version: 3.0
|
14
|
-
bundler-cache: true
|
15
|
-
- run: bundle exec standardrb
|
data/.github/workflows/test.yml
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: Tests
|
3
|
-
on: [push, pull_request]
|
4
|
-
jobs:
|
5
|
-
tests:
|
6
|
-
runs-on: ubuntu-latest
|
7
|
-
strategy:
|
8
|
-
matrix:
|
9
|
-
activerecord-version: ["5.0", "5.1", "5.2", "6.0", "6.1"]
|
10
|
-
ruby-version: ["2.6", "2.7", "3.0"]
|
11
|
-
exclude:
|
12
|
-
- activerecord-version: "5.0"
|
13
|
-
ruby-version: "3.0"
|
14
|
-
- activerecord-version: "5.1"
|
15
|
-
ruby-version: "3.0"
|
16
|
-
- activerecord-version: "5.2"
|
17
|
-
ruby-version: "3.0"
|
18
|
-
steps:
|
19
|
-
- uses: actions/checkout@v2
|
20
|
-
- name: Test ActiveRecord ${{ matrix.activerecord-version }} and Ruby ${{ matrix.ruby-version }}
|
21
|
-
run: RUBY_VERSION=${{ matrix.ruby-version }} docker-compose run -e AR_VERSION=${{ matrix.activerecord-version }} test
|
data/.gitignore
DELETED
data/.standard.yml
DELETED
data/Gemfile
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in ulid-rails.gemspec
|
6
|
-
gemspec
|
7
|
-
|
8
|
-
version = ENV["AR_VERSION"] || "6.0"
|
9
|
-
eval_gemfile File.expand_path("../gemfiles/#{version}.gemfile", __FILE__)
|
data/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "ulid/rails"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
data/bin/run_tests
DELETED
data/bin/setup
DELETED
data/docker-compose.yml
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
version: '3.6'
|
2
|
-
services:
|
3
|
-
test:
|
4
|
-
image: "ruby:${RUBY_VERSION}"
|
5
|
-
command: sh -c "rm -f Gemfile.lock && bundle install && bin/run_tests"
|
6
|
-
depends_on:
|
7
|
-
pg12:
|
8
|
-
condition: service_healthy
|
9
|
-
mysql56:
|
10
|
-
condition: service_healthy
|
11
|
-
mysql57:
|
12
|
-
condition: service_healthy
|
13
|
-
mysql80:
|
14
|
-
condition: service_healthy
|
15
|
-
working_dir: /app
|
16
|
-
volumes:
|
17
|
-
- bundle:/usr/local/bundle
|
18
|
-
- .:/app
|
19
|
-
|
20
|
-
mysql56:
|
21
|
-
image: mysql:5.6
|
22
|
-
environment:
|
23
|
-
MYSQL_ROOT_PASSWORD: password
|
24
|
-
command: --innodb-large-prefix --innodb-file-format=barracuda
|
25
|
-
healthcheck:
|
26
|
-
test: mysql --password=password -e "show databases;"
|
27
|
-
mysql57:
|
28
|
-
image: mysql:5.7
|
29
|
-
environment:
|
30
|
-
MYSQL_ROOT_PASSWORD: password
|
31
|
-
healthcheck:
|
32
|
-
test: mysql --password=password -e "show databases;"
|
33
|
-
mysql80:
|
34
|
-
image: mysql:8.0
|
35
|
-
command: --default-authentication-plugin=mysql_native_password
|
36
|
-
environment:
|
37
|
-
MYSQL_ROOT_PASSWORD: password
|
38
|
-
healthcheck:
|
39
|
-
test: mysql --password=password -e "show databases;"
|
40
|
-
pg12:
|
41
|
-
image: postgres:12
|
42
|
-
environment:
|
43
|
-
PGDATA: /data
|
44
|
-
POSTGRES_DB: db
|
45
|
-
POSTGRES_HOST_AUTH_METHOD: trust
|
46
|
-
healthcheck:
|
47
|
-
test: echo "\\l" | psql -U postgres
|
48
|
-
volumes:
|
49
|
-
bundle:
|
data/gemfiles/5.0.gemfile
DELETED
data/gemfiles/5.1.gemfile
DELETED
data/gemfiles/5.2.gemfile
DELETED
data/gemfiles/6.0.gemfile
DELETED
data/gemfiles/6.1.gemfile
DELETED
data/lib/ulid/rails/formatter.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require "base32/crockford"
|
2
|
-
|
3
|
-
module ULID
|
4
|
-
module Rails
|
5
|
-
module Formatter
|
6
|
-
def self.format(v)
|
7
|
-
sanitized = v.delete("-").hex
|
8
|
-
Base32::Crockford.encode(sanitized).rjust(26, "0")
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.unformat(v)
|
12
|
-
Base32::Crockford.decode(v).to_s(16).rjust(32, "0")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|