migrant 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/migrant/model_extensions.rb +7 -3
- data/lib/migrant/schema.rb +0 -1
- data/migrant.gemspec +23 -2
- data/test/test_validations.rb +15 -0
- metadata +97 -6
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
@@ -9,9 +9,13 @@ module Migrant
|
|
9
9
|
@schema ||= Schema.new
|
10
10
|
@schema.add_associations(self.reflect_on_all_associations)
|
11
11
|
@schema.define_structure(&block)
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
|
13
|
+
@schema.validations.each do |field, validation_options|
|
14
|
+
validations = (validation_options.class == Array)? validation_options : [validation_options]
|
15
|
+
validations.each do |validation|
|
16
|
+
validation = (validation.class == Hash)? validation : { validation => true }
|
17
|
+
self.validates(field, validation)
|
18
|
+
end
|
15
19
|
end
|
16
20
|
else
|
17
21
|
self.superclass.structure(&block) # For STI, cascade all fields onto the parent model
|
data/lib/migrant/schema.rb
CHANGED
@@ -64,7 +64,6 @@ module Migrant
|
|
64
64
|
# Add index if explicitly asked
|
65
65
|
@indexes << field if options.delete(:index) || data_type.class.to_s == 'Hash' && data_type.delete(:index)
|
66
66
|
@validations[field] = options.delete(:validates) if options[:validates]
|
67
|
-
|
68
67
|
options.merge!(:field => field)
|
69
68
|
|
70
69
|
# Matches: description DataType::Paragraph, :index => true
|
data/migrant.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{migrant}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Pascal Houliston"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-02-14}
|
13
13
|
s.description = %q{Migrant gives you a super-clean DSL to describe your ActiveRecord models (somewhat similar to DataMapper) and generates all your migrations for you so you can spend more time coding the stuff that counts!}
|
14
14
|
s.email = %q{101pascal@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -163,6 +163,13 @@ Gem::Specification.new do |s|
|
|
163
163
|
s.add_development_dependency(%q<turn>, [">= 0"])
|
164
164
|
s.add_development_dependency(%q<sqlite3-ruby>, [">= 0"])
|
165
165
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
166
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
167
|
+
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
168
|
+
s.add_development_dependency(%q<ansi>, [">= 0"])
|
169
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
170
|
+
s.add_development_dependency(%q<turn>, [">= 0"])
|
171
|
+
s.add_development_dependency(%q<sqlite3-ruby>, [">= 0"])
|
172
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
166
173
|
s.add_runtime_dependency(%q<rails>, [">= 0"])
|
167
174
|
else
|
168
175
|
s.add_dependency(%q<migrant>, [">= 0"])
|
@@ -187,6 +194,13 @@ Gem::Specification.new do |s|
|
|
187
194
|
s.add_dependency(%q<turn>, [">= 0"])
|
188
195
|
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
189
196
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
197
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
198
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
199
|
+
s.add_dependency(%q<ansi>, [">= 0"])
|
200
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
201
|
+
s.add_dependency(%q<turn>, [">= 0"])
|
202
|
+
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
203
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
190
204
|
s.add_dependency(%q<rails>, [">= 0"])
|
191
205
|
end
|
192
206
|
else
|
@@ -212,6 +226,13 @@ Gem::Specification.new do |s|
|
|
212
226
|
s.add_dependency(%q<turn>, [">= 0"])
|
213
227
|
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
214
228
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
229
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
230
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
231
|
+
s.add_dependency(%q<ansi>, [">= 0"])
|
232
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
233
|
+
s.add_dependency(%q<turn>, [">= 0"])
|
234
|
+
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
235
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
215
236
|
s.add_dependency(%q<rails>, [">= 0"])
|
216
237
|
end
|
217
238
|
end
|
data/test/test_validations.rb
CHANGED
@@ -29,6 +29,21 @@ class TestValidations < Test::Unit::TestCase
|
|
29
29
|
user = User.create
|
30
30
|
assert(user.errors.include?(:email), "Validation was not applied")
|
31
31
|
end
|
32
|
+
|
33
|
+
should "validate multiple validations via ActiveRecord when an array is given" do
|
34
|
+
Review.structure do
|
35
|
+
name "ABCD", :validates => [:presence, {:length => {:maximum => 4}}]
|
36
|
+
end
|
37
|
+
|
38
|
+
not_present = Review.create
|
39
|
+
too_long = Review.create(:name => "Textthatistoolong")
|
40
|
+
correct = Review.create(:name => "ABC")
|
41
|
+
|
42
|
+
assert(not_present.errors.include?(:name), "primary validation was not applied")
|
43
|
+
assert(too_long.errors.include?(:name), "secondary validation was not applied")
|
44
|
+
assert(!correct.errors.include?(:name), "validation for a correct model failed")
|
45
|
+
|
46
|
+
end
|
32
47
|
|
33
48
|
end
|
34
49
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 3
|
9
|
+
version: 0.2.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Pascal Houliston
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-02-14 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -304,7 +304,7 @@ dependencies:
|
|
304
304
|
prerelease: false
|
305
305
|
version_requirements: *id022
|
306
306
|
- !ruby/object:Gem::Dependency
|
307
|
-
name:
|
307
|
+
name: bundler
|
308
308
|
requirement: &id023 !ruby/object:Gem::Requirement
|
309
309
|
none: false
|
310
310
|
requirements:
|
@@ -313,9 +313,100 @@ dependencies:
|
|
313
313
|
segments:
|
314
314
|
- 0
|
315
315
|
version: "0"
|
316
|
-
type: :
|
316
|
+
type: :development
|
317
317
|
prerelease: false
|
318
318
|
version_requirements: *id023
|
319
|
+
- !ruby/object:Gem::Dependency
|
320
|
+
name: thoughtbot-shoulda
|
321
|
+
requirement: &id024 !ruby/object:Gem::Requirement
|
322
|
+
none: false
|
323
|
+
requirements:
|
324
|
+
- - ">="
|
325
|
+
- !ruby/object:Gem::Version
|
326
|
+
segments:
|
327
|
+
- 0
|
328
|
+
version: "0"
|
329
|
+
type: :development
|
330
|
+
prerelease: false
|
331
|
+
version_requirements: *id024
|
332
|
+
- !ruby/object:Gem::Dependency
|
333
|
+
name: ansi
|
334
|
+
requirement: &id025 !ruby/object:Gem::Requirement
|
335
|
+
none: false
|
336
|
+
requirements:
|
337
|
+
- - ">="
|
338
|
+
- !ruby/object:Gem::Version
|
339
|
+
segments:
|
340
|
+
- 0
|
341
|
+
version: "0"
|
342
|
+
type: :development
|
343
|
+
prerelease: false
|
344
|
+
version_requirements: *id025
|
345
|
+
- !ruby/object:Gem::Dependency
|
346
|
+
name: jeweler
|
347
|
+
requirement: &id026 !ruby/object:Gem::Requirement
|
348
|
+
none: false
|
349
|
+
requirements:
|
350
|
+
- - ">="
|
351
|
+
- !ruby/object:Gem::Version
|
352
|
+
segments:
|
353
|
+
- 0
|
354
|
+
version: "0"
|
355
|
+
type: :development
|
356
|
+
prerelease: false
|
357
|
+
version_requirements: *id026
|
358
|
+
- !ruby/object:Gem::Dependency
|
359
|
+
name: turn
|
360
|
+
requirement: &id027 !ruby/object:Gem::Requirement
|
361
|
+
none: false
|
362
|
+
requirements:
|
363
|
+
- - ">="
|
364
|
+
- !ruby/object:Gem::Version
|
365
|
+
segments:
|
366
|
+
- 0
|
367
|
+
version: "0"
|
368
|
+
type: :development
|
369
|
+
prerelease: false
|
370
|
+
version_requirements: *id027
|
371
|
+
- !ruby/object:Gem::Dependency
|
372
|
+
name: sqlite3-ruby
|
373
|
+
requirement: &id028 !ruby/object:Gem::Requirement
|
374
|
+
none: false
|
375
|
+
requirements:
|
376
|
+
- - ">="
|
377
|
+
- !ruby/object:Gem::Version
|
378
|
+
segments:
|
379
|
+
- 0
|
380
|
+
version: "0"
|
381
|
+
type: :development
|
382
|
+
prerelease: false
|
383
|
+
version_requirements: *id028
|
384
|
+
- !ruby/object:Gem::Dependency
|
385
|
+
name: simplecov
|
386
|
+
requirement: &id029 !ruby/object:Gem::Requirement
|
387
|
+
none: false
|
388
|
+
requirements:
|
389
|
+
- - ">="
|
390
|
+
- !ruby/object:Gem::Version
|
391
|
+
segments:
|
392
|
+
- 0
|
393
|
+
version: "0"
|
394
|
+
type: :development
|
395
|
+
prerelease: false
|
396
|
+
version_requirements: *id029
|
397
|
+
- !ruby/object:Gem::Dependency
|
398
|
+
name: rails
|
399
|
+
requirement: &id030 !ruby/object:Gem::Requirement
|
400
|
+
none: false
|
401
|
+
requirements:
|
402
|
+
- - ">="
|
403
|
+
- !ruby/object:Gem::Version
|
404
|
+
segments:
|
405
|
+
- 0
|
406
|
+
version: "0"
|
407
|
+
type: :runtime
|
408
|
+
prerelease: false
|
409
|
+
version_requirements: *id030
|
319
410
|
description: Migrant gives you a super-clean DSL to describe your ActiveRecord models (somewhat similar to DataMapper) and generates all your migrations for you so you can spend more time coding the stuff that counts!
|
320
411
|
email: 101pascal@gmail.com
|
321
412
|
executables: []
|
@@ -415,7 +506,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
415
506
|
requirements:
|
416
507
|
- - ">="
|
417
508
|
- !ruby/object:Gem::Version
|
418
|
-
hash:
|
509
|
+
hash: -1035077551
|
419
510
|
segments:
|
420
511
|
- 0
|
421
512
|
version: "0"
|