sequenced 3.2.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,7 +21,7 @@ module Sequenced
21
21
  end
22
22
 
23
23
  def skip?
24
- skip && skip.call(record)
24
+ skip&.call(record)
25
25
  end
26
26
 
27
27
  def next_id
@@ -32,8 +32,11 @@ module Sequenced
32
32
 
33
33
  def next_id_in_sequence
34
34
  start_at = self.start_at.respond_to?(:call) ? self.start_at.call(record) : self.start_at
35
- return start_at unless last_record = find_last_record
36
- max(last_record.send(column) + 1, start_at)
35
+ if (last_record = find_last_record)
36
+ max(last_record.send(column) + 1, start_at)
37
+ else
38
+ start_at
39
+ end
37
40
  end
38
41
 
39
42
  def unique?(id)
@@ -44,7 +47,7 @@ module Sequenced
44
47
  end.count == 0
45
48
  end
46
49
 
47
- private
50
+ private
48
51
 
49
52
  def lock_table
50
53
  if postgresql?
@@ -54,7 +57,7 @@ module Sequenced
54
57
 
55
58
  def postgresql?
56
59
  defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) &&
57
- record.class.connection.kind_of?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
60
+ record.class.connection.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
58
61
  end
59
62
 
60
63
  def base_relation
@@ -63,9 +66,9 @@ module Sequenced
63
66
 
64
67
  def find_last_record
65
68
  build_scope(*scope) do
66
- base_relation.
67
- where("#{column.to_s} IS NOT NULL").
68
- order("#{column.to_s} DESC")
69
+ base_relation
70
+ .where("#{column} IS NOT NULL")
71
+ .order("#{column} DESC")
69
72
  end.first
70
73
  end
71
74
 
@@ -78,6 +81,5 @@ module Sequenced
78
81
  def max(*values)
79
82
  values.to_a.max
80
83
  end
81
-
82
84
  end
83
85
  end
@@ -1,3 +1,3 @@
1
1
  module Sequenced
2
- VERSION = "3.2.0"
2
+ VERSION = "4.0.0"
3
3
  end
data/lib/sequenced.rb CHANGED
@@ -1,4 +1,6 @@
1
- require 'sequenced/generator'
2
- require 'sequenced/acts_as_sequenced'
1
+ require "sequenced/generator"
2
+ require "sequenced/acts_as_sequenced"
3
3
 
4
- ActiveRecord::Base.send(:include, Sequenced::ActsAsSequenced)
4
+ ActiveSupport.on_load(:active_record) do
5
+ include Sequenced::ActsAsSequenced
6
+ end
data/sequenced.gemspec CHANGED
@@ -2,13 +2,13 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
  require "sequenced/version"
3
3
 
4
4
  Gem::Specification.new do |s|
5
- s.name = "sequenced"
6
- s.version = Sequenced::VERSION
7
- s.authors = ["Derrick Reimer"]
8
- s.licenses = ['MIT']
9
- s.email = ["derrickreimer@gmail.com"]
10
- s.homepage = "https://github.com/derrickreimer/sequenced"
11
- s.summary = "Generate scoped sequential IDs for ActiveRecord models"
5
+ s.name = "sequenced"
6
+ s.version = Sequenced::VERSION
7
+ s.authors = ["Derrick Reimer"]
8
+ s.licenses = ["MIT"]
9
+ s.email = ["derrickreimer@gmail.com"]
10
+ s.homepage = "https://github.com/derrickreimer/sequenced"
11
+ s.summary = "Generate scoped sequential IDs for ActiveRecord models"
12
12
  s.description = "Sequenced is a gem that generates scoped sequential IDs for ActiveRecord models."
13
13
 
14
14
  s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequenced
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derrick Reimer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-29 00:00:00.000000000 Z
11
+ date: 2022-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -60,13 +60,24 @@ executables: []
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
+ - ".github/workflows/ci.yml"
63
64
  - ".gitignore"
64
- - ".travis.yml"
65
+ - Appraisals
65
66
  - CHANGELOG.md
66
67
  - Gemfile
67
68
  - MIT-LICENSE
68
69
  - README.md
69
70
  - Rakefile
71
+ - gemfiles/rails_5_2.gemfile
72
+ - gemfiles/rails_5_2.gemfile.lock
73
+ - gemfiles/rails_6.gemfile
74
+ - gemfiles/rails_6.gemfile.lock
75
+ - gemfiles/rails_6_1.gemfile
76
+ - gemfiles/rails_6_1.gemfile.lock
77
+ - gemfiles/rails_7.gemfile
78
+ - gemfiles/rails_7.gemfile.lock
79
+ - gemfiles/rails_master.gemfile
80
+ - gemfiles/rails_master.gemfile.lock
70
81
  - lib/sequenced.rb
71
82
  - lib/sequenced/acts_as_sequenced.rb
72
83
  - lib/sequenced/generator.rb
@@ -76,7 +87,7 @@ homepage: https://github.com/derrickreimer/sequenced
76
87
  licenses:
77
88
  - MIT
78
89
  metadata: {}
79
- post_install_message:
90
+ post_install_message:
80
91
  rdoc_options: []
81
92
  require_paths:
82
93
  - lib
@@ -91,9 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
102
  - !ruby/object:Gem::Version
92
103
  version: '0'
93
104
  requirements: []
94
- rubyforge_project:
95
- rubygems_version: 2.7.3
96
- signing_key:
105
+ rubygems_version: 3.3.7
106
+ signing_key:
97
107
  specification_version: 4
98
108
  summary: Generate scoped sequential IDs for ActiveRecord models
99
109
  test_files: []
data/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.4.1
4
-
5
- env:
6
- - DB=sqlite
7
- - DB=postgresql
8
-
9
- before_script:
10
- - rake db:create
11
-
12
- services:
13
- - postgresql