rein 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/{LICENSE → LICENSE.md} +0 -0
- data/README.md +147 -41
- data/lib/rein.rb +5 -0
- data/lib/rein/constraint/foreign_key.rb +2 -0
- data/lib/rein/constraint/inclusion.rb +5 -4
- data/lib/rein/constraint/null.rb +20 -0
- data/lib/rein/constraint/numericality.rb +6 -6
- data/lib/rein/constraint/options.rb +18 -0
- data/lib/rein/constraint/presence.rb +8 -7
- data/lib/rein/schema.rb +14 -0
- data/lib/rein/version.rb +1 -1
- data/lib/rein/view.rb +1 -1
- metadata +62 -13
- data/.gitignore +0 -4
- data/.rspec +0 -2
- data/.rubocop.yml +0 -35
- data/.travis.yml +0 -2
- data/.yardopts +0 -1
- data/Gemfile +0 -4
- data/Rakefile +0 -8
- data/rein.gemspec +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a9c78af74657a1a1a30eddab52f82f308dd1a1c
|
4
|
+
data.tar.gz: 72b3d37a29e6d2384ab7c6bc46268544dc560271
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c0229b55c19e5fded597a3f3d0b8836ba073fac83365efcf88fbe0c2a37ab9cde6989d2db7587fd093316742c5aa4692e383c4bb021edc774596a3cc8cf2a2f
|
7
|
+
data.tar.gz: 6bc108d82d305dc4115d7944e4dc84aafc789f92ae2d1349b8ed5273b44e4e07492f75e59bfae3c83ee44d38b7d5b30232bcff695207e652157f865cbb846baf
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,26 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 2.1.0
|
4
|
+
|
5
|
+
- Add `if` option to inclusion constraints.
|
6
|
+
- Add `name` option to constraints.
|
7
|
+
- Add null constraint.
|
8
|
+
- Ensure presence constraint enforces not null.
|
9
|
+
|
3
10
|
## 2.0.0
|
4
11
|
|
5
12
|
- Add support for enumerated types.
|
6
13
|
- Add `if` option to numericality constraints.
|
7
14
|
- Add `if` option to presence constraints.
|
8
15
|
- Fix a bug in presence contraints.
|
16
|
+
|
17
|
+
## 1.1.0
|
18
|
+
|
19
|
+
- Update README.
|
20
|
+
- Code cleanups.
|
21
|
+
- Disable monkey patching in rspec.
|
22
|
+
|
23
|
+
## 1.0.0
|
24
|
+
|
25
|
+
- Fix `Mysql2Adapter` for Rails 3.2.
|
26
|
+
- Add `column` option to `add_primary_key`.
|
data/{LICENSE → LICENSE.md}
RENAMED
File without changes
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Rein
|
2
2
|
|
3
|
+
[](https://travis-ci.org/nullobject/rein)
|
4
|
+
|
3
5
|
[Data integrity](http://en.wikipedia.org/wiki/Data_integrity) is a good thing.
|
4
6
|
Constraining the values allowed by your application at the database-level,
|
5
7
|
rather than at the application-level, is a more robust way of ensuring your
|
@@ -20,10 +22,13 @@ can easily tame the data in your database.
|
|
20
22
|
* [Inclusion constraints](#inclusion-constraints)
|
21
23
|
* [Numericality constraints](#numericality-constraints)
|
22
24
|
* [Presence constraints](#presence-constraints)
|
25
|
+
* [Null constraints](#null-constraints)
|
23
26
|
* [Data types](#data-types)
|
24
27
|
* [Enumerated types](#enumerated-types)
|
25
28
|
* [Views](#views)
|
29
|
+
* [Schemas](#schemas)
|
26
30
|
* [Example](#example)
|
31
|
+
* [Contributing](#contributing)
|
27
32
|
* [License](#license)
|
28
33
|
|
29
34
|
## Getting started
|
@@ -90,7 +95,7 @@ For example, we can ensure that `state` column values can only ever be
|
|
90
95
|
`available` or `on_loan`:
|
91
96
|
|
92
97
|
```ruby
|
93
|
-
add_inclusion_constraint :books, :state, in: %w
|
98
|
+
add_inclusion_constraint :books, :state, in: %w[available on_loan]
|
94
99
|
```
|
95
100
|
|
96
101
|
To remove an inclusion constraint:
|
@@ -99,6 +104,23 @@ To remove an inclusion constraint:
|
|
99
104
|
remove_inclusion_constraint :books, :state
|
100
105
|
```
|
101
106
|
|
107
|
+
You may also include an `if` option to enforce the constraint only under
|
108
|
+
certain conditions, like so:
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
add_inclusion_constraint :books, :state,
|
112
|
+
in: %w[available on_loan],
|
113
|
+
if: "deleted_at IS NULL"
|
114
|
+
```
|
115
|
+
|
116
|
+
You may optionally provide a `name` option to customize the name:
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
add_inclusion_constraint :books, :state,
|
120
|
+
in: %w[available on_loan],
|
121
|
+
name: "books_state_is_valid"
|
122
|
+
```
|
123
|
+
|
102
124
|
### Numericality constraints
|
103
125
|
|
104
126
|
*(PostgreSQL only)*
|
@@ -124,8 +146,8 @@ Here's all the options for constraining the values:
|
|
124
146
|
- `greater_than`
|
125
147
|
- `greater_than_or_equal_to`
|
126
148
|
|
127
|
-
You may also include an `if` option to enforce the constraint only under
|
128
|
-
like so:
|
149
|
+
You may also include an `if` option to enforce the constraint only under
|
150
|
+
certain conditions, like so:
|
129
151
|
|
130
152
|
```ruby
|
131
153
|
add_numericality_constraint :books, :publication_month,
|
@@ -134,6 +156,15 @@ add_numericality_constraint :books, :publication_month,
|
|
134
156
|
if: "status = 'published'"
|
135
157
|
```
|
136
158
|
|
159
|
+
You may optionally provide a `name` option to customize the name:
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
add_numericality_constraint :books, :publication_month,
|
163
|
+
greater_than_or_equal_to: 1,
|
164
|
+
less_than_or_equal_to: 12,
|
165
|
+
name: "books_publication_month_is_valid"
|
166
|
+
```
|
167
|
+
|
137
168
|
To remove a numericality constraint:
|
138
169
|
|
139
170
|
```ruby
|
@@ -160,12 +191,39 @@ you can pass an optional `if` option:
|
|
160
191
|
add_presence_constraint :books, :isbn, if: "status = 'published'"
|
161
192
|
```
|
162
193
|
|
194
|
+
You may optionally provide a `name` option to customize the name:
|
195
|
+
|
196
|
+
```ruby
|
197
|
+
add_presence_constraint :books, :isbn, name: "books_isbn_is_valid"
|
198
|
+
```
|
199
|
+
|
163
200
|
To remove a presence constraint:
|
164
201
|
|
165
202
|
```ruby
|
166
203
|
remove_presence_constraint :books, :title
|
167
204
|
```
|
168
205
|
|
206
|
+
### Null constraints
|
207
|
+
|
208
|
+
*(PostgreSQL only)*
|
209
|
+
|
210
|
+
A null constraint ensures that a column does *not* contain a null value. This
|
211
|
+
is the same as adding `NOT NULL` to a column, the difference being that it can
|
212
|
+
be _applied conditionally_.
|
213
|
+
|
214
|
+
For example, we can add a constraint to enforce that a book has a `due_date`,
|
215
|
+
but only if it's `on_loan`:
|
216
|
+
|
217
|
+
```ruby
|
218
|
+
add_null_constraint :books, :due_date, if: "state = 'on_loan'"
|
219
|
+
```
|
220
|
+
|
221
|
+
To remove a null constraint:
|
222
|
+
|
223
|
+
```ruby
|
224
|
+
remove_null_constraint :books, :due_date
|
225
|
+
```
|
226
|
+
|
169
227
|
## Data types
|
170
228
|
|
171
229
|
### Enumerated types
|
@@ -175,7 +233,7 @@ remove_presence_constraint :books, :title
|
|
175
233
|
An enum is a data type that represents a static, ordered set of values.
|
176
234
|
|
177
235
|
```ruby
|
178
|
-
create_enum_type :book_type, [
|
236
|
+
create_enum_type :book_type, %w[paperback hardcover]
|
179
237
|
```
|
180
238
|
|
181
239
|
To drop an enum type from the database:
|
@@ -193,64 +251,112 @@ For example, we can define an `available_books` view that returns only the
|
|
193
251
|
books which are currently available:
|
194
252
|
|
195
253
|
```ruby
|
196
|
-
create_view
|
254
|
+
create_view :available_books, "SELECT * FROM books WHERE state = 'available'"
|
197
255
|
```
|
198
256
|
|
199
257
|
To drop a view from the database:
|
200
258
|
|
201
259
|
```ruby
|
202
|
-
drop_view
|
260
|
+
drop_view :available_books
|
203
261
|
```
|
204
262
|
|
205
|
-
##
|
263
|
+
## Schemas
|
206
264
|
|
207
|
-
|
208
|
-
application.
|
265
|
+
*(PostgreSQL only)*
|
209
266
|
|
210
|
-
|
267
|
+
A database can contain one or more named schemas, which in turn contain tables.
|
268
|
+
Sometimes it might be helpful to split your database into multiple schemas to
|
269
|
+
logically group tables together.
|
211
270
|
|
212
271
|
```ruby
|
213
|
-
|
214
|
-
t.string :name, null: false
|
215
|
-
t.timestamps, null: false
|
216
|
-
end
|
217
|
-
|
218
|
-
# An author must have a name.
|
219
|
-
add_presence_constraint :authors, :name
|
272
|
+
create_schema :archive
|
220
273
|
```
|
221
274
|
|
222
|
-
|
275
|
+
To drop a schema from the database:
|
223
276
|
|
224
277
|
```ruby
|
225
|
-
|
226
|
-
|
227
|
-
t.string :title, null: false
|
228
|
-
t.string :state, null: false
|
229
|
-
t.integer :published_year, null: false
|
230
|
-
t.integer :published_month, null: false
|
231
|
-
t.timestamps, null: false
|
232
|
-
end
|
278
|
+
drop_schema :archive
|
279
|
+
```
|
233
280
|
|
234
|
-
|
235
|
-
# deleteing an author who has books.
|
236
|
-
add_foreign_key_constraint :books, :authors, on_delete: :restrict
|
281
|
+
## Example
|
237
282
|
|
238
|
-
|
239
|
-
|
283
|
+
Let's have a look at some example migrations to constrain database values for
|
284
|
+
our simple library application:
|
240
285
|
|
241
|
-
|
242
|
-
|
286
|
+
```ruby
|
287
|
+
class CreateAuthorsTable < ActiveRecord::Migration
|
288
|
+
def change
|
289
|
+
# The authors table contains all the authors of the books in the library.
|
290
|
+
create_table :authors do |t|
|
291
|
+
t.string :name, null: false
|
292
|
+
t.timestamps, null: false
|
293
|
+
end
|
294
|
+
|
295
|
+
# An author must have a name.
|
296
|
+
add_presence_constraint :authors, :name
|
297
|
+
end
|
298
|
+
end
|
243
299
|
|
244
|
-
|
245
|
-
|
246
|
-
|
300
|
+
class CreateBooksTable < ActiveRecord::Migration
|
301
|
+
def change
|
302
|
+
# The books table contains all the books in the library, and their state
|
303
|
+
# (i.e. whether they are on loan or available).
|
304
|
+
create_table :books do |t|
|
305
|
+
t.belongs_to :author, null: false
|
306
|
+
t.string :title, null: false
|
307
|
+
t.string :state, null: false
|
308
|
+
t.integer :published_year, null: false
|
309
|
+
t.integer :published_month, null: false
|
310
|
+
t.date :due_date
|
311
|
+
t.timestamps, null: false
|
312
|
+
end
|
313
|
+
|
314
|
+
# A book should always belong to an author. The database should
|
315
|
+
# automatically delete an author's books when we delete an author.
|
316
|
+
add_foreign_key_constraint :books, :authors, on_delete: :cascade
|
317
|
+
|
318
|
+
# A book must have a non-empty title.
|
319
|
+
add_presence_constraint :books, :title
|
320
|
+
|
321
|
+
# State is always either "available", "on_loan", or "on_hold".
|
322
|
+
add_inclusion_constraint :books, :state, in: %w[available on_loan on_hold]
|
323
|
+
|
324
|
+
# Our library doesn't deal in classics.
|
325
|
+
add_numericality_constraint :books, :published_year,
|
326
|
+
greater_than_or_equal_to: 1980
|
327
|
+
|
328
|
+
# Month is always between 1 and 12.
|
329
|
+
add_numericality_constraint :books, :published_month,
|
330
|
+
greater_than_or_equal_to: 1,
|
331
|
+
less_than_or_equal_to: 12
|
332
|
+
|
333
|
+
# A book has a due date if it is on loan.
|
334
|
+
add_null_constraint :books, :due_date, if: "state = 'on_loan'"
|
335
|
+
end
|
336
|
+
end
|
247
337
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
338
|
+
class CreateArchivedBooksTable < ActiveRecord::Migration
|
339
|
+
def change
|
340
|
+
# The archive schema contains all of the archived data. We want to keep
|
341
|
+
# this separate from the public schema.
|
342
|
+
create_schema :archive
|
343
|
+
|
344
|
+
# The archive.books table contains all the achived books.
|
345
|
+
create_table "archive.books" do |t|
|
346
|
+
t.belongs_to :author, null: false
|
347
|
+
t.string :title, null: false
|
348
|
+
end
|
349
|
+
|
350
|
+
# A book should always belong to an author. The database should prevent us
|
351
|
+
# from deleteing an author who has books.
|
352
|
+
add_foreign_key_constraint "archive.books", :authors, on_delete: :restrict
|
353
|
+
|
354
|
+
# A book must have a non-empty title.
|
355
|
+
add_presence_constraint "archive.books", :title
|
356
|
+
end
|
357
|
+
end
|
252
358
|
```
|
253
359
|
|
254
360
|
## License
|
255
361
|
|
256
|
-
Rein is licensed under the [MIT License](/LICENSE).
|
362
|
+
Rein is licensed under the [MIT License](/LICENSE.md).
|
data/lib/rein.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
require "active_record"
|
2
2
|
require "active_record/connection_adapters/abstract_mysql_adapter"
|
3
3
|
|
4
|
+
require "rein/constraint/options"
|
4
5
|
require "rein/constraint/primary_key"
|
5
6
|
require "rein/constraint/foreign_key"
|
6
7
|
require "rein/constraint/inclusion"
|
8
|
+
require "rein/constraint/null"
|
7
9
|
require "rein/constraint/numericality"
|
8
10
|
require "rein/constraint/presence"
|
9
11
|
require "rein/type/enum"
|
10
12
|
require "rein/view"
|
13
|
+
require "rein/schema"
|
11
14
|
|
12
15
|
module ActiveRecord
|
13
16
|
module ConnectionAdapters # :nodoc:
|
@@ -27,10 +30,12 @@ module ActiveRecord
|
|
27
30
|
include Rein::Constraint::PrimaryKey
|
28
31
|
include Rein::Constraint::ForeignKey
|
29
32
|
include Rein::Constraint::Inclusion
|
33
|
+
include Rein::Constraint::Null
|
30
34
|
include Rein::Constraint::Numericality
|
31
35
|
include Rein::Constraint::Presence
|
32
36
|
include Rein::Type::Enum
|
33
37
|
include Rein::View
|
38
|
+
include Rein::Schema
|
34
39
|
end
|
35
40
|
end
|
36
41
|
end
|
@@ -5,16 +5,17 @@ module Rein
|
|
5
5
|
# This module contains methods for defining inclusion constraints.
|
6
6
|
module Inclusion
|
7
7
|
include ActiveRecord::ConnectionAdapters::Quoting
|
8
|
+
include Rein::Constraint::Options
|
8
9
|
|
9
10
|
def add_inclusion_constraint(table, attribute, options = {})
|
10
|
-
name =
|
11
|
+
name = constraint_name(table, attribute, options)
|
11
12
|
values = options[:in].map { |value| quote(value) }.join(", ")
|
12
|
-
conditions = "#{attribute} IN (#{values})"
|
13
|
+
conditions = conditions_with_if("#{attribute} IN (#{values})", options)
|
13
14
|
execute("ALTER TABLE #{table} ADD CONSTRAINT #{name} CHECK (#{conditions})")
|
14
15
|
end
|
15
16
|
|
16
|
-
def remove_inclusion_constraint(table, attribute)
|
17
|
-
name =
|
17
|
+
def remove_inclusion_constraint(table, attribute, options = {})
|
18
|
+
name = constraint_name(table, attribute, options)
|
18
19
|
execute("ALTER TABLE #{table} DROP CONSTRAINT #{name}")
|
19
20
|
end
|
20
21
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Rein
|
2
|
+
module Constraint
|
3
|
+
# This module contains methods for defining null constraints.
|
4
|
+
module Null
|
5
|
+
include ActiveRecord::ConnectionAdapters::Quoting
|
6
|
+
include Rein::Constraint::Options
|
7
|
+
|
8
|
+
def add_null_constraint(table, attribute, options = {})
|
9
|
+
name = constraint_name(table, attribute, options)
|
10
|
+
conditions = conditions_with_if("#{attribute} IS NOT NULL", options)
|
11
|
+
execute("ALTER TABLE #{table} ADD CONSTRAINT #{name} CHECK (#{conditions})")
|
12
|
+
end
|
13
|
+
|
14
|
+
def remove_null_constraint(table, attribute, options = {})
|
15
|
+
name = constraint_name(table, attribute, options)
|
16
|
+
execute("ALTER TABLE #{table} DROP CONSTRAINT #{name}")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -2,6 +2,8 @@ module Rein
|
|
2
2
|
module Constraint
|
3
3
|
# This module contains methods for defining numericality constraints.
|
4
4
|
module Numericality
|
5
|
+
include Rein::Constraint::Options
|
6
|
+
|
5
7
|
OPERATORS = {
|
6
8
|
greater_than: :>,
|
7
9
|
greater_than_or_equal_to: :>=,
|
@@ -12,22 +14,20 @@ module Rein
|
|
12
14
|
}.freeze
|
13
15
|
|
14
16
|
def add_numericality_constraint(table, attribute, options = {})
|
15
|
-
name =
|
17
|
+
name = constraint_name(table, attribute, options)
|
16
18
|
|
17
19
|
conditions = OPERATORS.slice(*options.keys).map do |key, operator|
|
18
20
|
value = options[key]
|
19
21
|
[attribute, operator, value].join(" ")
|
20
22
|
end.join(" AND ")
|
21
23
|
|
22
|
-
|
23
|
-
conditions = "NOT (#{options[:if]}) OR (#{conditions})"
|
24
|
-
end
|
24
|
+
conditions = conditions_with_if(conditions, options)
|
25
25
|
|
26
26
|
execute("ALTER TABLE #{table} ADD CONSTRAINT #{name} CHECK (#{conditions})")
|
27
27
|
end
|
28
28
|
|
29
|
-
def remove_numericality_constraint(table, attribute)
|
30
|
-
name =
|
29
|
+
def remove_numericality_constraint(table, attribute, options = {})
|
30
|
+
name = constraint_name(table, attribute, options)
|
31
31
|
execute("ALTER TABLE #{table} DROP CONSTRAINT #{name}")
|
32
32
|
end
|
33
33
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Rein
|
2
|
+
module Constraint
|
3
|
+
# This module defines methods for handling options command to several constraints.
|
4
|
+
module Options
|
5
|
+
def conditions_with_if(conditions, options = {})
|
6
|
+
if options[:if].present?
|
7
|
+
"NOT (#{options[:if]}) OR (#{conditions})"
|
8
|
+
else
|
9
|
+
conditions
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def constraint_name(table, attribute, options = {})
|
14
|
+
options[:name].presence || "#{table}_#{attribute}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -3,18 +3,19 @@ module Rein
|
|
3
3
|
# This module contains methods for defining presence constraints.
|
4
4
|
module Presence
|
5
5
|
include ActiveRecord::ConnectionAdapters::Quoting
|
6
|
+
include Rein::Constraint::Options
|
6
7
|
|
7
8
|
def add_presence_constraint(table, attribute, options = {})
|
8
|
-
name =
|
9
|
-
conditions =
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
name = constraint_name(table, attribute, options)
|
10
|
+
conditions = conditions_with_if(
|
11
|
+
"(#{attribute} IS NOT NULL) AND (#{attribute} !~ '^\\s*$')",
|
12
|
+
options
|
13
|
+
)
|
13
14
|
execute("ALTER TABLE #{table} ADD CONSTRAINT #{name} CHECK (#{conditions})")
|
14
15
|
end
|
15
16
|
|
16
|
-
def remove_presence_constraint(table, attribute)
|
17
|
-
name =
|
17
|
+
def remove_presence_constraint(table, attribute, options = {})
|
18
|
+
name = constraint_name(table, attribute, options)
|
18
19
|
execute("ALTER TABLE #{table} DROP CONSTRAINT #{name}")
|
19
20
|
end
|
20
21
|
end
|
data/lib/rein/schema.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
module Rein
|
2
|
+
# This module contains methods for creating/dropping schemas.
|
3
|
+
module Schema
|
4
|
+
def create_schema(name)
|
5
|
+
sql = "CREATE SCHEMA #{name}"
|
6
|
+
execute(sql)
|
7
|
+
end
|
8
|
+
|
9
|
+
def drop_schema(name)
|
10
|
+
sql = "DROP SCHEMA #{name}"
|
11
|
+
execute(sql)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/rein/version.rb
CHANGED
data/lib/rein/view.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rein
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Bassett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,54 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.0.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '6'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
29
|
+
version: 4.0.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '6'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: activesupport
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 4.0.0
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '6'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 4.0.0
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '6'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: appraisal
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '2.1'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '2.1'
|
27
67
|
- !ruby/object:Gem::Dependency
|
28
68
|
name: bundler
|
29
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +78,20 @@ dependencies:
|
|
38
78
|
- - "~>"
|
39
79
|
- !ruby/object:Gem::Version
|
40
80
|
version: '1.14'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: pg
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0.20'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0.20'
|
41
95
|
- !ruby/object:Gem::Dependency
|
42
96
|
name: rake
|
43
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,26 +141,21 @@ executables: []
|
|
87
141
|
extensions: []
|
88
142
|
extra_rdoc_files: []
|
89
143
|
files:
|
90
|
-
- ".gitignore"
|
91
|
-
- ".rspec"
|
92
|
-
- ".rubocop.yml"
|
93
|
-
- ".travis.yml"
|
94
|
-
- ".yardopts"
|
95
144
|
- CHANGELOG.md
|
96
|
-
-
|
97
|
-
- LICENSE
|
145
|
+
- LICENSE.md
|
98
146
|
- README.md
|
99
|
-
- Rakefile
|
100
147
|
- lib/rein.rb
|
101
148
|
- lib/rein/constraint/foreign_key.rb
|
102
149
|
- lib/rein/constraint/inclusion.rb
|
150
|
+
- lib/rein/constraint/null.rb
|
103
151
|
- lib/rein/constraint/numericality.rb
|
152
|
+
- lib/rein/constraint/options.rb
|
104
153
|
- lib/rein/constraint/presence.rb
|
105
154
|
- lib/rein/constraint/primary_key.rb
|
155
|
+
- lib/rein/schema.rb
|
106
156
|
- lib/rein/type/enum.rb
|
107
157
|
- lib/rein/version.rb
|
108
158
|
- lib/rein/view.rb
|
109
|
-
- rein.gemspec
|
110
159
|
homepage: http://github.com/nullobject/rein
|
111
160
|
licenses:
|
112
161
|
- MIT
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
Exclude:
|
3
|
-
- "bin/**/*"
|
4
|
-
- "rein.gemspec"
|
5
|
-
|
6
|
-
Metrics/AbcSize:
|
7
|
-
Max: 27
|
8
|
-
|
9
|
-
Metrics/BlockLength:
|
10
|
-
ExcludedMethods: describe
|
11
|
-
|
12
|
-
Metrics/CyclomaticComplexity:
|
13
|
-
Max: 7
|
14
|
-
|
15
|
-
Metrics/LineLength:
|
16
|
-
Enabled: false
|
17
|
-
|
18
|
-
Metrics/MethodLength:
|
19
|
-
Max: 11
|
20
|
-
|
21
|
-
Style/BlockDelimiters:
|
22
|
-
Enabled: false
|
23
|
-
|
24
|
-
Style/Documentation:
|
25
|
-
Exclude:
|
26
|
-
- "spec/**/*"
|
27
|
-
|
28
|
-
Style/FrozenStringLiteralComment:
|
29
|
-
Enabled: false
|
30
|
-
|
31
|
-
Style/SpaceInsideHashLiteralBraces:
|
32
|
-
Enabled: false
|
33
|
-
|
34
|
-
Style/StringLiterals:
|
35
|
-
EnforcedStyle: double_quotes
|
data/.travis.yml
DELETED
data/.yardopts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--markup markdown
|
data/Gemfile
DELETED
data/Rakefile
DELETED
data/rein.gemspec
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
lib = File.expand_path("../lib", __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
|
4
|
-
require "rein/version"
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "rein"
|
8
|
-
spec.version = Rein::VERSION
|
9
|
-
spec.author = "Joshua Bassett"
|
10
|
-
spec.email = "josh.bassett@gmail.com"
|
11
|
-
spec.summary = "Database constraints made easy for ActiveRecord."
|
12
|
-
spec.description = "Rein adds bunch of methods to your ActiveRecord migrations so you can easily tame your database."
|
13
|
-
spec.homepage = "http://github.com/nullobject/rein"
|
14
|
-
spec.license = "MIT"
|
15
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
-
f.match(%r{^(test|spec|features)/})
|
17
|
-
end
|
18
|
-
spec.require_paths = ["lib"]
|
19
|
-
|
20
|
-
spec.add_runtime_dependency "activerecord", ">= 3.2.0"
|
21
|
-
|
22
|
-
spec.add_development_dependency "bundler", "~> 1.14"
|
23
|
-
spec.add_development_dependency "rake", "~> 12.0"
|
24
|
-
spec.add_development_dependency "rspec", "~> 3.5"
|
25
|
-
spec.add_development_dependency "rubocop", "~> 0.47"
|
26
|
-
end
|