├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .rspec ├── .rubocop.yml ├── .ruby-version ├── Appraisals ├── Gemfile ├── Gemfile.lock ├── Guardfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── auto_increment.gemspec ├── gemfiles ├── .bundle │ └── config ├── rails_6_0.gemfile ├── rails_6_0.gemfile.lock ├── rails_6_1.gemfile ├── rails_6_1.gemfile.lock ├── rails_7_0.gemfile ├── rails_7_0.gemfile.lock ├── rails_7_1.gemfile ├── rails_7_1.gemfile.lock ├── rails_7_2.gemfile └── rails_7_2.gemfile.lock ├── lib ├── auto_increment.rb └── auto_increment │ ├── active_record.rb │ ├── incrementor.rb │ └── version.rb └── spec ├── lib ├── active_record_spec.rb └── incrementor_spec.rb ├── models ├── account.rb └── user.rb ├── spec_helper.rb └── support ├── active_record.rb └── database_cleaner.rb /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - "*" 10 | jobs: 11 | standard: 12 | runs-on: ubuntu-latest 13 | permissions: 14 | checks: write 15 | contents: write 16 | steps: 17 | - name: Standard Ruby 18 | uses: standardrb/standard-ruby-action@v1 19 | with: 20 | autofix: false 21 | test: 22 | strategy: 23 | fail-fast: false 24 | matrix: 25 | ruby: ["3.2.5", "3.3.5"] 26 | gemfile: [rails_6_0, rails_6_1, rails_7_0, rails_7_1, rails_7_2] 27 | exclude: 28 | - ruby: "2.7.8" 29 | gemfile: rails_7_0 30 | - ruby: "2.7.8" 31 | gemfile: rails_7_1 32 | - ruby: "2.7.8" 33 | gemfile: rails_7_2 34 | 35 | runs-on: ubuntu-latest 36 | env: 37 | BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile 38 | steps: 39 | - uses: actions/checkout@v4 40 | - uses: ruby/setup-ruby@v1 41 | with: 42 | ruby-version: ${{ matrix.ruby }} 43 | bundler-cache: true 44 | - run: bundle exec rspec 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | !.keep 3 | *.DS_Store 4 | *.swo 5 | *.swp 6 | /.bundle 7 | /.env 8 | /.foreman 9 | /coverage/* 10 | /db/*.sqlite3 11 | /log/* 12 | /tmp/* 13 | !/log/.keep 14 | !/tmp/.keep 15 | /spec/db 16 | !/spec/db/.keep 17 | /tags 18 | pkg 19 | *.ipr 20 | *.iws 21 | *.iml 22 | /.idea 23 | .byebug_history 24 | gemfiles/.bundle/ 25 | .yardoc 26 | /doc 27 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --drb 2 | --format Fuubar 3 | --color -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - standard 3 | - standard-custom 4 | - standard-performance 5 | - rubocop-performance 6 | 7 | inherit_gem: 8 | standard: config/base.yml 9 | standard-custom: config/base.yml 10 | standard-performance: config/base.yml 11 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 3.3.5 2 | -------------------------------------------------------------------------------- /Appraisals: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | RAILS_VERSIONS = { 4 | "6_0" => "6.0.6.1", 5 | "6_1" => "6.1.7.8", 6 | "7_0" => "7.0.8.4", 7 | "7_1" => "7.1.4", 8 | "7_2" => "7.2.1" 9 | }.freeze 10 | 11 | RAILS_VERSIONS.each do |name, version| 12 | appraise "rails_#{name}" do 13 | gem "activerecord", version 14 | gem "activesupport", version 15 | group :development do 16 | gem "standard" if name.start_with?("7") 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | gemspec 6 | 7 | group :development do 8 | gem "appraisal" 9 | gem "bundler" 10 | gem "database_cleaner" 11 | gem "fuubar" 12 | gem "guard" 13 | gem "guard-rspec" 14 | gem "rake" 15 | gem "rspec" 16 | gem "rspec-nc" 17 | gem "sqlite3", "~> 1.7.3" 18 | gem "standard" 19 | end 20 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | auto_increment (1.6.2) 5 | activerecord (>= 6.0) 6 | activesupport (>= 6.0) 7 | 8 | GEM 9 | remote: https://rubygems.org/ 10 | specs: 11 | activemodel (7.2.1) 12 | activesupport (= 7.2.1) 13 | activerecord (7.2.1) 14 | activemodel (= 7.2.1) 15 | activesupport (= 7.2.1) 16 | timeout (>= 0.4.0) 17 | activesupport (7.2.1) 18 | base64 19 | bigdecimal 20 | concurrent-ruby (~> 1.0, >= 1.3.1) 21 | connection_pool (>= 2.2.5) 22 | drb 23 | i18n (>= 1.6, < 2) 24 | logger (>= 1.4.2) 25 | minitest (>= 5.1) 26 | securerandom (>= 0.3) 27 | tzinfo (~> 2.0, >= 2.0.5) 28 | appraisal (2.5.0) 29 | bundler 30 | rake 31 | thor (>= 0.14.0) 32 | ast (2.4.2) 33 | base64 (0.2.0) 34 | bigdecimal (3.1.8) 35 | coderay (1.1.3) 36 | concurrent-ruby (1.3.4) 37 | connection_pool (2.4.1) 38 | database_cleaner (2.0.2) 39 | database_cleaner-active_record (>= 2, < 3) 40 | database_cleaner-active_record (2.2.0) 41 | activerecord (>= 5.a) 42 | database_cleaner-core (~> 2.0.0) 43 | database_cleaner-core (2.0.1) 44 | diff-lcs (1.5.1) 45 | drb (2.2.1) 46 | ffi (1.17.0) 47 | ffi (1.17.0-x86_64-linux-gnu) 48 | formatador (1.1.0) 49 | fuubar (2.5.1) 50 | rspec-core (~> 3.0) 51 | ruby-progressbar (~> 1.4) 52 | guard (2.18.1) 53 | formatador (>= 0.2.4) 54 | listen (>= 2.7, < 4.0) 55 | lumberjack (>= 1.0.12, < 2.0) 56 | nenv (~> 0.1) 57 | notiffany (~> 0.0) 58 | pry (>= 0.13.0) 59 | shellany (~> 0.0) 60 | thor (>= 0.18.1) 61 | guard-compat (1.2.1) 62 | guard-rspec (4.7.3) 63 | guard (~> 2.1) 64 | guard-compat (~> 1.1) 65 | rspec (>= 2.99.0, < 4.0) 66 | i18n (1.14.6) 67 | concurrent-ruby (~> 1.0) 68 | json (2.7.2) 69 | language_server-protocol (3.17.0.3) 70 | lint_roller (1.1.0) 71 | listen (3.9.0) 72 | rb-fsevent (~> 0.10, >= 0.10.3) 73 | rb-inotify (~> 0.9, >= 0.9.10) 74 | logger (1.6.1) 75 | lumberjack (1.2.10) 76 | method_source (1.1.0) 77 | mini_portile2 (2.8.7) 78 | minitest (5.25.1) 79 | nenv (0.3.0) 80 | notiffany (0.1.3) 81 | nenv (~> 0.1) 82 | shellany (~> 0.0) 83 | parallel (1.26.3) 84 | parser (3.3.5.0) 85 | ast (~> 2.4.1) 86 | racc 87 | pry (0.14.2) 88 | coderay (~> 1.1) 89 | method_source (~> 1.0) 90 | racc (1.8.1) 91 | rainbow (3.1.1) 92 | rake (13.2.1) 93 | rb-fsevent (0.11.2) 94 | rb-inotify (0.11.1) 95 | ffi (~> 1.0) 96 | regexp_parser (2.9.2) 97 | rexml (3.3.7) 98 | rspec (3.13.0) 99 | rspec-core (~> 3.13.0) 100 | rspec-expectations (~> 3.13.0) 101 | rspec-mocks (~> 3.13.0) 102 | rspec-core (3.13.1) 103 | rspec-support (~> 3.13.0) 104 | rspec-expectations (3.13.3) 105 | diff-lcs (>= 1.2.0, < 2.0) 106 | rspec-support (~> 3.13.0) 107 | rspec-mocks (3.13.1) 108 | diff-lcs (>= 1.2.0, < 2.0) 109 | rspec-support (~> 3.13.0) 110 | rspec-nc (0.3.0) 111 | rspec (>= 3) 112 | terminal-notifier (>= 1.4) 113 | rspec-support (3.13.1) 114 | rubocop (1.65.1) 115 | json (~> 2.3) 116 | language_server-protocol (>= 3.17.0) 117 | parallel (~> 1.10) 118 | parser (>= 3.3.0.2) 119 | rainbow (>= 2.2.2, < 4.0) 120 | regexp_parser (>= 2.4, < 3.0) 121 | rexml (>= 3.2.5, < 4.0) 122 | rubocop-ast (>= 1.31.1, < 2.0) 123 | ruby-progressbar (~> 1.7) 124 | unicode-display_width (>= 2.4.0, < 3.0) 125 | rubocop-ast (1.32.3) 126 | parser (>= 3.3.1.0) 127 | rubocop-performance (1.21.1) 128 | rubocop (>= 1.48.1, < 2.0) 129 | rubocop-ast (>= 1.31.1, < 2.0) 130 | ruby-progressbar (1.13.0) 131 | securerandom (0.3.1) 132 | shellany (0.0.1) 133 | sqlite3 (1.7.3) 134 | mini_portile2 (~> 2.8.0) 135 | sqlite3 (1.7.3-x86_64-linux) 136 | standard (1.40.0) 137 | language_server-protocol (~> 3.17.0.2) 138 | lint_roller (~> 1.0) 139 | rubocop (~> 1.65.0) 140 | standard-custom (~> 1.0.0) 141 | standard-performance (~> 1.4) 142 | standard-custom (1.0.2) 143 | lint_roller (~> 1.0) 144 | rubocop (~> 1.50) 145 | standard-performance (1.4.0) 146 | lint_roller (~> 1.1) 147 | rubocop-performance (~> 1.21.0) 148 | terminal-notifier (2.0.0) 149 | thor (1.3.2) 150 | timeout (0.4.1) 151 | tzinfo (2.0.6) 152 | concurrent-ruby (~> 1.0) 153 | unicode-display_width (2.6.0) 154 | 155 | PLATFORMS 156 | ruby 157 | x86_64-linux 158 | 159 | DEPENDENCIES 160 | appraisal 161 | auto_increment! 162 | bundler 163 | database_cleaner 164 | fuubar 165 | guard 166 | guard-rspec 167 | rake 168 | rspec 169 | rspec-nc 170 | sqlite3 (~> 1.7.3) 171 | standard 172 | 173 | BUNDLED WITH 174 | 2.4.22 175 | -------------------------------------------------------------------------------- /Guardfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | guard :rspec, cmd: "bundle exec rspec" do 4 | watch(%r{^spec/.+_spec\.rb$}) 5 | watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } 6 | watch("spec/spec_helper.rb") { "spec" } 7 | end 8 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Felipe Diesel 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # auto_increment 2 | 3 | ![CI status](https://github.com/felipediesel/auto_increment/actions/workflows/ci.yml/badge.svg?branch=main) 4 | 5 | [![Code Climate](https://codeclimate.com/github/felipediesel/auto_increment/badges/gpa.svg)](https://codeclimate.com/github/felipediesel/auto_increment) 6 | 7 | auto_increment provides automatic incrementation for a integer or string fields in Rails. 8 | 9 | ## Installation 10 | 11 | You can use auto_increment as a gem from Rails 4.2 to Rails 6.1. 12 | 13 | To use the gem version, put the following gem requirement in your `Gemfile`: 14 | 15 | ```rb 16 | gem "auto_increment" 17 | ``` 18 | 19 | ## Usage 20 | 21 | To work with a auto increment column you used to do something like this in your model: 22 | 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 | ``` 30 | 31 | Looks fine, but not when you need to do it over and over again. In fact auto_increment does it under the cover. 32 | 33 | All you need to do is this: 34 | 35 | ```rb 36 | auto_increment :code 37 | ``` 38 | 39 | And your code field will be incremented 40 | 41 | ## Customizing 42 | 43 | So you have a different column or need a scope. auto_increment provides options. You can use it like this: 44 | 45 | ```rb 46 | auto_increment :letter, scope: [:account_id, :job_id], model_scope: :in_account, initial: 'C', force: true, lock: false, before: :create 47 | ``` 48 | 49 | First argument is the column that will be incremented. Can be integer or string. 50 | 51 | - scope: you can define columns that will be scoped and you can use as many as you want (default: nil) 52 | - model_scope: you can define model scopes that will be executed and you can use as many as you want (default: nil) 53 | - initial: initial value of column (default: 1) 54 | - force: you can set a value before create and auto_increment will not change that, but if you do want this, set force to true (default: false) 55 | - lock: you can set a lock on the max query. (default: false) 56 | - before: you can choose a different callback to be used (:create, :save, :validation) (default: create) 57 | 58 | ## Compatibility 59 | 60 | Tested with Rails 6.1, 6 in Ruby 2.7.7. 61 | Tested with Rails 7.1, 7, 6.1, 6 in Ruby 3.2.2. 62 | 63 | For older versions, use version 1.5.2. 64 | 65 | ## License 66 | 67 | [MIT License](LICENSE.txt) 68 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "rspec/core/rake_task" 4 | require "bundler/gem_tasks" 5 | 6 | RSpec::Core::RakeTask.new(:spec) 7 | 8 | task default: :spec 9 | -------------------------------------------------------------------------------- /auto_increment.gemspec: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | $LOAD_PATH.push File.expand_path("lib", __dir__) 4 | require "auto_increment/version" 5 | 6 | Gem::Specification.new do |s| 7 | s.name = "auto_increment" 8 | s.version = AutoIncrement::VERSION.dup 9 | s.licenses = "MIT" 10 | s.platform = Gem::Platform::RUBY 11 | s.authors = ["Felipe Diesel"] 12 | s.email = ["diesel@hey.com"] 13 | s.homepage = "http://github.com/felipediesel/auto_increment" 14 | s.summary = "Auto increment a string or integer column" 15 | s.description = "Automaticaly increments an ActiveRecord column" 16 | 17 | s.files = `git ls-files`.split("\n") 18 | s.require_paths = ["lib"] 19 | 20 | s.add_dependency "activerecord", ">= 6.0" 21 | s.add_dependency "activesupport", ">= 6.0" 22 | 23 | s.metadata["rubygems_mfa_required"] = "true" 24 | end 25 | -------------------------------------------------------------------------------- /gemfiles/.bundle/config: -------------------------------------------------------------------------------- 1 | --- 2 | BUNDLE_RETRY: "1" 3 | -------------------------------------------------------------------------------- /gemfiles/rails_6_0.gemfile: -------------------------------------------------------------------------------- 1 | # This file was generated by Appraisal 2 | 3 | source "https://rubygems.org" 4 | 5 | gem "activerecord", "6.0.6.1" 6 | gem "activesupport", "6.0.6.1" 7 | 8 | group :development do 9 | gem "appraisal" 10 | gem "bundler" 11 | gem "database_cleaner" 12 | gem "fuubar" 13 | gem "guard" 14 | gem "guard-rspec" 15 | gem "rake" 16 | gem "rspec" 17 | gem "rspec-nc" 18 | gem "sqlite3", "~> 1.7.3" 19 | gem "standard" 20 | end 21 | 22 | gemspec path: "../" 23 | -------------------------------------------------------------------------------- /gemfiles/rails_6_0.gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: .. 3 | specs: 4 | auto_increment (1.6.2) 5 | activerecord (>= 6.0) 6 | activesupport (>= 6.0) 7 | 8 | GEM 9 | remote: https://rubygems.org/ 10 | specs: 11 | activemodel (6.0.6.1) 12 | activesupport (= 6.0.6.1) 13 | activerecord (6.0.6.1) 14 | activemodel (= 6.0.6.1) 15 | activesupport (= 6.0.6.1) 16 | activesupport (6.0.6.1) 17 | concurrent-ruby (~> 1.0, >= 1.0.2) 18 | i18n (>= 0.7, < 2) 19 | minitest (~> 5.1) 20 | tzinfo (~> 1.1) 21 | zeitwerk (~> 2.2, >= 2.2.2) 22 | appraisal (2.5.0) 23 | bundler 24 | rake 25 | thor (>= 0.14.0) 26 | ast (2.4.2) 27 | coderay (1.1.3) 28 | concurrent-ruby (1.2.3) 29 | database_cleaner (2.0.2) 30 | database_cleaner-active_record (>= 2, < 3) 31 | database_cleaner-active_record (2.1.0) 32 | activerecord (>= 5.a) 33 | database_cleaner-core (~> 2.0.0) 34 | database_cleaner-core (2.0.1) 35 | diff-lcs (1.5.1) 36 | ffi (1.16.3) 37 | formatador (1.1.0) 38 | fuubar (2.5.1) 39 | rspec-core (~> 3.0) 40 | ruby-progressbar (~> 1.4) 41 | guard (2.18.1) 42 | formatador (>= 0.2.4) 43 | listen (>= 2.7, < 4.0) 44 | lumberjack (>= 1.0.12, < 2.0) 45 | nenv (~> 0.1) 46 | notiffany (~> 0.0) 47 | pry (>= 0.13.0) 48 | shellany (~> 0.0) 49 | thor (>= 0.18.1) 50 | guard-compat (1.2.1) 51 | guard-rspec (4.7.3) 52 | guard (~> 2.1) 53 | guard-compat (~> 1.1) 54 | rspec (>= 2.99.0, < 4.0) 55 | i18n (1.14.5) 56 | concurrent-ruby (~> 1.0) 57 | json (2.7.2) 58 | language_server-protocol (3.17.0.3) 59 | lint_roller (1.1.0) 60 | listen (3.9.0) 61 | rb-fsevent (~> 0.10, >= 0.10.3) 62 | rb-inotify (~> 0.9, >= 0.9.10) 63 | lumberjack (1.2.10) 64 | method_source (1.1.0) 65 | mini_portile2 (2.8.7) 66 | minitest (5.23.0) 67 | nenv (0.3.0) 68 | notiffany (0.1.3) 69 | nenv (~> 0.1) 70 | shellany (~> 0.0) 71 | parallel (1.26.3) 72 | parser (3.3.5.0) 73 | ast (~> 2.4.1) 74 | racc 75 | pry (0.14.2) 76 | coderay (~> 1.1) 77 | method_source (~> 1.0) 78 | racc (1.8.1) 79 | rainbow (3.1.1) 80 | rake (13.2.1) 81 | rb-fsevent (0.11.2) 82 | rb-inotify (0.10.1) 83 | ffi (~> 1.0) 84 | regexp_parser (2.9.2) 85 | rexml (3.3.7) 86 | rspec (3.13.0) 87 | rspec-core (~> 3.13.0) 88 | rspec-expectations (~> 3.13.0) 89 | rspec-mocks (~> 3.13.0) 90 | rspec-core (3.13.0) 91 | rspec-support (~> 3.13.0) 92 | rspec-expectations (3.13.0) 93 | diff-lcs (>= 1.2.0, < 2.0) 94 | rspec-support (~> 3.13.0) 95 | rspec-mocks (3.13.1) 96 | diff-lcs (>= 1.2.0, < 2.0) 97 | rspec-support (~> 3.13.0) 98 | rspec-nc (0.3.0) 99 | rspec (>= 3) 100 | terminal-notifier (>= 1.4) 101 | rspec-support (3.13.1) 102 | rubocop (1.65.1) 103 | json (~> 2.3) 104 | language_server-protocol (>= 3.17.0) 105 | parallel (~> 1.10) 106 | parser (>= 3.3.0.2) 107 | rainbow (>= 2.2.2, < 4.0) 108 | regexp_parser (>= 2.4, < 3.0) 109 | rexml (>= 3.2.5, < 4.0) 110 | rubocop-ast (>= 1.31.1, < 2.0) 111 | ruby-progressbar (~> 1.7) 112 | unicode-display_width (>= 2.4.0, < 3.0) 113 | rubocop-ast (1.32.3) 114 | parser (>= 3.3.1.0) 115 | rubocop-performance (1.21.1) 116 | rubocop (>= 1.48.1, < 2.0) 117 | rubocop-ast (>= 1.31.1, < 2.0) 118 | ruby-progressbar (1.13.0) 119 | shellany (0.0.1) 120 | sqlite3 (1.7.3) 121 | mini_portile2 (~> 2.8.0) 122 | standard (1.40.0) 123 | language_server-protocol (~> 3.17.0.2) 124 | lint_roller (~> 1.0) 125 | rubocop (~> 1.65.0) 126 | standard-custom (~> 1.0.0) 127 | standard-performance (~> 1.4) 128 | standard-custom (1.0.2) 129 | lint_roller (~> 1.0) 130 | rubocop (~> 1.50) 131 | standard-performance (1.4.0) 132 | lint_roller (~> 1.1) 133 | rubocop-performance (~> 1.21.0) 134 | terminal-notifier (2.0.0) 135 | thor (1.3.1) 136 | thread_safe (0.3.6) 137 | tzinfo (1.2.11) 138 | thread_safe (~> 0.1) 139 | unicode-display_width (2.6.0) 140 | zeitwerk (2.6.14) 141 | 142 | PLATFORMS 143 | arm64-darwin-23 144 | arm64-darwin-24 145 | x86_64-linux 146 | 147 | DEPENDENCIES 148 | activerecord (= 6.0.6.1) 149 | activesupport (= 6.0.6.1) 150 | appraisal 151 | auto_increment! 152 | bundler 153 | database_cleaner 154 | fuubar 155 | guard 156 | guard-rspec 157 | rake 158 | rspec 159 | rspec-nc 160 | sqlite3 (~> 1.7.3) 161 | standard 162 | 163 | BUNDLED WITH 164 | 2.4.22 165 | -------------------------------------------------------------------------------- /gemfiles/rails_6_1.gemfile: -------------------------------------------------------------------------------- 1 | # This file was generated by Appraisal 2 | 3 | source "https://rubygems.org" 4 | 5 | gem "activerecord", "6.1.7.8" 6 | gem "activesupport", "6.1.7.8" 7 | 8 | group :development do 9 | gem "appraisal" 10 | gem "bundler" 11 | gem "database_cleaner" 12 | gem "fuubar" 13 | gem "guard" 14 | gem "guard-rspec" 15 | gem "rake" 16 | gem "rspec" 17 | gem "rspec-nc" 18 | gem "sqlite3", "~> 1.7.3" 19 | gem "standard" 20 | end 21 | 22 | gemspec path: "../" 23 | -------------------------------------------------------------------------------- /gemfiles/rails_6_1.gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: .. 3 | specs: 4 | auto_increment (1.6.2) 5 | activerecord (>= 6.0) 6 | activesupport (>= 6.0) 7 | 8 | GEM 9 | remote: https://rubygems.org/ 10 | specs: 11 | activemodel (6.1.7.8) 12 | activesupport (= 6.1.7.8) 13 | activerecord (6.1.7.8) 14 | activemodel (= 6.1.7.8) 15 | activesupport (= 6.1.7.8) 16 | activesupport (6.1.7.8) 17 | concurrent-ruby (~> 1.0, >= 1.0.2) 18 | i18n (>= 1.6, < 2) 19 | minitest (>= 5.1) 20 | tzinfo (~> 2.0) 21 | zeitwerk (~> 2.3) 22 | appraisal (2.5.0) 23 | bundler 24 | rake 25 | thor (>= 0.14.0) 26 | ast (2.4.2) 27 | coderay (1.1.3) 28 | concurrent-ruby (1.3.4) 29 | database_cleaner (2.0.2) 30 | database_cleaner-active_record (>= 2, < 3) 31 | database_cleaner-active_record (2.1.0) 32 | activerecord (>= 5.a) 33 | database_cleaner-core (~> 2.0.0) 34 | database_cleaner-core (2.0.1) 35 | diff-lcs (1.5.1) 36 | ffi (1.16.3) 37 | formatador (1.1.0) 38 | fuubar (2.5.1) 39 | rspec-core (~> 3.0) 40 | ruby-progressbar (~> 1.4) 41 | guard (2.18.1) 42 | formatador (>= 0.2.4) 43 | listen (>= 2.7, < 4.0) 44 | lumberjack (>= 1.0.12, < 2.0) 45 | nenv (~> 0.1) 46 | notiffany (~> 0.0) 47 | pry (>= 0.13.0) 48 | shellany (~> 0.0) 49 | thor (>= 0.18.1) 50 | guard-compat (1.2.1) 51 | guard-rspec (4.7.3) 52 | guard (~> 2.1) 53 | guard-compat (~> 1.1) 54 | rspec (>= 2.99.0, < 4.0) 55 | i18n (1.14.6) 56 | concurrent-ruby (~> 1.0) 57 | json (2.7.2) 58 | language_server-protocol (3.17.0.3) 59 | lint_roller (1.1.0) 60 | listen (3.9.0) 61 | rb-fsevent (~> 0.10, >= 0.10.3) 62 | rb-inotify (~> 0.9, >= 0.9.10) 63 | lumberjack (1.2.10) 64 | method_source (1.1.0) 65 | mini_portile2 (2.8.7) 66 | minitest (5.25.1) 67 | nenv (0.3.0) 68 | notiffany (0.1.3) 69 | nenv (~> 0.1) 70 | shellany (~> 0.0) 71 | parallel (1.26.3) 72 | parser (3.3.5.0) 73 | ast (~> 2.4.1) 74 | racc 75 | pry (0.14.2) 76 | coderay (~> 1.1) 77 | method_source (~> 1.0) 78 | racc (1.8.1) 79 | rainbow (3.1.1) 80 | rake (13.2.1) 81 | rb-fsevent (0.11.2) 82 | rb-inotify (0.10.1) 83 | ffi (~> 1.0) 84 | regexp_parser (2.9.2) 85 | rexml (3.3.7) 86 | rspec (3.13.0) 87 | rspec-core (~> 3.13.0) 88 | rspec-expectations (~> 3.13.0) 89 | rspec-mocks (~> 3.13.0) 90 | rspec-core (3.13.0) 91 | rspec-support (~> 3.13.0) 92 | rspec-expectations (3.13.0) 93 | diff-lcs (>= 1.2.0, < 2.0) 94 | rspec-support (~> 3.13.0) 95 | rspec-mocks (3.13.1) 96 | diff-lcs (>= 1.2.0, < 2.0) 97 | rspec-support (~> 3.13.0) 98 | rspec-nc (0.3.0) 99 | rspec (>= 3) 100 | terminal-notifier (>= 1.4) 101 | rspec-support (3.13.1) 102 | rubocop (1.65.1) 103 | json (~> 2.3) 104 | language_server-protocol (>= 3.17.0) 105 | parallel (~> 1.10) 106 | parser (>= 3.3.0.2) 107 | rainbow (>= 2.2.2, < 4.0) 108 | regexp_parser (>= 2.4, < 3.0) 109 | rexml (>= 3.2.5, < 4.0) 110 | rubocop-ast (>= 1.31.1, < 2.0) 111 | ruby-progressbar (~> 1.7) 112 | unicode-display_width (>= 2.4.0, < 3.0) 113 | rubocop-ast (1.32.3) 114 | parser (>= 3.3.1.0) 115 | rubocop-performance (1.21.1) 116 | rubocop (>= 1.48.1, < 2.0) 117 | rubocop-ast (>= 1.31.1, < 2.0) 118 | ruby-progressbar (1.13.0) 119 | shellany (0.0.1) 120 | sqlite3 (1.7.3) 121 | mini_portile2 (~> 2.8.0) 122 | standard (1.40.0) 123 | language_server-protocol (~> 3.17.0.2) 124 | lint_roller (~> 1.0) 125 | rubocop (~> 1.65.0) 126 | standard-custom (~> 1.0.0) 127 | standard-performance (~> 1.4) 128 | standard-custom (1.0.2) 129 | lint_roller (~> 1.0) 130 | rubocop (~> 1.50) 131 | standard-performance (1.4.0) 132 | lint_roller (~> 1.1) 133 | rubocop-performance (~> 1.21.0) 134 | terminal-notifier (2.0.0) 135 | thor (1.3.1) 136 | tzinfo (2.0.6) 137 | concurrent-ruby (~> 1.0) 138 | unicode-display_width (2.6.0) 139 | zeitwerk (2.6.18) 140 | 141 | PLATFORMS 142 | arm64-darwin-23 143 | arm64-darwin-24 144 | x86_64-linux 145 | 146 | DEPENDENCIES 147 | activerecord (= 6.1.7.8) 148 | activesupport (= 6.1.7.8) 149 | appraisal 150 | auto_increment! 151 | bundler 152 | database_cleaner 153 | fuubar 154 | guard 155 | guard-rspec 156 | rake 157 | rspec 158 | rspec-nc 159 | sqlite3 (~> 1.7.3) 160 | standard 161 | 162 | BUNDLED WITH 163 | 2.4.22 164 | -------------------------------------------------------------------------------- /gemfiles/rails_7_0.gemfile: -------------------------------------------------------------------------------- 1 | # This file was generated by Appraisal 2 | 3 | source "https://rubygems.org" 4 | 5 | gem "activerecord", "7.0.8.4" 6 | gem "activesupport", "7.0.8.4" 7 | 8 | group :development do 9 | gem "appraisal" 10 | gem "bundler" 11 | gem "database_cleaner" 12 | gem "fuubar" 13 | gem "guard" 14 | gem "guard-rspec" 15 | gem "rake" 16 | gem "rspec" 17 | gem "rspec-nc" 18 | gem "sqlite3", "~> 1.7.3" 19 | gem "standard" 20 | end 21 | 22 | gemspec path: "../" 23 | -------------------------------------------------------------------------------- /gemfiles/rails_7_0.gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: .. 3 | specs: 4 | auto_increment (1.6.2) 5 | activerecord (>= 6.0) 6 | activesupport (>= 6.0) 7 | 8 | GEM 9 | remote: https://rubygems.org/ 10 | specs: 11 | activemodel (7.0.8.4) 12 | activesupport (= 7.0.8.4) 13 | activerecord (7.0.8.4) 14 | activemodel (= 7.0.8.4) 15 | activesupport (= 7.0.8.4) 16 | activesupport (7.0.8.4) 17 | concurrent-ruby (~> 1.0, >= 1.0.2) 18 | i18n (>= 1.6, < 2) 19 | minitest (>= 5.1) 20 | tzinfo (~> 2.0) 21 | appraisal (2.5.0) 22 | bundler 23 | rake 24 | thor (>= 0.14.0) 25 | ast (2.4.2) 26 | coderay (1.1.3) 27 | concurrent-ruby (1.3.4) 28 | database_cleaner (2.0.2) 29 | database_cleaner-active_record (>= 2, < 3) 30 | database_cleaner-active_record (2.1.0) 31 | activerecord (>= 5.a) 32 | database_cleaner-core (~> 2.0.0) 33 | database_cleaner-core (2.0.1) 34 | diff-lcs (1.5.1) 35 | ffi (1.16.3) 36 | formatador (1.1.0) 37 | fuubar (2.5.1) 38 | rspec-core (~> 3.0) 39 | ruby-progressbar (~> 1.4) 40 | guard (2.18.1) 41 | formatador (>= 0.2.4) 42 | listen (>= 2.7, < 4.0) 43 | lumberjack (>= 1.0.12, < 2.0) 44 | nenv (~> 0.1) 45 | notiffany (~> 0.0) 46 | pry (>= 0.13.0) 47 | shellany (~> 0.0) 48 | thor (>= 0.18.1) 49 | guard-compat (1.2.1) 50 | guard-rspec (4.7.3) 51 | guard (~> 2.1) 52 | guard-compat (~> 1.1) 53 | rspec (>= 2.99.0, < 4.0) 54 | i18n (1.14.6) 55 | concurrent-ruby (~> 1.0) 56 | json (2.7.2) 57 | language_server-protocol (3.17.0.3) 58 | lint_roller (1.1.0) 59 | listen (3.9.0) 60 | rb-fsevent (~> 0.10, >= 0.10.3) 61 | rb-inotify (~> 0.9, >= 0.9.10) 62 | lumberjack (1.2.10) 63 | method_source (1.1.0) 64 | mini_portile2 (2.8.7) 65 | minitest (5.25.1) 66 | nenv (0.3.0) 67 | notiffany (0.1.3) 68 | nenv (~> 0.1) 69 | shellany (~> 0.0) 70 | parallel (1.26.3) 71 | parser (3.3.5.0) 72 | ast (~> 2.4.1) 73 | racc 74 | pry (0.14.2) 75 | coderay (~> 1.1) 76 | method_source (~> 1.0) 77 | racc (1.8.1) 78 | rainbow (3.1.1) 79 | rake (13.2.1) 80 | rb-fsevent (0.11.2) 81 | rb-inotify (0.10.1) 82 | ffi (~> 1.0) 83 | regexp_parser (2.9.2) 84 | rexml (3.3.7) 85 | rspec (3.13.0) 86 | rspec-core (~> 3.13.0) 87 | rspec-expectations (~> 3.13.0) 88 | rspec-mocks (~> 3.13.0) 89 | rspec-core (3.13.0) 90 | rspec-support (~> 3.13.0) 91 | rspec-expectations (3.13.0) 92 | diff-lcs (>= 1.2.0, < 2.0) 93 | rspec-support (~> 3.13.0) 94 | rspec-mocks (3.13.1) 95 | diff-lcs (>= 1.2.0, < 2.0) 96 | rspec-support (~> 3.13.0) 97 | rspec-nc (0.3.0) 98 | rspec (>= 3) 99 | terminal-notifier (>= 1.4) 100 | rspec-support (3.13.1) 101 | rubocop (1.65.1) 102 | json (~> 2.3) 103 | language_server-protocol (>= 3.17.0) 104 | parallel (~> 1.10) 105 | parser (>= 3.3.0.2) 106 | rainbow (>= 2.2.2, < 4.0) 107 | regexp_parser (>= 2.4, < 3.0) 108 | rexml (>= 3.2.5, < 4.0) 109 | rubocop-ast (>= 1.31.1, < 2.0) 110 | ruby-progressbar (~> 1.7) 111 | unicode-display_width (>= 2.4.0, < 3.0) 112 | rubocop-ast (1.32.3) 113 | parser (>= 3.3.1.0) 114 | rubocop-performance (1.21.1) 115 | rubocop (>= 1.48.1, < 2.0) 116 | rubocop-ast (>= 1.31.1, < 2.0) 117 | ruby-progressbar (1.13.0) 118 | shellany (0.0.1) 119 | sqlite3 (1.7.3) 120 | mini_portile2 (~> 2.8.0) 121 | standard (1.40.0) 122 | language_server-protocol (~> 3.17.0.2) 123 | lint_roller (~> 1.0) 124 | rubocop (~> 1.65.0) 125 | standard-custom (~> 1.0.0) 126 | standard-performance (~> 1.4) 127 | standard-custom (1.0.2) 128 | lint_roller (~> 1.0) 129 | rubocop (~> 1.50) 130 | standard-performance (1.4.0) 131 | lint_roller (~> 1.1) 132 | rubocop-performance (~> 1.21.0) 133 | terminal-notifier (2.0.0) 134 | thor (1.3.1) 135 | tzinfo (2.0.6) 136 | concurrent-ruby (~> 1.0) 137 | unicode-display_width (2.6.0) 138 | 139 | PLATFORMS 140 | arm64-darwin-23 141 | arm64-darwin-24 142 | x86_64-linux 143 | 144 | DEPENDENCIES 145 | activerecord (= 7.0.8.4) 146 | activesupport (= 7.0.8.4) 147 | appraisal 148 | auto_increment! 149 | bundler 150 | database_cleaner 151 | fuubar 152 | guard 153 | guard-rspec 154 | rake 155 | rspec 156 | rspec-nc 157 | sqlite3 (~> 1.7.3) 158 | standard 159 | 160 | BUNDLED WITH 161 | 2.4.22 162 | -------------------------------------------------------------------------------- /gemfiles/rails_7_1.gemfile: -------------------------------------------------------------------------------- 1 | # This file was generated by Appraisal 2 | 3 | source "https://rubygems.org" 4 | 5 | gem "activerecord", "7.1.4" 6 | gem "activesupport", "7.1.4" 7 | 8 | group :development do 9 | gem "appraisal" 10 | gem "bundler" 11 | gem "database_cleaner" 12 | gem "fuubar" 13 | gem "guard" 14 | gem "guard-rspec" 15 | gem "rake" 16 | gem "rspec" 17 | gem "rspec-nc" 18 | gem "sqlite3", "~> 1.7.3" 19 | gem "standard" 20 | end 21 | 22 | gemspec path: "../" 23 | -------------------------------------------------------------------------------- /gemfiles/rails_7_1.gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: .. 3 | specs: 4 | auto_increment (1.6.2) 5 | activerecord (>= 6.0) 6 | activesupport (>= 6.0) 7 | 8 | GEM 9 | remote: https://rubygems.org/ 10 | specs: 11 | activemodel (7.1.4) 12 | activesupport (= 7.1.4) 13 | activerecord (7.1.4) 14 | activemodel (= 7.1.4) 15 | activesupport (= 7.1.4) 16 | timeout (>= 0.4.0) 17 | activesupport (7.1.4) 18 | base64 19 | bigdecimal 20 | concurrent-ruby (~> 1.0, >= 1.0.2) 21 | connection_pool (>= 2.2.5) 22 | drb 23 | i18n (>= 1.6, < 2) 24 | minitest (>= 5.1) 25 | mutex_m 26 | tzinfo (~> 2.0) 27 | appraisal (2.5.0) 28 | bundler 29 | rake 30 | thor (>= 0.14.0) 31 | ast (2.4.2) 32 | base64 (0.2.0) 33 | bigdecimal (3.1.8) 34 | coderay (1.1.3) 35 | concurrent-ruby (1.3.4) 36 | connection_pool (2.4.1) 37 | database_cleaner (2.0.2) 38 | database_cleaner-active_record (>= 2, < 3) 39 | database_cleaner-active_record (2.1.0) 40 | activerecord (>= 5.a) 41 | database_cleaner-core (~> 2.0.0) 42 | database_cleaner-core (2.0.1) 43 | diff-lcs (1.5.1) 44 | drb (2.2.1) 45 | ffi (1.16.3) 46 | formatador (1.1.0) 47 | fuubar (2.5.1) 48 | rspec-core (~> 3.0) 49 | ruby-progressbar (~> 1.4) 50 | guard (2.18.1) 51 | formatador (>= 0.2.4) 52 | listen (>= 2.7, < 4.0) 53 | lumberjack (>= 1.0.12, < 2.0) 54 | nenv (~> 0.1) 55 | notiffany (~> 0.0) 56 | pry (>= 0.13.0) 57 | shellany (~> 0.0) 58 | thor (>= 0.18.1) 59 | guard-compat (1.2.1) 60 | guard-rspec (4.7.3) 61 | guard (~> 2.1) 62 | guard-compat (~> 1.1) 63 | rspec (>= 2.99.0, < 4.0) 64 | i18n (1.14.6) 65 | concurrent-ruby (~> 1.0) 66 | json (2.7.2) 67 | language_server-protocol (3.17.0.3) 68 | lint_roller (1.1.0) 69 | listen (3.9.0) 70 | rb-fsevent (~> 0.10, >= 0.10.3) 71 | rb-inotify (~> 0.9, >= 0.9.10) 72 | lumberjack (1.2.10) 73 | method_source (1.1.0) 74 | mini_portile2 (2.8.7) 75 | minitest (5.25.1) 76 | mutex_m (0.2.0) 77 | nenv (0.3.0) 78 | notiffany (0.1.3) 79 | nenv (~> 0.1) 80 | shellany (~> 0.0) 81 | parallel (1.26.3) 82 | parser (3.3.5.0) 83 | ast (~> 2.4.1) 84 | racc 85 | pry (0.14.2) 86 | coderay (~> 1.1) 87 | method_source (~> 1.0) 88 | racc (1.8.1) 89 | rainbow (3.1.1) 90 | rake (13.2.1) 91 | rb-fsevent (0.11.2) 92 | rb-inotify (0.10.1) 93 | ffi (~> 1.0) 94 | regexp_parser (2.9.2) 95 | rexml (3.3.7) 96 | rspec (3.13.0) 97 | rspec-core (~> 3.13.0) 98 | rspec-expectations (~> 3.13.0) 99 | rspec-mocks (~> 3.13.0) 100 | rspec-core (3.13.0) 101 | rspec-support (~> 3.13.0) 102 | rspec-expectations (3.13.0) 103 | diff-lcs (>= 1.2.0, < 2.0) 104 | rspec-support (~> 3.13.0) 105 | rspec-mocks (3.13.1) 106 | diff-lcs (>= 1.2.0, < 2.0) 107 | rspec-support (~> 3.13.0) 108 | rspec-nc (0.3.0) 109 | rspec (>= 3) 110 | terminal-notifier (>= 1.4) 111 | rspec-support (3.13.1) 112 | rubocop (1.65.1) 113 | json (~> 2.3) 114 | language_server-protocol (>= 3.17.0) 115 | parallel (~> 1.10) 116 | parser (>= 3.3.0.2) 117 | rainbow (>= 2.2.2, < 4.0) 118 | regexp_parser (>= 2.4, < 3.0) 119 | rexml (>= 3.2.5, < 4.0) 120 | rubocop-ast (>= 1.31.1, < 2.0) 121 | ruby-progressbar (~> 1.7) 122 | unicode-display_width (>= 2.4.0, < 3.0) 123 | rubocop-ast (1.32.3) 124 | parser (>= 3.3.1.0) 125 | rubocop-performance (1.21.1) 126 | rubocop (>= 1.48.1, < 2.0) 127 | rubocop-ast (>= 1.31.1, < 2.0) 128 | ruby-progressbar (1.13.0) 129 | shellany (0.0.1) 130 | sqlite3 (1.7.3) 131 | mini_portile2 (~> 2.8.0) 132 | standard (1.40.0) 133 | language_server-protocol (~> 3.17.0.2) 134 | lint_roller (~> 1.0) 135 | rubocop (~> 1.65.0) 136 | standard-custom (~> 1.0.0) 137 | standard-performance (~> 1.4) 138 | standard-custom (1.0.2) 139 | lint_roller (~> 1.0) 140 | rubocop (~> 1.50) 141 | standard-performance (1.4.0) 142 | lint_roller (~> 1.1) 143 | rubocop-performance (~> 1.21.0) 144 | terminal-notifier (2.0.0) 145 | thor (1.3.1) 146 | timeout (0.4.1) 147 | tzinfo (2.0.6) 148 | concurrent-ruby (~> 1.0) 149 | unicode-display_width (2.6.0) 150 | 151 | PLATFORMS 152 | arm64-darwin-23 153 | arm64-darwin-24 154 | x86_64-linux 155 | 156 | DEPENDENCIES 157 | activerecord (= 7.1.4) 158 | activesupport (= 7.1.4) 159 | appraisal 160 | auto_increment! 161 | bundler 162 | database_cleaner 163 | fuubar 164 | guard 165 | guard-rspec 166 | rake 167 | rspec 168 | rspec-nc 169 | sqlite3 (~> 1.7.3) 170 | standard 171 | 172 | BUNDLED WITH 173 | 2.4.22 174 | -------------------------------------------------------------------------------- /gemfiles/rails_7_2.gemfile: -------------------------------------------------------------------------------- 1 | # This file was generated by Appraisal 2 | 3 | source "https://rubygems.org" 4 | 5 | gem "activerecord", "7.2.1" 6 | gem "activesupport", "7.2.1" 7 | 8 | group :development do 9 | gem "appraisal" 10 | gem "bundler" 11 | gem "database_cleaner" 12 | gem "fuubar" 13 | gem "guard" 14 | gem "guard-rspec" 15 | gem "rake" 16 | gem "rspec" 17 | gem "rspec-nc" 18 | gem "sqlite3", "~> 1.7.3" 19 | gem "standard" 20 | end 21 | 22 | gemspec path: "../" 23 | -------------------------------------------------------------------------------- /gemfiles/rails_7_2.gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: .. 3 | specs: 4 | auto_increment (1.6.2) 5 | activerecord (>= 6.0) 6 | activesupport (>= 6.0) 7 | 8 | GEM 9 | remote: https://rubygems.org/ 10 | specs: 11 | activemodel (7.2.1) 12 | activesupport (= 7.2.1) 13 | activerecord (7.2.1) 14 | activemodel (= 7.2.1) 15 | activesupport (= 7.2.1) 16 | timeout (>= 0.4.0) 17 | activesupport (7.2.1) 18 | base64 19 | bigdecimal 20 | concurrent-ruby (~> 1.0, >= 1.3.1) 21 | connection_pool (>= 2.2.5) 22 | drb 23 | i18n (>= 1.6, < 2) 24 | logger (>= 1.4.2) 25 | minitest (>= 5.1) 26 | securerandom (>= 0.3) 27 | tzinfo (~> 2.0, >= 2.0.5) 28 | appraisal (2.5.0) 29 | bundler 30 | rake 31 | thor (>= 0.14.0) 32 | ast (2.4.2) 33 | base64 (0.2.0) 34 | bigdecimal (3.1.8) 35 | coderay (1.1.3) 36 | concurrent-ruby (1.3.4) 37 | connection_pool (2.4.1) 38 | database_cleaner (2.0.2) 39 | database_cleaner-active_record (>= 2, < 3) 40 | database_cleaner-active_record (2.2.0) 41 | activerecord (>= 5.a) 42 | database_cleaner-core (~> 2.0.0) 43 | database_cleaner-core (2.0.1) 44 | diff-lcs (1.5.1) 45 | drb (2.2.1) 46 | ffi (1.17.0-arm64-darwin) 47 | ffi (1.17.0-x86_64-linux-gnu) 48 | formatador (1.1.0) 49 | fuubar (2.5.1) 50 | rspec-core (~> 3.0) 51 | ruby-progressbar (~> 1.4) 52 | guard (2.18.1) 53 | formatador (>= 0.2.4) 54 | listen (>= 2.7, < 4.0) 55 | lumberjack (>= 1.0.12, < 2.0) 56 | nenv (~> 0.1) 57 | notiffany (~> 0.0) 58 | pry (>= 0.13.0) 59 | shellany (~> 0.0) 60 | thor (>= 0.18.1) 61 | guard-compat (1.2.1) 62 | guard-rspec (4.7.3) 63 | guard (~> 2.1) 64 | guard-compat (~> 1.1) 65 | rspec (>= 2.99.0, < 4.0) 66 | i18n (1.14.6) 67 | concurrent-ruby (~> 1.0) 68 | json (2.7.2) 69 | language_server-protocol (3.17.0.3) 70 | lint_roller (1.1.0) 71 | listen (3.9.0) 72 | rb-fsevent (~> 0.10, >= 0.10.3) 73 | rb-inotify (~> 0.9, >= 0.9.10) 74 | logger (1.6.1) 75 | lumberjack (1.2.10) 76 | method_source (1.1.0) 77 | mini_portile2 (2.8.7) 78 | minitest (5.25.1) 79 | nenv (0.3.0) 80 | notiffany (0.1.3) 81 | nenv (~> 0.1) 82 | shellany (~> 0.0) 83 | parallel (1.26.3) 84 | parser (3.3.5.0) 85 | ast (~> 2.4.1) 86 | racc 87 | pry (0.14.2) 88 | coderay (~> 1.1) 89 | method_source (~> 1.0) 90 | racc (1.8.1) 91 | rainbow (3.1.1) 92 | rake (13.2.1) 93 | rb-fsevent (0.11.2) 94 | rb-inotify (0.11.1) 95 | ffi (~> 1.0) 96 | regexp_parser (2.9.2) 97 | rexml (3.3.7) 98 | rspec (3.13.0) 99 | rspec-core (~> 3.13.0) 100 | rspec-expectations (~> 3.13.0) 101 | rspec-mocks (~> 3.13.0) 102 | rspec-core (3.13.1) 103 | rspec-support (~> 3.13.0) 104 | rspec-expectations (3.13.3) 105 | diff-lcs (>= 1.2.0, < 2.0) 106 | rspec-support (~> 3.13.0) 107 | rspec-mocks (3.13.1) 108 | diff-lcs (>= 1.2.0, < 2.0) 109 | rspec-support (~> 3.13.0) 110 | rspec-nc (0.3.0) 111 | rspec (>= 3) 112 | terminal-notifier (>= 1.4) 113 | rspec-support (3.13.1) 114 | rubocop (1.65.1) 115 | json (~> 2.3) 116 | language_server-protocol (>= 3.17.0) 117 | parallel (~> 1.10) 118 | parser (>= 3.3.0.2) 119 | rainbow (>= 2.2.2, < 4.0) 120 | regexp_parser (>= 2.4, < 3.0) 121 | rexml (>= 3.2.5, < 4.0) 122 | rubocop-ast (>= 1.31.1, < 2.0) 123 | ruby-progressbar (~> 1.7) 124 | unicode-display_width (>= 2.4.0, < 3.0) 125 | rubocop-ast (1.32.3) 126 | parser (>= 3.3.1.0) 127 | rubocop-performance (1.21.1) 128 | rubocop (>= 1.48.1, < 2.0) 129 | rubocop-ast (>= 1.31.1, < 2.0) 130 | ruby-progressbar (1.13.0) 131 | securerandom (0.3.1) 132 | shellany (0.0.1) 133 | sqlite3 (1.7.3) 134 | mini_portile2 (~> 2.8.0) 135 | standard (1.40.0) 136 | language_server-protocol (~> 3.17.0.2) 137 | lint_roller (~> 1.0) 138 | rubocop (~> 1.65.0) 139 | standard-custom (~> 1.0.0) 140 | standard-performance (~> 1.4) 141 | standard-custom (1.0.2) 142 | lint_roller (~> 1.0) 143 | rubocop (~> 1.50) 144 | standard-performance (1.4.0) 145 | lint_roller (~> 1.1) 146 | rubocop-performance (~> 1.21.0) 147 | terminal-notifier (2.0.0) 148 | thor (1.3.2) 149 | timeout (0.4.1) 150 | tzinfo (2.0.6) 151 | concurrent-ruby (~> 1.0) 152 | unicode-display_width (2.6.0) 153 | 154 | PLATFORMS 155 | arm64-darwin-24 156 | x86_64-linux 157 | 158 | DEPENDENCIES 159 | activerecord (= 7.2.1) 160 | activesupport (= 7.2.1) 161 | appraisal 162 | auto_increment! 163 | bundler 164 | database_cleaner 165 | fuubar 166 | guard 167 | guard-rspec 168 | rake 169 | rspec 170 | rspec-nc 171 | sqlite3 (~> 1.7.3) 172 | standard 173 | 174 | BUNDLED WITH 175 | 2.4.22 176 | -------------------------------------------------------------------------------- /lib/auto_increment.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "date" 4 | require "i18n" 5 | require "active_record" 6 | require "active_support" 7 | require "active_support/time_with_zone" 8 | require "auto_increment/version" 9 | 10 | # +AutoIncrement+ 11 | module AutoIncrement 12 | autoload :Incrementor, "auto_increment/incrementor" 13 | autoload :ActiveRecord, "auto_increment/active_record" 14 | end 15 | 16 | ActiveRecord::Base.include AutoIncrement::ActiveRecord 17 | -------------------------------------------------------------------------------- /lib/auto_increment/active_record.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # +AutoIncrement+ 4 | module AutoIncrement 5 | # +AutoIncrement::ActiveRecord+ 6 | module ActiveRecord 7 | extend ActiveSupport::Concern 8 | # +AutoIncrement::ActiveRecord::ClassMethods+ 9 | module ClassMethods 10 | def auto_increment(column = nil, **options) 11 | send("before_#{options.fetch(:before, :create)}") do |record| 12 | Incrementor.new(record, column, **options).run 13 | end 14 | end 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /lib/auto_increment/incrementor.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # +AutoIncrement+ 4 | module AutoIncrement 5 | # +AutoIncrement::Incrementor+ 6 | class Incrementor 7 | def initialize(record, column = nil, **options) 8 | @record = record 9 | @column = column || options.fetch(:column, :code) 10 | @initial = options.fetch(:initial, 1) 11 | @force = options.fetch(:force, false) 12 | @scope = Array.wrap(options[:scope]).compact 13 | @model_scope = Array.wrap(options[:model_scope]).compact 14 | @lock = options.fetch(:lock, false) 15 | end 16 | 17 | def run 18 | write if can_write? 19 | end 20 | 21 | private 22 | 23 | def can_write? 24 | @record.send(@column).blank? || @force 25 | end 26 | 27 | def write 28 | @record.send :write_attribute, @column, increment 29 | end 30 | 31 | def build_scopes(query) 32 | @scope.each do |scope| 33 | query = query.where(scope => @record.send(scope)) if @record.respond_to?(scope) 34 | end 35 | 36 | query 37 | end 38 | 39 | def build_model_scope(query) 40 | @model_scope.each do |scope| 41 | query = query.send(scope) 42 | end 43 | 44 | query 45 | end 46 | 47 | def maximum 48 | query = build_scopes(build_model_scope(@record.class)) 49 | query.lock if lock? 50 | 51 | if string? 52 | query.select("#{@column} max") 53 | .order(Arel.sql("LENGTH(#{@column}) DESC, #{@column} DESC")) 54 | .first.try :max 55 | else 56 | query.maximum @column 57 | end 58 | end 59 | 60 | def lock? 61 | @lock == true 62 | end 63 | 64 | def increment 65 | max = maximum 66 | 67 | max.blank? ? @initial : max.next 68 | end 69 | 70 | def string? 71 | @initial.instance_of?(String) 72 | end 73 | end 74 | end 75 | -------------------------------------------------------------------------------- /lib/auto_increment/version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # +AutoIncrement::VERSION+ 4 | module AutoIncrement 5 | VERSION = "1.6.2" 6 | end 7 | -------------------------------------------------------------------------------- /spec/lib/active_record_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "spec_helper" 4 | require "models/account" 5 | require "models/user" 6 | 7 | describe AutoIncrement do 8 | before :all do 9 | @account1 = Account.create name: "My Account" 10 | @account2 = Account.create name: "Another Account", code: 50 11 | 12 | @user1_account1 = @account1.users.create name: "Felipe", letter_code: "Z" 13 | @user1_account2 = @account2.users.create name: "Daniel" 14 | @user2_account2 = @account2.users.create name: "Mark" 15 | @user3_account2 = @account2.users.create name: "Robert" 16 | end 17 | 18 | describe "initial" do 19 | it { expect(@account1.code).to eq 1 } 20 | it { expect(@user1_account1.letter_code).to eq "A" } 21 | end 22 | 23 | describe "do not increment outside scope" do 24 | it { expect(@user1_account2.letter_code).to eq "A" } 25 | end 26 | 27 | describe "not set column if is already set" do 28 | it { expect(@account2.code).to eq 50 } 29 | end 30 | 31 | describe "set column if option force is used" do 32 | it { expect(@user1_account1.letter_code).to eq "A" } 33 | end 34 | 35 | describe "locks query for increment" do 36 | before :all do 37 | threads = [] 38 | lock = Mutex.new 39 | @account = Account.create name: "Another Account", code: 50 40 | @accounts = [] 41 | 5.times do |_t| 42 | threads << Thread.new do 43 | lock.synchronize do 44 | 5.times do |_thr| 45 | @accounts << (@account.users.create name: "Daniel") 46 | end 47 | end 48 | end 49 | end 50 | threads.each(&:join) 51 | end 52 | 53 | let(:account_last_letter_code) do 54 | @accounts.max_by(&:letter_code).letter_code 55 | end 56 | 57 | it { expect(@accounts.size).to eq 25 } 58 | it { expect(account_last_letter_code).to eq "Y" } 59 | end 60 | 61 | describe "set before validation" do 62 | account3 = Account.new 63 | account3.valid? 64 | 65 | it { expect(account3.code).not_to be_nil } 66 | end 67 | 68 | describe "uses model scopes" do 69 | it { expect(@user3_account2.letter_code).to eq("C") } 70 | end 71 | end 72 | -------------------------------------------------------------------------------- /spec/lib/incrementor_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "spec_helper" 4 | 5 | describe AutoIncrement::Incrementor do 6 | { 7 | nil => 1, 8 | 0 => 1, 9 | 1 => 2, 10 | "A" => "B", 11 | "Z" => "AA", 12 | "AA" => "AB", 13 | "AAAAA" => "AAAAB" 14 | }.each do |previous_value, next_value| 15 | describe "increment value for #{previous_value}" do 16 | subject do 17 | AutoIncrement::Incrementor.new User.new 18 | end 19 | 20 | it do 21 | allow(subject).to receive(:maximum) { previous_value } 22 | expect(subject.send(:increment)).to eq next_value 23 | end 24 | end 25 | end 26 | 27 | describe "initial value of string" do 28 | subject do 29 | AutoIncrement::Incrementor.new User.new, initial: "A" 30 | end 31 | 32 | it do 33 | allow(subject).to receive(:maximum) { nil } 34 | expect(subject.send(:increment)).to eq "A" 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /spec/models/account.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Spec +Account+ 4 | class Account < ActiveRecord::Base 5 | auto_increment :code, before: :validation 6 | 7 | has_many :users 8 | end 9 | -------------------------------------------------------------------------------- /spec/models/user.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # + Spec +User+ 4 | class User < ActiveRecord::Base 5 | auto_increment :letter_code, scope: :account_id, initial: "A", force: true, 6 | lock: true, model_scope: :with_mark 7 | 8 | belongs_to :account 9 | 10 | default_scope -> { where "name <> ?", "Mark" } 11 | 12 | scope :with_mark, -> { unscoped } 13 | end 14 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "pry" 4 | require "auto_increment" 5 | require "database_cleaner" 6 | 7 | db_path = "spec/db/sync.db" 8 | 9 | File.delete(db_path) if File.exist?(db_path) 10 | 11 | ActiveRecord::Base.establish_connection( 12 | adapter: "sqlite3", 13 | database: db_path, 14 | timeout: 5000 15 | ) 16 | 17 | require "support/active_record" 18 | require "support/database_cleaner" 19 | -------------------------------------------------------------------------------- /spec/support/active_record.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # +ActiveRecord+ migration for Accounts 4 | ActiveRecord::Migration.create_table :accounts do |t| 5 | t.string :name 6 | t.integer :code 7 | end 8 | 9 | # +ActiveRecord+ migration for Users 10 | ActiveRecord::Migration.create_table :users do |t| 11 | t.string :name 12 | t.integer :account_id 13 | t.string :letter_code 14 | end 15 | -------------------------------------------------------------------------------- /spec/support/database_cleaner.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | RSpec.configure do |config| 4 | config.before(:suite) do 5 | DatabaseCleaner.strategy = :transaction 6 | DatabaseCleaner.clean_with(:truncation) 7 | end 8 | 9 | config.around(:each) do |example| 10 | DatabaseCleaner.cleaning do 11 | example.run 12 | end 13 | end 14 | end 15 | --------------------------------------------------------------------------------