ulid-rails 0.6.0 → 1.0.0

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: 286faae595c37c666671a84b8eeeb070497b585dd58cde500e96f8b9939e61e8
4
- data.tar.gz: 8463132209c6706611a889e16ddfcf91d24173e88ec47cba9da743df8ccdc12f
3
+ metadata.gz: ad104e01d6ca64c2430e444ea5d900dcabf387200d177edf90be642bbebe3eaf
4
+ data.tar.gz: 28dc14190454edd67f047908981940d2741fb6cd7da2b416a4631cd0ea651e8d
5
5
  SHA512:
6
- metadata.gz: b84e1c464698d32480e5d27a9d91d13565478e5c3aebc2f8e4fd9c58bf07774eee5b65df3dc2cf4326bfcca7790ab2698ebc51d63cba7b82458707e72959b149
7
- data.tar.gz: c687adcd8d9b8abee8c85c3bd4ce30dd5393883b7993366ca85c502b748cb668dd150ff5977153b8f90278d36fecbc8f02b07aa3d88a138031f78da0a5376120
6
+ metadata.gz: f7e03ce00d239548a353a0fb5d1601d8af16303a384fd7c20176065a34a4a3345b8fda3bcc1c18d140858edda8e7544638226037bc2d20c74a1341de3ac62d9d
7
+ data.tar.gz: 0c7a894e1124d72608f9e493ce7db594780715c1c0e0a69345970d59b093dcf10bc4bc4b1f21f5db9a48bc4862838cb06851485958b19caa4f8085fb1227eacb
@@ -6,13 +6,9 @@ jobs:
6
6
  runs-on: ubuntu-latest
7
7
  strategy:
8
8
  matrix:
9
- activerecord-version: ["5.0", "5.1", "4.2", "5.2", "6.0", "6.1"]
9
+ activerecord-version: ["5.0", "5.1", "5.2", "6.0", "6.1"]
10
10
  ruby-version: ["2.6", "2.7", "3.0"]
11
11
  exclude:
12
- - activerecord-version: "4.2"
13
- ruby-version: "2.7"
14
- - activerecord-version: "4.2"
15
- ruby-version: "3.0"
16
12
  - activerecord-version: "5.0"
17
13
  ruby-version: "3.0"
18
14
  - activerecord-version: "5.1"
data/CHANGELOG.md CHANGED
@@ -1,24 +1,32 @@
1
1
  # ulid-rails CHANGELOG
2
2
 
3
- ## 0.6
3
+ ## 1.0.0
4
4
 
5
- - Add support for Rails 4.2, 5.0 and 5.1.
5
+ - Drop support for Rails 4.2.
6
6
 
7
- ## 0.5
7
+ ### Breaking Changes
8
+
9
+ - `primary_key` option has been removed. You need to specify `auto_generate: true` to automatically fill your primary key columns.
10
+
11
+ ## 0.6.0
12
+
13
+ - Add support for Rails 4.2, 5.0 and 5.1.
14
+
15
+ ## 0.5.0
8
16
 
9
17
  - Ensure ULID order respects timestamp order to millisecond precision.
10
18
  - Validation of ULID format when setting value. A wrong format value will trigger a `ULID::Rails::ArgumentError`.
11
19
 
12
- ## 0.4
20
+ ## 0.4.0
13
21
 
14
22
  - Support old ruby versions
15
23
  - Fix auto_generate #2
16
24
 
17
- ## 0.3
25
+ ## 0.3.0
18
26
 
19
27
  - Support PostgresQL
20
28
 
21
- ## 0.2
29
+ ## 0.2.0
22
30
 
23
31
  ### Breaking Changes
24
32
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ULID::Rails
2
2
 
3
- This gem makes it possible to use [ULID](https://github.com/ulid/spec) for DB primary keys in a Ruby on Rails app.
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
5
 
6
6
  ## Installation
@@ -41,7 +41,7 @@ Just add the below lines to your models.
41
41
  ```ruby
42
42
  class MyModel < ApplicationRecord
43
43
  include ULID::Rails
44
- ulid :id, primary_key: true # The first argument is the ULID column name
44
+ ulid :id, auto_generate: true # The first argument is the ULID column name
45
45
  end
46
46
  ```
47
47
 
@@ -53,7 +53,7 @@ Since ULID includes milli seconds precision timestamp, you don't need to store `
53
53
  ```ruby
54
54
  class MyModel < ApplicationRecord
55
55
  include ULID::Rails
56
- ulid :id, primary_key: true # The first argument is the ULID column name
56
+ ulid :id, auto_generate: true # The first argument is the ULID column name
57
57
 
58
58
  # defines `created_at` method which extract timestamp value from id column.
59
59
  # This way you don't need physical `created_at` column.
@@ -82,14 +82,13 @@ end
82
82
 
83
83
  ### Auto-generate ULID
84
84
 
85
- If `primary_key` is `true`, ULID is auto-generated before create by default.
86
- You can enable or disable auto-generation with `auto_generate` option.
85
+ If `auto_generate` is `true`, ULID is auto-generated before create by default.
86
+ If not specified, the default is `false`.
87
87
 
88
88
  ```
89
89
  class Model < ApplicationRecord
90
- ulid :id, primary_key: true # primary key. auto-generate enabled
90
+ ulid :id, auto_generate: true # auto-generate enabled
91
91
  ulid :foreign_key # auto-generate disabled
92
- ulid :ulid, auto_generate: true # non primary, auto-generate enabled
93
92
  end
94
93
  ```
95
94
 
@@ -1,21 +1,12 @@
1
+ require "active_model/type"
1
2
  require "ulid/rails/formatter"
2
3
  require "ulid/rails/validator"
3
4
  require "ulid/rails/errors"
4
- require "ulid/rails/constants"
5
5
 
6
6
  module ULID
7
7
  module Rails
8
- case RAILS_VERSION
9
- when "4.2"
10
- require "active_record/type"
11
- Binary = ActiveRecord::Type::Binary
12
- else
13
- require "active_model/type"
14
- Binary = ActiveModel::Type::Binary
15
- end
16
-
17
- class Type < Binary
18
- class Data < Binary::Data
8
+ class Type < ActiveModel::Type::Binary
9
+ class Data < ActiveModel::Type::Binary::Data
19
10
  alias_method :hex, :to_s
20
11
  end
21
12
 
@@ -50,16 +41,6 @@ module ULID
50
41
  end
51
42
  end
52
43
 
53
- if RAILS_4_2
54
- alias_method :type_cast_for_database, :serialize
55
- alias_method :type_cast_from_database, :deserialize
56
-
57
- def type_cast_from_user(value)
58
- assert_valid_value(value)
59
- super
60
- end
61
- end
62
-
63
44
  private
64
45
 
65
46
  def adapter
@@ -1,5 +1,5 @@
1
1
  module ULID
2
2
  module Rails
3
- VERSION = "0.6.0"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
data/lib/ulid/rails.rb CHANGED
@@ -1,21 +1,20 @@
1
1
  require "active_record"
2
2
  require "active_support/concern"
3
+ require "active_model/type"
3
4
  require "ulid"
4
5
  require "base32/crockford"
5
6
  require "ulid/rails/version"
6
7
  require "ulid/rails/type"
7
8
  require "ulid/rails/patch"
8
- require "ulid/rails/constants"
9
9
 
10
10
  module ULID
11
11
  module Rails
12
12
  extend ActiveSupport::Concern
13
13
 
14
14
  class_methods do
15
- def ulid(column_name, primary_key: false, auto_generate: nil)
15
+ def ulid(column_name, auto_generate: false)
16
16
  attribute column_name, ULID::Rails::Type.new
17
17
 
18
- auto_generate = primary_key || auto_generate
19
18
  if auto_generate
20
19
  before_create do
21
20
  send("#{column_name}=", ULID.generate) if send(column_name).nil?
@@ -45,11 +44,7 @@ module ULID
45
44
  end
46
45
  end
47
46
 
48
- unless RAILS_4_2
49
- require "active_model/type"
50
- ActiveModel::Type.register(:ulid, ULID::Rails::Type)
51
- end
52
-
47
+ ActiveModel::Type.register(:ulid, ULID::Rails::Type)
53
48
  ActiveRecord::ConnectionAdapters::TableDefinition.send :include, Patch::Migrations
54
49
  end
55
50
  end
data/ulid-rails.gemspec CHANGED
@@ -5,13 +5,22 @@ 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
9
  spec.authors = ["Kazunori Kajihiro", "Zendesk"]
9
10
  spec.email = ["kazunori.kajihiro@gmail.com", "ruby-core@zendesk.com"]
10
11
 
11
12
  spec.summary = "ULID for rails"
12
13
  spec.description = "ULID for rails"
14
+ spec.homepage = "https://github.com/k2nr/ulid-rails/"
13
15
  spec.license = "MIT"
14
16
 
17
+ spec.metadata = {
18
+ "changelog_uri" => "https://github.com/k2nr/ulid-rails/blob/master/CHANGELOG.md",
19
+ "source_code_uri" => "https://github.com/k2nr/ulid-rails/",
20
+ "bug_tracker_uri" => "https://github.com/k2nr/ulid-rails/issues",
21
+ "rubygems_mfa_required" => "true"
22
+ }
23
+
15
24
  # Specify which files should be added to the gem when it is released.
16
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
26
  spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
@@ -23,9 +32,9 @@ Gem::Specification.new do |spec|
23
32
 
24
33
  spec.add_dependency "ulid", "~> 1.0"
25
34
  spec.add_dependency "base32-crockford", "~> 0.1"
26
- spec.add_dependency "activesupport", ">= 4.2"
27
- spec.add_dependency "activemodel", ">= 4.2"
28
- spec.add_dependency "activerecord", ">= 4.2"
35
+ spec.add_dependency "activesupport", ">= 5.0"
36
+ spec.add_dependency "activemodel", ">= 5.0"
37
+ spec.add_dependency "activerecord", ">= 5.0"
29
38
  spec.add_development_dependency "bundler"
30
39
  spec.add_development_dependency "rake"
31
40
  spec.add_development_dependency "minitest", "~> 5.0"
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: 0.6.0
4
+ version: 1.0.0
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: 2021-11-11 00:00:00.000000000 Z
12
+ date: 2021-11-23 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: '4.2'
48
+ version: '5.0'
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: '4.2'
55
+ version: '5.0'
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: '4.2'
62
+ version: '5.0'
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: '4.2'
69
+ version: '5.0'
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: '4.2'
76
+ version: '5.0'
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: '4.2'
83
+ version: '5.0'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: bundler
86
86
  requirement: !ruby/object:Gem::Requirement
@@ -159,14 +159,12 @@ files:
159
159
  - bin/run_tests
160
160
  - bin/setup
161
161
  - docker-compose.yml
162
- - gemfiles/4.2.gemfile
163
162
  - gemfiles/5.0.gemfile
164
163
  - gemfiles/5.1.gemfile
165
164
  - gemfiles/5.2.gemfile
166
165
  - gemfiles/6.0.gemfile
167
166
  - gemfiles/6.1.gemfile
168
167
  - lib/ulid/rails.rb
169
- - lib/ulid/rails/constants.rb
170
168
  - lib/ulid/rails/errors.rb
171
169
  - lib/ulid/rails/formatter.rb
172
170
  - lib/ulid/rails/patch.rb
@@ -174,10 +172,14 @@ files:
174
172
  - lib/ulid/rails/validator.rb
175
173
  - lib/ulid/rails/version.rb
176
174
  - ulid-rails.gemspec
177
- homepage:
175
+ homepage: https://github.com/k2nr/ulid-rails/
178
176
  licenses:
179
177
  - MIT
180
- metadata: {}
178
+ metadata:
179
+ changelog_uri: https://github.com/k2nr/ulid-rails/blob/master/CHANGELOG.md
180
+ source_code_uri: https://github.com/k2nr/ulid-rails/
181
+ bug_tracker_uri: https://github.com/k2nr/ulid-rails/issues
182
+ rubygems_mfa_required: 'true'
181
183
  post_install_message:
182
184
  rdoc_options: []
183
185
  require_paths:
@@ -186,7 +188,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
186
188
  requirements:
187
189
  - - ">="
188
190
  - !ruby/object:Gem::Version
189
- version: '0'
191
+ version: 2.5.0
190
192
  required_rubygems_version: !ruby/object:Gem::Requirement
191
193
  requirements:
192
194
  - - ">="
data/gemfiles/4.2.gemfile DELETED
@@ -1,6 +0,0 @@
1
- gem "activesupport", "~> 4.2"
2
- gem "activemodel", "~> 4.2"
3
- gem "activerecord", "~> 4.2"
4
- gem "sqlite3", "~> 1.3.6"
5
- gem "mysql2", ">= 0.3.13", "< 0.6.0"
6
- gem "pg", "~> 0.15"
@@ -1,6 +0,0 @@
1
- module ULID
2
- module Rails
3
- RAILS_VERSION = "#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"
4
- RAILS_4_2 = RAILS_VERSION == "4.2"
5
- end
6
- end