has_unique_attribute 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cb4f16d85b2c9337c307e504d6b8305bb4dcedb89c51ae9ba07824351cb3bb8
4
- data.tar.gz: 3a3a05fa55d6212192f80e28e240c93ef05fffb3b5d19749b3b9112c779af214
3
+ metadata.gz: 426b87d300246d3c953e91209a64584eba26a16ea1fdec7ae2dbd6175902039d
4
+ data.tar.gz: a4412af2fb3bee8a8dc3b03477ea2e34f984623f146200af35a430cdd0603dc8
5
5
  SHA512:
6
- metadata.gz: 74822da50a7341ba65310ed9b3a190c9837962fdc5c5499cbd2e17a3ed64907a50548656289699ab98dbe00ebb5637d2cff37c2821747d1e4d350b4b8f6c5826
7
- data.tar.gz: 06cfae3160fc109e51eef9d25eda0cc5cb939538460c5e71e44d3f4aa77e8e0c976b59820324fbd26a549925d1c1cd73add67722077fe7133af2f05717732591
6
+ metadata.gz: 02b7bef86a0dc9e0a6e596f45c8b94533a01490508ce7b4a22b87ad5330b733e64152d4b4ba19233ccae19336e051e57c7833f1824b0df75af14414557481a67
7
+ data.tar.gz: 47377c84410c889520d5eed8a57d178eba7203c5366850682a32806d622802cc9287db03f3dc5fb2a428392fbb3de85c4307e5766c5bee15a9e794e591949d20
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /Gemfile.lock
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
data/.rubocop.yml CHANGED
@@ -6,16 +6,18 @@ AllCops:
6
6
  DefaultFormatter: progress
7
7
  DisplayCopNames: true
8
8
  ExtraDetails: true
9
- TargetRubyVersion: 2.6
9
+ NewCops: enable
10
+ SuggestExtensions: false
11
+ TargetRubyVersion: 3.2
10
12
  Exclude:
11
13
  - 'bin/*'
12
14
 
15
+ Gemspec/DevelopmentDependencies:
16
+ EnforcedStyle: gemspec
17
+
13
18
  Layout/AccessModifierIndentation:
14
19
  EnforcedStyle: outdent
15
20
 
16
- Layout/EmptyLinesAroundAttributeAccessor:
17
- Enabled: true
18
-
19
21
  Layout/ExtraSpacing:
20
22
  AllowForAlignment: true
21
23
 
@@ -29,30 +31,12 @@ Layout/LineLength:
29
31
  Layout/MultilineMethodCallIndentation:
30
32
  EnforcedStyle: indented
31
33
 
32
- Layout/SpaceAroundMethodCallOperator:
33
- Enabled: true
34
-
35
34
  Layout/SpaceInLambdaLiteral:
36
35
  EnforcedStyle: require_space
37
36
 
38
37
  Lint/AmbiguousBlockAssociation:
39
38
  Enabled: false
40
39
 
41
- Lint/DeprecatedOpenSSLConstant:
42
- Enabled: true
43
-
44
- Lint/DuplicateElsifCondition:
45
- Enabled: true
46
-
47
- Lint/MixedRegexpCaptureTypes:
48
- Enabled: true
49
-
50
- Lint/RaiseException:
51
- Enabled: true
52
-
53
- Lint/StructNewOverride:
54
- Enabled: true
55
-
56
40
  Metrics/BlockLength:
57
41
  Exclude:
58
42
  - 'spec/**/*'
@@ -60,30 +44,6 @@ Metrics/BlockLength:
60
44
  Naming/RescuedExceptionsVariableName:
61
45
  PreferredName: error
62
46
 
63
- Performance/AncestorsInclude:
64
- Enabled: true
65
-
66
- Performance/BigDecimalWithNumericArgument:
67
- Enabled: true
68
-
69
- Performance/RedundantSortBlock:
70
- Enabled: true
71
-
72
- Performance/RedundantStringChars:
73
- Enabled: true
74
-
75
- Performance/ReverseFirst:
76
- Enabled: true
77
-
78
- Performance/SortReverse:
79
- Enabled: true
80
-
81
- Performance/Squeeze:
82
- Enabled: true
83
-
84
- Performance/StringInclude:
85
- Enabled: true
86
-
87
47
  RSpec/ExpectChange:
88
48
  EnforcedStyle: block
89
49
 
@@ -93,60 +53,5 @@ RSpec/HookArgument:
93
53
  RSpec/NestedGroups:
94
54
  Max: 5
95
55
 
96
- Style/AccessorGrouping:
97
- Enabled: true
98
-
99
- Style/ArrayCoercion:
100
- Enabled: true
101
-
102
- Style/BisectedAttrAccessor:
103
- Enabled: true
104
-
105
- Style/CaseLikeIf:
106
- Enabled: true
107
-
108
- Style/ClassAndModuleChildren:
109
- SafeAutoCorrect: true
110
-
111
56
  Style/Documentation:
112
57
  Enabled: false
113
-
114
- Style/ExponentialNotation:
115
- Enabled: true
116
-
117
- Style/FrozenStringLiteralComment:
118
- Safe: true
119
-
120
- Style/HashAsLastArrayItem:
121
- Enabled: true
122
-
123
- Style/HashEachMethods:
124
- Enabled: true
125
-
126
- Style/HashLikeCase:
127
- Enabled: true
128
-
129
- Style/HashTransformKeys:
130
- Enabled: true
131
-
132
- Style/HashTransformValues:
133
- Enabled: true
134
-
135
- Style/RedundantAssignment:
136
- Enabled: true
137
-
138
- Style/RedundantFetchBlock:
139
- Enabled: true
140
- Safe: true
141
-
142
- Style/RedundantFileExtensionInRequire:
143
- Enabled: true
144
-
145
- Style/RedundantRegexpCharacterClass:
146
- Enabled: true
147
-
148
- Style/RedundantRegexpEscape:
149
- Enabled: true
150
-
151
- Style/SlicingWithRange:
152
- Enabled: true
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.2
data/README.md CHANGED
@@ -101,4 +101,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
101
101
 
102
102
  ## Contributing
103
103
 
104
- Bug reports and pull requests are welcome on GitHub at https://github.com/Mihail-K/has_unique_attribute.
104
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mintyfresh/has_unique_attribute.
@@ -8,16 +8,18 @@ require 'has_unique_attribute/version'
8
8
  Gem::Specification.new do |spec|
9
9
  spec.name = 'has_unique_attribute'
10
10
  spec.version = HasUniqueAttribute::VERSION
11
- spec.authors = ['Mihail-K']
11
+ spec.authors = ['Minty Fresh']
12
12
  spec.email = []
13
13
  spec.licenses = ['MIT']
14
14
 
15
15
  spec.summary = 'Handle unique attributes safely using the database.'
16
16
  spec.description = 'Adds custom handling for database uniqueness constraints to ActiveRecord.'
17
- spec.homepage = 'https://github.com/Mihail-K/has_unique_attribute'
17
+ spec.homepage = 'https://github.com/mintyfresh/has_unique_attribute'
18
+
19
+ spec.required_ruby_version = '>= 3.2'
18
20
 
19
21
  spec.metadata['homepage_uri'] = spec.homepage
20
- spec.metadata['source_code_uri'] = 'https://github.com/Mihail-K/has_unique_attribute'
22
+ spec.metadata['source_code_uri'] = 'https://github.com/mintyfresh/has_unique_attribute'
21
23
 
22
24
  # Specify which files should be added to the gem when it is released.
23
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -32,7 +34,8 @@ Gem::Specification.new do |spec|
32
34
  spec.add_development_dependency 'bundler', '~> 2.0'
33
35
  spec.add_development_dependency 'rake', '~> 13.0'
34
36
  spec.add_development_dependency 'rspec', '~> 3.0'
35
- spec.add_development_dependency 'rubocop', '~> 0.88'
36
- spec.add_development_dependency 'rubocop-performance', '~> 1.7'
37
- spec.add_development_dependency 'rubocop-rspec', '~> 1.42'
37
+ spec.add_development_dependency 'rubocop', '~> 1.56'
38
+ spec.add_development_dependency 'rubocop-performance', '~> 1.19'
39
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.23'
40
+ spec.metadata['rubygems_mfa_required'] = 'true'
38
41
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HasUniqueAttribute
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
@@ -19,10 +19,15 @@ private
19
19
  # @param index_name [String]
20
20
  # @return [void]
21
21
  def assert_unique_index_defined!(index_name)
22
+ return unless table_exists? # Database schema probably hasn't been loaded yet.
23
+
24
+ index_name = index_name.to_s
22
25
  index = connection.indexes(table_name).find { |index_definition| index_definition.name == index_name }
23
26
 
24
27
  raise ArgumentError, "#{name} does not have index: `#{index_name}`" if index.nil?
25
28
  raise ArgumentError, "#{name} defines an index `#{index_name}`, but it is not unique" unless index.unique
29
+ rescue ActiveRecord::NoDatabaseError, ActiveRecord::StatementInvalid
30
+ # Database or table does not exist yet. Ignore for now.
26
31
  end
27
32
 
28
33
  # @param attribute_name [String]
@@ -39,7 +44,7 @@ private
39
44
  existing_method = instance_method(:save)
40
45
 
41
46
  define_method(:save) do |*args, **kwargs|
42
- existing_method.bind(self).call(*args, **kwargs)
47
+ existing_method.bind_call(self, *args, **kwargs)
43
48
  rescue ActiveRecord::RecordNotUnique => error
44
49
  if error.message.include?(index_name)
45
50
  errors.add(attribute_name, message)
@@ -59,7 +64,7 @@ private
59
64
  existing_method = instance_method(:save!)
60
65
 
61
66
  define_method(:save!) do |*args, **kwargs|
62
- existing_method.bind(self).call(*args, **kwargs)
67
+ existing_method.bind_call(self, *args, **kwargs)
63
68
  rescue ActiveRecord::RecordNotUnique => error
64
69
  if error.message.include?(index_name)
65
70
  errors.add(attribute_name, message)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_unique_attribute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
- - Mihail-K
7
+ - Minty Fresh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-09 00:00:00.000000000 Z
11
+ date: 2023-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,42 +58,42 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.88'
61
+ version: '1.56'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.88'
68
+ version: '1.56'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rubocop-performance
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.7'
75
+ version: '1.19'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.7'
82
+ version: '1.19'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop-rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.42'
89
+ version: '2.23'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.42'
96
+ version: '2.23'
97
97
  description: Adds custom handling for database uniqueness constraints to ActiveRecord.
98
98
  email: []
99
99
  executables: []
@@ -103,9 +103,9 @@ files:
103
103
  - ".gitignore"
104
104
  - ".rspec"
105
105
  - ".rubocop.yml"
106
+ - ".ruby-version"
106
107
  - ".travis.yml"
107
108
  - Gemfile
108
- - Gemfile.lock
109
109
  - LICENSE.md
110
110
  - README.md
111
111
  - Rakefile
@@ -116,12 +116,13 @@ files:
116
116
  - has_unique_attribute.gemspec
117
117
  - lib/has_unique_attribute.rb
118
118
  - lib/has_unique_attribute/version.rb
119
- homepage: https://github.com/Mihail-K/has_unique_attribute
119
+ homepage: https://github.com/mintyfresh/has_unique_attribute
120
120
  licenses:
121
121
  - MIT
122
122
  metadata:
123
- homepage_uri: https://github.com/Mihail-K/has_unique_attribute
124
- source_code_uri: https://github.com/Mihail-K/has_unique_attribute
123
+ homepage_uri: https://github.com/mintyfresh/has_unique_attribute
124
+ source_code_uri: https://github.com/mintyfresh/has_unique_attribute
125
+ rubygems_mfa_required: 'true'
125
126
  post_install_message:
126
127
  rdoc_options: []
127
128
  require_paths:
@@ -130,14 +131,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
131
  requirements:
131
132
  - - ">="
132
133
  - !ruby/object:Gem::Version
133
- version: '0'
134
+ version: '3.2'
134
135
  required_rubygems_version: !ruby/object:Gem::Requirement
135
136
  requirements:
136
137
  - - ">="
137
138
  - !ruby/object:Gem::Version
138
139
  version: '0'
139
140
  requirements: []
140
- rubygems_version: 3.2.3
141
+ rubygems_version: 3.4.12
141
142
  signing_key:
142
143
  specification_version: 4
143
144
  summary: Handle unique attributes safely using the database.
data/Gemfile.lock DELETED
@@ -1,62 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- has_unique_attribute (0.1.3)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- ast (2.4.1)
10
- diff-lcs (1.4.4)
11
- parallel (1.19.2)
12
- parser (2.7.1.4)
13
- ast (~> 2.4.1)
14
- rainbow (3.0.0)
15
- rake (13.0.1)
16
- regexp_parser (1.7.1)
17
- rexml (3.2.4)
18
- rspec (3.9.0)
19
- rspec-core (~> 3.9.0)
20
- rspec-expectations (~> 3.9.0)
21
- rspec-mocks (~> 3.9.0)
22
- rspec-core (3.9.2)
23
- rspec-support (~> 3.9.3)
24
- rspec-expectations (3.9.2)
25
- diff-lcs (>= 1.2.0, < 2.0)
26
- rspec-support (~> 3.9.0)
27
- rspec-mocks (3.9.1)
28
- diff-lcs (>= 1.2.0, < 2.0)
29
- rspec-support (~> 3.9.0)
30
- rspec-support (3.9.3)
31
- rubocop (0.88.0)
32
- parallel (~> 1.10)
33
- parser (>= 2.7.1.1)
34
- rainbow (>= 2.2.2, < 4.0)
35
- regexp_parser (>= 1.7)
36
- rexml
37
- rubocop-ast (>= 0.1.0, < 1.0)
38
- ruby-progressbar (~> 1.7)
39
- unicode-display_width (>= 1.4.0, < 2.0)
40
- rubocop-ast (0.1.0)
41
- parser (>= 2.7.0.1)
42
- rubocop-performance (1.7.0)
43
- rubocop (>= 0.82.0)
44
- rubocop-rspec (1.42.0)
45
- rubocop (>= 0.87.0)
46
- ruby-progressbar (1.10.1)
47
- unicode-display_width (1.7.0)
48
-
49
- PLATFORMS
50
- ruby
51
-
52
- DEPENDENCIES
53
- bundler (~> 2.0)
54
- has_unique_attribute!
55
- rake (~> 13.0)
56
- rspec (~> 3.0)
57
- rubocop (~> 0.88)
58
- rubocop-performance (~> 1.7)
59
- rubocop-rspec (~> 1.42)
60
-
61
- BUNDLED WITH
62
- 2.2.3