sequenced-4.0.0/0000755000004100000410000000000014333131245013516 5ustar www-datawww-datasequenced-4.0.0/README.md0000644000004100000410000001524114333131245015000 0ustar www-datawww-data# Sequenced [![.github/workflows/ci.yml](https://github.com/derrickreimer/sequenced/actions/workflows/ci.yml/badge.svg)](https://github.com/derrickreimer/sequenced/actions/workflows/ci.yml) [![Code Climate](https://codeclimate.com/github/djreimer/sequenced.svg)](https://codeclimate.com/github/djreimer/sequenced) [![Gem Version](https://badge.fury.io/rb/sequenced.svg)](http://badge.fury.io/rb/sequenced) Sequenced is a simple gem that generates scoped sequential IDs for ActiveRecord models. This gem provides an `acts_as_sequenced` macro that automatically assigns a unique, sequential ID to each record. The sequential ID is not a replacement for the database primary key, but rather adds another way to retrieve the object without exposing the primary key. ## Purpose It's generally a bad practice to expose your primary keys to the world in your URLs. However, it is often appropriate to number objects in sequence (in the context of a parent object). For example, given a Question model that has many Answers, it makes sense to number answers sequentially for each individual question. You can achieve this with Sequenced in one line of code: ```ruby class Question < ActiveRecord::Base has_many :answers end class Answer < ActiveRecord::Base belongs_to :question acts_as_sequenced scope: :question_id end ``` ## Installation Add the gem to your Gemfile: gem 'sequenced' Install the gem with bundler: bundle install ## Usage To add a sequential ID to a model, first add an integer column called `sequential_id` to the model (or you many name the column anything you like and override the default). For example: rails generate migration add_sequential_id_to_answers sequential_id:integer rake db:migrate Then, call the `acts_as_sequenced` macro in your model class: ```ruby class Answer < ActiveRecord::Base belongs_to :question acts_as_sequenced scope: :question_id end ``` The `scope` option can be any attribute, but will typically be the foreign key of an associated parent object. You can even scope by multiple columns for polymorphic relationships: ```ruby class Answer < ActiveRecord::Base belongs_to :questionable, :polymorphic => true acts_as_sequenced scope: [:questionable_id, :questionable_type] end ``` Multiple sequences can be defined by using the macro multiple times: ```ruby class Answer < ActiveRecord::Base belongs_to :account belongs_to :question acts_as_sequenced column: :question_answer_number, scope: :question_id acts_as_sequenced column: :account_answer_number, scope: :account_id end ``` ## Schema and data integrity **This gem is only concurrent-safe for PostgreSQL databases**. For other database systems, unexpected behavior may occur if you attempt to create records concurrently. You can mitigate this somewhat by applying a unique index to your sequential ID column (or a multicolumn unique index on sequential ID and scope columns, if you are using scopes). This will ensure that you can never have duplicate sequential IDs within a scope, causing concurrent updates to instead raise a uniqueness error at the database-level. It is also a good idea to apply a not-null constraint to your sequential ID column as well if you never intend to skip it. Here is an example migration for a model that has a `sequential_id` scoped to a `burrow_id`: ```ruby # app/db/migrations/20151120190645_create_badgers.rb class CreateBadgers < ActiveRecord::Migration def change create_table :badgers do |t| t.integer :sequential_id, null: false t.integer :burrow_id end add_index :badgers, [:sequential_id, :burrow_id], unique: true end end ``` If you are adding a sequenced column to an existing table, you need to account for that in your migration. Here is an example migration that adds and sets the `sequential_id` column based on the current database records: ```ruby # app/db/migrations/20151120190645_add_sequental_id_to_badgers.rb class AddSequentalIdToBadgers < ActiveRecord::Migration add_column :badgers, :sequential_id, :integer execute <<~SQL UPDATE badgers SET sequential_id = old_badgers.next_sequential_id FROM ( SELECT id, ROW_NUMBER() OVER( PARTITION BY burrow_id ORDER BY id ) AS next_sequential_id FROM badgers ) old_badgers WHERE badgers.id = old_badgers.id SQL change_column :badgers, :sequential_id, :integer, null: false add_index :badgers, [:sequential_id, :burrow_id], unique: true end ``` ## Configuration ### Overriding the default sequential ID column By default, Sequenced uses the `sequential_id` column and assumes it already exists. If you wish to store the sequential ID in different integer column, simply specify the column name with the `column` option: ```ruby acts_as_sequenced scope: :question_id, column: :my_sequential_id ``` ### Starting the sequence at a specific number By default, Sequenced begins sequences with 1. To start at a different integer, simply set the `start_at` option: ```ruby acts_as_sequenced start_at: 1000 ``` You may also pass a lambda to the `start_at` option: ```ruby acts_as_sequenced start_at: lambda { |r| r.computed_start_value } ``` ### Indexing the sequential ID column For optimal performance, it's a good idea to index the sequential ID column on sequenced models. ### Skipping sequential ID generation If you'd like to skip generating a sequential ID under certain conditions, you may pass a lambda to the `skip` option: ```ruby acts_as_sequenced skip: lambda { |r| r.score == 0 } ``` ## Example Suppose you have a question model that has many answers. This example demonstrates how to use Sequenced to enable access to the nested answer resource via its sequential ID. ```ruby # app/models/question.rb class Question < ActiveRecord::Base has_many :answers end # app/models/answer.rb class Answer < ActiveRecord::Base belongs_to :question acts_as_sequenced scope: :question_id # Automatically use the sequential ID in URLs def to_param self.sequential_id.to_s end end # config/routes.rb resources :questions do resources :answers end # app/controllers/answers_controller.rb class AnswersController < ApplicationController def show @question = Question.find(params[:question_id]) @answer = @question.answers.find_by(sequential_id: params[:id]) end end ``` Now, answers are accessible via their sequential IDs: http://example.com/questions/5/answers/1 # Good instead of by their primary keys: http://example.com/questions/5/answer/32454 # Bad ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Added some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request sequenced-4.0.0/gemfiles/0000755000004100000410000000000014333131245015311 5ustar www-datawww-datasequenced-4.0.0/gemfiles/rails_5_2.gemfile.lock0000644000004100000410000001064414333131245021356 0ustar www-datawww-dataPATH remote: .. specs: sequenced (4.0.0) activerecord (>= 3.0) activesupport (>= 3.0) GEM remote: https://rubygems.org/ specs: actioncable (5.2.8.1) actionpack (= 5.2.8.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) actionmailer (5.2.8.1) actionpack (= 5.2.8.1) actionview (= 5.2.8.1) activejob (= 5.2.8.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) actionpack (5.2.8.1) actionview (= 5.2.8.1) activesupport (= 5.2.8.1) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) actionview (5.2.8.1) activesupport (= 5.2.8.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) activejob (5.2.8.1) activesupport (= 5.2.8.1) globalid (>= 0.3.6) activemodel (5.2.8.1) activesupport (= 5.2.8.1) activerecord (5.2.8.1) activemodel (= 5.2.8.1) activesupport (= 5.2.8.1) arel (>= 9.0) activestorage (5.2.8.1) actionpack (= 5.2.8.1) activerecord (= 5.2.8.1) marcel (~> 1.0.0) activesupport (5.2.8.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) appraisal (2.4.1) bundler rake thor (>= 0.14.0) arel (9.0.0) ast (2.4.2) builder (3.2.4) concurrent-ruby (1.1.10) crass (1.0.6) digest (3.1.0) erubi (1.11.0) globalid (1.0.0) activesupport (>= 5.0) i18n (1.12.0) concurrent-ruby (~> 1.0) json (2.6.2) loofah (2.18.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) marcel (1.0.2) method_source (1.0.0) mini_mime (1.1.2) mini_portile2 (2.8.0) minitest (5.16.2) net-imap (0.2.3) digest net-protocol strscan net-pop (0.1.1) digest net-protocol timeout net-protocol (0.1.3) timeout net-smtp (0.3.1) digest net-protocol timeout nio4r (2.5.8) nokogiri (1.13.8) mini_portile2 (~> 2.8.0) racc (~> 1.4) nokogiri (1.13.8-arm64-darwin) racc (~> 1.4) nokogiri (1.13.8-x86_64-linux) racc (~> 1.4) parallel (1.22.1) parser (3.1.2.1) ast (~> 2.4.1) pg (1.4.3) racc (1.6.0) rack (2.2.4) rack-test (2.0.2) rack (>= 1.3) rails (5.2.8.1) actioncable (= 5.2.8.1) actionmailer (= 5.2.8.1) actionpack (= 5.2.8.1) actionview (= 5.2.8.1) activejob (= 5.2.8.1) activemodel (= 5.2.8.1) activerecord (= 5.2.8.1) activestorage (= 5.2.8.1) activesupport (= 5.2.8.1) bundler (>= 1.3.0) railties (= 5.2.8.1) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.4.3) loofah (~> 2.3) railties (5.2.8.1) actionpack (= 5.2.8.1) activesupport (= 5.2.8.1) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) rainbow (3.1.1) rake (13.0.6) regexp_parser (2.5.0) rexml (3.2.5) rubocop (1.35.0) json (~> 2.3) parallel (~> 1.10) parser (>= 3.1.2.1) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) rubocop-ast (>= 1.20.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.21.0) parser (>= 3.1.1.0) rubocop-performance (1.14.3) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) ruby-progressbar (1.11.0) sprockets (4.1.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.4.2) actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) sqlite3 (1.4.4) standard (1.16.0) rubocop (= 1.35.0) rubocop-performance (= 1.14.3) standardrb (1.0.1) standard strscan (3.0.4) thor (1.2.1) thread_safe (0.3.6) timeout (0.3.0) tzinfo (1.2.10) thread_safe (~> 0.1) unicode-display_width (2.2.0) websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) PLATFORMS arm64-darwin-21 ruby x86_64-linux DEPENDENCIES appraisal net-imap net-pop net-smtp pg rails (~> 5.2.0) sequenced! sqlite3 (~> 1.4.4) standardrb BUNDLED WITH 2.3.16 sequenced-4.0.0/gemfiles/rails_master.gemfile0000644000004100000410000000045314333131245021332 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "appraisal" gem "standardrb" gem "rails", github: "rails/rails", branch: "main" group :development, :test do gem "sqlite3", "~> 1.4.4" gem "pg" gem "net-imap" gem "net-pop" gem "net-smtp" end gemspec path: "../" sequenced-4.0.0/gemfiles/rails_5_2.gemfile0000644000004100000410000000042014333131245020416 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "appraisal" gem "standardrb" gem "rails", "~> 5.2.0" group :development, :test do gem "sqlite3", "~> 1.4.4" gem "pg" gem "net-imap" gem "net-pop" gem "net-smtp" end gemspec path: "../" sequenced-4.0.0/gemfiles/rails_6_1.gemfile0000644000004100000410000000042014333131245020416 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "appraisal" gem "standardrb" gem "rails", "~> 6.1.0" group :development, :test do gem "sqlite3", "~> 1.4.4" gem "pg" gem "net-imap" gem "net-pop" gem "net-smtp" end gemspec path: "../" sequenced-4.0.0/gemfiles/rails_master.gemfile.lock0000644000004100000410000001224514333131245022263 0ustar www-datawww-dataGIT remote: https://github.com/rails/rails.git revision: cb5765a12751ca03866a89cf19fefcbc2d93a8ea branch: main specs: actioncable (7.1.0.alpha) actionpack (= 7.1.0.alpha) activesupport (= 7.1.0.alpha) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) actionmailbox (7.1.0.alpha) actionpack (= 7.1.0.alpha) activejob (= 7.1.0.alpha) activerecord (= 7.1.0.alpha) activestorage (= 7.1.0.alpha) activesupport (= 7.1.0.alpha) mail (>= 2.7.1) net-imap net-pop net-smtp actionmailer (7.1.0.alpha) actionpack (= 7.1.0.alpha) actionview (= 7.1.0.alpha) activejob (= 7.1.0.alpha) activesupport (= 7.1.0.alpha) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) actionpack (7.1.0.alpha) actionview (= 7.1.0.alpha) activesupport (= 7.1.0.alpha) rack (~> 2.0, >= 2.2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) actiontext (7.1.0.alpha) actionpack (= 7.1.0.alpha) activerecord (= 7.1.0.alpha) activestorage (= 7.1.0.alpha) activesupport (= 7.1.0.alpha) globalid (>= 0.6.0) nokogiri (>= 1.8.5) actionview (7.1.0.alpha) activesupport (= 7.1.0.alpha) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) activejob (7.1.0.alpha) activesupport (= 7.1.0.alpha) globalid (>= 0.3.6) activemodel (7.1.0.alpha) activesupport (= 7.1.0.alpha) activerecord (7.1.0.alpha) activemodel (= 7.1.0.alpha) activesupport (= 7.1.0.alpha) activestorage (7.1.0.alpha) actionpack (= 7.1.0.alpha) activejob (= 7.1.0.alpha) activerecord (= 7.1.0.alpha) activesupport (= 7.1.0.alpha) marcel (~> 1.0) mini_mime (>= 1.1.0) activesupport (7.1.0.alpha) concurrent-ruby (~> 1.0, >= 1.0.2) connection_pool (>= 2.2.5) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) rails (7.1.0.alpha) actioncable (= 7.1.0.alpha) actionmailbox (= 7.1.0.alpha) actionmailer (= 7.1.0.alpha) actionpack (= 7.1.0.alpha) actiontext (= 7.1.0.alpha) actionview (= 7.1.0.alpha) activejob (= 7.1.0.alpha) activemodel (= 7.1.0.alpha) activerecord (= 7.1.0.alpha) activestorage (= 7.1.0.alpha) activesupport (= 7.1.0.alpha) bundler (>= 1.15.0) railties (= 7.1.0.alpha) railties (7.1.0.alpha) actionpack (= 7.1.0.alpha) activesupport (= 7.1.0.alpha) method_source rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.6) PATH remote: .. specs: sequenced (4.0.0) activerecord (>= 3.0) activesupport (>= 3.0) GEM remote: https://rubygems.org/ specs: appraisal (2.4.1) bundler rake thor (>= 0.14.0) ast (2.4.2) builder (3.2.4) concurrent-ruby (1.1.10) connection_pool (2.2.5) crass (1.0.6) digest (3.1.0) erubi (1.11.0) globalid (1.0.0) activesupport (>= 5.0) i18n (1.12.0) concurrent-ruby (~> 1.0) json (2.6.2) loofah (2.18.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) marcel (1.0.2) method_source (1.0.0) mini_mime (1.1.2) minitest (5.16.2) net-imap (0.2.3) digest net-protocol strscan net-pop (0.1.1) digest net-protocol timeout net-protocol (0.1.3) timeout net-smtp (0.3.1) digest net-protocol timeout nio4r (2.5.8) nokogiri (1.13.8-arm64-darwin) racc (~> 1.4) nokogiri (1.13.8-x86_64-linux) racc (~> 1.4) parallel (1.22.1) parser (3.1.2.1) ast (~> 2.4.1) pg (1.4.3) racc (1.6.0) rack (2.2.4) rack-test (2.0.2) rack (>= 1.3) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.4.3) loofah (~> 2.3) rainbow (3.1.1) rake (13.0.6) regexp_parser (2.5.0) rexml (3.2.5) rubocop (1.35.0) json (~> 2.3) parallel (~> 1.10) parser (>= 3.1.2.1) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) rubocop-ast (>= 1.20.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.21.0) parser (>= 3.1.1.0) rubocop-performance (1.14.3) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) ruby-progressbar (1.11.0) sqlite3 (1.4.4) standard (1.16.0) rubocop (= 1.35.0) rubocop-performance (= 1.14.3) standardrb (1.0.1) standard strscan (3.0.4) thor (1.2.1) timeout (0.3.0) tzinfo (2.0.5) concurrent-ruby (~> 1.0) unicode-display_width (2.2.0) websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) zeitwerk (2.6.0) PLATFORMS arm64-darwin-21 x86_64-linux DEPENDENCIES appraisal net-imap net-pop net-smtp pg rails! sequenced! sqlite3 (~> 1.4.4) standardrb BUNDLED WITH 2.3.16 sequenced-4.0.0/gemfiles/rails_7.gemfile0000644000004100000410000000042014333131245020177 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "appraisal" gem "standardrb" gem "rails", "~> 7.0.0" group :development, :test do gem "sqlite3", "~> 1.4.4" gem "pg" gem "net-imap" gem "net-pop" gem "net-smtp" end gemspec path: "../" sequenced-4.0.0/gemfiles/rails_7.gemfile.lock0000644000004100000410000001140614333131245021134 0ustar www-datawww-dataPATH remote: .. specs: sequenced (4.0.0) activerecord (>= 3.0) activesupport (>= 3.0) GEM remote: https://rubygems.org/ specs: actioncable (7.0.3.1) actionpack (= 7.0.3.1) activesupport (= 7.0.3.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) actionmailbox (7.0.3.1) actionpack (= 7.0.3.1) activejob (= 7.0.3.1) activerecord (= 7.0.3.1) activestorage (= 7.0.3.1) activesupport (= 7.0.3.1) mail (>= 2.7.1) net-imap net-pop net-smtp actionmailer (7.0.3.1) actionpack (= 7.0.3.1) actionview (= 7.0.3.1) activejob (= 7.0.3.1) activesupport (= 7.0.3.1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) actionpack (7.0.3.1) actionview (= 7.0.3.1) activesupport (= 7.0.3.1) rack (~> 2.0, >= 2.2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) actiontext (7.0.3.1) actionpack (= 7.0.3.1) activerecord (= 7.0.3.1) activestorage (= 7.0.3.1) activesupport (= 7.0.3.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) actionview (7.0.3.1) activesupport (= 7.0.3.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) activejob (7.0.3.1) activesupport (= 7.0.3.1) globalid (>= 0.3.6) activemodel (7.0.3.1) activesupport (= 7.0.3.1) activerecord (7.0.3.1) activemodel (= 7.0.3.1) activesupport (= 7.0.3.1) activestorage (7.0.3.1) actionpack (= 7.0.3.1) activejob (= 7.0.3.1) activerecord (= 7.0.3.1) activesupport (= 7.0.3.1) marcel (~> 1.0) mini_mime (>= 1.1.0) activesupport (7.0.3.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) appraisal (2.4.1) bundler rake thor (>= 0.14.0) ast (2.4.2) builder (3.2.4) concurrent-ruby (1.1.10) crass (1.0.6) digest (3.1.0) erubi (1.11.0) globalid (1.0.0) activesupport (>= 5.0) i18n (1.12.0) concurrent-ruby (~> 1.0) json (2.6.2) loofah (2.18.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) marcel (1.0.2) method_source (1.0.0) mini_mime (1.1.2) minitest (5.16.2) net-imap (0.2.3) digest net-protocol strscan net-pop (0.1.1) digest net-protocol timeout net-protocol (0.1.3) timeout net-smtp (0.3.1) digest net-protocol timeout nio4r (2.5.8) nokogiri (1.13.8-arm64-darwin) racc (~> 1.4) nokogiri (1.13.8-x86_64-linux) racc (~> 1.4) parallel (1.22.1) parser (3.1.2.1) ast (~> 2.4.1) pg (1.4.3) racc (1.6.0) rack (2.2.4) rack-test (2.0.2) rack (>= 1.3) rails (7.0.3.1) actioncable (= 7.0.3.1) actionmailbox (= 7.0.3.1) actionmailer (= 7.0.3.1) actionpack (= 7.0.3.1) actiontext (= 7.0.3.1) actionview (= 7.0.3.1) activejob (= 7.0.3.1) activemodel (= 7.0.3.1) activerecord (= 7.0.3.1) activestorage (= 7.0.3.1) activesupport (= 7.0.3.1) bundler (>= 1.15.0) railties (= 7.0.3.1) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.4.3) loofah (~> 2.3) railties (7.0.3.1) actionpack (= 7.0.3.1) activesupport (= 7.0.3.1) method_source rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.5) rainbow (3.1.1) rake (13.0.6) regexp_parser (2.5.0) rexml (3.2.5) rubocop (1.35.0) json (~> 2.3) parallel (~> 1.10) parser (>= 3.1.2.1) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) rubocop-ast (>= 1.20.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.21.0) parser (>= 3.1.1.0) rubocop-performance (1.14.3) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) ruby-progressbar (1.11.0) sqlite3 (1.4.4) standard (1.16.0) rubocop (= 1.35.0) rubocop-performance (= 1.14.3) standardrb (1.0.1) standard strscan (3.0.4) thor (1.2.1) timeout (0.3.0) tzinfo (2.0.5) concurrent-ruby (~> 1.0) unicode-display_width (2.2.0) websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) zeitwerk (2.6.0) PLATFORMS arm64-darwin-21 x86_64-linux DEPENDENCIES appraisal net-imap net-pop net-smtp pg rails (~> 7.0.0) sequenced! sqlite3 (~> 1.4.4) standardrb BUNDLED WITH 2.3.16 sequenced-4.0.0/gemfiles/rails_6_1.gemfile.lock0000644000004100000410000001140414333131245021351 0ustar www-datawww-dataPATH remote: .. specs: sequenced (4.0.0) activerecord (>= 3.0) activesupport (>= 3.0) GEM remote: https://rubygems.org/ specs: actioncable (6.1.6) actionpack (= 6.1.6) activesupport (= 6.1.6) nio4r (~> 2.0) websocket-driver (>= 0.6.1) actionmailbox (6.1.6) actionpack (= 6.1.6) activejob (= 6.1.6) activerecord (= 6.1.6) activestorage (= 6.1.6) activesupport (= 6.1.6) mail (>= 2.7.1) actionmailer (6.1.6) actionpack (= 6.1.6) actionview (= 6.1.6) activejob (= 6.1.6) activesupport (= 6.1.6) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) actionpack (6.1.6) actionview (= 6.1.6) activesupport (= 6.1.6) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) actiontext (6.1.6) actionpack (= 6.1.6) activerecord (= 6.1.6) activestorage (= 6.1.6) activesupport (= 6.1.6) nokogiri (>= 1.8.5) actionview (6.1.6) activesupport (= 6.1.6) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) activejob (6.1.6) activesupport (= 6.1.6) globalid (>= 0.3.6) activemodel (6.1.6) activesupport (= 6.1.6) activerecord (6.1.6) activemodel (= 6.1.6) activesupport (= 6.1.6) activestorage (6.1.6) actionpack (= 6.1.6) activejob (= 6.1.6) activerecord (= 6.1.6) activesupport (= 6.1.6) marcel (~> 1.0) mini_mime (>= 1.1.0) activesupport (6.1.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) appraisal (2.4.1) bundler rake thor (>= 0.14.0) ast (2.4.2) builder (3.2.4) concurrent-ruby (1.1.10) crass (1.0.6) digest (3.1.0) erubi (1.11.0) globalid (1.0.0) activesupport (>= 5.0) i18n (1.12.0) concurrent-ruby (~> 1.0) json (2.6.2) loofah (2.18.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) marcel (1.0.2) method_source (1.0.0) mini_mime (1.1.2) minitest (5.16.2) net-imap (0.2.3) digest net-protocol strscan net-pop (0.1.1) digest net-protocol timeout net-protocol (0.1.3) timeout net-smtp (0.3.1) digest net-protocol timeout nio4r (2.5.8) nokogiri (1.13.8-arm64-darwin) racc (~> 1.4) nokogiri (1.13.8-x86_64-linux) racc (~> 1.4) parallel (1.22.1) parser (3.1.2.1) ast (~> 2.4.1) pg (1.4.3) racc (1.6.0) rack (2.2.4) rack-test (2.0.2) rack (>= 1.3) rails (6.1.6) actioncable (= 6.1.6) actionmailbox (= 6.1.6) actionmailer (= 6.1.6) actionpack (= 6.1.6) actiontext (= 6.1.6) actionview (= 6.1.6) activejob (= 6.1.6) activemodel (= 6.1.6) activerecord (= 6.1.6) activestorage (= 6.1.6) activesupport (= 6.1.6) bundler (>= 1.15.0) railties (= 6.1.6) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.4.3) loofah (~> 2.3) railties (6.1.6) actionpack (= 6.1.6) activesupport (= 6.1.6) method_source rake (>= 12.2) thor (~> 1.0) rainbow (3.1.1) rake (13.0.6) regexp_parser (2.5.0) rexml (3.2.5) rubocop (1.35.0) json (~> 2.3) parallel (~> 1.10) parser (>= 3.1.2.1) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) rubocop-ast (>= 1.20.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.21.0) parser (>= 3.1.1.0) rubocop-performance (1.14.3) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) ruby-progressbar (1.11.0) sprockets (4.1.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.4.2) actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) sqlite3 (1.4.4) standard (1.16.0) rubocop (= 1.35.0) rubocop-performance (= 1.14.3) standardrb (1.0.1) standard strscan (3.0.4) thor (1.2.1) timeout (0.3.0) tzinfo (2.0.5) concurrent-ruby (~> 1.0) unicode-display_width (2.2.0) websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) zeitwerk (2.6.0) PLATFORMS arm64-darwin-21 x86_64-linux DEPENDENCIES appraisal net-imap net-pop net-smtp pg rails (~> 6.1.0) sequenced! sqlite3 (~> 1.4.4) standardrb BUNDLED WITH 2.3.16 sequenced-4.0.0/gemfiles/rails_6.gemfile0000644000004100000410000000042014333131245020176 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "appraisal" gem "standardrb" gem "rails", "~> 6.0.0" group :development, :test do gem "sqlite3", "~> 1.4.4" gem "pg" gem "net-imap" gem "net-pop" gem "net-smtp" end gemspec path: "../" sequenced-4.0.0/gemfiles/rails_6.gemfile.lock0000644000004100000410000001143414333131245021134 0ustar www-datawww-dataPATH remote: .. specs: sequenced (4.0.0) activerecord (>= 3.0) activesupport (>= 3.0) GEM remote: https://rubygems.org/ specs: actioncable (6.0.5.1) actionpack (= 6.0.5.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) actionmailbox (6.0.5.1) actionpack (= 6.0.5.1) activejob (= 6.0.5.1) activerecord (= 6.0.5.1) activestorage (= 6.0.5.1) activesupport (= 6.0.5.1) mail (>= 2.7.1) actionmailer (6.0.5.1) actionpack (= 6.0.5.1) actionview (= 6.0.5.1) activejob (= 6.0.5.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) actionpack (6.0.5.1) actionview (= 6.0.5.1) activesupport (= 6.0.5.1) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) actiontext (6.0.5.1) actionpack (= 6.0.5.1) activerecord (= 6.0.5.1) activestorage (= 6.0.5.1) activesupport (= 6.0.5.1) nokogiri (>= 1.8.5) actionview (6.0.5.1) activesupport (= 6.0.5.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) activejob (6.0.5.1) activesupport (= 6.0.5.1) globalid (>= 0.3.6) activemodel (6.0.5.1) activesupport (= 6.0.5.1) activerecord (6.0.5.1) activemodel (= 6.0.5.1) activesupport (= 6.0.5.1) activestorage (6.0.5.1) actionpack (= 6.0.5.1) activejob (= 6.0.5.1) activerecord (= 6.0.5.1) marcel (~> 1.0) activesupport (6.0.5.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) zeitwerk (~> 2.2, >= 2.2.2) appraisal (2.4.1) bundler rake thor (>= 0.14.0) ast (2.4.2) builder (3.2.4) concurrent-ruby (1.1.10) crass (1.0.6) digest (3.1.0) erubi (1.11.0) globalid (1.0.0) activesupport (>= 5.0) i18n (1.12.0) concurrent-ruby (~> 1.0) json (2.6.2) loofah (2.18.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) marcel (1.0.2) method_source (1.0.0) mini_mime (1.1.2) minitest (5.16.2) net-imap (0.2.3) digest net-protocol strscan net-pop (0.1.1) digest net-protocol timeout net-protocol (0.1.3) timeout net-smtp (0.3.1) digest net-protocol timeout nio4r (2.5.8) nokogiri (1.13.8-arm64-darwin) racc (~> 1.4) nokogiri (1.13.8-x86_64-linux) racc (~> 1.4) parallel (1.22.1) parser (3.1.2.1) ast (~> 2.4.1) pg (1.4.3) racc (1.6.0) rack (2.2.4) rack-test (2.0.2) rack (>= 1.3) rails (6.0.5.1) actioncable (= 6.0.5.1) actionmailbox (= 6.0.5.1) actionmailer (= 6.0.5.1) actionpack (= 6.0.5.1) actiontext (= 6.0.5.1) actionview (= 6.0.5.1) activejob (= 6.0.5.1) activemodel (= 6.0.5.1) activerecord (= 6.0.5.1) activestorage (= 6.0.5.1) activesupport (= 6.0.5.1) bundler (>= 1.3.0) railties (= 6.0.5.1) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.4.3) loofah (~> 2.3) railties (6.0.5.1) actionpack (= 6.0.5.1) activesupport (= 6.0.5.1) method_source rake (>= 0.8.7) thor (>= 0.20.3, < 2.0) rainbow (3.1.1) rake (13.0.6) regexp_parser (2.5.0) rexml (3.2.5) rubocop (1.35.0) json (~> 2.3) parallel (~> 1.10) parser (>= 3.1.2.1) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) rubocop-ast (>= 1.20.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.21.0) parser (>= 3.1.1.0) rubocop-performance (1.14.3) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) ruby-progressbar (1.11.0) sprockets (4.1.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.4.2) actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) sqlite3 (1.4.4) standard (1.16.0) rubocop (= 1.35.0) rubocop-performance (= 1.14.3) standardrb (1.0.1) standard strscan (3.0.4) thor (1.2.1) thread_safe (0.3.6) timeout (0.3.0) tzinfo (1.2.10) thread_safe (~> 0.1) unicode-display_width (2.2.0) websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) zeitwerk (2.6.0) PLATFORMS arm64-darwin-21 x86_64-linux DEPENDENCIES appraisal net-imap net-pop net-smtp pg rails (~> 6.0.0) sequenced! sqlite3 (~> 1.4.4) standardrb BUNDLED WITH 2.3.16 sequenced-4.0.0/CHANGELOG.md0000644000004100000410000000522314333131245015331 0ustar www-datawww-data4.0.0 (August 16, 2022) ------------------------ * Drop official support Ruby 2.6 or older * Drop official support Rails 5.1 or older * Migrate from Travis CI to GitHub Actions * Include Sequenced when ActiveRecord loads ([#52](https://github.com/derrickreimer/sequenced/pull/52)) 3.2.0 (January 29, 2020) ------------------------ * Support non-default primary key columns (set via `primary_key=`) ([#41](https://github.com/derrickreimer/sequenced/pull/41)) * Fix issue with Postgres adapter check when using a subclassed adapter ([#42](https://github.com/derrickreimer/sequenced/pull/42)) 3.1.1 (January 30, 2016) ------------------------- * Rails 3 compatibility (samphilipd, [#22](https://github.com/derrickreimer/sequenced/pull/22)) 3.1.0 (January 23, 2016) ------------------------- * Allow multiple sequences on one record (samphilipd, [#19](https://github.com/derrickreimer/sequenced/pull/19)) 3.0.0 (November 28, 2015) ------------------------- * Make this gem thread-safe for PostgreSQL (samphilipd, [#16](https://github.com/derrickreimer/sequenced/pull/16)) 2.0.0 (October 24, 2014) ------------------------ * Revert "Move generation callback from `before_save` to `before_validation` to allow validations to utilize the sequential id". This change introduced a critical bug where generating multiple records in one transaction would lead to duplicate ids (see #10) 1.6.0 (April 10, 2014) ---------------------- * Move generation callback from `before_save` to `before_validation` to allow validations to utilize the sequential id (makebytes) 1.5.0 (December 26, 2013) ------------------------- * Add the ability to pass a lambda for the start_at option (Bobby Uhlenbrock) * Major internal refactor for cleaner, more modular code * Scope by base class when single table inheritance is being used (Adam Becker) 1.4.0 (July 15, 2013) --------------------- * Remove hard dependency on Rails 3 in the test suite * Add skip option to sequence generation 1.3.0 (April 11, 2013) ---------------------- * Fix a potential bug that could overwrite previously set sequential IDs if they are later found to be non-unique. 1.2.0 (April 11, 2013) ---------------------- * Accept an array of symbols for the scope attribute to scope by multiple columns. 1.1.0 (July 5, 2012) -------------------- * Raise ArgumentError instead of Sequenced::InvalidAttributeError * Remove custom exceptions * Stop calling it a "plugin" 1.0.0 (March 7, 2012) --------------------- * Restrict dependencies on ActiveSupport and ActiveRecord to `~> 3.0` * Make error messages more descriptive * Update gem description 0.1.0 (February 19, 2012) ------------------------- * Initial release sequenced-4.0.0/Appraisals0000644000004100000410000000045414333131245015543 0ustar www-datawww-dataappraise "rails-5-2" do gem "rails", "~> 5.2.0" end appraise "rails-6" do gem "rails", "~> 6.0.0" end appraise "rails-6-1" do gem "rails", "~> 6.1.0" end appraise "rails-7" do gem "rails", "~> 7.0.0" end appraise "rails-master" do gem "rails", github: "rails/rails", branch: "main" end sequenced-4.0.0/.gitignore0000644000004100000410000000024114333131245015503 0ustar www-datawww-data.bundle/ .rvmrc Gemfile.lock log/*.log pkg/ test/dummy/db/*.sqlite3 test/dummy/log/*.log test/dummy/tmp/ test/dummy/.sass-cache *.gem .ruby-version .ruby-gemset sequenced-4.0.0/sequenced.gemspec0000644000004100000410000000132614333131245017041 0ustar www-datawww-data$:.push File.expand_path("../lib", __FILE__) require "sequenced/version" Gem::Specification.new do |s| s.name = "sequenced" s.version = Sequenced::VERSION s.authors = ["Derrick Reimer"] s.licenses = ["MIT"] s.email = ["derrickreimer@gmail.com"] s.homepage = "https://github.com/derrickreimer/sequenced" s.summary = "Generate scoped sequential IDs for ActiveRecord models" s.description = "Sequenced is a gem that generates scoped sequential IDs for ActiveRecord models." s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } s.add_dependency "activesupport", ">= 3.0" s.add_dependency "activerecord", ">= 3.0" s.add_development_dependency "rails", ">= 3.1" end sequenced-4.0.0/Rakefile0000644000004100000410000000260314333131245015164 0ustar www-datawww-data#!/usr/bin/env rake begin require "bundler/setup" rescue LoadError puts "You must `gem install bundler` and `bundle install` to run rake tasks" end begin require "rdoc/task" rescue LoadError require "rdoc/rdoc" require "rake/rdoctask" RDoc::Task = Rake::RDocTask end RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_dir = "rdoc" rdoc.title = "Sequenced" rdoc.options << "--line-numbers" rdoc.rdoc_files.include("README.rdoc") rdoc.rdoc_files.include("lib/**/*.rb") end Bundler::GemHelper.install_tasks require "rake/testtask" Rake::TestTask.new(:test) do |t| t.libs << "lib" t.libs << "test" t.pattern = "test/**/*_test.rb" t.verbose = false end task default: :test namespace :db do task :create do # File.expand_path is executed directory of generated Rails app rakefile = File.expand_path("Rakefile", "test/dummy/") command = "rake -f '%s' db:create" % rakefile sh(command) end task :drop do # File.expand_path is executed directory of generated Rails app rakefile = File.expand_path("Rakefile", "test/dummy/") command = "rake -f '%s' db:drop" % rakefile sh(command) end namespace :test do task :prepare do # File.expand_path is executed directory of generated Rails app rakefile = File.expand_path("Rakefile", "test/dummy/") command = "rake -f '%s' db:test:prepare" % rakefile sh(command) end end end sequenced-4.0.0/lib/0000755000004100000410000000000014333131245014264 5ustar www-datawww-datasequenced-4.0.0/lib/sequenced.rb0000644000004100000410000000022714333131245016566 0ustar www-datawww-datarequire "sequenced/generator" require "sequenced/acts_as_sequenced" ActiveSupport.on_load(:active_record) do include Sequenced::ActsAsSequenced end sequenced-4.0.0/lib/sequenced/0000755000004100000410000000000014333131245016240 5ustar www-datawww-datasequenced-4.0.0/lib/sequenced/version.rb0000644000004100000410000000005114333131245020246 0ustar www-datawww-datamodule Sequenced VERSION = "4.0.0" end sequenced-4.0.0/lib/sequenced/acts_as_sequenced.rb0000644000004100000410000000473114333131245022243 0ustar www-datawww-datarequire "active_support/core_ext/hash/slice" require "active_support/core_ext/class/attribute_accessors" module Sequenced module ActsAsSequenced DEFAULT_OPTIONS = { column: :sequential_id, start_at: 1 }.freeze SequencedColumnExists = Class.new(StandardError) def self.included(base) base.extend ClassMethods end module ClassMethods # Public: Defines ActiveRecord callbacks to set a sequential ID scoped # on a specific class. # # Can be called multiple times to add hooks for different column names. # # options - The Hash of options for configuration: # :scope - The Symbol representing the columm on which the # sequential ID should be scoped (default: nil) # :column - The Symbol representing the column that stores the # sequential ID (default: :sequential_id) # :start_at - The Integer value at which the sequence should # start (default: 1) # :skip - Skips the sequential ID generation when the lambda # expression evaluates to nil. Gets passed the # model object # # Examples # # class Answer < ActiveRecord::Base # belongs_to :question # acts_as_sequenced :scope => :question_id # end # # Returns nothing. def acts_as_sequenced(options = {}) unless defined?(sequenced_options) include Sequenced::ActsAsSequenced::InstanceMethods mattr_accessor :sequenced_options, instance_accessor: false self.sequenced_options = [] before_save :set_sequential_ids end options = DEFAULT_OPTIONS.merge(options) column_name = options[:column] if sequenced_options.any? { |options| options[:column] == column_name } raise(SequencedColumnExists, <<-MSG.squish) Tried to set #{column_name} as sequenced but there was already a definition here. Did you accidentally call acts_as_sequenced multiple times on the same column? MSG else sequenced_options << options end end end module InstanceMethods def set_sequential_ids self.class.base_class.sequenced_options.each do |options| Sequenced::Generator.new(self, options).set end end end end end sequenced-4.0.0/lib/sequenced/generator.rb0000644000004100000410000000361214333131245020555 0ustar www-datawww-datamodule Sequenced class Generator attr_reader :record, :scope, :column, :start_at, :skip def initialize(record, options = {}) @record = record @scope = options[:scope] @column = options[:column].to_sym @start_at = options[:start_at] @skip = options[:skip] end def set return if skip? || id_set? lock_table record.send(:"#{column}=", next_id) end def id_set? !record.send(column).nil? end def skip? skip&.call(record) end def next_id next_id_in_sequence.tap do |id| id += 1 until unique?(id) end end def next_id_in_sequence start_at = self.start_at.respond_to?(:call) ? self.start_at.call(record) : self.start_at if (last_record = find_last_record) max(last_record.send(column) + 1, start_at) else start_at end end def unique?(id) build_scope(*scope) do rel = base_relation rel = rel.where.not(record.class.primary_key => record.id) if record.persisted? rel.where(column => id) end.count == 0 end private def lock_table if postgresql? record.class.connection.execute("LOCK TABLE #{record.class.table_name} IN EXCLUSIVE MODE") end end def postgresql? defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) && record.class.connection.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) end def base_relation record.class.base_class.unscoped end def find_last_record build_scope(*scope) do base_relation .where("#{column} IS NOT NULL") .order("#{column} DESC") end.first end def build_scope(*columns) rel = yield columns.each { |c| rel = rel.where(c => record.send(c.to_sym)) } rel end def max(*values) values.to_a.max end end end sequenced-4.0.0/Gemfile0000644000004100000410000000134214333131245015011 0ustar www-datawww-datasource "https://rubygems.org" # Declare your gem's dependencies in sequenced.gemspec. # Bundler will treat runtime dependencies like base dependencies, and # development dependencies will be added by default to the :development group. gemspec gem "appraisal" gem "standardrb" group :development, :test do gem "sqlite3", "~> 1.4.4" # gem 'mysql2' gem "pg" gem "net-imap" gem "net-pop" gem "net-smtp" end # Declare any dependencies that are still in development here instead of in # your gemspec. These might include edge Rails or gems from your path or # Git. Remember to move these dependencies to your gemspec before releasing # your gem to rubygems.org. # To use debugger # gem 'ruby-debug19', :require => 'ruby-debug' sequenced-4.0.0/.github/0000755000004100000410000000000014333131245015056 5ustar www-datawww-datasequenced-4.0.0/.github/workflows/0000755000004100000410000000000014333131245017113 5ustar www-datawww-datasequenced-4.0.0/.github/workflows/ci.yml0000644000004100000410000000437114333131245020236 0ustar www-datawww-dataname: Tests on: pull_request: branches: - '*' push: branches: - master jobs: sqlite: runs-on: ubuntu-latest strategy: matrix: ruby: ['2.7', '3.0', '3.1'] gemfile: - rails_5_2 - rails_6 - rails_6_1 - rails_7 - rails_master exclude: - ruby: '3.0' gemfile: 'rails_5_2' - ruby: '3.1' gemfile: 'rails_5_2' env: BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile BUNDLE_PATH_RELATIVE_TO_CWD: true steps: - uses: actions/checkout@master - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} bundler: default bundler-cache: true - name: StandardRb check run: bundle exec standardrb - name: Run tests env: DATABASE_URL: "sqlite3:test" RAILS_ENV: test run: | bundle exec rails db:test:prepare bundle exec rails test postgres: runs-on: ubuntu-latest strategy: matrix: ruby: ['2.7', '3.0', '3.1'] gemfile: - rails_5_2 - rails_6 - rails_6_1 - rails_7 - rails_master exclude: - ruby: '3.0' gemfile: 'rails_5_2' - ruby: '3.1' gemfile: 'rails_5_2' env: BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile BUNDLE_PATH_RELATIVE_TO_CWD: true services: postgres: image: postgres:12 env: POSTGRES_USER: postgres POSTGRES_PASSWORD: password POSTGRES_DB: test ports: ['5432:5432'] steps: - uses: actions/checkout@master - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} bundler: default bundler-cache: true - name: StandardRb check run: bundle exec standardrb - name: Run tests env: DATABASE_URL: postgres://postgres:password@localhost:5432/test RAILS_ENV: test run: | bundle exec rails db:test:prepare bundle exec rails test sequenced-4.0.0/MIT-LICENSE0000644000004100000410000000204314333131245015151 0ustar www-datawww-dataCopyright 2012-2020 Derrick Reimer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.