ar-uuid 0.2.0 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/bin/console ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "ar-uuid"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ begin
11
+ require "pry"
12
+ Pry.start
13
+ rescue LoadError
14
+ require "irb"
15
+ IRB.start(__FILE__)
16
+ end
data/bin/setup ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ IFS=$'\n\t'
6
+ set -vx
7
+
8
+ bundle install
9
+
10
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec path: ".."
5
+ gem "activerecord", "~> 6.0.0"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec path: ".."
5
+ gem "activerecord", "~> 6.1.0"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec path: ".."
5
+ gem "activerecord", "~> 7.0.0"
@@ -1,6 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ActiveSupport.on_load(:active_record) do
2
4
  require "active_record/connection_adapters/postgresql_adapter"
3
5
 
4
- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include ActiveRecord::UUID::Schema
5
- ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition.include ActiveRecord::UUID::TableDefinition
6
+ ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include(
7
+ AR::UUID::Schema
8
+ )
9
+
10
+ ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition.include(
11
+ AR::UUID::TableDefinition
12
+ )
6
13
  end
@@ -1,14 +1,16 @@
1
- module ActiveRecord
1
+ # frozen_string_literal: true
2
+
3
+ module AR
2
4
  module UUID
3
5
  module Schema
4
6
  def create_table(table_name, options = {}, &block)
5
7
  options[:id] = :uuid unless options.key?(:id)
6
- super(table_name, options, &block)
8
+ super(table_name, **options, &block)
7
9
  end
8
10
 
9
11
  def add_reference(table_name, ref_name, options = {})
10
12
  options[:type] = :uuid unless options.key?(:type)
11
- super(table_name, ref_name, options)
13
+ super(table_name, ref_name, **options)
12
14
  end
13
15
  end
14
16
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AR
4
+ module UUID
5
+ module TableDefinition
6
+ def references(*args)
7
+ options = args.extract_options!
8
+ options[:type] = :uuid unless options.include?(:type)
9
+
10
+ unless options.include?(:null)
11
+ options[:null] =
12
+ !::AR::UUID::Utils.belongs_to_required_by_default
13
+ end
14
+
15
+ super(*args, **options)
16
+ end
17
+ alias belongs_to references
18
+
19
+ def primary_key(name, type = :primary_key, **options)
20
+ options[:default] = ::AR::UUID::Utils.uuid_default_function
21
+ super(name, type, **options)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,13 +1,18 @@
1
- module ActiveRecord
1
+ # frozen_string_literal: true
2
+
3
+ module AR
2
4
  module UUID
3
5
  MissingExtensionError = Class.new(StandardError) do
4
6
  def initialize
5
- super(%[Use either `enable_extension "uuid-ossp"` or `enable_extension "pgcrypto"`])
7
+ super(
8
+ 'Use either `enable_extension "uuid-ossp"` or' \
9
+ '`enable_extension "pgcrypto"`'
10
+ )
6
11
  end
7
12
  end
8
13
 
9
14
  module Utils
10
- EXTENSIONS_SQL = <<-SQL.freeze
15
+ EXTENSIONS_SQL = <<~SQL
11
16
  select
12
17
  extname
13
18
  from pg_extension
@@ -17,15 +22,16 @@ module ActiveRecord
17
22
  limit 1
18
23
  SQL
19
24
 
20
- FUNCTION_NAMES = {
25
+ FUNCTION_NAMES = { # rubocop:disable Style/MutableConstant
21
26
  "uuid-ossp" => "uuid_generate_v4()",
22
27
  "pgcrypto" => "gen_random_uuid()"
23
- }.freeze
28
+ }
24
29
 
25
30
  def self.uuid_extname
26
31
  connection = ::ActiveRecord::Base.connection
27
32
  result = connection.execute(EXTENSIONS_SQL).first
28
33
  raise MissingExtensionError unless result
34
+
29
35
  result.fetch("extname")
30
36
  end
31
37
 
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AR
4
+ module UUID
5
+ VERSION = "0.2.3"
6
+ end
7
+ end
data/lib/ar/uuid.rb ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AR
4
+ module UUID
5
+ require "active_record"
6
+ require "active_record/base"
7
+ require "ar/uuid/version"
8
+ require "ar/uuid/schema"
9
+ require "ar/uuid/table_definition"
10
+ require "ar/uuid/ext"
11
+ require "ar/uuid/utils"
12
+ end
13
+ end
data/lib/ar-uuid.rb CHANGED
@@ -1 +1,3 @@
1
- require "active_record/uuid"
1
+ # frozen_string_literal: true
2
+
3
+ require "ar/uuid"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar-uuid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-24 00:00:00.000000000 Z
11
+ date: 2022-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: minitest-utils
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: minitest-utils
56
+ name: mocha
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: mocha
70
+ name: pg
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: pg
84
+ name: pry-meta
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: pry-meta
98
+ name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: codeclimate-test-reporter
112
+ name: rubocop
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -122,39 +122,77 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
- description: Add UUID support for ActiveRecord. It enforces uuid primary keys, fixes
126
- ActiveRecord"s first/last methods and more.
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-fnando
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: Override migration methods to support UUID columns without having to
154
+ be explicit about it.
127
155
  email:
128
156
  - fnando.vieira@gmail.com
129
157
  executables: []
130
158
  extensions: []
131
159
  extra_rdoc_files: []
132
160
  files:
161
+ - ".github/FUNDING.yml"
162
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
163
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
164
+ - ".github/PULL_REQUEST_TEMPLATE.md"
165
+ - ".github/dependabot.yml"
166
+ - ".github/workflows/ruby-tests.yml"
133
167
  - ".gitignore"
134
- - ".travis.yml"
168
+ - ".rubocop.yml"
169
+ - CHANGELOG.md
170
+ - CODE_OF_CONDUCT.md
171
+ - CONTRIBUTING.md
135
172
  - Gemfile
173
+ - LICENSE.md
136
174
  - LICENSE.txt
137
175
  - README.md
138
176
  - Rakefile
139
177
  - ar-uuid.gemspec
140
- - gemfiles/4_2.gemfile
141
- - gemfiles/4_2.gemfile.lock
142
- - gemfiles/5_0.gemfile
143
- - gemfiles/5_0.gemfile.lock
144
- - gemfiles/5_1.gemfile
145
- - gemfiles/5_1.gemfile.lock
146
- - lib/active_record/uuid.rb
147
- - lib/active_record/uuid/ext.rb
148
- - lib/active_record/uuid/schema.rb
149
- - lib/active_record/uuid/table_definition.rb
150
- - lib/active_record/uuid/utils.rb
151
- - lib/active_record/uuid/version.rb
178
+ - bin/console
179
+ - bin/setup
180
+ - gemfiles/6_0.gemfile
181
+ - gemfiles/6_1.gemfile
182
+ - gemfiles/7_0.gemfile
152
183
  - lib/ar-uuid.rb
184
+ - lib/ar/uuid.rb
185
+ - lib/ar/uuid/ext.rb
186
+ - lib/ar/uuid/schema.rb
187
+ - lib/ar/uuid/table_definition.rb
188
+ - lib/ar/uuid/utils.rb
189
+ - lib/ar/uuid/version.rb
153
190
  homepage: http://rubygems.org/gems/ar-uuid
154
191
  licenses:
155
192
  - MIT
156
- metadata: {}
157
- post_install_message:
193
+ metadata:
194
+ rubygems_mfa_required: 'true'
195
+ post_install_message:
158
196
  rdoc_options: []
159
197
  require_paths:
160
198
  - lib
@@ -162,17 +200,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
200
  requirements:
163
201
  - - ">="
164
202
  - !ruby/object:Gem::Version
165
- version: '0'
203
+ version: 2.7.0
166
204
  required_rubygems_version: !ruby/object:Gem::Requirement
167
205
  requirements:
168
206
  - - ">="
169
207
  - !ruby/object:Gem::Version
170
208
  version: '0'
171
209
  requirements: []
172
- rubyforge_project:
173
- rubygems_version: 2.6.11
174
- signing_key:
210
+ rubygems_version: 3.3.7
211
+ signing_key:
175
212
  specification_version: 4
176
- summary: Add UUID support for ActiveRecord. It enforces uuid primary keys, fixes ActiveRecord"s
177
- first/last methods and more.
213
+ summary: Override migration methods to support UUID columns without having to be explicit
214
+ about it.
178
215
  test_files: []
data/.travis.yml DELETED
@@ -1,22 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache: bundler
4
- before_install:
5
- - gem install bundler
6
- before_script:
7
- - createdb test
8
- addons:
9
- postgresql: "9.4"
10
- rvm:
11
- - 2.4.1
12
- gemfile:
13
- - gemfiles/5_1.gemfile
14
- - gemfiles/5_0.gemfile
15
- - gemfiles/4_2.gemfile
16
- env:
17
- global:
18
- secure: jx2vy7MRmkFfs2DUx4+Yh7sxMw8yYlPyZuGt4f3S1Myb3voOrsht/9mJ5QENhKX/Rx+u5BBHCPS/YgKZKb12xYCQZwH3NLTk0etQZCykFfgtOmKYEJmIro/61Ctqdz/lo9LUQ3PRxs0bfvlOeygGTc6+XmK2KpyYF1RSIPJ+A2s=
19
- notifications:
20
- email: false
21
- after_success:
22
- - bundle exec codeclimate-test-reporter
data/gemfiles/4_2.gemfile DELETED
@@ -1,3 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec path: ".."
3
- gem "activerecord", "~> 4.2.0"
@@ -1,81 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- ar-uuid (0.1.2)
5
- activerecord
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (4.2.8)
11
- activesupport (= 4.2.8)
12
- builder (~> 3.1)
13
- activerecord (4.2.8)
14
- activemodel (= 4.2.8)
15
- activesupport (= 4.2.8)
16
- arel (~> 6.0)
17
- activesupport (4.2.8)
18
- i18n (~> 0.7)
19
- minitest (~> 5.1)
20
- thread_safe (~> 0.3, >= 0.3.4)
21
- tzinfo (~> 1.1)
22
- arel (6.0.4)
23
- awesome_print (1.8.0)
24
- builder (3.2.3)
25
- byebug (9.0.6)
26
- codeclimate-test-reporter (1.0.8)
27
- simplecov (<= 0.13)
28
- coderay (1.1.1)
29
- docile (1.1.5)
30
- i18n (0.8.4)
31
- json (2.1.0)
32
- metaclass (0.0.4)
33
- method_source (0.8.2)
34
- minitest (5.10.2)
35
- minitest-utils (0.3.1)
36
- minitest
37
- mocha (1.2.1)
38
- metaclass (~> 0.0.1)
39
- pg (0.21.0)
40
- pry (0.10.4)
41
- coderay (~> 1.1.0)
42
- method_source (~> 0.8.1)
43
- slop (~> 3.4)
44
- pry-byebug (3.4.2)
45
- byebug (~> 9.0)
46
- pry (~> 0.10)
47
- pry-meta (0.0.10)
48
- awesome_print
49
- pry
50
- pry-byebug
51
- pry-remote
52
- pry-remote (0.1.8)
53
- pry (~> 0.9)
54
- slop (~> 3.0)
55
- rake (12.0.0)
56
- simplecov (0.13.0)
57
- docile (~> 1.1.0)
58
- json (>= 1.8, < 3)
59
- simplecov-html (~> 0.10.0)
60
- simplecov-html (0.10.1)
61
- slop (3.6.0)
62
- thread_safe (0.3.6)
63
- tzinfo (1.2.3)
64
- thread_safe (~> 0.1)
65
-
66
- PLATFORMS
67
- ruby
68
-
69
- DEPENDENCIES
70
- activerecord (~> 4.2.0)
71
- ar-uuid!
72
- bundler
73
- codeclimate-test-reporter
74
- minitest-utils
75
- mocha
76
- pg
77
- pry-meta
78
- rake
79
-
80
- BUNDLED WITH
81
- 1.15.1
data/gemfiles/5_0.gemfile DELETED
@@ -1,3 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec path: ".."
3
- gem "activerecord", "~> 5.0.0"
@@ -1,80 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- ar-uuid (0.1.2)
5
- activerecord
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (5.0.3)
11
- activesupport (= 5.0.3)
12
- activerecord (5.0.3)
13
- activemodel (= 5.0.3)
14
- activesupport (= 5.0.3)
15
- arel (~> 7.0)
16
- activesupport (5.0.3)
17
- concurrent-ruby (~> 1.0, >= 1.0.2)
18
- i18n (~> 0.7)
19
- minitest (~> 5.1)
20
- tzinfo (~> 1.1)
21
- arel (7.1.4)
22
- awesome_print (1.8.0)
23
- byebug (9.0.6)
24
- codeclimate-test-reporter (1.0.8)
25
- simplecov (<= 0.13)
26
- coderay (1.1.1)
27
- concurrent-ruby (1.0.5)
28
- docile (1.1.5)
29
- i18n (0.8.4)
30
- json (2.1.0)
31
- metaclass (0.0.4)
32
- method_source (0.8.2)
33
- minitest (5.10.2)
34
- minitest-utils (0.3.1)
35
- minitest
36
- mocha (1.2.1)
37
- metaclass (~> 0.0.1)
38
- pg (0.21.0)
39
- pry (0.10.4)
40
- coderay (~> 1.1.0)
41
- method_source (~> 0.8.1)
42
- slop (~> 3.4)
43
- pry-byebug (3.4.2)
44
- byebug (~> 9.0)
45
- pry (~> 0.10)
46
- pry-meta (0.0.10)
47
- awesome_print
48
- pry
49
- pry-byebug
50
- pry-remote
51
- pry-remote (0.1.8)
52
- pry (~> 0.9)
53
- slop (~> 3.0)
54
- rake (12.0.0)
55
- simplecov (0.13.0)
56
- docile (~> 1.1.0)
57
- json (>= 1.8, < 3)
58
- simplecov-html (~> 0.10.0)
59
- simplecov-html (0.10.1)
60
- slop (3.6.0)
61
- thread_safe (0.3.6)
62
- tzinfo (1.2.3)
63
- thread_safe (~> 0.1)
64
-
65
- PLATFORMS
66
- ruby
67
-
68
- DEPENDENCIES
69
- activerecord (~> 5.0.0)
70
- ar-uuid!
71
- bundler
72
- codeclimate-test-reporter
73
- minitest-utils
74
- mocha
75
- pg
76
- pry-meta
77
- rake
78
-
79
- BUNDLED WITH
80
- 1.15.1
data/gemfiles/5_1.gemfile DELETED
@@ -1,3 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec path: ".."
3
- gem "activerecord", "~> 5.1.0"
@@ -1,80 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- ar-uuid (0.1.2)
5
- activerecord
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (5.1.1)
11
- activesupport (= 5.1.1)
12
- activerecord (5.1.1)
13
- activemodel (= 5.1.1)
14
- activesupport (= 5.1.1)
15
- arel (~> 8.0)
16
- activesupport (5.1.1)
17
- concurrent-ruby (~> 1.0, >= 1.0.2)
18
- i18n (~> 0.7)
19
- minitest (~> 5.1)
20
- tzinfo (~> 1.1)
21
- arel (8.0.0)
22
- awesome_print (1.8.0)
23
- byebug (9.0.6)
24
- codeclimate-test-reporter (1.0.8)
25
- simplecov (<= 0.13)
26
- coderay (1.1.1)
27
- concurrent-ruby (1.0.5)
28
- docile (1.1.5)
29
- i18n (0.8.4)
30
- json (2.1.0)
31
- metaclass (0.0.4)
32
- method_source (0.8.2)
33
- minitest (5.10.2)
34
- minitest-utils (0.3.1)
35
- minitest
36
- mocha (1.2.1)
37
- metaclass (~> 0.0.1)
38
- pg (0.21.0)
39
- pry (0.10.4)
40
- coderay (~> 1.1.0)
41
- method_source (~> 0.8.1)
42
- slop (~> 3.4)
43
- pry-byebug (3.4.2)
44
- byebug (~> 9.0)
45
- pry (~> 0.10)
46
- pry-meta (0.0.10)
47
- awesome_print
48
- pry
49
- pry-byebug
50
- pry-remote
51
- pry-remote (0.1.8)
52
- pry (~> 0.9)
53
- slop (~> 3.0)
54
- rake (12.0.0)
55
- simplecov (0.13.0)
56
- docile (~> 1.1.0)
57
- json (>= 1.8, < 3)
58
- simplecov-html (~> 0.10.0)
59
- simplecov-html (0.10.1)
60
- slop (3.6.0)
61
- thread_safe (0.3.6)
62
- tzinfo (1.2.3)
63
- thread_safe (~> 0.1)
64
-
65
- PLATFORMS
66
- ruby
67
-
68
- DEPENDENCIES
69
- activerecord (~> 5.1.0)
70
- ar-uuid!
71
- bundler
72
- codeclimate-test-reporter
73
- minitest-utils
74
- mocha
75
- pg
76
- pry-meta
77
- rake
78
-
79
- BUNDLED WITH
80
- 1.15.1
@@ -1,21 +0,0 @@
1
- module ActiveRecord
2
- module UUID
3
- module TableDefinition
4
- def references(*args)
5
- options = args.extract_options!
6
- options[:type] = :uuid unless options.include?(:type)
7
- options[:null] = !::ActiveRecord::UUID::Utils.belongs_to_required_by_default unless options.include?(:null)
8
- args << options
9
-
10
- super(*args)
11
- end
12
-
13
- alias_method :belongs_to, :references
14
-
15
- def primary_key(name, type = :primary_key, **options)
16
- options[:default] = ::ActiveRecord::UUID::Utils.uuid_default_function
17
- super(name, type, **options)
18
- end
19
- end
20
- end
21
- end
@@ -1,5 +0,0 @@
1
- module ActiveRecord
2
- module UUID
3
- VERSION = "0.2.0"
4
- end
5
- end
@@ -1,11 +0,0 @@
1
- module ActiveRecord
2
- module UUID
3
- require "active_record"
4
- require "active_record/base"
5
- require "active_record/uuid/version"
6
- require "active_record/uuid/schema"
7
- require "active_record/uuid/table_definition"
8
- require "active_record/uuid/ext"
9
- require "active_record/uuid/utils"
10
- end
11
- end