uniqueness 1.0.0 → 1.1.0

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: 243b87e83c913921e3266d09feb453e20f7972c8874dc658c5333a53ac83457f
4
- data.tar.gz: a230d443b895550792b5906d044b217d10ae91856ee8b037c5f1b2c5e753a523
3
+ metadata.gz: 15c21bdccc3be6418bd7790452453a6c21428c7a0baa02c21a14b646d8b7e4e5
4
+ data.tar.gz: 1ea759808248b3e347ebb65daee328938a440253fb7dfa5706e00b1010c86478
5
5
  SHA512:
6
- metadata.gz: 124d86366caaf37d669c45187ba6d019779fd37f4c39c111c1153b35fd6622c687ce08a2833c8ec364a1c47faff3ef3ab2babb933840efb45af02011cd554615
7
- data.tar.gz: bb787f85f99b405407390bcc3b9ab5e4886b946188f2a48e3946b9af6cf112d19daaa8bb0f81b8c29d245e2a2490192b649226fae0bf7770e246cdebdbc25024
6
+ metadata.gz: 38b11ec667ff10cc9b29da7ec365a9576f76f53dbfa156efca7abf9285ece34292692cd04abe1e736f756317f520c12b4880005d08a847feebaea8e69787ba64
7
+ data.tar.gz: bedea48d8fd12243b897e6d12ab57db13f140b88aec58def96d301bbd1bea69a5aa19cabcffda93acb63c7ec139fc2f60350fed21d1eb882bbbc1ceaae64fe3c
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ .DS_Store
1
2
  /coverage/
2
3
  /InstalledFiles
3
4
  /pkg/
@@ -1 +1 @@
1
- 2.5.1
1
+ 2.3.0
@@ -1,21 +1,73 @@
1
1
  language: ruby
2
- rvm:
3
- - 2.6.0
4
- - 2.5.0
5
- - 2.4.0
6
- - 2.3.0
7
- before_install:
8
- - gem install bundler -v '~> 2'
9
- gemfile:
10
- - gemfiles/5.0.gemfile
11
- - gemfiles/5.1.gemfile
12
- - gemfiles/5.2.gemfile
13
- - gemfiles/6.0.gemfile
2
+
3
+ before_install: gem install bundler -v '~> 1.17'
4
+
14
5
  matrix:
15
- exclude:
16
- - rvm: 2.3.0
6
+ include:
7
+ # Rails 4.0
8
+ - rvm: 2.0.0
9
+ gemfile: gemfiles/4.0.gemfile
10
+ - rvm: 2.1.10
11
+ gemfile: gemfiles/4.0.gemfile
12
+ - rvm: 2.2.10
13
+ gemfile: gemfiles/4.0.gemfile
14
+
15
+ # Rails 4.1
16
+ - rvm: 2.0.0
17
+ gemfile: gemfiles/4.1.gemfile
18
+ - rvm: 2.1.10
19
+ gemfile: gemfiles/4.1.gemfile
20
+ - rvm: 2.2.10
21
+ gemfile: gemfiles/4.1.gemfile
22
+ - rvm: 2.3.8
23
+ gemfile: gemfiles/4.1.gemfile
24
+
25
+ # Rails 4.2
26
+ - rvm: 2.1.10
27
+ gemfile: gemfiles/4.2.gemfile
28
+ - rvm: 2.2.10
29
+ gemfile: gemfiles/4.2.gemfile
30
+ - rvm: 2.3.8
31
+ gemfile: gemfiles/4.2.gemfile
32
+ - rvm: 2.4.5
33
+ gemfile: gemfiles/4.2.gemfile
34
+
35
+ # Rails 5.0
36
+ - rvm: 2.3.8
37
+ gemfile: gemfiles/5.0.gemfile
38
+ before_install: gem install bundler -v '~> 2.0'
39
+ - rvm: 2.4.5
40
+ gemfile: gemfiles/5.0.gemfile
41
+ before_install: gem install bundler -v '~> 2.0'
42
+
43
+ # Rails 5.1
44
+ - rvm: 2.3.8
45
+ gemfile: gemfiles/5.1.gemfile
46
+ before_install: gem install bundler -v '~> 2.0'
47
+ - rvm: 2.4.5
48
+ gemfile: gemfiles/5.1.gemfile
49
+ before_install: gem install bundler -v '~> 2.0'
50
+ - rvm: 2.5.3
51
+ gemfile: gemfiles/5.1.gemfile
52
+ before_install: gem install bundler -v '~> 2.0'
53
+
54
+ # Rails 5.2
55
+ - rvm: 2.3.8
56
+ gemfile: gemfiles/5.2.gemfile
57
+ before_install: gem install bundler -v '~> 2.0'
58
+ - rvm: 2.4.5
59
+ gemfile: gemfiles/5.2.gemfile
60
+ before_install: gem install bundler -v '~> 2.0'
61
+ - rvm: 2.5.3
62
+ gemfile: gemfiles/5.2.gemfile
63
+ before_install: gem install bundler -v '~> 2.0'
64
+
65
+ # Rails 6.0
66
+ - rvm: 2.5.3
17
67
  gemfile: gemfiles/6.0.gemfile
18
- - rvm: 2.4.0
68
+ before_install: gem install bundler -v '~> 2.0'
69
+ - rvm: 2.6.0
19
70
  gemfile: gemfiles/6.0.gemfile
71
+ before_install: gem install bundler -v '~> 2.0'
20
72
  cache:
21
73
  - bundler
data/Appraisals CHANGED
@@ -1,3 +1,17 @@
1
+ appraise '40' do
2
+ gem 'rails', '~> 4.0.0'
3
+ end
4
+
5
+
6
+ appraise '41' do
7
+ gem 'rails', '~> 4.1.0'
8
+ end
9
+
10
+
11
+ appraise '42' do
12
+ gem 'rails', '~> 4.2.0'
13
+ end
14
+
1
15
  appraise '5.0' do
2
16
  gem 'rails', '~> 5.0.0'
3
17
  end
data/README.md CHANGED
@@ -51,6 +51,8 @@ To auto-generate a new random string for field `foo`:
51
51
  You can customize the generated string by
52
52
  passing an options hash. The following keys are supported:
53
53
 
54
+ `:trigger_on` when to be generated, can be one of ActiveRecord callbacks (`before_validation`, `before_create`, `before_save`, `after_initialize`), default to __:before_validation__
55
+
54
56
  `:length` number of characters, defaults to __32__
55
57
 
56
58
  `:type` type of string, can be one of: `:human`, `:auto`, defaults to __:auto__
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 4.0.0"
6
+ gem "bundler", '~> 1.11'
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,123 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ uniqueness (1.1.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.2.0)
36
+ bundler
37
+ rake
38
+ thor (>= 0.14.0)
39
+ arel (4.0.2)
40
+ builder (3.1.4)
41
+ concurrent-ruby (1.1.5)
42
+ coveralls (0.8.22)
43
+ json (>= 1.8, < 3)
44
+ simplecov (~> 0.16.1)
45
+ term-ansicolor (~> 1.3)
46
+ thor (~> 0.19.4)
47
+ tins (~> 1.6)
48
+ diff-lcs (1.3)
49
+ docile (1.3.1)
50
+ erubis (2.7.0)
51
+ i18n (0.9.5)
52
+ concurrent-ruby (~> 1.0)
53
+ json (2.2.0)
54
+ mail (2.7.1)
55
+ mini_mime (>= 0.1.1)
56
+ mini_mime (1.0.1)
57
+ minitest (4.7.5)
58
+ multi_json (1.13.1)
59
+ rack (1.5.5)
60
+ rack-test (0.6.3)
61
+ rack (>= 1.0)
62
+ rails (4.0.13)
63
+ actionmailer (= 4.0.13)
64
+ actionpack (= 4.0.13)
65
+ activerecord (= 4.0.13)
66
+ activesupport (= 4.0.13)
67
+ bundler (>= 1.3.0, < 2.0)
68
+ railties (= 4.0.13)
69
+ sprockets-rails (~> 2.0)
70
+ railties (4.0.13)
71
+ actionpack (= 4.0.13)
72
+ activesupport (= 4.0.13)
73
+ rake (>= 0.8.7)
74
+ thor (>= 0.18.1, < 2.0)
75
+ rake (12.3.2)
76
+ rspec (3.8.0)
77
+ rspec-core (~> 3.8.0)
78
+ rspec-expectations (~> 3.8.0)
79
+ rspec-mocks (~> 3.8.0)
80
+ rspec-core (3.8.0)
81
+ rspec-support (~> 3.8.0)
82
+ rspec-expectations (3.8.2)
83
+ diff-lcs (>= 1.2.0, < 2.0)
84
+ rspec-support (~> 3.8.0)
85
+ rspec-mocks (3.8.0)
86
+ diff-lcs (>= 1.2.0, < 2.0)
87
+ rspec-support (~> 3.8.0)
88
+ rspec-support (3.8.0)
89
+ simplecov (0.16.1)
90
+ docile (~> 1.1)
91
+ json (>= 1.8, < 3)
92
+ simplecov-html (~> 0.10.0)
93
+ simplecov-html (0.10.2)
94
+ sprockets (3.7.2)
95
+ concurrent-ruby (~> 1.0)
96
+ rack (> 1, < 3)
97
+ sprockets-rails (2.3.3)
98
+ actionpack (>= 3.0)
99
+ activesupport (>= 3.0)
100
+ sprockets (>= 2.8, < 4.0)
101
+ sqlite3 (1.3.13)
102
+ term-ansicolor (1.7.1)
103
+ tins (~> 1.0)
104
+ thor (0.19.4)
105
+ thread_safe (0.3.6)
106
+ tins (1.20.2)
107
+ tzinfo (0.3.55)
108
+
109
+ PLATFORMS
110
+ ruby
111
+
112
+ DEPENDENCIES
113
+ appraisal
114
+ bundler (~> 1.11)
115
+ coveralls
116
+ rails (~> 4.0.0)
117
+ rake (~> 12.0)
118
+ rspec
119
+ sqlite3 (~> 1.3, < 1.4)
120
+ uniqueness!
121
+
122
+ BUNDLED WITH
123
+ 1.16.6
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", "~> 4.1.0"
4
+
5
+ gemspec :path => "../"
@@ -0,0 +1,127 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ uniqueness (1.1.0)
5
+ activerecord (>= 4.0.0)
6
+ railties (>= 4.0.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionmailer (4.1.16)
12
+ actionpack (= 4.1.16)
13
+ actionview (= 4.1.16)
14
+ mail (~> 2.5, >= 2.5.4)
15
+ actionpack (4.1.16)
16
+ actionview (= 4.1.16)
17
+ activesupport (= 4.1.16)
18
+ rack (~> 1.5.2)
19
+ rack-test (~> 0.6.2)
20
+ actionview (4.1.16)
21
+ activesupport (= 4.1.16)
22
+ builder (~> 3.1)
23
+ erubis (~> 2.7.0)
24
+ activemodel (4.1.16)
25
+ activesupport (= 4.1.16)
26
+ builder (~> 3.1)
27
+ activerecord (4.1.16)
28
+ activemodel (= 4.1.16)
29
+ activesupport (= 4.1.16)
30
+ arel (~> 5.0.0)
31
+ activesupport (4.1.16)
32
+ i18n (~> 0.6, >= 0.6.9)
33
+ json (~> 1.7, >= 1.7.7)
34
+ minitest (~> 5.1)
35
+ thread_safe (~> 0.1)
36
+ tzinfo (~> 1.1)
37
+ appraisal (2.2.0)
38
+ bundler
39
+ rake
40
+ thor (>= 0.14.0)
41
+ arel (5.0.1.20140414130214)
42
+ builder (3.2.3)
43
+ concurrent-ruby (1.1.5)
44
+ coveralls (0.8.22)
45
+ json (>= 1.8, < 3)
46
+ simplecov (~> 0.16.1)
47
+ term-ansicolor (~> 1.3)
48
+ thor (~> 0.19.4)
49
+ tins (~> 1.6)
50
+ diff-lcs (1.3)
51
+ docile (1.3.1)
52
+ erubis (2.7.0)
53
+ i18n (0.9.5)
54
+ concurrent-ruby (~> 1.0)
55
+ json (1.8.6)
56
+ mail (2.7.1)
57
+ mini_mime (>= 0.1.1)
58
+ mini_mime (1.0.1)
59
+ minitest (5.11.3)
60
+ rack (1.5.5)
61
+ rack-test (0.6.3)
62
+ rack (>= 1.0)
63
+ rails (4.1.16)
64
+ actionmailer (= 4.1.16)
65
+ actionpack (= 4.1.16)
66
+ actionview (= 4.1.16)
67
+ activemodel (= 4.1.16)
68
+ activerecord (= 4.1.16)
69
+ activesupport (= 4.1.16)
70
+ bundler (>= 1.3.0, < 2.0)
71
+ railties (= 4.1.16)
72
+ sprockets-rails (~> 2.0)
73
+ railties (4.1.16)
74
+ actionpack (= 4.1.16)
75
+ activesupport (= 4.1.16)
76
+ rake (>= 0.8.7)
77
+ thor (>= 0.18.1, < 2.0)
78
+ rake (12.3.2)
79
+ rspec (3.8.0)
80
+ rspec-core (~> 3.8.0)
81
+ rspec-expectations (~> 3.8.0)
82
+ rspec-mocks (~> 3.8.0)
83
+ rspec-core (3.8.0)
84
+ rspec-support (~> 3.8.0)
85
+ rspec-expectations (3.8.2)
86
+ diff-lcs (>= 1.2.0, < 2.0)
87
+ rspec-support (~> 3.8.0)
88
+ rspec-mocks (3.8.0)
89
+ diff-lcs (>= 1.2.0, < 2.0)
90
+ rspec-support (~> 3.8.0)
91
+ rspec-support (3.8.0)
92
+ simplecov (0.16.1)
93
+ docile (~> 1.1)
94
+ json (>= 1.8, < 3)
95
+ simplecov-html (~> 0.10.0)
96
+ simplecov-html (0.10.2)
97
+ sprockets (3.7.2)
98
+ concurrent-ruby (~> 1.0)
99
+ rack (> 1, < 3)
100
+ sprockets-rails (2.3.3)
101
+ actionpack (>= 3.0)
102
+ activesupport (>= 3.0)
103
+ sprockets (>= 2.8, < 4.0)
104
+ sqlite3 (1.3.13)
105
+ term-ansicolor (1.7.1)
106
+ tins (~> 1.0)
107
+ thor (0.19.4)
108
+ thread_safe (0.3.6)
109
+ tins (1.20.2)
110
+ tzinfo (1.2.5)
111
+ thread_safe (~> 0.1)
112
+
113
+ PLATFORMS
114
+ ruby
115
+
116
+ DEPENDENCIES
117
+ appraisal
118
+ bundler (~> 1.17)
119
+ coveralls
120
+ rails (~> 4.1.0)
121
+ rake (~> 12.0)
122
+ rspec
123
+ sqlite3 (~> 1.3, < 1.4)
124
+ uniqueness!
125
+
126
+ BUNDLED WITH
127
+ 1.17.3
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 4.2.0"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,153 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ uniqueness (1.1.0)
5
+ activerecord (>= 4.0.0)
6
+ railties (>= 4.0.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionmailer (4.2.11.1)
12
+ actionpack (= 4.2.11.1)
13
+ actionview (= 4.2.11.1)
14
+ activejob (= 4.2.11.1)
15
+ mail (~> 2.5, >= 2.5.4)
16
+ rails-dom-testing (~> 1.0, >= 1.0.5)
17
+ actionpack (4.2.11.1)
18
+ actionview (= 4.2.11.1)
19
+ activesupport (= 4.2.11.1)
20
+ rack (~> 1.6)
21
+ rack-test (~> 0.6.2)
22
+ rails-dom-testing (~> 1.0, >= 1.0.5)
23
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
24
+ actionview (4.2.11.1)
25
+ activesupport (= 4.2.11.1)
26
+ builder (~> 3.1)
27
+ erubis (~> 2.7.0)
28
+ rails-dom-testing (~> 1.0, >= 1.0.5)
29
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
30
+ activejob (4.2.11.1)
31
+ activesupport (= 4.2.11.1)
32
+ globalid (>= 0.3.0)
33
+ activemodel (4.2.11.1)
34
+ activesupport (= 4.2.11.1)
35
+ builder (~> 3.1)
36
+ activerecord (4.2.11.1)
37
+ activemodel (= 4.2.11.1)
38
+ activesupport (= 4.2.11.1)
39
+ arel (~> 6.0)
40
+ activesupport (4.2.11.1)
41
+ i18n (~> 0.7)
42
+ minitest (~> 5.1)
43
+ thread_safe (~> 0.3, >= 0.3.4)
44
+ tzinfo (~> 1.1)
45
+ appraisal (2.2.0)
46
+ bundler
47
+ rake
48
+ thor (>= 0.14.0)
49
+ arel (6.0.4)
50
+ builder (3.2.3)
51
+ concurrent-ruby (1.1.5)
52
+ coveralls (0.8.22)
53
+ json (>= 1.8, < 3)
54
+ simplecov (~> 0.16.1)
55
+ term-ansicolor (~> 1.3)
56
+ thor (~> 0.19.4)
57
+ tins (~> 1.6)
58
+ crass (1.0.4)
59
+ diff-lcs (1.3)
60
+ docile (1.3.1)
61
+ erubis (2.7.0)
62
+ globalid (0.4.2)
63
+ activesupport (>= 4.2.0)
64
+ i18n (0.9.5)
65
+ concurrent-ruby (~> 1.0)
66
+ json (2.2.0)
67
+ loofah (2.2.3)
68
+ crass (~> 1.0.2)
69
+ nokogiri (>= 1.5.9)
70
+ mail (2.7.1)
71
+ mini_mime (>= 0.1.1)
72
+ mini_mime (1.0.1)
73
+ mini_portile2 (2.4.0)
74
+ minitest (5.11.3)
75
+ nokogiri (1.9.1)
76
+ mini_portile2 (~> 2.4.0)
77
+ rack (1.6.11)
78
+ rack-test (0.6.3)
79
+ rack (>= 1.0)
80
+ rails (4.2.11.1)
81
+ actionmailer (= 4.2.11.1)
82
+ actionpack (= 4.2.11.1)
83
+ actionview (= 4.2.11.1)
84
+ activejob (= 4.2.11.1)
85
+ activemodel (= 4.2.11.1)
86
+ activerecord (= 4.2.11.1)
87
+ activesupport (= 4.2.11.1)
88
+ bundler (>= 1.3.0, < 2.0)
89
+ railties (= 4.2.11.1)
90
+ sprockets-rails
91
+ rails-deprecated_sanitizer (1.0.3)
92
+ activesupport (>= 4.2.0.alpha)
93
+ rails-dom-testing (1.0.9)
94
+ activesupport (>= 4.2.0, < 5.0)
95
+ nokogiri (~> 1.6)
96
+ rails-deprecated_sanitizer (>= 1.0.1)
97
+ rails-html-sanitizer (1.0.4)
98
+ loofah (~> 2.2, >= 2.2.2)
99
+ railties (4.2.11.1)
100
+ actionpack (= 4.2.11.1)
101
+ activesupport (= 4.2.11.1)
102
+ rake (>= 0.8.7)
103
+ thor (>= 0.18.1, < 2.0)
104
+ rake (12.3.2)
105
+ rspec (3.8.0)
106
+ rspec-core (~> 3.8.0)
107
+ rspec-expectations (~> 3.8.0)
108
+ rspec-mocks (~> 3.8.0)
109
+ rspec-core (3.8.0)
110
+ rspec-support (~> 3.8.0)
111
+ rspec-expectations (3.8.2)
112
+ diff-lcs (>= 1.2.0, < 2.0)
113
+ rspec-support (~> 3.8.0)
114
+ rspec-mocks (3.8.0)
115
+ diff-lcs (>= 1.2.0, < 2.0)
116
+ rspec-support (~> 3.8.0)
117
+ rspec-support (3.8.0)
118
+ simplecov (0.16.1)
119
+ docile (~> 1.1)
120
+ json (>= 1.8, < 3)
121
+ simplecov-html (~> 0.10.0)
122
+ simplecov-html (0.10.2)
123
+ sprockets (3.7.2)
124
+ concurrent-ruby (~> 1.0)
125
+ rack (> 1, < 3)
126
+ sprockets-rails (3.2.1)
127
+ actionpack (>= 4.0)
128
+ activesupport (>= 4.0)
129
+ sprockets (>= 3.0.0)
130
+ sqlite3 (1.3.13)
131
+ term-ansicolor (1.7.1)
132
+ tins (~> 1.0)
133
+ thor (0.19.4)
134
+ thread_safe (0.3.6)
135
+ tins (1.20.2)
136
+ tzinfo (1.2.5)
137
+ thread_safe (~> 0.1)
138
+
139
+ PLATFORMS
140
+ ruby
141
+
142
+ DEPENDENCIES
143
+ appraisal
144
+ bundler (~> 1.17)
145
+ coveralls
146
+ rails (~> 4.2.0)
147
+ rake (~> 12.0)
148
+ rspec
149
+ sqlite3 (~> 1.3, < 1.4)
150
+ uniqueness!
151
+
152
+ BUNDLED WITH
153
+ 1.17.3
@@ -2,6 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
+ gem "bundler", "~> 2.0"
5
6
  gem "rails", "~> 5.0.0"
6
7
 
7
8
  gemspec path: "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- uniqueness (0.8.1)
4
+ uniqueness (1.1.0)
5
5
  activerecord (>= 4.0.0)
6
6
  railties (>= 4.0.0)
7
7
 
@@ -148,7 +148,7 @@ PLATFORMS
148
148
 
149
149
  DEPENDENCIES
150
150
  appraisal
151
- bundler (~> 2)
151
+ bundler (~> 2.0)
152
152
  coveralls
153
153
  rails (~> 5.0.0)
154
154
  rake (~> 12.0)
@@ -2,6 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
+ gem "bundler", "~> 2.0"
5
6
  gem "rails", "~> 5.1.0"
6
7
 
7
8
  gemspec path: "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- uniqueness (0.8.1)
4
+ uniqueness (1.1.0)
5
5
  activerecord (>= 4.0.0)
6
6
  railties (>= 4.0.0)
7
7
 
@@ -148,7 +148,7 @@ PLATFORMS
148
148
 
149
149
  DEPENDENCIES
150
150
  appraisal
151
- bundler (~> 2)
151
+ bundler (~> 2.0)
152
152
  coveralls
153
153
  rails (~> 5.1.0)
154
154
  rake (~> 12.0)
@@ -2,6 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
+ gem "bundler", "~> 2.0"
5
6
  gem "rails", "~> 5.2.0"
6
7
 
7
8
  gemspec path: "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- uniqueness (0.8.1)
4
+ uniqueness (1.1.0)
5
5
  activerecord (>= 4.0.0)
6
6
  railties (>= 4.0.0)
7
7
 
@@ -156,7 +156,7 @@ PLATFORMS
156
156
 
157
157
  DEPENDENCIES
158
158
  appraisal
159
- bundler (~> 2)
159
+ bundler (~> 2.0)
160
160
  coveralls
161
161
  rails (~> 5.2.0)
162
162
  rake (~> 12.0)
@@ -2,6 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
+ gem "bundler", "~> 2.0"
5
6
  gem "rails", "6.0.0.beta3"
6
7
 
7
8
  gemspec path: "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- uniqueness (0.8.1)
4
+ uniqueness (1.1.0)
5
5
  activerecord (>= 4.0.0)
6
6
  railties (>= 4.0.0)
7
7
 
@@ -187,7 +187,7 @@ PLATFORMS
187
187
 
188
188
  DEPENDENCIES
189
189
  appraisal
190
- bundler (~> 2)
190
+ bundler (~> 2.0)
191
191
  coveralls
192
192
  rails (= 6.0.0.beta3)
193
193
  rake (~> 12.0)
@@ -34,7 +34,8 @@ module Uniqueness
34
34
  blacklist: [],
35
35
  scope: [],
36
36
  suffix: '',
37
- prefix: ''
37
+ prefix: '',
38
+ trigger_on: :before_validation
38
39
  }
39
40
  end
40
41
  end
@@ -16,6 +16,7 @@ module Uniqueness
16
16
  # You can customize the generated string by
17
17
  # passing an options hash. The following keys are supported:
18
18
  #
19
+ # +:trigger_on+ when to be generated, can be one of ActiveRecord callbacks (<tt>before_validation</tt>, <tt>before_create</tt>, <tt>before_save</tt>, <tt>after_initialize</tt>), default to <tt>:before_validation</tt>
19
20
  # +:length+ number of characters, defaults to <tt>32</tt>
20
21
  #
21
22
  # +:case_sensitive+ defaults to <tt>true</tt>
@@ -32,9 +33,20 @@ module Uniqueness
32
33
  def has_unique_field(name, options = {})
33
34
  self.uniqueness_options ||= {}
34
35
  self.uniqueness_options[name] = Uniqueness.uniqueness_default_options.merge(options)
35
- before_validation :uniqueness_generate
36
+
37
+ case options[:trigger_on]
38
+ when :before_create
39
+ before_create :uniqueness_generate
40
+ when :before_save
41
+ before_save :uniqueness_generate
42
+ when :after_initialize
43
+ after_initialize :uniqueness_generate
44
+ else
45
+ before_validation :uniqueness_generate
46
+ end
47
+
36
48
  validate :uniqueness_validation
37
- define_method("regenerate_#{name}") { update_attributes(name => Uniqueness.generate(self.uniqueness_options[name])) }
49
+ define_method("regenerate_#{name}") { update(name => Uniqueness.generate(self.uniqueness_options[name])) }
38
50
  end
39
51
  end
40
52
 
@@ -1,3 +1,3 @@
1
1
  module Uniqueness
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.require_paths = ['lib']
18
18
  spec.license = 'MIT'
19
19
 
20
- spec.add_development_dependency 'bundler', '~> 2'
20
+ spec.add_development_dependency 'bundler', '~> 1.17'
21
21
  spec.add_development_dependency 'rake', '~> 12.0'
22
22
  spec.add_development_dependency 'rspec'
23
23
  spec.add_development_dependency 'sqlite3', '~> 1.3', '< 1.4'
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: 1.0.0
4
+ version: 1.1.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: 2019-04-12 00:00:00.000000000 Z
11
+ date: 2019-04-15 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: '2'
19
+ version: '1.17'
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: '2'
26
+ version: '1.17'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -149,6 +149,12 @@ files:
149
149
  - Rakefile
150
150
  - bin/console
151
151
  - bin/setup
152
+ - gemfiles/4.0.gemfile
153
+ - gemfiles/4.0.gemfile.lock
154
+ - gemfiles/4.1.gemfile
155
+ - gemfiles/4.1.gemfile.lock
156
+ - gemfiles/4.2.gemfile
157
+ - gemfiles/4.2.gemfile.lock
152
158
  - gemfiles/5.0.gemfile
153
159
  - gemfiles/5.0.gemfile.lock
154
160
  - gemfiles/5.1.gemfile