auto_increment 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/Appraisals +5 -1
- data/README.md +19 -13
- data/auto_increment.gemspec +4 -4
- data/gemfiles/rails_4.2.11.1.gemfile +1 -0
- data/gemfiles/rails_5.0.7.2.gemfile +1 -0
- data/gemfiles/rails_5.1.6.2.gemfile +1 -0
- data/gemfiles/rails_5.2.2.1.gemfile +1 -0
- data/gemfiles/{rails_6.0.0.beta3.gemfile → rails_6.0.3.4.gemfile} +2 -2
- data/gemfiles/rails_6.1.0.gemfile +8 -0
- data/lib/auto_increment/version.rb +1 -1
- data/spec/db/sync.db +0 -0
- metadata +8 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f19f9f54c7b8a7641d6adb7527d9f9054ad131d015af8aec346cac61711129f7
|
4
|
+
data.tar.gz: 6ac27b9292e3003db26a709ac7b4c78f18b1e5d7c0c35c0f9f1e47a7f7132763
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85ac0c4b0cd645f05703685bfcf3d64158a409db01d37eda4bf85c0e65c57029a2d656a1830fce754b150a901533ee5f4f60e152fce632926805c8f88ccd0e3b
|
7
|
+
data.tar.gz: bab85c29b564da957bb9088000bf4da689e937ba86caacbc4290d910480d4bf620e44ba68c0f1f9acc6eccaca57a5513474bbf553ba402d70d0709f8a9a76c37
|
data/.travis.yml
CHANGED
@@ -2,8 +2,7 @@ language: ruby
|
|
2
2
|
sudo: false
|
3
3
|
cache: bundler
|
4
4
|
rvm:
|
5
|
-
- 2.
|
6
|
-
- 2.6.2
|
5
|
+
- 2.6.6
|
7
6
|
before_install:
|
8
7
|
- gem update --system
|
9
8
|
gemfile:
|
@@ -11,4 +10,5 @@ gemfile:
|
|
11
10
|
- gemfiles/rails_5.0.7.2.gemfile
|
12
11
|
- gemfiles/rails_5.1.6.2.gemfile
|
13
12
|
- gemfiles/rails_5.2.2.1.gemfile
|
14
|
-
- gemfiles/rails_6.0.
|
13
|
+
- gemfiles/rails_6.0.3.4.gemfile
|
14
|
+
- gemfiles/rails_6.1.0.gemfile
|
data/Appraisals
CHANGED
@@ -3,12 +3,16 @@ RAILS_VERSIONS = %w(
|
|
3
3
|
5.0.7.2
|
4
4
|
5.1.6.2
|
5
5
|
5.2.2.1
|
6
|
-
6.0.
|
6
|
+
6.0.3.4
|
7
|
+
6.1.0
|
7
8
|
)
|
8
9
|
|
9
10
|
RAILS_VERSIONS.each do |version|
|
10
11
|
appraise "rails_#{version}" do
|
11
12
|
gem 'activerecord', version
|
12
13
|
gem 'activesupport', version
|
14
|
+
if version.split('.').first.to_i < 6
|
15
|
+
gem 'sqlite3', '1.3.13'
|
16
|
+
end
|
13
17
|
end
|
14
18
|
end
|
data/README.md
CHANGED
@@ -8,37 +8,43 @@ auto_increment provides automatic incrementation for a integer or string fields
|
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
11
|
-
You can use auto_increment as a gem from Rails 4.2 to Rails
|
11
|
+
You can use auto_increment as a gem from Rails 4.2 to Rails 6.1.
|
12
12
|
|
13
13
|
To use the gem version, put the following gem requirement in your `Gemfile`:
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
```rb
|
16
|
+
gem "auto_increment"
|
17
|
+
```
|
17
18
|
|
18
19
|
## Usage
|
19
20
|
|
20
21
|
To work with a auto increment column you used to do something like this in your model:
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
```rb
|
24
|
+
before_create :set_code
|
25
|
+
def set_code
|
26
|
+
max_code = Operation.maximum(:code)
|
27
|
+
self.code = max_code.to_i + 1
|
28
|
+
end
|
29
|
+
```
|
27
30
|
|
28
31
|
Looks fine, but not when you need to do it over and over again. In fact auto_increment does it under the cover.
|
29
32
|
|
30
33
|
All you need to do is this:
|
31
34
|
|
32
|
-
|
35
|
+
```rb
|
36
|
+
auto_increment :code
|
37
|
+
```
|
33
38
|
|
34
39
|
And your code field will be incremented
|
35
40
|
|
36
|
-
|
37
41
|
## Customizing
|
38
42
|
|
39
43
|
So you have a different column or need a scope. auto_increment provides options. You can use it like this:
|
40
44
|
|
41
|
-
|
45
|
+
```rb
|
46
|
+
auto_increment :letter, scope: [:account_id, :job_id], model_scope: :in_account, initial: 'C', force: true, lock: false, before: :create
|
47
|
+
```
|
42
48
|
|
43
49
|
First argument is the column that will be incremented. Can be integer or string.
|
44
50
|
|
@@ -52,8 +58,8 @@ First argument is the column that will be incremented. Can be integer or string.
|
|
52
58
|
|
53
59
|
## Compatibility
|
54
60
|
|
55
|
-
Tested with Rails 4.2, 5, 5.
|
61
|
+
Tested with Rails 6.1.0, 6.0.3.4, 5.2.2.1, 5.1.6.2, 5.0.7.2 and 4.2.11.1 in Ruby 2.6.6.
|
56
62
|
|
57
63
|
## License
|
58
64
|
|
59
|
-
MIT License
|
65
|
+
[MIT License](LICENSE.txt)
|
data/auto_increment.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.licenses = 'MIT'
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
10
|
s.authors = ['Felipe Diesel']
|
11
|
-
s.email = ['
|
11
|
+
s.email = ['diesel@hey.com']
|
12
12
|
s.homepage = 'http://github.com/felipediesel/auto_increment'
|
13
13
|
s.summary = 'Auto increment a string or integer field'
|
14
14
|
s.description = 'Automaticaly increments a string or integer field ' \
|
@@ -18,8 +18,8 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
19
|
s.require_paths = ['lib']
|
20
20
|
|
21
|
-
s.add_dependency 'activerecord', '>= 4.0'
|
22
|
-
s.add_dependency 'activesupport', '>= 4.0'
|
21
|
+
s.add_dependency 'activerecord', '>= 4.0'
|
22
|
+
s.add_dependency 'activesupport', '>= 4.0'
|
23
23
|
|
24
24
|
s.add_development_dependency 'bundler'
|
25
25
|
s.add_development_dependency 'rake'
|
@@ -33,5 +33,5 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.add_development_dependency 'database_cleaner'
|
34
34
|
s.add_development_dependency 'appraisal'
|
35
35
|
|
36
|
-
s.add_development_dependency 'sqlite3', '
|
36
|
+
s.add_development_dependency 'sqlite3', '>= 1.3.13'
|
37
37
|
end
|
data/spec/db/sync.db
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auto_increment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felipe Diesel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -17,9 +17,6 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.0'
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '6.1'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,9 +24,6 @@ dependencies:
|
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '4.0'
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '6.1'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: activesupport
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -37,9 +31,6 @@ dependencies:
|
|
37
31
|
- - ">="
|
38
32
|
- !ruby/object:Gem::Version
|
39
33
|
version: '4.0'
|
40
|
-
- - "<"
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '6.1'
|
43
34
|
type: :runtime
|
44
35
|
prerelease: false
|
45
36
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -47,9 +38,6 @@ dependencies:
|
|
47
38
|
- - ">="
|
48
39
|
- !ruby/object:Gem::Version
|
49
40
|
version: '4.0'
|
50
|
-
- - "<"
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: '6.1'
|
53
41
|
- !ruby/object:Gem::Dependency
|
54
42
|
name: bundler
|
55
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -194,19 +182,19 @@ dependencies:
|
|
194
182
|
name: sqlite3
|
195
183
|
requirement: !ruby/object:Gem::Requirement
|
196
184
|
requirements:
|
197
|
-
- - "
|
185
|
+
- - ">="
|
198
186
|
- !ruby/object:Gem::Version
|
199
187
|
version: 1.3.13
|
200
188
|
type: :development
|
201
189
|
prerelease: false
|
202
190
|
version_requirements: !ruby/object:Gem::Requirement
|
203
191
|
requirements:
|
204
|
-
- - "
|
192
|
+
- - ">="
|
205
193
|
- !ruby/object:Gem::Version
|
206
194
|
version: 1.3.13
|
207
195
|
description: Automaticaly increments a string or integer field in ActiveRecord.
|
208
196
|
email:
|
209
|
-
-
|
197
|
+
- diesel@hey.com
|
210
198
|
executables: []
|
211
199
|
extensions: []
|
212
200
|
extra_rdoc_files: []
|
@@ -227,7 +215,8 @@ files:
|
|
227
215
|
- gemfiles/rails_5.0.7.2.gemfile
|
228
216
|
- gemfiles/rails_5.1.6.2.gemfile
|
229
217
|
- gemfiles/rails_5.2.2.1.gemfile
|
230
|
-
- gemfiles/rails_6.0.
|
218
|
+
- gemfiles/rails_6.0.3.4.gemfile
|
219
|
+
- gemfiles/rails_6.1.0.gemfile
|
231
220
|
- lib/auto_increment.rb
|
232
221
|
- lib/auto_increment/active_record.rb
|
233
222
|
- lib/auto_increment/incrementor.rb
|
@@ -259,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
259
248
|
- !ruby/object:Gem::Version
|
260
249
|
version: '0'
|
261
250
|
requirements: []
|
262
|
-
rubygems_version: 3.
|
251
|
+
rubygems_version: 3.1.4
|
263
252
|
signing_key:
|
264
253
|
specification_version: 4
|
265
254
|
summary: Auto increment a string or integer field
|