uuidable 0.2.6 → 1.0.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: dcd18d2671d63318c004ef81436ee00b6e606780c44cca390b40852bf7f02e36
4
- data.tar.gz: c5af166c82e3fa9d61a83082ceb82b3fc2f2cdddafb931401624dca3a524001f
3
+ metadata.gz: 8f43acd04287f3d03ac22b80038131e2c28a8f1550f25d70aa16154eb163a364
4
+ data.tar.gz: e95a275d8d777f319791c7ce0e4001ab3024bd41f5b7c39276dac528eac492f3
5
5
  SHA512:
6
- metadata.gz: ed744b932a2ac2aac350d516a353a0b2f232ab51ececc71ee2772146c594f8ef07872ce4a2fbe36f2c377eba3c9c07388f03ed0ca56e26eebe995a4cc8c0ebff
7
- data.tar.gz: a495f3803242998373a70a1fd23244aec3d318fc27e80a9019461bf9fc02f80fa0c6ea9480bfe9c1a03dc64f87e908cf6bfc9a76a7325eb5c0a39371087960c9
6
+ metadata.gz: 98e8c6c2b5473183245bea43c8b3cc250f015db15726634c0aa0a184079ec5b8207c95c09145d7b527c78dde67e164463b21d170f50a0dd711d3a77c37e34d93
7
+ data.tar.gz: 55af82b9f9431d1ec3f4fe821954e05a342f4c23ae3e5827634245a745023350a507096c28f7bfa28acf725d14adc23509b53932c51790d80e4dde9bb100f317
@@ -0,0 +1,25 @@
1
+ name: Build + publish
2
+
3
+ on:
4
+ push:
5
+ tags: [ v* ]
6
+ jobs:
7
+ build:
8
+ name: Build + Publish
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v1
12
+
13
+ - name: Release Gem
14
+ if: contains(github.ref, 'refs/tags/v')
15
+ uses: cadwallion/publish-rubygems-action@master
16
+ env:
17
+ RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
18
+ RELEASE_COMMAND: bundle exec rake release
19
+ # steps:
20
+ # - uses: actions/checkout@v3
21
+ # - name: Set up Ruby
22
+ # uses: ruby/setup-ruby@v1
23
+ # with:
24
+ # ruby-version: .ruby-version
25
+ # bundler-cache: true
@@ -0,0 +1,37 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Test
9
+
10
+ on:
11
+ push:
12
+ branches: [ '*' ]
13
+
14
+ permissions:
15
+ contents: read
16
+
17
+ jobs:
18
+ test:
19
+ runs-on: ${{ matrix.os }}-latest
20
+ strategy:
21
+ matrix:
22
+ os: [ubuntu, macos]
23
+ ruby-version: ['2.7', '3.0', '3.1']
24
+
25
+ steps:
26
+ - uses: actions/checkout@v3
27
+ - name: Set up Ruby
28
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
29
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
30
+ uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: ${{ matrix.ruby-version }}
33
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
34
+ - name: Run rubocop
35
+ run: bundle exec rubocop
36
+ - name: Run tests
37
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /.history/
data/.rubocop.yml CHANGED
@@ -1,11 +1,14 @@
1
- Metrics/LineLength:
2
- Max: 120
1
+ AllCops:
2
+ NewCops: disable
3
+
4
+ Layout/LineLength:
5
+ Max: 140
3
6
 
4
7
  Metrics/CyclomaticComplexity:
5
8
  Max: 10
6
9
 
7
10
  Metrics/MethodLength:
8
- Max: 20
11
+ Max: 30
9
12
 
10
13
  Metrics/AbcSize:
11
14
  Max: 25
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in uuidable.gemspec
data/Gemfile.lock CHANGED
@@ -1,29 +1,41 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- uuidable (0.2.6)
5
- activerecord (>= 4.2, < 6.2)
4
+ uuidable (1.0.1)
5
+ activerecord (>= 4.2, < 7.2)
6
+ mysql-binuuid-rails (>= 1.3, < 2)
6
7
  uuidtools (>= 2.1, < 3)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
11
- activemodel (6.1.3)
12
- activesupport (= 6.1.3)
13
- activerecord (6.1.3)
14
- activemodel (= 6.1.3)
15
- activesupport (= 6.1.3)
16
- activesupport (6.1.3)
12
+ activemodel (7.1.3.2)
13
+ activesupport (= 7.1.3.2)
14
+ activerecord (7.1.3.2)
15
+ activemodel (= 7.1.3.2)
16
+ activesupport (= 7.1.3.2)
17
+ timeout (>= 0.4.0)
18
+ activesupport (7.1.3.2)
19
+ base64
20
+ bigdecimal
17
21
  concurrent-ruby (~> 1.0, >= 1.0.2)
22
+ connection_pool (>= 2.2.5)
23
+ drb
18
24
  i18n (>= 1.6, < 2)
19
25
  minitest (>= 5.1)
26
+ mutex_m
20
27
  tzinfo (~> 2.0)
21
- zeitwerk (~> 2.3)
22
- addressable (2.4.0)
23
- ast (2.3.0)
28
+ addressable (2.8.0)
29
+ public_suffix (>= 2.0.2, < 5.0)
30
+ ast (2.4.2)
24
31
  backports (3.6.8)
25
- concurrent-ruby (1.1.8)
26
- diff-lcs (1.2.5)
32
+ base64 (0.2.0)
33
+ bigdecimal (3.1.6)
34
+ concurrent-ruby (1.2.3)
35
+ connection_pool (2.4.1)
36
+ diff-lcs (1.5.0)
37
+ drb (2.2.0)
38
+ ruby2_keywords
27
39
  ethon (0.8.1)
28
40
  ffi (>= 1.3.0)
29
41
  faraday (0.9.2)
@@ -39,47 +51,58 @@ GEM
39
51
  net-http-persistent (>= 2.7)
40
52
  net-http-pipeline
41
53
  highline (1.7.8)
42
- i18n (1.8.9)
54
+ i18n (1.14.1)
43
55
  concurrent-ruby (~> 1.0)
44
56
  json (2.3.1)
45
57
  launchy (2.4.3)
46
58
  addressable (~> 2.3)
47
- minitest (5.14.4)
59
+ minitest (5.22.2)
48
60
  multi_json (1.11.2)
49
61
  multipart-post (2.0.0)
62
+ mutex_m (0.2.0)
63
+ mysql-binuuid-rails (1.3.0)
64
+ activerecord (>= 5)
50
65
  net-http-persistent (2.9.4)
51
66
  net-http-pipeline (1.0.1)
52
- parallel (1.12.0)
53
- parser (2.4.0.2)
54
- ast (~> 2.3)
55
- powerpack (0.1.1)
67
+ parallel (1.22.1)
68
+ parser (3.1.2.0)
69
+ ast (~> 2.4.1)
70
+ public_suffix (4.0.7)
56
71
  pusher-client (0.6.2)
57
72
  json
58
73
  websocket (~> 1.0)
59
- rainbow (2.2.2)
60
- rake
61
- rake (13.0.1)
62
- rspec (3.4.0)
63
- rspec-core (~> 3.4.0)
64
- rspec-expectations (~> 3.4.0)
65
- rspec-mocks (~> 3.4.0)
66
- rspec-core (3.4.3)
67
- rspec-support (~> 3.4.0)
68
- rspec-expectations (3.4.0)
74
+ rainbow (3.1.1)
75
+ rake (13.0.6)
76
+ regexp_parser (2.5.0)
77
+ rexml (3.2.5)
78
+ rspec (3.11.0)
79
+ rspec-core (~> 3.11.0)
80
+ rspec-expectations (~> 3.11.0)
81
+ rspec-mocks (~> 3.11.0)
82
+ rspec-core (3.11.0)
83
+ rspec-support (~> 3.11.0)
84
+ rspec-expectations (3.11.0)
69
85
  diff-lcs (>= 1.2.0, < 2.0)
70
- rspec-support (~> 3.4.0)
71
- rspec-mocks (3.4.1)
86
+ rspec-support (~> 3.11.0)
87
+ rspec-mocks (3.11.1)
72
88
  diff-lcs (>= 1.2.0, < 2.0)
73
- rspec-support (~> 3.4.0)
74
- rspec-support (3.4.1)
75
- rubocop (0.50.0)
89
+ rspec-support (~> 3.11.0)
90
+ rspec-support (3.11.0)
91
+ rubocop (1.32.0)
92
+ json (~> 2.3)
76
93
  parallel (~> 1.10)
77
- parser (>= 2.3.3.1, < 3.0)
78
- powerpack (~> 0.1)
79
- rainbow (>= 2.2.2, < 3.0)
94
+ parser (>= 3.1.0.0)
95
+ rainbow (>= 2.2.2, < 4.0)
96
+ regexp_parser (>= 1.8, < 3.0)
97
+ rexml (>= 3.2.5, < 4.0)
98
+ rubocop-ast (>= 1.19.1, < 2.0)
80
99
  ruby-progressbar (~> 1.7)
81
- unicode-display_width (~> 1.0, >= 1.0.1)
82
- ruby-progressbar (1.9.0)
100
+ unicode-display_width (>= 1.4.0, < 3.0)
101
+ rubocop-ast (1.19.1)
102
+ parser (>= 3.1.1.0)
103
+ ruby-progressbar (1.11.0)
104
+ ruby2_keywords (0.0.5)
105
+ timeout (0.4.1)
83
106
  travis (1.8.2)
84
107
  backports
85
108
  faraday (~> 0.9)
@@ -91,18 +114,17 @@ GEM
91
114
  typhoeus (~> 0.6, >= 0.6.8)
92
115
  typhoeus (0.8.0)
93
116
  ethon (>= 0.8.0)
94
- tzinfo (2.0.4)
117
+ tzinfo (2.0.6)
95
118
  concurrent-ruby (~> 1.0)
96
- unicode-display_width (1.3.0)
119
+ unicode-display_width (2.2.0)
97
120
  uuidtools (2.2.0)
98
121
  websocket (1.2.2)
99
- zeitwerk (2.4.2)
100
122
 
101
123
  PLATFORMS
102
124
  ruby
103
125
 
104
126
  DEPENDENCIES
105
- bundler (~> 1.11)
127
+ bundler (~> 2.4)
106
128
  rake (~> 13.0)
107
129
  rspec (~> 3.0)
108
130
  rubocop
@@ -110,4 +132,4 @@ DEPENDENCIES
110
132
  uuidable!
111
133
 
112
134
  BUNDLED WITH
113
- 1.17.3
135
+ 2.4.22
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
- # Uuidable [![Build Status](https://travis-ci.org/flant/uuidable.svg?branch=master)](https://travis-ci.org/flant/uuidable)
1
+ # Uuidable
2
+
3
+ [![Build](https://github.com/flant/uuidable/actions/workflows/ruby.yml/badge.svg)](https://github.com/flant/uuidable/actions/workflows/ruby.yml) [![Gem Version](https://badge.fury.io/rb/uuidable.svg)](https://badge.fury.io/rb/uuidable)
2
4
 
3
5
  With this gem you can use UUID instead of id in routes. But id is still primary key.
4
6
 
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'uuidable'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Uuidable
2
4
  # ActiveRecord mixin
3
5
  module ActiveRecord
@@ -7,7 +9,7 @@ module Uuidable
7
9
 
8
10
  module Finder
9
11
  def find(*args)
10
- if args.first && args.first.is_a?(String) && args.first.match(UUIDTools::UUID_REGEXP)
12
+ if args.first.is_a?(String) && args.first&.match(UUIDTools::UUID_REGEXP)
11
13
  find_by_uuid!(*args)
12
14
  else
13
15
  super
@@ -19,8 +21,24 @@ module Uuidable
19
21
  module ClassMethods
20
22
  include Finder
21
23
 
22
- def uuidable(as_param: true)
23
- after_initialize { self.uuid = Uuidable.generate_uuid if attributes.keys.include?('uuid') && uuid.blank? }
24
+ def uuidable(as_param: true) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
25
+ # Configure all uuid columns for MySQL. Database may not be connected (i.e. on assets precompile), so we must supress errors.
26
+ conn_config = respond_to?(:connection_db_config) ? connection_db_config.configuration_hash : connection_config
27
+
28
+ if conn_config[:adapter].include?('mysql') && schema_loaded?
29
+ begin
30
+ columns.select { |c| c.type == :binary && c.limit == 16 && c.name.include?('uuid') }.each do |column|
31
+ attribute column.name.to_sym, MySQLBinUUID::Type.new
32
+ end
33
+ rescue ::ActiveRecord::ConnectionNotEstablished, Mysql2::Error::ConnectionError, ::ActiveRecord::NoDatabaseError # rubocop:disable Lint/SuppressedException
34
+ end
35
+ end
36
+
37
+ after_initialize do
38
+ self.uuid = Uuidable.generate_uuid if attributes.keys.include?('uuid') && uuid.blank?
39
+ self.uuid__old = uuid if respond_to?(:uuid__old)
40
+ end
41
+
24
42
  validates :uuid, presence: true, uniqueness: true, if: :uuid_changed?
25
43
 
26
44
  if as_param
@@ -44,6 +62,6 @@ module Uuidable
44
62
  end
45
63
 
46
64
  ActiveSupport.on_load(:active_record) do
47
- ActiveRecord::Base.send(:include, Uuidable::ActiveRecord)
48
- ActiveRecord::Relation.send(:prepend, Uuidable::ActiveRecord::Finder)
65
+ ActiveRecord::Base.include Uuidable::ActiveRecord
66
+ ActiveRecord::Relation.prepend Uuidable::ActiveRecord::Finder
49
67
  end
@@ -1,31 +1,33 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Uuidable
2
4
  COLUMN_NAME = :uuid
3
5
  COLUMN_TYPE = :binary
4
- COLUMN_OPTIONS = { limit: 36, null: false }.freeze
6
+ COLUMN_OPTIONS = { limit: 16, null: false }.freeze
5
7
  INDEX_OPTIONS = { unique: true }.freeze
6
8
 
7
9
  # Module adds method to table definition
8
10
  module TableDefinition
9
- def uuid(opts = {})
11
+ def uuid(column_name = COLUMN_NAME, **opts)
10
12
  index_opts = opts.delete(:index)
11
13
  index_opts = {} if index_opts.nil?
12
14
 
13
- column_name = opts.delete(:column_name) || COLUMN_NAME
15
+ column_name ||= opts.delete(:column_name)
14
16
 
15
- column column_name, COLUMN_TYPE, COLUMN_OPTIONS.merge(opts)
16
- index column_name, INDEX_OPTIONS.merge(index_opts) if index_opts
17
+ column column_name, COLUMN_TYPE, **COLUMN_OPTIONS.merge(opts)
18
+ index column_name, **INDEX_OPTIONS.merge(index_opts) if index_opts
17
19
  end
18
20
  end
19
21
 
20
22
  # Module adds method to alter table migration
21
23
  module Migration
22
- def add_uuid_column(table_name, opts = {})
24
+ def add_uuid_column(table_name, column_name = COLUMN_NAME, **opts)
23
25
  index_opts = opts.delete(:index)
24
26
  index_opts = {} if index_opts == true
25
27
 
26
- column_name = opts.delete(:column_name) || COLUMN_NAME
28
+ column_name ||= opts.delete(:column_name)
27
29
 
28
- add_column table_name, column_name, COLUMN_TYPE, COLUMN_OPTIONS.merge(opts)
30
+ add_column table_name, column_name, COLUMN_TYPE, **COLUMN_OPTIONS.merge(opts)
29
31
 
30
32
  add_uuid_index(table_name, index_opts.merge(column_name: column_name)) if index_opts
31
33
  end
@@ -33,13 +35,13 @@ module Uuidable
33
35
  def add_uuid_index(table_name, opts = {})
34
36
  column_name = opts.delete(:column_name) || COLUMN_NAME
35
37
 
36
- add_index table_name, column_name, INDEX_OPTIONS.merge(opts)
38
+ add_index table_name, column_name, **INDEX_OPTIONS.merge(opts)
37
39
  end
38
40
  end
39
41
  end
40
42
 
41
43
  if defined? ActiveRecord::ConnectionAdapters::TableDefinition
42
- ActiveRecord::ConnectionAdapters::TableDefinition.send :include, Uuidable::TableDefinition
44
+ ActiveRecord::ConnectionAdapters::TableDefinition.include Uuidable::TableDefinition
43
45
  end
44
46
 
45
- ActiveRecord::Migration.send :include, Uuidable::Migration if defined? ActiveRecord::Migration
47
+ ActiveRecord::Migration.include Uuidable::Migration if defined? ActiveRecord::Migration
@@ -0,0 +1,143 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable all
4
+ module Uuidable
5
+ module V1MigrationHelpers
6
+ NEW_POSTFIX = '__new'
7
+ OLD_POSTFIX = '__old'
8
+
9
+ # Will create uuid columns with new type, move data from pre-v1 column and then move pre-v1 to *__old.
10
+ # WARNING: will only work on MySQL 8+.
11
+ def uuidable_migrate_uuid_columns_to_v1(table_name, columns_options = {}, **opts)
12
+ columns_options.stringify_keys!
13
+ uuid_columns = connection.columns(table_name).select do |column|
14
+ (columns_options.blank? || columns_options.key?(column.name)) &&
15
+ valid_column_for_migration?(column, **opts)
16
+ end
17
+
18
+ return if uuid_columns.blank?
19
+
20
+ indexes = indexes_with_columns(table_name, uuid_columns)
21
+
22
+ change_table table_name, bulk: true do |t|
23
+ uuid_columns.each do |column|
24
+ options = columns_options[column.name] || { null: column.null }
25
+ t.column :"#{column.name}#{NEW_POSTFIX}", :binary, **COLUMN_OPTIONS.merge(options).merge(after: column.name)
26
+ end
27
+ end
28
+
29
+ update = uuid_columns.map do |column, _opts|
30
+ <<~SQL
31
+ `#{table_name}`.`#{column.name}#{NEW_POSTFIX}` = IF(
32
+ IS_UUID(`#{table_name}`.`#{column.name}`),
33
+ UUID_TO_BIN(`#{table_name}`.`#{column.name}`),
34
+ `#{table_name}`.`#{column.name}`
35
+ )
36
+ SQL
37
+ end.join(', ')
38
+
39
+ execute "UPDATE `#{table_name}` SET #{update}"
40
+
41
+ change_table table_name, bulk: true do |t|
42
+ uuid_columns.each do |column|
43
+ t.rename column.name, :"#{column.name}#{OLD_POSTFIX}"
44
+ t.rename :"#{column.name}#{NEW_POSTFIX}", column.name
45
+ end
46
+
47
+ indexes.each do |ind|
48
+ t.remove_index name: ind.name
49
+ end
50
+ end
51
+
52
+ # recreate indexes with new column
53
+ change_table table_name, bulk: true do |t|
54
+ indexes.each do |ind|
55
+ t.index ind.columns, name: ind.name, unique: ind.unique
56
+ end
57
+ end
58
+ end
59
+
60
+ # WARNING: will only work until *__old columns is not deleted!
61
+ def uuidable_rollback_uuid_columns_from_v1(table_name, *columns)
62
+ columns.map!(&:to_s)
63
+ indexes = indexes(table_name)
64
+
65
+ uuid_columns = connection.columns(table_name).select do |column|
66
+ (columns.blank? || columns.include?(column.name)) &&
67
+ valid_column_for_migration?(column, limit: 16)
68
+ end
69
+
70
+ return if uuid_columns.blank?
71
+
72
+ indexes = indexes_with_columns(table_name, uuid_columns)
73
+
74
+ change_table table_name, bulk: true do |t|
75
+ uuid_columns.each do |column|
76
+ t.rename column.name, :"#{column.name}#{NEW_POSTFIX}"
77
+ t.rename :"#{column.name}#{OLD_POSTFIX}", column.name
78
+ end
79
+
80
+ indexes.each do |ind|
81
+ t.remove_index name: ind.name
82
+ end
83
+ end
84
+
85
+ change_table table_name, bulk: true do |t|
86
+ uuid_columns.each do |column|
87
+ t.remove :"#{column.name}#{NEW_POSTFIX}"
88
+ end
89
+
90
+ indexes.each do |ind|
91
+ t.index name: ind.name, unique: ind.unique
92
+ end
93
+ end
94
+ end
95
+
96
+ def uuidable_migrate_all_pre_v1_uuid_columns!
97
+ tables.each do |table_name|
98
+ uuidable_migrate_uuid_columns_to_v1 table_name
99
+ end
100
+ end
101
+
102
+ def uuidable_rollback_all_pre_v1_uuid_columns!
103
+ tables.each do |table_name|
104
+ uuidable_rollback_uuid_columns_from_v1 table_name
105
+ end
106
+ end
107
+
108
+ # WARNING: this is irreversible migration! It will drop all *uuid__old columns and their indexes in all tables!
109
+ def uuidable_drop_all_pre_v1_uuid_columns!
110
+ tables.each do |table_name|
111
+ indexes = indexes(table_name)
112
+ change_table table_name, bulk: true do |t|
113
+ connection.columns(table_name).each do |column|
114
+ next unless column.name.include?(OLD_POSTFIX)
115
+
116
+ indexes.each do |ind|
117
+ next unless ind.columns.include?(column.name)
118
+
119
+ t.remove_index name: ind.name
120
+ end
121
+
122
+ t.remove column.name
123
+ end
124
+ end
125
+ end
126
+ end
127
+
128
+ def valid_column_for_migration?(column, limit: 36, skip_type_check: false)
129
+ column.name.include?('uuid') &&
130
+ !column.name.include?(NEW_POSTFIX) &&
131
+ !column.name.include?(OLD_POSTFIX) &&
132
+ (skip_type_check || (
133
+ column.type == :binary &&
134
+ column.limit == limit
135
+ ))
136
+ end
137
+
138
+ def indexes_with_columns(table_name, columns)
139
+ indexes(table_name).select { |ind| (ind.columns & columns.map(&:name)).any? }
140
+ end
141
+ end
142
+ end
143
+ # rubocop:enable all
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Uuidable
2
- VERSION = '0.2.6'.freeze
4
+ VERSION = '1.0.1'
3
5
  end
data/lib/uuidable.rb CHANGED
@@ -1,7 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'uuidable/version'
2
- require 'active_support'
4
+ require 'active_model'
3
5
  require 'uuidtools'
4
6
 
7
+ require 'mysql-binuuid-rails'
8
+
5
9
  # Main module
6
10
  module Uuidable
7
11
  module_function
@@ -12,4 +16,5 @@ module Uuidable
12
16
  end
13
17
 
14
18
  require 'uuidable/migration'
19
+ require 'uuidable/v1_migration_helpers'
15
20
  require 'uuidable/active_record'
data/uuidable.gemspec CHANGED
@@ -1,4 +1,6 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require 'uuidable/version'
4
6
 
@@ -18,11 +20,14 @@ Gem::Specification.new do |spec|
18
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
21
  spec.require_paths = ['lib']
20
22
 
21
- spec.add_development_dependency 'bundler', '~> 1.11'
23
+ spec.required_ruby_version = '>= 2.7'
24
+
25
+ spec.add_development_dependency 'bundler', '~> 2.4'
22
26
  spec.add_development_dependency 'rake', '~> 13.0'
23
27
  spec.add_development_dependency 'rspec', '~> 3.0'
24
28
  spec.add_development_dependency 'travis', '~> 1.8', '>= 1.8.2'
25
29
 
26
- spec.add_dependency 'activerecord', '>= 4.2', '< 6.2'
30
+ spec.add_dependency 'activerecord', '>= 4.2', '< 7.2'
31
+ spec.add_dependency 'mysql-binuuid-rails', '>= 1.3', '< 2'
27
32
  spec.add_dependency 'uuidtools', '>= 2.1', '< 3'
28
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uuidable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Gnuskov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-15 00:00:00.000000000 Z
11
+ date: 2024-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.11'
19
+ version: '2.4'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.11'
26
+ version: '2.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -81,7 +81,7 @@ dependencies:
81
81
  version: '4.2'
82
82
  - - "<"
83
83
  - !ruby/object:Gem::Version
84
- version: '6.2'
84
+ version: '7.2'
85
85
  type: :runtime
86
86
  prerelease: false
87
87
  version_requirements: !ruby/object:Gem::Requirement
@@ -91,7 +91,27 @@ dependencies:
91
91
  version: '4.2'
92
92
  - - "<"
93
93
  - !ruby/object:Gem::Version
94
- version: '6.2'
94
+ version: '7.2'
95
+ - !ruby/object:Gem::Dependency
96
+ name: mysql-binuuid-rails
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '1.3'
102
+ - - "<"
103
+ - !ruby/object:Gem::Version
104
+ version: '2'
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '1.3'
112
+ - - "<"
113
+ - !ruby/object:Gem::Version
114
+ version: '2'
95
115
  - !ruby/object:Gem::Dependency
96
116
  name: uuidtools
97
117
  requirement: !ruby/object:Gem::Requirement
@@ -119,11 +139,12 @@ executables: []
119
139
  extensions: []
120
140
  extra_rdoc_files: []
121
141
  files:
142
+ - ".github/workflows/gem-push.yml"
143
+ - ".github/workflows/ruby.yml"
122
144
  - ".gitignore"
123
145
  - ".overcommit.yml"
124
146
  - ".rspec"
125
147
  - ".rubocop.yml"
126
- - ".travis.yml"
127
148
  - Gemfile
128
149
  - Gemfile.lock
129
150
  - LICENSE.txt
@@ -134,13 +155,14 @@ files:
134
155
  - lib/uuidable.rb
135
156
  - lib/uuidable/active_record.rb
136
157
  - lib/uuidable/migration.rb
158
+ - lib/uuidable/v1_migration_helpers.rb
137
159
  - lib/uuidable/version.rb
138
160
  - uuidable.gemspec
139
161
  homepage: https://github.com/flant/uuidable
140
162
  licenses:
141
163
  - MIT
142
164
  metadata: {}
143
- post_install_message:
165
+ post_install_message:
144
166
  rdoc_options: []
145
167
  require_paths:
146
168
  - lib
@@ -148,15 +170,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
170
  requirements:
149
171
  - - ">="
150
172
  - !ruby/object:Gem::Version
151
- version: '0'
173
+ version: '2.7'
152
174
  required_rubygems_version: !ruby/object:Gem::Requirement
153
175
  requirements:
154
176
  - - ">="
155
177
  - !ruby/object:Gem::Version
156
178
  version: '0'
157
179
  requirements: []
158
- rubygems_version: 3.0.8
159
- signing_key:
180
+ rubygems_version: 3.5.3
181
+ signing_key:
160
182
  specification_version: 4
161
183
  summary: Helps using uuid everywhere in routes instead of id for ActiveRecord models.
162
184
  test_files: []
data/.travis.yml DELETED
@@ -1,15 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.5.1
4
- before_install: gem install bundler -v 1.17.3
5
- script:
6
- - bundle exec rubocop
7
- - bundle exec rspec
8
- deploy:
9
- provider: rubygems
10
- api_key:
11
- secure: UrlqP2DVITJ7IfNWyJAL1981jzQlrRaBoOINDvaea1fSf54U0Bf4zvhiad/5ZMml8dv07sLnp4+gDyZW2jnxae+44A4BxxOYD8UGmEztSjFfQrR6Mbe7vapTatJ4r86c5kv/ea/seUQyy4JgR7cy6MlsFj6HJIw01IiIz3XDMF0hL0C2PXwtCnWgamgnDE6Eqrj/DJ2qhJf/8ELl53N/4fPfnFZKNXzUHhqJqNFgXmoQ092dhkkjmwSZqg0KyANLC1zMW0fqBGpX29/b2QCw0AQDWDlRstA6y2MaVnCGmAE37xZBbO7w03g1Neyjovoz2SklR3z16zmFMx/b6MGDTmnFtMFD6rNn0Paac5zO8U9UmrL4kCUicF9muekneh26Ba9IBIUc/BjujK+yzRHVX3ycdhKz263P1m5PrmJk4VO6OZxSN7rjHPHoz5dy864h1kfhQUQ7o/RxpN5N5i9/fUHH88dYq8mELRQtZGJl3DqJrv6S2NN67/3VLsbPD2LoO01YMKhJmu6MKQzcjGYaA/wjdPWHVsoORvWEY0oWEMrI8qIOCDQH9D1JPyhBUF35jgKI4AcgLNkboByKXdyZD+qklsy8pCl4BtQHtpowZ5/UOp1wi9K5RkU9AwD4RqNz5czliTyjOn5kICdgrdBk6LmU280sdynSlyxOK6AA1g4=
12
- gem: uuidable
13
- on:
14
- tags: true
15
- repo: flant/uuidable