mikado 0.0.2 → 0.0.3
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.
- data/.gitignore +2 -0
- data/Gemfile +5 -0
- data/README +34 -1
- data/Rakefile +28 -0
- data/lib/mikado/version.rb +1 -1
- data/lib/mikado.rb +1 -4
- data/test/helper.rb +5 -2
- data/test/mikado_test.rb +1 -0
- data/test/{setup.rb → prepare.rb} +3 -1
- metadata +6 -8
- data/test/db/test.sqlite3 +0 -0
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README
CHANGED
@@ -1 +1,34 @@
|
|
1
|
-
|
1
|
+
Mikado wraps Activerecord validation conditions with a block.
|
2
|
+
|
3
|
+
Example:
|
4
|
+
|
5
|
+
Instead of
|
6
|
+
|
7
|
+
class Item < ActiveRecord::Base
|
8
|
+
validates_presence_of :title, :if => :live?
|
9
|
+
|
10
|
+
def live?
|
11
|
+
true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
you can write like this
|
16
|
+
|
17
|
+
class Item < ActiveRecord::Base
|
18
|
+
include Mikado
|
19
|
+
|
20
|
+
mikado :live? do
|
21
|
+
validates_presence_of :title
|
22
|
+
end
|
23
|
+
|
24
|
+
def live?
|
25
|
+
true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
Currently mikado only supports the :if condition.
|
30
|
+
You can help yourself, just negate the condition value.
|
31
|
+
|
32
|
+
It supports all validations with name validates_*
|
33
|
+
It also supports the methods validate, validate_on_create,
|
34
|
+
validate_on_update and validate_each
|
data/Rakefile
CHANGED
@@ -1,2 +1,30 @@
|
|
1
1
|
require 'bundler'
|
2
2
|
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
desc "run tests"
|
5
|
+
task :default do
|
6
|
+
unless File.exists?('test/db/test.sqlite3')
|
7
|
+
puts "Database doesn't exists"
|
8
|
+
puts "run rake db:test:prepare"
|
9
|
+
exit
|
10
|
+
end
|
11
|
+
|
12
|
+
Dir['test/*_test.rb'].each do |file|
|
13
|
+
require file
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
namespace :db do
|
18
|
+
namespace :test do
|
19
|
+
desc "create and prepare test database"
|
20
|
+
task :prepare do
|
21
|
+
Dir.mkdir('test/db') unless File.directory?('test/db')
|
22
|
+
require 'test/prepare'
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "delete test database"
|
26
|
+
task :delete do
|
27
|
+
FileUtils.rm_rf('test/db')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/mikado/version.rb
CHANGED
data/lib/mikado.rb
CHANGED
data/test/helper.rb
CHANGED
data/test/mikado_test.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mikado
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matthias Zirnstein
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-04 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -37,11 +37,10 @@ files:
|
|
37
37
|
- lib/mikado/conditional_validation.rb
|
38
38
|
- lib/mikado/version.rb
|
39
39
|
- mikado.gemspec
|
40
|
-
- test/db/test.sqlite3
|
41
40
|
- test/helper.rb
|
42
41
|
- test/item.rb
|
43
42
|
- test/mikado_test.rb
|
44
|
-
- test/
|
43
|
+
- test/prepare.rb
|
45
44
|
has_rdoc: true
|
46
45
|
homepage: https://github.com/zirni/mikado
|
47
46
|
licenses: []
|
@@ -77,8 +76,7 @@ signing_key:
|
|
77
76
|
specification_version: 3
|
78
77
|
summary: Wrap validation conditions with a single command
|
79
78
|
test_files:
|
80
|
-
- test/db/test.sqlite3
|
81
79
|
- test/helper.rb
|
82
80
|
- test/item.rb
|
83
81
|
- test/mikado_test.rb
|
84
|
-
- test/
|
82
|
+
- test/prepare.rb
|
data/test/db/test.sqlite3
DELETED
Binary file
|