uniqueness 0.9.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "5.0.0.beta3"
5
+ gem "rails", "6.0.0.beta3"
6
6
 
7
7
  gemspec path: "../"
@@ -0,0 +1,199 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ uniqueness (0.8.1)
5
+ activerecord (>= 4.0.0)
6
+ railties (>= 4.0.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actioncable (6.0.0.beta3)
12
+ actionpack (= 6.0.0.beta3)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (6.0.0.beta3)
16
+ actionpack (= 6.0.0.beta3)
17
+ activejob (= 6.0.0.beta3)
18
+ activerecord (= 6.0.0.beta3)
19
+ activestorage (= 6.0.0.beta3)
20
+ activesupport (= 6.0.0.beta3)
21
+ mail (>= 2.7.1)
22
+ actionmailer (6.0.0.beta3)
23
+ actionpack (= 6.0.0.beta3)
24
+ actionview (= 6.0.0.beta3)
25
+ activejob (= 6.0.0.beta3)
26
+ mail (~> 2.5, >= 2.5.4)
27
+ rails-dom-testing (~> 2.0)
28
+ actionpack (6.0.0.beta3)
29
+ actionview (= 6.0.0.beta3)
30
+ activesupport (= 6.0.0.beta3)
31
+ rack (~> 2.0)
32
+ rack-test (>= 0.6.3)
33
+ rails-dom-testing (~> 2.0)
34
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
35
+ actiontext (6.0.0.beta3)
36
+ actionpack (= 6.0.0.beta3)
37
+ activerecord (= 6.0.0.beta3)
38
+ activestorage (= 6.0.0.beta3)
39
+ activesupport (= 6.0.0.beta3)
40
+ nokogiri (>= 1.8.5)
41
+ actionview (6.0.0.beta3)
42
+ activesupport (= 6.0.0.beta3)
43
+ builder (~> 3.1)
44
+ erubi (~> 1.4)
45
+ rails-dom-testing (~> 2.0)
46
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
47
+ activejob (6.0.0.beta3)
48
+ activesupport (= 6.0.0.beta3)
49
+ globalid (>= 0.3.6)
50
+ activemodel (6.0.0.beta3)
51
+ activesupport (= 6.0.0.beta3)
52
+ activerecord (6.0.0.beta3)
53
+ activemodel (= 6.0.0.beta3)
54
+ activesupport (= 6.0.0.beta3)
55
+ activestorage (6.0.0.beta3)
56
+ actionpack (= 6.0.0.beta3)
57
+ activerecord (= 6.0.0.beta3)
58
+ marcel (~> 0.3.1)
59
+ activesupport (6.0.0.beta3)
60
+ concurrent-ruby (~> 1.0, >= 1.0.2)
61
+ i18n (>= 0.7, < 2)
62
+ minitest (~> 5.1)
63
+ tzinfo (~> 1.1)
64
+ zeitwerk (~> 1.3, >= 1.3.1)
65
+ appraisal (2.2.0)
66
+ bundler
67
+ rake
68
+ thor (>= 0.14.0)
69
+ builder (3.2.3)
70
+ concurrent-ruby (1.1.5)
71
+ coveralls (0.7.1)
72
+ multi_json (~> 1.3)
73
+ rest-client
74
+ simplecov (>= 0.7)
75
+ term-ansicolor
76
+ thor
77
+ crass (1.0.4)
78
+ diff-lcs (1.3)
79
+ docile (1.3.1)
80
+ domain_name (0.5.20180417)
81
+ unf (>= 0.0.5, < 1.0.0)
82
+ erubi (1.8.0)
83
+ globalid (0.4.2)
84
+ activesupport (>= 4.2.0)
85
+ http-cookie (1.0.3)
86
+ domain_name (~> 0.5)
87
+ i18n (1.6.0)
88
+ concurrent-ruby (~> 1.0)
89
+ json (2.2.0)
90
+ loofah (2.2.3)
91
+ crass (~> 1.0.2)
92
+ nokogiri (>= 1.5.9)
93
+ mail (2.7.1)
94
+ mini_mime (>= 0.1.1)
95
+ marcel (0.3.3)
96
+ mimemagic (~> 0.3.2)
97
+ method_source (0.9.2)
98
+ mime-types (3.2.2)
99
+ mime-types-data (~> 3.2015)
100
+ mime-types-data (3.2019.0331)
101
+ mimemagic (0.3.3)
102
+ mini_mime (1.0.1)
103
+ mini_portile2 (2.4.0)
104
+ minitest (5.11.3)
105
+ multi_json (1.13.1)
106
+ netrc (0.11.0)
107
+ nio4r (2.3.1)
108
+ nokogiri (1.10.2)
109
+ mini_portile2 (~> 2.4.0)
110
+ rack (2.0.7)
111
+ rack-test (1.1.0)
112
+ rack (>= 1.0, < 3)
113
+ rails (6.0.0.beta3)
114
+ actioncable (= 6.0.0.beta3)
115
+ actionmailbox (= 6.0.0.beta3)
116
+ actionmailer (= 6.0.0.beta3)
117
+ actionpack (= 6.0.0.beta3)
118
+ actiontext (= 6.0.0.beta3)
119
+ actionview (= 6.0.0.beta3)
120
+ activejob (= 6.0.0.beta3)
121
+ activemodel (= 6.0.0.beta3)
122
+ activerecord (= 6.0.0.beta3)
123
+ activestorage (= 6.0.0.beta3)
124
+ activesupport (= 6.0.0.beta3)
125
+ bundler (>= 1.3.0)
126
+ railties (= 6.0.0.beta3)
127
+ sprockets-rails (>= 2.0.0)
128
+ rails-dom-testing (2.0.3)
129
+ activesupport (>= 4.2.0)
130
+ nokogiri (>= 1.6)
131
+ rails-html-sanitizer (1.0.4)
132
+ loofah (~> 2.2, >= 2.2.2)
133
+ railties (6.0.0.beta3)
134
+ actionpack (= 6.0.0.beta3)
135
+ activesupport (= 6.0.0.beta3)
136
+ method_source
137
+ rake (>= 0.8.7)
138
+ thor (>= 0.20.3, < 2.0)
139
+ rake (12.3.2)
140
+ rest-client (2.0.2)
141
+ http-cookie (>= 1.0.2, < 2.0)
142
+ mime-types (>= 1.16, < 4.0)
143
+ netrc (~> 0.8)
144
+ rspec (3.8.0)
145
+ rspec-core (~> 3.8.0)
146
+ rspec-expectations (~> 3.8.0)
147
+ rspec-mocks (~> 3.8.0)
148
+ rspec-core (3.8.0)
149
+ rspec-support (~> 3.8.0)
150
+ rspec-expectations (3.8.2)
151
+ diff-lcs (>= 1.2.0, < 2.0)
152
+ rspec-support (~> 3.8.0)
153
+ rspec-mocks (3.8.0)
154
+ diff-lcs (>= 1.2.0, < 2.0)
155
+ rspec-support (~> 3.8.0)
156
+ rspec-support (3.8.0)
157
+ simplecov (0.16.1)
158
+ docile (~> 1.1)
159
+ json (>= 1.8, < 3)
160
+ simplecov-html (~> 0.10.0)
161
+ simplecov-html (0.10.2)
162
+ sprockets (3.7.2)
163
+ concurrent-ruby (~> 1.0)
164
+ rack (> 1, < 3)
165
+ sprockets-rails (3.2.1)
166
+ actionpack (>= 4.0)
167
+ activesupport (>= 4.0)
168
+ sprockets (>= 3.0.0)
169
+ sqlite3 (1.3.13)
170
+ term-ansicolor (1.7.1)
171
+ tins (~> 1.0)
172
+ thor (0.20.3)
173
+ thread_safe (0.3.6)
174
+ tins (1.20.2)
175
+ tzinfo (1.2.5)
176
+ thread_safe (~> 0.1)
177
+ unf (0.1.4)
178
+ unf_ext
179
+ unf_ext (0.0.7.5)
180
+ websocket-driver (0.7.0)
181
+ websocket-extensions (>= 0.1.0)
182
+ websocket-extensions (0.1.3)
183
+ zeitwerk (1.4.3)
184
+
185
+ PLATFORMS
186
+ ruby
187
+
188
+ DEPENDENCIES
189
+ appraisal
190
+ bundler (~> 2)
191
+ coveralls
192
+ rails (= 6.0.0.beta3)
193
+ rake (~> 12.0)
194
+ rspec
195
+ sqlite3 (~> 1.3, < 1.4)
196
+ uniqueness!
197
+
198
+ BUNDLED WITH
199
+ 2.0.1
@@ -1,3 +1,5 @@
1
+ require 'securerandom'
2
+
1
3
  module Uniqueness
2
4
  class << self
3
5
  def generate(opts = {})
@@ -7,7 +9,7 @@ module Uniqueness
7
9
  dict -= [*(:A..:Z)].map(&:to_s) unless options[:case_sensitive]
8
10
  dict -= uniqueness_ambigious_dictionary if options[:type].to_sym == :human
9
11
  dict = uniqueness_numbers_dictionary if options[:type].to_sym == :numbers
10
- code = Array.new(options[:length]).map { dict[rand(dict.length)] }.join
12
+ code = Array.new(options[:length]).map { dict[SecureRandom.random_number(dict.length)] }.join
11
13
  "#{options[:prefix]}#{code}#{options[:suffix]}"
12
14
  end
13
15
 
@@ -51,6 +51,7 @@ module Uniqueness
51
51
 
52
52
  def uniqueness_validation
53
53
  self.class.uniqueness_options.each do |field, options|
54
+ next unless new_record? || self.changes.has_key?(field)
54
55
  value = send(field)
55
56
  if value.nil?
56
57
  errors.add(field, 'should not be empty')
@@ -1,3 +1,3 @@
1
1
  module Uniqueness
2
- VERSION = '0.9.0'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
@@ -17,10 +17,10 @@ Gem::Specification.new do |spec|
17
17
  spec.require_paths = ['lib']
18
18
  spec.license = 'MIT'
19
19
 
20
- spec.add_development_dependency 'bundler', '~> 1.11'
21
- spec.add_development_dependency 'rake', '~> 10.0'
20
+ spec.add_development_dependency 'bundler', '~> 2'
21
+ spec.add_development_dependency 'rake', '~> 12.0'
22
22
  spec.add_development_dependency 'rspec'
23
- spec.add_development_dependency 'sqlite3'
23
+ spec.add_development_dependency 'sqlite3', '~> 1.3', '< 1.4'
24
24
  spec.add_development_dependency 'coveralls'
25
25
  spec.add_development_dependency 'appraisal'
26
26
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uniqueness
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Omar Abdel-Wahab
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-23 00:00:00.000000000 Z
11
+ date: 2019-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.11'
19
+ version: '2'
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'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '12.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '12.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -56,16 +56,22 @@ dependencies:
56
56
  name: sqlite3
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '1.3'
62
+ - - "<"
63
+ - !ruby/object:Gem::Version
64
+ version: '1.4'
62
65
  type: :development
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
65
68
  requirements:
66
- - - ">="
69
+ - - "~>"
67
70
  - !ruby/object:Gem::Version
68
- version: '0'
71
+ version: '1.3'
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.4'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: coveralls
71
77
  requirement: !ruby/object:Gem::Requirement
@@ -133,6 +139,7 @@ files:
133
139
  - ".coveralls.yml"
134
140
  - ".gitignore"
135
141
  - ".rubocop.yml"
142
+ - ".ruby-version"
136
143
  - ".travis.yml"
137
144
  - Appraisals
138
145
  - CONTRIBUTING.md
@@ -142,14 +149,14 @@ files:
142
149
  - Rakefile
143
150
  - bin/console
144
151
  - bin/setup
145
- - gemfiles/40.gemfile
146
- - gemfiles/40.gemfile.lock
147
- - gemfiles/41.gemfile
148
- - gemfiles/41.gemfile.lock
149
- - gemfiles/42.gemfile
150
- - gemfiles/42.gemfile.lock
151
- - gemfiles/50.gemfile
152
- - gemfiles/50.gemfile.lock
152
+ - gemfiles/5.0.gemfile
153
+ - gemfiles/5.0.gemfile.lock
154
+ - gemfiles/5.1.gemfile
155
+ - gemfiles/5.1.gemfile.lock
156
+ - gemfiles/5.2.gemfile
157
+ - gemfiles/5.2.gemfile.lock
158
+ - gemfiles/6.0.gemfile
159
+ - gemfiles/6.0.gemfile.lock
153
160
  - lib/uniqueness.rb
154
161
  - lib/uniqueness/engine.rb
155
162
  - lib/uniqueness/generator.rb
@@ -176,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
183
  version: '0'
177
184
  requirements: []
178
185
  rubyforge_project:
179
- rubygems_version: 2.6.14
186
+ rubygems_version: 2.7.9
180
187
  signing_key:
181
188
  specification_version: 4
182
189
  summary: Adds unique attribute support to ActiveModel models.
@@ -1,124 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- uniqueness (0.8.0)
5
- activerecord (>= 4.0.0)
6
- railties (>= 4.0.0)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- actionmailer (4.0.13)
12
- actionpack (= 4.0.13)
13
- mail (~> 2.5, >= 2.5.4)
14
- actionpack (4.0.13)
15
- activesupport (= 4.0.13)
16
- builder (~> 3.1.0)
17
- erubis (~> 2.7.0)
18
- rack (~> 1.5.2)
19
- rack-test (~> 0.6.2)
20
- activemodel (4.0.13)
21
- activesupport (= 4.0.13)
22
- builder (~> 3.1.0)
23
- activerecord (4.0.13)
24
- activemodel (= 4.0.13)
25
- activerecord-deprecated_finders (~> 1.0.2)
26
- activesupport (= 4.0.13)
27
- arel (~> 4.0.0)
28
- activerecord-deprecated_finders (1.0.4)
29
- activesupport (4.0.13)
30
- i18n (~> 0.6, >= 0.6.9)
31
- minitest (~> 4.2)
32
- multi_json (~> 1.3)
33
- thread_safe (~> 0.1)
34
- tzinfo (~> 0.3.37)
35
- appraisal (2.1.0)
36
- bundler
37
- rake
38
- thor (>= 0.14.0)
39
- arel (4.0.2)
40
- builder (3.1.4)
41
- concurrent-ruby (1.0.1)
42
- coveralls (0.8.13)
43
- json (~> 1.8)
44
- simplecov (~> 0.11.0)
45
- term-ansicolor (~> 1.3)
46
- thor (~> 0.19.1)
47
- tins (~> 1.6.0)
48
- diff-lcs (1.2.5)
49
- docile (1.1.5)
50
- erubis (2.7.0)
51
- i18n (0.7.0)
52
- json (1.8.3)
53
- mail (2.6.4)
54
- mime-types (>= 1.16, < 4)
55
- mime-types (3.0)
56
- mime-types-data (~> 3.2015)
57
- mime-types-data (3.2016.0221)
58
- minitest (4.7.5)
59
- multi_json (1.11.2)
60
- rack (1.5.5)
61
- rack-test (0.6.3)
62
- rack (>= 1.0)
63
- rails (4.0.13)
64
- actionmailer (= 4.0.13)
65
- actionpack (= 4.0.13)
66
- activerecord (= 4.0.13)
67
- activesupport (= 4.0.13)
68
- bundler (>= 1.3.0, < 2.0)
69
- railties (= 4.0.13)
70
- sprockets-rails (~> 2.0)
71
- railties (4.0.13)
72
- actionpack (= 4.0.13)
73
- activesupport (= 4.0.13)
74
- rake (>= 0.8.7)
75
- thor (>= 0.18.1, < 2.0)
76
- rake (10.5.0)
77
- rspec (3.4.0)
78
- rspec-core (~> 3.4.0)
79
- rspec-expectations (~> 3.4.0)
80
- rspec-mocks (~> 3.4.0)
81
- rspec-core (3.4.4)
82
- rspec-support (~> 3.4.0)
83
- rspec-expectations (3.4.0)
84
- diff-lcs (>= 1.2.0, < 2.0)
85
- rspec-support (~> 3.4.0)
86
- rspec-mocks (3.4.1)
87
- diff-lcs (>= 1.2.0, < 2.0)
88
- rspec-support (~> 3.4.0)
89
- rspec-support (3.4.1)
90
- simplecov (0.11.2)
91
- docile (~> 1.1.0)
92
- json (~> 1.8)
93
- simplecov-html (~> 0.10.0)
94
- simplecov-html (0.10.0)
95
- sprockets (3.5.2)
96
- concurrent-ruby (~> 1.0)
97
- rack (> 1, < 3)
98
- sprockets-rails (2.3.3)
99
- actionpack (>= 3.0)
100
- activesupport (>= 3.0)
101
- sprockets (>= 2.8, < 4.0)
102
- sqlite3 (1.3.11)
103
- term-ansicolor (1.3.2)
104
- tins (~> 1.0)
105
- thor (0.19.1)
106
- thread_safe (0.3.5)
107
- tins (1.6.0)
108
- tzinfo (0.3.48)
109
-
110
- PLATFORMS
111
- ruby
112
-
113
- DEPENDENCIES
114
- appraisal
115
- bundler (~> 1.11)
116
- coveralls
117
- rails (~> 4.0.0)
118
- rake (~> 10.0)
119
- rspec
120
- sqlite3
121
- uniqueness!
122
-
123
- BUNDLED WITH
124
- 1.16.1