ulid-rails 1.1.0 → 2.0.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f122ca0476d8b8c06f1f4bf08219bdf653d0ba890a3cdb6d9d5d99dfec353424
4
- data.tar.gz: 0d1d58ea8a26637db28421610971049cbc9730201c39f9d9444757a65a249a4e
3
+ metadata.gz: 4fe6dfad2124c31cc7fbd3b744c8309d3abbd1fe8b3f0f737e87730d48e4a7ad
4
+ data.tar.gz: 5c94f88160609b46cb584c5e802e1a8fbfc3ae92e75e08277ca50c4f5693d24b
5
5
  SHA512:
6
- metadata.gz: c37272d98ec13e144f2aa8c704d3db3140bf672cf3f6d7e76931acc7ab008b0a51cc91a51c402a8dbc14d73da3ce31092ace18e99efcf31b9ad4ff4c5fd6cb16
7
- data.tar.gz: d7bcabb538e9f4a588b7d28b79459c06e44c9bfaeffdcaf5e563823908cdad5bcf7de3cd9fd2da20b21062415686e40f5df0904b53e38b9ac367084021616a19
6
+ metadata.gz: 0f39ff3a403a16b42ea3ee18a82938b266998f936dabe319084d52dedc2a2260761b92ed3273b8b074c0ee95b30979eef30b41abfa8db73ea16b0436652f1b26
7
+ data.tar.gz: a836d749d63b71b66cc310262db3c3cd529b5378e17c3ef5c265503c695d446fdc954df36f9c74b828ab423620e707138877322db1546b1d6fc3f3e7c4b986aa
data/.env CHANGED
@@ -1 +1 @@
1
- RUBY_VERSION=2.6
1
+ RUBY_VERSION=2.7
@@ -6,6 +6,7 @@ on:
6
6
  push:
7
7
  branches:
8
8
  - master
9
+ workflow_dispatch:
9
10
 
10
11
  jobs:
11
12
  standardrb:
@@ -6,25 +6,22 @@ on:
6
6
  push:
7
7
  branches:
8
8
  - master
9
+ workflow_dispatch:
9
10
 
10
11
  jobs:
11
12
  tests:
13
+ name: ActiveRecord ${{ matrix.activerecord-version }} / Ruby ${{ matrix.ruby-version }}
12
14
  runs-on: ubuntu-latest
13
15
  strategy:
14
16
  fail-fast: false
15
17
  matrix:
16
- activerecord-version: ["5.0", "5.1", "5.2", "6.0", "6.1", "7.0"]
17
- ruby-version: ["2.6", "2.7", "3.0", "3.1"]
18
- exclude:
19
- - {activerecord-version: "5.0", ruby-version: "3.0"}
20
- - {activerecord-version: "5.0", ruby-version: "3.1"}
21
- - {activerecord-version: "5.1", ruby-version: "3.0"}
22
- - {activerecord-version: "5.1", ruby-version: "3.1"}
23
- - {activerecord-version: "5.2", ruby-version: "3.0"}
24
- - {activerecord-version: "5.2", ruby-version: "3.1"}
25
- - {activerecord-version: "6.0", ruby-version: "3.1"}
26
- - {activerecord-version: "7.0", ruby-version: "2.6"}
18
+ activerecord-version: ["6.0", "6.1", "7.0", "7.0.5"]
19
+ ruby-version: ["2.7", "3.0", "3.1", "3.2"]
20
+ include:
21
+ - {activerecord-version: "5.2", ruby-version: "2.7"}
27
22
  steps:
28
23
  - uses: actions/checkout@v3
29
- - name: Test ActiveRecord ${{ matrix.activerecord-version }} and Ruby ${{ matrix.ruby-version }}
30
- run: RUBY_VERSION=${{ matrix.ruby-version }} docker-compose run -e AR_VERSION=${{ matrix.activerecord-version }} test
24
+ - run: docker-compose run test
25
+ env:
26
+ RUBY_VERSION: ${{ matrix.ruby-version }}
27
+ AR_VERSION: ${{ matrix.activerecord-version }}
data/.rubocop.yml CHANGED
@@ -10,3 +10,4 @@ AllCops:
10
10
  NewCops: enable
11
11
  Exclude:
12
12
  - 'vendor/**/*'
13
+ TargetRubyVersion: "2.7"
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # ulid-rails CHANGELOG
2
2
 
3
+ ## Unreleased
4
+
5
+ ## 2.0.0.pre.1
6
+
7
+ - Drop support for Rails 5.0 and Rails 5.1.
8
+ - Fix various issues when calling `#where` with non-String values, or multiple ULID values.
9
+
10
+ ## 1.1.1
11
+
12
+ - Drop support for ruby 2.6.
13
+ - Fix compatibility with ActiveRecord 7.0.5+.
14
+
3
15
  ## 1.1.0
4
16
 
5
17
  - 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).
data/README.md CHANGED
@@ -37,6 +37,8 @@ Specify `id: false` to `create_table` and add `id` column as 16-byte binary type
37
37
  end
38
38
  ```
39
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)`.
41
+
40
42
  ### Model Changes
41
43
 
42
44
  Just add the below lines to your models.
@@ -110,7 +112,7 @@ You need to specicfy `type` option
110
112
 
111
113
  Please note that this library doesn't work properly with `has_and_belongs_to_many` associations.
112
114
 
113
- Our recommendation is to be explicit and instead use the `has_many, through: join_class` association.
115
+ Our recommendation is to be explicit and instead use the `has_many, through: join_class` association.
114
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,
115
117
  and your join class must have `belongs_to` main classes defined as shown in the example below:
116
118
 
@@ -160,13 +162,9 @@ $ docker-compose run -e AR_VERSION=6.1 test
160
162
  Or run tests locally, without docker-compose
161
163
 
162
164
  ```
163
- $ AR_VERSION=4.2 bundle update && AR_VERSION=4.2 bundle exec rake test
165
+ $ AR_VERSION=6.1 bundle update && AR_VERSION=6.1 bundle exec rake test
164
166
  ```
165
167
 
166
- ## Known issues
167
-
168
- - ActiveRecord 5.0 and 5.1 do not work properly with some data association loading methods. For example, eager loading with limit/offset on a model that has a ulid ID. Refer to test cases that are skiped for AR 5.0 and 5.1.
169
-
170
168
  ## License
171
169
 
172
170
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/docker-compose.yml CHANGED
@@ -1,8 +1,10 @@
1
1
  version: '3.6'
2
2
  services:
3
3
  test:
4
- image: "ruby:${RUBY_VERSION}"
4
+ image: "ruby:${RUBY_VERSION}"
5
5
  command: sh -c "rm -f Gemfile.lock && bundle install && bin/run_tests"
6
+ environment:
7
+ - AR_VERSION=${AR_VERSION}
6
8
  depends_on:
7
9
  pg12:
8
10
  condition: service_healthy
@@ -23,20 +25,20 @@ services:
23
25
  MYSQL_ROOT_PASSWORD: password
24
26
  command: --innodb-large-prefix --innodb-file-format=barracuda
25
27
  healthcheck:
26
- test: mysql --password=password -e "show databases;"
28
+ test: mysql --password=password -e "show databases;"
27
29
  mysql57:
28
30
  image: mysql:5.7
29
31
  environment:
30
32
  MYSQL_ROOT_PASSWORD: password
31
33
  healthcheck:
32
- test: mysql --password=password -e "show databases;"
34
+ test: mysql --password=password -e "show databases;"
33
35
  mysql80:
34
36
  image: mysql:8.0
35
37
  command: --default-authentication-plugin=mysql_native_password
36
38
  environment:
37
39
  MYSQL_ROOT_PASSWORD: password
38
40
  healthcheck:
39
- test: mysql --password=password -e "show databases;"
41
+ test: mysql --password=password -e "show databases;"
40
42
  pg12:
41
43
  image: postgres:12
42
44
  environment:
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: ".."
4
+
5
+ gem "activesupport", "~> 7.0.5"
6
+ gem "activemodel", "~> 7.0.5"
7
+ gem "activerecord", "~> 7.0.5"
8
+ gem "sqlite3", "~> 1.4"
9
+ gem "mysql2", "~> 0.5"
10
+ gem "pg", "~> 1.1"
data/gemfiles/7.0.gemfile CHANGED
@@ -2,9 +2,9 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec path: ".."
4
4
 
5
- gem "activesupport", "~> 7.0.0"
6
- gem "activemodel", "~> 7.0.0"
7
- gem "activerecord", "~> 7.0.0"
5
+ gem "activesupport", "~> 7.0.0", "< 7.0.5"
6
+ gem "activemodel", "~> 7.0.0", "< 7.0.5"
7
+ gem "activerecord", "~> 7.0.0", "< 7.0.5"
8
8
  gem "sqlite3", "~> 1.4"
9
9
  gem "mysql2", "~> 0.5"
10
10
  gem "pg", "~> 1.1"
@@ -8,46 +8,6 @@ module ULID
8
8
  as: "FROM_UNIXTIME(CONV(HEX(#{ulid_column_name} >> 80), 16, 10) / 1000.0)"
9
9
  end
10
10
  end
11
-
12
- module FinderMethods
13
- def limited_ids_for(relation)
14
- id_rows = super
15
- if klass.attribute_types[primary_key].is_a? ULID::Rails::Type
16
- id_rows.map do |id|
17
- klass.attribute_types[primary_key].deserialize id
18
- end
19
- else
20
- id_rows
21
- end
22
- end
23
- end
24
-
25
- module SchemaStatements
26
- def distinct_relation_for_primary_key(relation) # :nodoc:
27
- values = columns_for_distinct(
28
- visitor.compile(relation.table[relation.primary_key]),
29
- relation.order_values
30
- )
31
-
32
- limited = relation.reselect(values).distinct!
33
- limited_ids = select_rows(limited.arel, "SQL").map(&:last)
34
-
35
- if relation.klass.attribute_types[relation.primary_key].is_a? ULID::Rails::Type
36
- limited_ids.map! do |id|
37
- relation.klass.attribute_types[relation.primary_key].deserialize id
38
- end
39
- end
40
-
41
- if limited_ids.empty?
42
- relation.none!
43
- else
44
- relation.where!(relation.primary_key => limited_ids)
45
- end
46
-
47
- relation.limit_value = relation.offset_value = nil
48
- relation
49
- end
50
- end
51
11
  end
52
12
  end
53
13
  end
@@ -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
@@ -1,53 +1,78 @@
1
1
  require "active_model/type"
2
- require "ulid/rails/formatter"
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
- class Data < ActiveModel::Type::Binary::Data
10
- alias_method :hex, :to_s
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 initialize(formatter = Formatter, validator = Validator)
14
- @formatter = formatter
15
- @validator = validator
16
- super()
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 assert_valid_value(value)
20
- raise ArgumentError, "`#{value}` is not a ULID format" unless @validator.is_valid?(value)
20
+ def serialize(value)
21
+ return value if value.is_a?(Data)
22
+ return Data.null 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
- value = value.to_s if value.is_a?(Data)
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
- def serialize(value)
34
- return if value.nil?
33
+ private
35
34
 
36
- case adapter
37
- when "mysql2", "sqlite3"
38
- Data.new(@formatter.unformat(value))
39
- when "postgresql"
40
- Data.new([@formatter.unformat(value)].pack("H*"))
35
+ def cast_string_to_ulid(value, data_class: Data)
36
+ raise ArgumentError if !value.is_a?(String)
37
+
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
- private
46
+ class Data < ActiveModel::Type::Binary::Data
47
+ def self.null
48
+ new(nil)
49
+ end
45
50
 
46
- def adapter
47
- if ::ActiveRecord::Base.respond_to?(:connection_db_config)
48
- ::ActiveRecord::Base.connection_db_config.configuration_hash[:adapter]
49
- else
50
- ::ActiveRecord::Base.connection_config[:adapter]
51
+ def self.from_serialized(data)
52
+ deserialized = Base32::Crockford.encode(data.hex).rjust(26, "0")
53
+ new(deserialized)
54
+ end
55
+
56
+ def self.valid_ulid?(str)
57
+ return true if str.nil?
58
+
59
+ str.length == 26 && Base32::Crockford.valid?(str)
60
+ end
61
+
62
+ def initialize(value)
63
+ @value = nil
64
+ super if self.class.valid_ulid?(value)
65
+ end
66
+
67
+ attr_reader :value
68
+
69
+ def hex
70
+ return nil if @value.nil?
71
+
72
+ hexed = Base32::Crockford.decode(@value).to_s(16).rjust(32, "0")
73
+ raise ArgumentError if hexed.length > 32
74
+
75
+ hexed
51
76
  end
52
77
  end
53
78
  end
@@ -1,5 +1,5 @@
1
1
  module ULID
2
2
  module Rails
3
- VERSION = "1.1.0"
3
+ VERSION = "2.0.0.pre.1"
4
4
  end
5
5
  end
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, ULID::Rails::Type.new
18
+ attribute column_name, :ulid
17
19
 
18
20
  if auto_generate
19
21
  before_create do
@@ -44,15 +46,10 @@ module ULID
44
46
  end
45
47
  end
46
48
 
47
- ActiveModel::Type.register(:ulid, ULID::Rails::Type)
48
- ActiveRecord::ConnectionAdapters::TableDefinition.send :include, Patch::Migrations
49
- case ActiveRecord::VERSION::MAJOR
50
- when 5
51
- ActiveRecord::FinderMethods.prepend(Patch::FinderMethods) unless ActiveRecord::VERSION::MINOR < 2
52
- when 6
53
- ActiveRecord::FinderMethods.prepend(Patch::FinderMethods)
54
- when 7
55
- ActiveRecord::ConnectionAdapters::SchemaStatements.prepend(Patch::SchemaStatements)
56
- end
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)
57
54
  end
58
55
  end
data/ulid-rails.gemspec CHANGED
@@ -32,10 +32,11 @@ Gem::Specification.new do |spec|
32
32
 
33
33
  spec.add_dependency "ulid", "~> 1.0"
34
34
  spec.add_dependency "base32-crockford", "~> 0.1"
35
- spec.add_dependency "activesupport", ">= 5.0"
36
- spec.add_dependency "activemodel", ">= 5.0"
37
- spec.add_dependency "activerecord", ">= 5.0"
35
+ spec.add_dependency "activesupport", ">= 5.2"
36
+ spec.add_dependency "activemodel", ">= 5.2"
37
+ spec.add_dependency "activerecord", ">= 5.2"
38
38
  spec.add_development_dependency "bundler"
39
+ spec.add_development_dependency "pry-byebug"
39
40
  spec.add_development_dependency "rake"
40
41
  spec.add_development_dependency "minitest", "~> 5.0"
41
42
  spec.add_development_dependency "rubocop-minitest"
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: 1.1.0
4
+ version: 2.0.0.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazunori Kajihiro
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-12-23 00:00:00.000000000 Z
12
+ date: 2023-09-07 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.0'
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.0'
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.0'
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.0'
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.0'
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.0'
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
@@ -174,18 +188,17 @@ files:
174
188
  - bin/run_tests
175
189
  - bin/setup
176
190
  - docker-compose.yml
177
- - gemfiles/5.0.gemfile
178
- - gemfiles/5.1.gemfile
179
191
  - gemfiles/5.2.gemfile
180
192
  - gemfiles/6.0.gemfile
181
193
  - gemfiles/6.1.gemfile
194
+ - gemfiles/7.0.5.gemfile
182
195
  - gemfiles/7.0.gemfile
183
196
  - lib/ulid/rails.rb
184
197
  - lib/ulid/rails/errors.rb
185
- - lib/ulid/rails/formatter.rb
186
198
  - lib/ulid/rails/patch.rb
199
+ - lib/ulid/rails/postgresql_type.rb
200
+ - lib/ulid/rails/sqlite_type.rb
187
201
  - lib/ulid/rails/type.rb
188
- - lib/ulid/rails/validator.rb
189
202
  - lib/ulid/rails/version.rb
190
203
  - ulid-rails.gemspec
191
204
  homepage: https://github.com/k2nr/ulid-rails/
@@ -207,11 +220,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
207
220
  version: 2.5.0
208
221
  required_rubygems_version: !ruby/object:Gem::Requirement
209
222
  requirements:
210
- - - ">="
223
+ - - ">"
211
224
  - !ruby/object:Gem::Version
212
- version: '0'
225
+ version: 1.3.1
213
226
  requirements: []
214
- rubygems_version: 3.1.6
227
+ rubygems_version: 3.4.12
215
228
  signing_key:
216
229
  specification_version: 4
217
230
  summary: ULID for rails
data/gemfiles/5.0.gemfile DELETED
@@ -1,10 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec path: ".."
4
-
5
- gem "activesupport", "~> 5.0.0"
6
- gem "activemodel", "~> 5.0.0"
7
- gem "activerecord", "~> 5.0.0"
8
- gem "sqlite3", "~> 1.3.6"
9
- gem "mysql2", ">= 0.3.18", "< 0.6.0"
10
- gem "pg", ">= 0.18", "< 2.0"
data/gemfiles/5.1.gemfile DELETED
@@ -1,10 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec path: ".."
4
-
5
- gem "activesupport", "~> 5.1.0"
6
- gem "activemodel", "~> 5.1.0"
7
- gem "activerecord", "~> 5.1.0"
8
- gem "sqlite3", "~> 1.3", ">= 1.3.6"
9
- gem "mysql2", ">= 0.3.18", "< 0.6.0"
10
- gem "pg", ">= 0.18", "< 2.0"
@@ -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
@@ -1,12 +0,0 @@
1
- require "base32/crockford"
2
-
3
- module ULID
4
- module Rails
5
- module Validator
6
- def self.is_valid?(v)
7
- return true if v.nil?
8
- v.length == 26 && Base32::Crockford.valid?(v)
9
- end
10
- end
11
- end
12
- end