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 CHANGED
@@ -1,4 +1,6 @@
1
1
  *.gem
2
+ .rvmrc
2
3
  .bundle
3
4
  Gemfile.lock
4
5
  pkg/*
6
+ test/db/*
data/Gemfile CHANGED
@@ -2,3 +2,8 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in mikado.gemspec
4
4
  gemspec
5
+
6
+ group :test do
7
+ gem 'activerecord', '2.3.5', :require => 'active_record'
8
+ gem 'sqlite3'
9
+ end
data/README CHANGED
@@ -1 +1,34 @@
1
- This is mikado validation helper
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
@@ -1,3 +1,3 @@
1
1
  module Mikado
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/mikado.rb CHANGED
@@ -1,4 +1 @@
1
- require 'rubygems'
2
- require 'active_record'
3
- require File.expand_path('../mikado/conditional_validation', __FILE__)
4
-
1
+ require File.expand_path('../mikado/conditional_validation', __FILE__)
data/test/helper.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  require File.expand_path('../../lib/mikado', __FILE__)
2
- require 'sqlite3'
3
- require 'test/unit'
2
+ require 'rubygems'
3
+ require 'bundler/setup'
4
+
5
+ Bundler.require :test
6
+
4
7
  require 'test/item'
5
8
 
6
9
  ActiveRecord::Base.establish_connection(
data/test/mikado_test.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'test/helper'
2
+ require 'test/unit'
2
3
 
3
4
  class ItemTest < Test::Unit::TestCase
4
5
  def setup
@@ -1,4 +1,6 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
1
3
  ActiveRecord::Migration.create_table :items do |t|
2
4
  t.string :title
3
5
  t.string :description
4
- end
6
+ end
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: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
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-03 00:00:00 -07:00
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/setup.rb
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/setup.rb
82
+ - test/prepare.rb
data/test/db/test.sqlite3 DELETED
Binary file