sequenced 2.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +100 -0
  3. data/Appraisals +19 -0
  4. data/CHANGELOG.md +32 -0
  5. data/Gemfile +12 -3
  6. data/MIT-LICENSE +1 -1
  7. data/README.md +90 -50
  8. data/Rakefile +39 -15
  9. data/gemfiles/rails_5_2.gemfile +17 -0
  10. data/gemfiles/rails_5_2.gemfile.lock +193 -0
  11. data/gemfiles/rails_6.gemfile +17 -0
  12. data/gemfiles/rails_6.gemfile.lock +204 -0
  13. data/gemfiles/rails_6_1.gemfile +17 -0
  14. data/gemfiles/rails_6_1.gemfile.lock +207 -0
  15. data/gemfiles/rails_7.gemfile +17 -0
  16. data/gemfiles/rails_7.gemfile.lock +206 -0
  17. data/gemfiles/rails_master.gemfile +17 -0
  18. data/gemfiles/rails_master.gemfile.lock +215 -0
  19. data/lib/sequenced/acts_as_sequenced.rb +34 -8
  20. data/lib/sequenced/generator.rb +28 -13
  21. data/lib/sequenced/version.rb +1 -1
  22. data/lib/sequenced.rb +5 -3
  23. data/sequenced.gemspec +8 -10
  24. metadata +29 -168
  25. data/.travis.yml +0 -4
  26. data/TODO.md +0 -7
  27. data/test/acts_as_sequenced_test.rb +0 -132
  28. data/test/dummy/README.rdoc +0 -261
  29. data/test/dummy/Rakefile +0 -7
  30. data/test/dummy/app/assets/javascripts/application.js +0 -15
  31. data/test/dummy/app/assets/stylesheets/application.css +0 -13
  32. data/test/dummy/app/controllers/application_controller.rb +0 -3
  33. data/test/dummy/app/helpers/application_helper.rb +0 -2
  34. data/test/dummy/app/mailers/.gitkeep +0 -0
  35. data/test/dummy/app/models/.gitkeep +0 -0
  36. data/test/dummy/app/models/account.rb +0 -6
  37. data/test/dummy/app/models/address.rb +0 -4
  38. data/test/dummy/app/models/answer.rb +0 -4
  39. data/test/dummy/app/models/comment.rb +0 -8
  40. data/test/dummy/app/models/email.rb +0 -4
  41. data/test/dummy/app/models/invoice.rb +0 -4
  42. data/test/dummy/app/models/monster.rb +0 -3
  43. data/test/dummy/app/models/order.rb +0 -4
  44. data/test/dummy/app/models/policeman.rb +0 -5
  45. data/test/dummy/app/models/product.rb +0 -8
  46. data/test/dummy/app/models/question.rb +0 -4
  47. data/test/dummy/app/models/rating.rb +0 -3
  48. data/test/dummy/app/models/subscription.rb +0 -3
  49. data/test/dummy/app/models/user.rb +0 -4
  50. data/test/dummy/app/models/werewolf.rb +0 -2
  51. data/test/dummy/app/models/zombie.rb +0 -2
  52. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  53. data/test/dummy/config/application.rb +0 -56
  54. data/test/dummy/config/boot.rb +0 -10
  55. data/test/dummy/config/database.yml +0 -25
  56. data/test/dummy/config/environment.rb +0 -5
  57. data/test/dummy/config/environments/development.rb +0 -37
  58. data/test/dummy/config/environments/production.rb +0 -67
  59. data/test/dummy/config/environments/test.rb +0 -38
  60. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  61. data/test/dummy/config/initializers/inflections.rb +0 -15
  62. data/test/dummy/config/initializers/mime_types.rb +0 -5
  63. data/test/dummy/config/initializers/secret_token.rb +0 -7
  64. data/test/dummy/config/initializers/session_store.rb +0 -8
  65. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  66. data/test/dummy/config/locales/en.yml +0 -5
  67. data/test/dummy/config/routes.rb +0 -58
  68. data/test/dummy/config.ru +0 -4
  69. data/test/dummy/db/development.sqlite3 +0 -0
  70. data/test/dummy/db/migrate/20120219165346_create_questions.rb +0 -10
  71. data/test/dummy/db/migrate/20120219165548_create_answers.rb +0 -13
  72. data/test/dummy/db/migrate/20120219171957_create_accounts.rb +0 -9
  73. data/test/dummy/db/migrate/20120219172039_create_invoices.rb +0 -12
  74. data/test/dummy/db/migrate/20120219172922_create_orders.rb +0 -10
  75. data/test/dummy/db/migrate/20120219174931_create_subscriptions.rb +0 -10
  76. data/test/dummy/db/migrate/20120219175744_create_users.rb +0 -12
  77. data/test/dummy/db/migrate/20120219232323_create_addresses.rb +0 -9
  78. data/test/dummy/db/migrate/20120220000804_create_comments.rb +0 -12
  79. data/test/dummy/db/migrate/20130411225444_create_emails.rb +0 -12
  80. data/test/dummy/db/migrate/20130715002029_create_ratings.rb +0 -10
  81. data/test/dummy/db/migrate/20130730004055_create_products.rb +0 -9
  82. data/test/dummy/db/migrate/20131226000000_create_monsters.rb +0 -9
  83. data/test/dummy/db/migrate/20140404195334_create_policemen.rb +0 -9
  84. data/test/dummy/db/schema.rb +0 -108
  85. data/test/dummy/db/test.sqlite3 +0 -0
  86. data/test/dummy/lib/assets/.gitkeep +0 -0
  87. data/test/dummy/log/.gitkeep +0 -0
  88. data/test/dummy/log/development.log +0 -62
  89. data/test/dummy/log/test.log +0 -30088
  90. data/test/dummy/public/404.html +0 -26
  91. data/test/dummy/public/422.html +0 -26
  92. data/test/dummy/public/500.html +0 -25
  93. data/test/dummy/public/favicon.ico +0 -0
  94. data/test/dummy/script/rails +0 -6
  95. data/test/test_helper.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2c19db66c935260344abf853e2e1725a7dc9ef4d
4
- data.tar.gz: 27bc38c11839f113839eaf23b8f213f677fa9024
2
+ SHA256:
3
+ metadata.gz: ac1653ef8238785f146ca84e84e967e36d3c7606ce7a0f51bceb9d78103c2b6c
4
+ data.tar.gz: 57858eab7e36ca6e02ec5f823ef75873284f5841be580629665ce986d7283067
5
5
  SHA512:
6
- metadata.gz: 1f47927ecd09469be6fc26fb30b9a752a8f94bee42cba8c54c5cb44d4e0fafa328e6c3dad9a69529a20b4461add62e1d6cd14a730230b284db904d8bb97da4be
7
- data.tar.gz: 9e9707f1c891f16bd0f30a7f0dc001a6f212b9006ef3294549c5c037da817029d850f52b219872e0ac6d7ad8551a140492b28ca2a3d79cdf52117df465791366
6
+ metadata.gz: efc18dd491c36c4c2cc0b5057fb91b4cfde57647ada400d6a3f05bd3726eebe4cc0c62e67a24bf533618339f32a7cd149c38c9eee384a629871b58293a4e4c18
7
+ data.tar.gz: 3fcd11391e68b818818f76178cfdebb9fe6abac44ee104ef0b53351396497840ac5d914485f0b511ae87b0c891c0dfe9435f406e0d9c1399fe0c72f577226328
@@ -0,0 +1,100 @@
1
+ name: Tests
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - '*'
7
+ push:
8
+ branches:
9
+ - master
10
+ jobs:
11
+ sqlite:
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby: ['2.7', '3.0', '3.1']
16
+ gemfile:
17
+ - rails_5_2
18
+ - rails_6
19
+ - rails_6_1
20
+ - rails_7
21
+ - rails_master
22
+ exclude:
23
+ - ruby: '3.0'
24
+ gemfile: 'rails_5_2'
25
+ - ruby: '3.1'
26
+ gemfile: 'rails_5_2'
27
+ env:
28
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
29
+ BUNDLE_PATH_RELATIVE_TO_CWD: true
30
+
31
+ steps:
32
+ - uses: actions/checkout@master
33
+
34
+ - name: Set up Ruby
35
+ uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: ${{ matrix.ruby }}
38
+ bundler: default
39
+ bundler-cache: true
40
+
41
+ - name: StandardRb check
42
+ run: bundle exec standardrb
43
+
44
+ - name: Run tests
45
+ env:
46
+ DATABASE_URL: "sqlite3:test"
47
+ RAILS_ENV: test
48
+ run: |
49
+ bundle exec rails db:test:prepare
50
+ bundle exec rails test
51
+
52
+ postgres:
53
+ runs-on: ubuntu-latest
54
+ strategy:
55
+ matrix:
56
+ ruby: ['2.7', '3.0', '3.1']
57
+ gemfile:
58
+ - rails_5_2
59
+ - rails_6
60
+ - rails_6_1
61
+ - rails_7
62
+ - rails_master
63
+ exclude:
64
+ - ruby: '3.0'
65
+ gemfile: 'rails_5_2'
66
+ - ruby: '3.1'
67
+ gemfile: 'rails_5_2'
68
+ env:
69
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
70
+ BUNDLE_PATH_RELATIVE_TO_CWD: true
71
+
72
+ services:
73
+ postgres:
74
+ image: postgres:12
75
+ env:
76
+ POSTGRES_USER: postgres
77
+ POSTGRES_PASSWORD: password
78
+ POSTGRES_DB: test
79
+ ports: ['5432:5432']
80
+
81
+ steps:
82
+ - uses: actions/checkout@master
83
+
84
+ - name: Set up Ruby
85
+ uses: ruby/setup-ruby@v1
86
+ with:
87
+ ruby-version: ${{ matrix.ruby }}
88
+ bundler: default
89
+ bundler-cache: true
90
+
91
+ - name: StandardRb check
92
+ run: bundle exec standardrb
93
+
94
+ - name: Run tests
95
+ env:
96
+ DATABASE_URL: postgres://postgres:password@localhost:5432/test
97
+ RAILS_ENV: test
98
+ run: |
99
+ bundle exec rails db:test:prepare
100
+ bundle exec rails test
data/Appraisals ADDED
@@ -0,0 +1,19 @@
1
+ appraise "rails-5-2" do
2
+ gem "rails", "~> 5.2.0"
3
+ end
4
+
5
+ appraise "rails-6" do
6
+ gem "rails", "~> 6.0.0"
7
+ end
8
+
9
+ appraise "rails-6-1" do
10
+ gem "rails", "~> 6.1.0"
11
+ end
12
+
13
+ appraise "rails-7" do
14
+ gem "rails", "~> 7.0.0"
15
+ end
16
+
17
+ appraise "rails-master" do
18
+ gem "rails", github: "rails/rails", branch: "main"
19
+ end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,35 @@
1
+ 4.0.0 (August 16, 2022)
2
+ ------------------------
3
+
4
+ * Drop official support Ruby 2.6 or older
5
+ * Drop official support Rails 5.1 or older
6
+ * Migrate from Travis CI to GitHub Actions
7
+ * Include Sequenced when ActiveRecord loads ([#52](https://github.com/derrickreimer/sequenced/pull/52))
8
+
9
+ 3.2.0 (January 29, 2020)
10
+ ------------------------
11
+
12
+ * Support non-default primary key columns (set via `primary_key=`) ([#41](https://github.com/derrickreimer/sequenced/pull/41))
13
+ * Fix issue with Postgres adapter check when using a subclassed adapter ([#42](https://github.com/derrickreimer/sequenced/pull/42))
14
+
15
+ 3.1.1 (January 30, 2016)
16
+ -------------------------
17
+
18
+ * Rails 3 compatibility
19
+ (samphilipd, [#22](https://github.com/derrickreimer/sequenced/pull/22))
20
+
21
+ 3.1.0 (January 23, 2016)
22
+ -------------------------
23
+
24
+ * Allow multiple sequences on one record
25
+ (samphilipd, [#19](https://github.com/derrickreimer/sequenced/pull/19))
26
+
27
+ 3.0.0 (November 28, 2015)
28
+ -------------------------
29
+
30
+ * Make this gem thread-safe for PostgreSQL
31
+ (samphilipd, [#16](https://github.com/derrickreimer/sequenced/pull/16))
32
+
1
33
  2.0.0 (October 24, 2014)
2
34
  ------------------------
3
35
 
data/Gemfile CHANGED
@@ -1,12 +1,21 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Declare your gem's dependencies in sequenced.gemspec.
4
4
  # Bundler will treat runtime dependencies like base dependencies, and
5
5
  # development dependencies will be added by default to the :development group.
6
6
  gemspec
7
7
 
8
- # jquery-rails is used by the dummy application
9
- gem "jquery-rails"
8
+ gem "appraisal"
9
+ gem "standardrb"
10
+
11
+ group :development, :test do
12
+ gem "sqlite3", "~> 1.4.4"
13
+ # gem 'mysql2'
14
+ gem "pg"
15
+ gem "net-imap"
16
+ gem "net-pop"
17
+ gem "net-smtp"
18
+ end
10
19
 
11
20
  # Declare any dependencies that are still in development here instead of in
12
21
  # your gemspec. These might include edge Rails or gems from your path or
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2011-2014 Derrick Reimer
1
+ Copyright 2012-2020 Derrick Reimer
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,23 +1,23 @@
1
1
  # Sequenced
2
2
 
3
- [![Build Status](https://travis-ci.org/djreimer/sequenced.png)](https://travis-ci.org/djreimer/sequenced)
4
- [![Code Climate](https://codeclimate.com/github/djreimer/sequenced.png)](https://codeclimate.com/github/djreimer/sequenced)
5
- [![Gem Version](https://badge.fury.io/rb/sequenced.png)](http://badge.fury.io/rb/sequenced)
6
-
7
- Sequenced is a simple gem that generates scoped sequential IDs for
8
- ActiveRecord models. This gem provides an `acts_as_sequenced` macro that
9
- automatically assigns a unique, sequential ID to each record. The sequential ID is
10
- not a replacement for the database primary key, but rather adds another way to
3
+ [![.github/workflows/ci.yml](https://github.com/derrickreimer/sequenced/actions/workflows/ci.yml/badge.svg)](https://github.com/derrickreimer/sequenced/actions/workflows/ci.yml)
4
+ [![Code Climate](https://codeclimate.com/github/djreimer/sequenced.svg)](https://codeclimate.com/github/djreimer/sequenced)
5
+ [![Gem Version](https://badge.fury.io/rb/sequenced.svg)](http://badge.fury.io/rb/sequenced)
6
+
7
+ Sequenced is a simple gem that generates scoped sequential IDs for
8
+ ActiveRecord models. This gem provides an `acts_as_sequenced` macro that
9
+ automatically assigns a unique, sequential ID to each record. The sequential ID is
10
+ not a replacement for the database primary key, but rather adds another way to
11
11
  retrieve the object without exposing the primary key.
12
12
 
13
13
  ## Purpose
14
14
 
15
- It's generally a bad practice to expose your primary keys to the world
16
- in your URLs. However, it is often appropriate to number objects in sequence
15
+ It's generally a bad practice to expose your primary keys to the world
16
+ in your URLs. However, it is often appropriate to number objects in sequence
17
17
  (in the context of a parent object).
18
18
 
19
19
  For example, given a Question model that has many Answers, it makes sense
20
- to number answers sequentially for each individual question. You can achieve
20
+ to number answers sequentially for each individual question. You can achieve
21
21
  this with Sequenced in one line of code:
22
22
 
23
23
  ```ruby
@@ -34,7 +34,7 @@ end
34
34
  ## Installation
35
35
 
36
36
  Add the gem to your Gemfile:
37
-
37
+
38
38
  gem 'sequenced'
39
39
 
40
40
  Install the gem with bundler:
@@ -70,12 +70,75 @@ class Answer < ActiveRecord::Base
70
70
  end
71
71
  ```
72
72
 
73
+ Multiple sequences can be defined by using the macro multiple times:
74
+
75
+ ```ruby
76
+ class Answer < ActiveRecord::Base
77
+ belongs_to :account
78
+ belongs_to :question
79
+
80
+ acts_as_sequenced column: :question_answer_number, scope: :question_id
81
+ acts_as_sequenced column: :account_answer_number, scope: :account_id
82
+ end
83
+ ```
84
+
85
+ ## Schema and data integrity
86
+
87
+ **This gem is only concurrent-safe for PostgreSQL databases**. For other database systems, unexpected behavior may occur if you attempt to create records concurrently.
88
+
89
+ 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.
90
+
91
+ 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.
92
+
93
+ Here is an example migration for a model that has a `sequential_id` scoped to a `burrow_id`:
94
+
95
+ ```ruby
96
+ # app/db/migrations/20151120190645_create_badgers.rb
97
+ class CreateBadgers < ActiveRecord::Migration
98
+ def change
99
+ create_table :badgers do |t|
100
+ t.integer :sequential_id, null: false
101
+ t.integer :burrow_id
102
+ end
103
+
104
+ add_index :badgers, [:sequential_id, :burrow_id], unique: true
105
+ end
106
+ end
107
+ ```
108
+
109
+ If you are adding a sequenced column to an existing table, you need to account for that in your migration.
110
+
111
+ Here is an example migration that adds and sets the `sequential_id` column based on the current database records:
112
+ ```ruby
113
+ # app/db/migrations/20151120190645_add_sequental_id_to_badgers.rb
114
+ class AddSequentalIdToBadgers < ActiveRecord::Migration
115
+ add_column :badgers, :sequential_id, :integer
116
+
117
+ execute <<~SQL
118
+ UPDATE badgers
119
+ SET sequential_id = old_badgers.next_sequential_id
120
+ FROM (
121
+ SELECT id, ROW_NUMBER()
122
+ OVER(
123
+ PARTITION BY burrow_id
124
+ ORDER BY id
125
+ ) AS next_sequential_id
126
+ FROM badgers
127
+ ) old_badgers
128
+ WHERE badgers.id = old_badgers.id
129
+ SQL
130
+
131
+ change_column :badgers, :sequential_id, :integer, null: false
132
+ add_index :badgers, [:sequential_id, :burrow_id], unique: true
133
+ end
134
+ ```
135
+
73
136
  ## Configuration
74
137
 
75
138
  ### Overriding the default sequential ID column
76
139
 
77
- By default, Sequenced uses the `sequential_id` column and assumes it already
78
- exists. If you wish to store the sequential ID in different integer column,
140
+ By default, Sequenced uses the `sequential_id` column and assumes it already
141
+ exists. If you wish to store the sequential ID in different integer column,
79
142
  simply specify the column name with the `column` option:
80
143
 
81
144
  ```ruby
@@ -84,7 +147,7 @@ acts_as_sequenced scope: :question_id, column: :my_sequential_id
84
147
 
85
148
  ### Starting the sequence at a specific number
86
149
 
87
- By default, Sequenced begins sequences with 1. To start at a different
150
+ By default, Sequenced begins sequences with 1. To start at a different
88
151
  integer, simply set the `start_at` option:
89
152
 
90
153
  ```ruby
@@ -113,7 +176,7 @@ acts_as_sequenced skip: lambda { |r| r.score == 0 }
113
176
 
114
177
  ## Example
115
178
 
116
- Suppose you have a question model that has many answers. This example
179
+ Suppose you have a question model that has many answers. This example
117
180
  demonstrates how to use Sequenced to enable access to the nested answer
118
181
  resource via its sequential ID.
119
182
 
@@ -127,10 +190,10 @@ end
127
190
  class Answer < ActiveRecord::Base
128
191
  belongs_to :question
129
192
  acts_as_sequenced scope: :question_id
130
-
193
+
131
194
  # Automatically use the sequential ID in URLs
132
195
  def to_param
133
- self.sequential_id
196
+ self.sequential_id.to_s
134
197
  end
135
198
  end
136
199
 
@@ -141,48 +204,25 @@ end
141
204
 
142
205
  # app/controllers/answers_controller.rb
143
206
  class AnswersController < ApplicationController
144
- before_filter :load_question
145
- before_filter :load_answer, only: [:show, :edit, :update, :destroy]
146
-
147
- private
148
-
149
- def load_question
207
+ def show
150
208
  @question = Question.find(params[:question_id])
151
- end
152
-
153
- def load_answer
154
- @answer = @question.answers.where(:sequential_id => params[:id]).first
209
+ @answer = @question.answers.find_by(sequential_id: params[:id])
155
210
  end
156
211
  end
157
212
  ```
158
213
 
159
214
  Now, answers are accessible via their sequential IDs:
160
215
 
161
- http://example.com/questions/5/answers/1 # Good
216
+ http://example.com/questions/5/answers/1 # Good
162
217
 
163
218
  instead of by their primary keys:
164
219
 
165
220
  http://example.com/questions/5/answer/32454 # Bad
166
221
 
167
- ## License
168
-
169
- Copyright &copy; 2011-2014 Derrick Reimer
170
-
171
- Permission is hereby granted, free of charge, to any person obtaining
172
- a copy of this software and associated documentation files (the
173
- "Software"), to deal in the Software without restriction, including
174
- without limitation the rights to use, copy, modify, merge, publish,
175
- distribute, sublicense, and/or sell copies of the Software, and to
176
- permit persons to whom the Software is furnished to do so, subject to
177
- the following conditions:
178
-
179
- The above copyright notice and this permission notice shall be
180
- included in all copies or substantial portions of the Software.
222
+ ## Contributing
181
223
 
182
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
183
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
184
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
185
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
186
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
187
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
188
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
224
+ 1. Fork it
225
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
226
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
227
+ 4. Push to the branch (`git push origin my-new-feature`)
228
+ 5. Create new Pull Request
data/Rakefile CHANGED
@@ -1,35 +1,59 @@
1
1
  #!/usr/bin/env rake
2
2
  begin
3
- require 'bundler/setup'
3
+ require "bundler/setup"
4
4
  rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
6
6
  end
7
7
  begin
8
- require 'rdoc/task'
8
+ require "rdoc/task"
9
9
  rescue LoadError
10
- require 'rdoc/rdoc'
11
- require 'rake/rdoctask'
10
+ require "rdoc/rdoc"
11
+ require "rake/rdoctask"
12
12
  RDoc::Task = Rake::RDocTask
13
13
  end
14
14
 
15
15
  RDoc::Task.new(:rdoc) do |rdoc|
16
- rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = 'Sequenced'
18
- rdoc.options << '--line-numbers'
19
- rdoc.rdoc_files.include('README.rdoc')
20
- rdoc.rdoc_files.include('lib/**/*.rb')
16
+ rdoc.rdoc_dir = "rdoc"
17
+ rdoc.title = "Sequenced"
18
+ rdoc.options << "--line-numbers"
19
+ rdoc.rdoc_files.include("README.rdoc")
20
+ rdoc.rdoc_files.include("lib/**/*.rb")
21
21
  end
22
22
 
23
23
  Bundler::GemHelper.install_tasks
24
24
 
25
- require 'rake/testtask'
25
+ require "rake/testtask"
26
26
 
27
27
  Rake::TestTask.new(:test) do |t|
28
- t.libs << 'lib'
29
- t.libs << 'test'
30
- t.pattern = 'test/**/*_test.rb'
28
+ t.libs << "lib"
29
+ t.libs << "test"
30
+ t.pattern = "test/**/*_test.rb"
31
31
  t.verbose = false
32
32
  end
33
33
 
34
+ task default: :test
34
35
 
35
- task :default => :test
36
+ namespace :db do
37
+ task :create do
38
+ # File.expand_path is executed directory of generated Rails app
39
+ rakefile = File.expand_path("Rakefile", "test/dummy/")
40
+ command = "rake -f '%s' db:create" % rakefile
41
+ sh(command)
42
+ end
43
+
44
+ task :drop do
45
+ # File.expand_path is executed directory of generated Rails app
46
+ rakefile = File.expand_path("Rakefile", "test/dummy/")
47
+ command = "rake -f '%s' db:drop" % rakefile
48
+ sh(command)
49
+ end
50
+
51
+ namespace :test do
52
+ task :prepare do
53
+ # File.expand_path is executed directory of generated Rails app
54
+ rakefile = File.expand_path("Rakefile", "test/dummy/")
55
+ command = "rake -f '%s' db:test:prepare" % rakefile
56
+ sh(command)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,17 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "standardrb"
7
+ gem "rails", "~> 5.2.0"
8
+
9
+ group :development, :test do
10
+ gem "sqlite3", "~> 1.4.4"
11
+ gem "pg"
12
+ gem "net-imap"
13
+ gem "net-pop"
14
+ gem "net-smtp"
15
+ end
16
+
17
+ gemspec path: "../"