rein 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/rein.rb CHANGED
@@ -8,10 +8,11 @@ RC = Rein::Constraint
8
8
  require 'active_record'
9
9
  require 'active_support/core_ext/hash'
10
10
 
11
- require 'rein/constraint/foreign_key'
12
11
  require 'rein/constraint/primary_key'
12
+ require 'rein/constraint/foreign_key'
13
13
  require 'rein/constraint/inclusion'
14
14
  require 'rein/constraint/numericality'
15
+ require 'rein/constraint/presence'
15
16
  require 'rein/view'
16
17
 
17
18
  module ActiveRecord::ConnectionAdapters
@@ -32,6 +33,7 @@ module ActiveRecord::ConnectionAdapters
32
33
  include RC::ForeignKey
33
34
  include RC::Inclusion
34
35
  include RC::Numericality
36
+ include RC::Presence
35
37
  include Rein::View
36
38
  end
37
39
  end
@@ -0,0 +1,11 @@
1
+ module RC
2
+ module Presence
3
+ include ActiveRecord::ConnectionAdapters::Quoting
4
+
5
+ def add_presence_constraint(table, attribute)
6
+ name = "#{table}_#{attribute}"
7
+ conditions = "#{attribute} !~ '^\s*$'"
8
+ execute("ALTER TABLE #{table} ADD CONSTRAINT #{name} CHECK (#{conditions})")
9
+ end
10
+ end
11
+ end
data/lib/rein/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rein
2
- VERSION = "0.7.1" unless defined?(Rein::VERSION)
2
+ VERSION = "0.8.0" unless defined?(Rein::VERSION)
3
3
  end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rein
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 7
8
- - 1
9
- version: 0.7.1
4
+ prerelease:
5
+ version: 0.8.0
10
6
  platform: ruby
11
7
  authors:
12
8
  - Josh Bassett
@@ -25,116 +21,75 @@ dependencies:
25
21
  requirements:
26
22
  - - ">="
27
23
  - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
24
  version: "0"
31
25
  type: :runtime
32
26
  version_requirements: *id001
33
27
  - !ruby/object:Gem::Dependency
34
- name: bundler
28
+ name: hirb
35
29
  prerelease: false
36
30
  requirement: &id002 !ruby/object:Gem::Requirement
37
31
  none: false
38
32
  requirements:
39
33
  - - ~>
40
34
  - !ruby/object:Gem::Version
41
- segments:
42
- - 1
43
- - 0
44
- - 0
45
- version: 1.0.0
35
+ version: 0.3.2
46
36
  type: :development
47
37
  version_requirements: *id002
48
38
  - !ruby/object:Gem::Dependency
49
- name: hirb
39
+ name: rake
50
40
  prerelease: false
51
41
  requirement: &id003 !ruby/object:Gem::Requirement
52
42
  none: false
53
43
  requirements:
54
44
  - - ~>
55
45
  - !ruby/object:Gem::Version
56
- segments:
57
- - 0
58
- - 3
59
- - 2
60
- version: 0.3.2
46
+ version: 0.8.7
61
47
  type: :development
62
48
  version_requirements: *id003
63
49
  - !ruby/object:Gem::Dependency
64
- name: rake
50
+ name: rcov
65
51
  prerelease: false
66
52
  requirement: &id004 !ruby/object:Gem::Requirement
67
53
  none: false
68
54
  requirements:
69
55
  - - ~>
70
56
  - !ruby/object:Gem::Version
71
- segments:
72
- - 0
73
- - 8
74
- - 7
75
- version: 0.8.7
57
+ version: 0.9.9
76
58
  type: :development
77
59
  version_requirements: *id004
78
60
  - !ruby/object:Gem::Dependency
79
- name: rcov
61
+ name: rspec
80
62
  prerelease: false
81
63
  requirement: &id005 !ruby/object:Gem::Requirement
82
64
  none: false
83
65
  requirements:
84
66
  - - ~>
85
67
  - !ruby/object:Gem::Version
86
- segments:
87
- - 0
88
- - 9
89
- - 8
90
- version: 0.9.8
68
+ version: 2.4.0
91
69
  type: :development
92
70
  version_requirements: *id005
93
- - !ruby/object:Gem::Dependency
94
- name: rspec
95
- prerelease: false
96
- requirement: &id006 !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ~>
100
- - !ruby/object:Gem::Version
101
- segments:
102
- - 2
103
- - 0
104
- - 0
105
- version: 2.0.0
106
- type: :development
107
- version_requirements: *id006
108
71
  - !ruby/object:Gem::Dependency
109
72
  name: rr
110
73
  prerelease: false
111
- requirement: &id007 !ruby/object:Gem::Requirement
74
+ requirement: &id006 !ruby/object:Gem::Requirement
112
75
  none: false
113
76
  requirements:
114
77
  - - ~>
115
78
  - !ruby/object:Gem::Version
116
- segments:
117
- - 1
118
- - 0
119
- - 0
120
79
  version: 1.0.0
121
80
  type: :development
122
- version_requirements: *id007
81
+ version_requirements: *id006
123
82
  - !ruby/object:Gem::Dependency
124
83
  name: wirble
125
84
  prerelease: false
126
- requirement: &id008 !ruby/object:Gem::Requirement
85
+ requirement: &id007 !ruby/object:Gem::Requirement
127
86
  none: false
128
87
  requirements:
129
88
  - - ~>
130
89
  - !ruby/object:Gem::Version
131
- segments:
132
- - 0
133
- - 1
134
- - 3
135
90
  version: 0.1.3
136
91
  type: :development
137
- version_requirements: *id008
92
+ version_requirements: *id007
138
93
  description: Rein adds bunch of methods to your ActiveRecord migrations so you can easily tame your database.
139
94
  email: josh.bassett@gmail.com
140
95
  executables: []
@@ -148,6 +103,7 @@ files:
148
103
  - lib/rein/constraint/foreign_key.rb
149
104
  - lib/rein/constraint/inclusion.rb
150
105
  - lib/rein/constraint/numericality.rb
106
+ - lib/rein/constraint/presence.rb
151
107
  - lib/rein/constraint/primary_key.rb
152
108
  - lib/rein/version.rb
153
109
  - lib/rein/view.rb
@@ -169,23 +125,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
169
125
  requirements:
170
126
  - - ">="
171
127
  - !ruby/object:Gem::Version
172
- segments:
173
- - 0
174
128
  version: "0"
175
129
  required_rubygems_version: !ruby/object:Gem::Requirement
176
130
  none: false
177
131
  requirements:
178
132
  - - ">="
179
133
  - !ruby/object:Gem::Version
180
- segments:
181
- - 1
182
- - 3
183
- - 6
184
134
  version: 1.3.6
185
135
  requirements: []
186
136
 
187
137
  rubyforge_project: rein
188
- rubygems_version: 1.3.7
138
+ rubygems_version: 1.5.0
189
139
  signing_key:
190
140
  specification_version: 3
191
141
  summary: Database constraints made easy for ActiveRecord.