dm-validations-ext 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,37 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## Rubinius
17
+ *.rbc
18
+
19
+ ## PROJECT::GENERAL
20
+ *.gem
21
+ coverage
22
+ rdoc
23
+ pkg
24
+ tmp
25
+ doc
26
+ log
27
+ .yardoc
28
+ measurements
29
+
30
+ ## BUNDLER
31
+ .bundle
32
+ Gemfile.local
33
+ Gemfile.lock
34
+ Gemfile.local.lock
35
+
36
+ ## PROJECT::SPECIFIC
37
+ spec/db/
data/Gemfile ADDED
@@ -0,0 +1,141 @@
1
+ # If you're working on more than one datamapper gem at a time, then it's
2
+ # recommended to create a local Gemfile and use this instead of the git
3
+ # sources. This will make sure that you are developing against your
4
+ # other local datamapper sources that you currently work on. Gemfile.local
5
+ # will behave identically to the standard Gemfile apart from the fact that
6
+ # it fetches the datamapper gems from local paths. This means that you can use
7
+ # the same environment variables, like ADAPTER(S) or PLUGIN(S) when running
8
+ # bundle commands. Gemfile.local is added to .gitignore, so you don't need to
9
+ # worry about accidentally checking local development paths into git.
10
+ # In order to create a local Gemfile, all you need to do is run:
11
+ #
12
+ # bundle exec rake local_gemfile
13
+ #
14
+ # This will give you a Gemfile.local file that points to your local clones of
15
+ # the various datamapper gems. It's assumed that all datamapper repo clones
16
+ # reside in the same directory. You can use the Gemfile.local like so for
17
+ # running any bundle command:
18
+ #
19
+ # BUNDLE_GEMFILE=Gemfile.local bundle foo
20
+ #
21
+ # You can also specify which adapter(s) should be part of the bundle by setting
22
+ # an environment variable. This of course also works when using the Gemfile.local
23
+ #
24
+ # bundle foo # dm-sqlite-adapter
25
+ # ADAPTER=mysql bundle foo # dm-mysql-adapter
26
+ # ADAPTERS=sqlite,mysql bundle foo # dm-sqlite-adapter and dm-mysql-adapter
27
+ #
28
+ # Of course you can also use the ADAPTER(S) variable when using the Gemfile.local
29
+ # and running specs against selected adapters.
30
+ #
31
+ # For easily working with adapters supported on your machine, it's recommended
32
+ # that you first install all adapters that you are planning to use or work on
33
+ # by doing something like
34
+ #
35
+ # ADAPTERS=sqlite,mysql,postgres bundle install
36
+ #
37
+ # This will clone the various repositories and make them available to bundler.
38
+ # Once you have them installed you can easily switch between adapters for the
39
+ # various development tasks. Running something like
40
+ #
41
+ # ADAPTER=mysql bundle exec rake spec
42
+ #
43
+ # will make sure that the dm-mysql-adapter is part of the bundle, and will be used
44
+ # when running the specs.
45
+ #
46
+ # You can also specify which plugin(s) should be part of the bundle by setting
47
+ # an environment variable. This also works when using the Gemfile.local
48
+ #
49
+ # bundle foo # dm-migrations
50
+ # PLUGINS=dm-validations bundle foo # dm-migrations and dm-validations
51
+ # PLUGINS=dm-validations,dm-types bundle foo # dm-migrations, dm-validations and dm-types
52
+ #
53
+ # Of course you can combine the PLUGIN(S) and ADAPTER(S) env vars to run specs
54
+ # for certain adapter/plugin combinations.
55
+ #
56
+ # Finally, to speed up running specs and other tasks, it's recommended to run
57
+ #
58
+ # bundle lock
59
+ #
60
+ # after running 'bundle install' for the first time. This will make 'bundle exec' run
61
+ # a lot faster compared to the unlocked version. With an unlocked bundle you would
62
+ # typically just run 'bundle install' from time to time to fetch the latest sources from
63
+ # upstream. When you locked your bundle, you need to run
64
+ #
65
+ # bundle install --relock
66
+ #
67
+ # to make sure to fetch the latest updates and then lock the bundle again. Gemfile.lock
68
+ # is added to the .gitignore file, so you don't need to worry about accidentally checking
69
+ # it into version control.
70
+
71
+ source 'http://rubygems.org'
72
+
73
+ DATAMAPPER = 'http://github.com/datamapper'
74
+ DM_VERSION = '~> 1.0.1'
75
+
76
+ group :runtime do # Runtime dependencies (as in the gemspec)
77
+
78
+ if ENV['EXTLIB']
79
+ gem 'extlib', '~> 0.9.15', :git => "#{DATAMAPPER}/extlib.git"
80
+ else
81
+ gem 'activesupport', '~> 3.0.0', :git => 'http://github.com/rails/rails.git', :branch => '3-0-stable', :require => nil
82
+ end
83
+
84
+ gem 'dm-core', DM_VERSION, :git => "#{DATAMAPPER}/dm-core.git"
85
+ gem 'dm-validations', DM_VERSION, :git => "#{DATAMAPPER}/dm-validations.git"
86
+
87
+ end
88
+
89
+ group(:development) do # Development dependencies (as in the gemspec)
90
+
91
+ gem 'rake', '~> 0.8.7'
92
+ gem 'rspec', '~> 2.0.1'
93
+ gem 'jeweler', '~> 1.4'
94
+
95
+ end
96
+
97
+ group :quality do # These gems contain rake tasks that check the quality of the source code
98
+
99
+ gem 'metric_fu', '~> 1.3'
100
+ gem 'rcov', '~> 0.9.8'
101
+ gem 'reek', '~> 1.2.8'
102
+ gem 'roodi', '~> 2.1'
103
+ gem 'yard', '~> 0.5'
104
+ gem 'yardstick', '~> 0.1'
105
+
106
+ end
107
+
108
+ group :datamapper do # We need this because we want to pin these dependencies to their git master sources
109
+
110
+ adapters = ENV['ADAPTER'] || ENV['ADAPTERS']
111
+ adapters = adapters.to_s.tr(',', ' ').split.uniq - %w[ in_memory ]
112
+
113
+ DO_VERSION = '~> 0.10.2'
114
+ DM_DO_ADAPTERS = %w[ sqlite postgres mysql oracle sqlserver ]
115
+
116
+ if (do_adapters = DM_DO_ADAPTERS & adapters).any?
117
+ options = {}
118
+ options[:git] = "#{DATAMAPPER}/do.git" if ENV['DO_GIT'] == 'true'
119
+
120
+ gem 'data_objects', DO_VERSION, options.dup
121
+
122
+ do_adapters.each do |adapter|
123
+ adapter = 'sqlite3' if adapter == 'sqlite'
124
+ gem "do_#{adapter}", DO_VERSION, options.dup
125
+ end
126
+
127
+ gem 'dm-do-adapter', DM_VERSION, :git => "#{DATAMAPPER}/dm-do-adapter.git"
128
+ end
129
+
130
+ adapters.each do |adapter|
131
+ gem "dm-#{adapter}-adapter", DM_VERSION, :git => "#{DATAMAPPER}/dm-#{adapter}-adapter.git"
132
+ end
133
+
134
+ plugins = ENV['PLUGINS'] || ENV['PLUGIN']
135
+ plugins = plugins.to_s.tr(',', ' ').split.push('dm-migrations').uniq
136
+
137
+ plugins.each do |plugin|
138
+ gem plugin, DM_VERSION, :git => "#{DATAMAPPER}/#{plugin}.git"
139
+ end
140
+
141
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Piotr Solnica
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,54 @@
1
+ = dm-validations-ext
2
+
3
+ DataMapper plugin providing access to validation errors of associated parent and children objects. See the example below to get an idea on how it works.
4
+
5
+ = Example
6
+
7
+ DataMapper.setup :default, "sqlite::memory"
8
+
9
+ class User
10
+ include DataMapper::Resource
11
+
12
+ property :id, Serial
13
+ property :name, String
14
+
15
+ belongs_to :group
16
+ has n, :roles
17
+ end
18
+
19
+ class Group
20
+ include DataMapper::Resource
21
+
22
+ property :id, Serial
23
+ property :name, String, :length => 10..255
24
+
25
+ has n, :users
26
+ end
27
+
28
+ class Role
29
+ include DataMapper::Resource
30
+
31
+ property :id, Serial
32
+ property :name, String, :length => 4..10
33
+
34
+ belongs_to :user
35
+ end
36
+
37
+ DataMapper.finalize
38
+ DataMapper.auto_migrate!
39
+
40
+ user = User.new(:name => "John")
41
+ group = Group.new(:name => "Too Short")
42
+ role = Role.new(:name => "Way Too Long")
43
+
44
+ user.group = group
45
+ user.roles << role
46
+
47
+ user.save
48
+ # => false
49
+
50
+ user.errors[:group].inspect
51
+ # => <DataMapper::Validations::ValidationErrors:0xa098a30 @resource=#<Group @id=nil @name="Too Short">, @errors={:name=>["Name must be between 10 and 255 characters long"]}>
52
+
53
+ user.errors[:roles].inspect
54
+ # => [#<DataMapper::Validations::ValidationErrors:0xa0931ac @resource=#<Role @id=nil @name="Way Too Long" @user_id=nil>, @errors={:name=>["Name must be between 4 and 10 characters long"], :user_id=>["User must not be blank"]}>]
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ gem 'jeweler', '~> 1.4'
6
+ require 'jeweler'
7
+
8
+ Jeweler::Tasks.new do |gem|
9
+ gem.name = 'dm-validations-ext'
10
+ gem.summary = 'DataMapper plugin providing better error messages handling.'
11
+ gem.description = gem.summary
12
+ gem.email = 'piotr.solnica [a] gmail [d] com'
13
+ gem.homepage = 'http://github.com/solnic/%s' % gem.name
14
+ gem.authors = [ 'Piotr Solnica' ]
15
+ gem.has_rdoc = 'yard'
16
+
17
+ gem.add_dependency 'dm-validations', '~> 1.0.2'
18
+
19
+ gem.add_development_dependency 'rspec', '~> 2.0.1'
20
+ gem.add_development_dependency 'jeweler', '~> 1.4'
21
+ end
22
+
23
+ Jeweler::GemcutterTasks.new
24
+
25
+ FileList['tasks/**/*.rake'].each { |task| import task }
26
+ rescue LoadError
27
+ puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
28
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,68 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{dm-validations-ext}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Piotr Solnica"]
12
+ s.date = %q{2010-10-26}
13
+ s.description = %q{DataMapper plugin providing better error messages handling.}
14
+ s.email = %q{piotr.solnica [a] gmail [d] com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".gitignore",
21
+ "Gemfile",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "dm-validations-ext.gemspec",
27
+ "lib/dm-validations-ext.rb",
28
+ "spec/public/validations_ext_spec.rb",
29
+ "spec/rcov.opts",
30
+ "spec/spec_helper.rb",
31
+ "tasks/ci.rake",
32
+ "tasks/local_gemfile.rake",
33
+ "tasks/metrics.rake",
34
+ "tasks/spec.rake",
35
+ "tasks/yard.rake",
36
+ "tasks/yardstick.rake"
37
+ ]
38
+ s.has_rdoc = %q{yard}
39
+ s.homepage = %q{http://github.com/solnic/dm-validations-ext}
40
+ s.rdoc_options = ["--charset=UTF-8"]
41
+ s.require_paths = ["lib"]
42
+ s.rubygems_version = %q{1.3.7}
43
+ s.summary = %q{DataMapper plugin providing better error messages handling.}
44
+ s.test_files = [
45
+ "spec/spec_helper.rb",
46
+ "spec/public/validations_ext_spec.rb"
47
+ ]
48
+
49
+ if s.respond_to? :specification_version then
50
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
51
+ s.specification_version = 3
52
+
53
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
54
+ s.add_runtime_dependency(%q<dm-validations>, ["~> 1.0.2"])
55
+ s.add_development_dependency(%q<rspec>, ["~> 2.0.1"])
56
+ s.add_development_dependency(%q<jeweler>, ["~> 1.4"])
57
+ else
58
+ s.add_dependency(%q<dm-validations>, ["~> 1.0.2"])
59
+ s.add_dependency(%q<rspec>, ["~> 2.0.1"])
60
+ s.add_dependency(%q<jeweler>, ["~> 1.4"])
61
+ end
62
+ else
63
+ s.add_dependency(%q<dm-validations>, ["~> 1.0.2"])
64
+ s.add_dependency(%q<rspec>, ["~> 2.0.1"])
65
+ s.add_dependency(%q<jeweler>, ["~> 1.4"])
66
+ end
67
+ end
68
+
@@ -0,0 +1,60 @@
1
+ module DataMapper
2
+ module ValidationsExt
3
+ def _save(execute_hooks = true)
4
+ result = super
5
+
6
+ # TODO: should we wrap it with run_once?
7
+ unless result
8
+ validate if dirty_self?
9
+ validate_parents if dirty_parents?
10
+ validate_children if dirty_children?
11
+ end
12
+
13
+ result
14
+ end
15
+
16
+ # Run validations on the resource
17
+ #
18
+ # @return [Boolean]
19
+ # true if the resource is valid
20
+ #
21
+ # @api public
22
+ def validate
23
+ valid?
24
+ end
25
+
26
+ # Run validations on the associated parent resources
27
+ #
28
+ # @api semipublic
29
+ def validate_parents
30
+ parent_relationships.each do |relationship|
31
+ parent = relationship.get(self)
32
+ unless parent.valid?
33
+ unless errors[relationship.name].include?(parent.errors)
34
+ errors[relationship.name] = parent.errors
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ # Run validations on the associated child resources
41
+ #
42
+ # @api semipublic
43
+ def validate_children
44
+ child_associations.each do |collection|
45
+ if collection.dirty?
46
+ collection.each do |child|
47
+ unless child.valid?
48
+ relationship_errors = (errors[collection.relationship.name] ||= [])
49
+ unless relationship_errors.include?(child.errors)
50
+ relationship_errors << child.errors
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ Model.append_inclusions self
59
+ end # ValidationsExt
60
+ end # DataMapper
@@ -0,0 +1,124 @@
1
+ require 'spec_helper'
2
+
3
+ describe DataMapper::ValidationsExt do
4
+ supported_by :all do
5
+ before :all do
6
+ class User
7
+ include DataMapper::Resource
8
+
9
+ property :id, Serial
10
+ property :name, String, :required => true
11
+
12
+ belongs_to :group, :required => false
13
+ has n, :roles
14
+ end
15
+
16
+ class Group
17
+ include DataMapper::Resource
18
+
19
+ property :id, Serial
20
+ property :name, String, :length => 6..255
21
+
22
+ has n, :users
23
+ end
24
+
25
+ class Role
26
+ include DataMapper::Resource
27
+
28
+ property :name, String, :required => true, :key => true
29
+ belongs_to :user, :key => true
30
+ end
31
+
32
+ DataMapper.finalize
33
+ DataMapper.auto_migrate!
34
+ end
35
+
36
+ describe "Parent errors" do
37
+ describe "when the parent is valid" do
38
+ before :all do
39
+ @group = Group.new(:name => "DataMapperists")
40
+ @user = User.new(:name => "John", :group => @group)
41
+ end
42
+
43
+ describe "#save" do
44
+ subject { @user.save }
45
+ it { should be(true) }
46
+ end
47
+
48
+ describe "#errors" do
49
+ before { @user.save }
50
+ subject { @user.errors[:group] }
51
+ it { should be_blank }
52
+ end
53
+ end
54
+
55
+ describe "when the parent is valid" do
56
+ before :all do
57
+ @group = Group.new(:name => "a")
58
+ @user = User.new(:name => "John", :group => @group)
59
+ end
60
+
61
+ describe "#save" do
62
+ subject { @user.save }
63
+ it { should be(false) }
64
+ end
65
+
66
+ describe "#errors" do
67
+ before { @user.save }
68
+ let(:expected_errors) { @group.errors }
69
+ subject { @user.errors[:group] }
70
+
71
+ it { should_not be_nil }
72
+ it { should be_kind_of(DataMapper::Validations::ValidationErrors) }
73
+ it { should eql(expected_errors) }
74
+ end
75
+ end
76
+ end
77
+
78
+ describe "Child errors" do
79
+ describe "when children are not valid" do
80
+ before :all do
81
+ @user = User.create(:name => 'John')
82
+
83
+ @role = Role.new
84
+ @user.roles << @role
85
+ @role_errors = [ @role.errors ]
86
+ end
87
+
88
+ describe "#save" do
89
+ subject { @user.save }
90
+
91
+ it { should be(false) }
92
+ end
93
+
94
+ describe "#errors" do
95
+ before { @user.save }
96
+ subject { @user.errors[:roles] }
97
+
98
+ it { should_not be_nil }
99
+ it { should be_kind_of(Array) }
100
+ it { should eql(@role_errors) }
101
+ end
102
+ end
103
+
104
+ describe "when children are valid" do
105
+ before :all do
106
+ @user = User.create(:name => 'Jane')
107
+ @user.roles << @user.roles.new(:name => "SuperUser")
108
+ end
109
+
110
+ describe "#save" do
111
+ subject { @user.save }
112
+
113
+ it { should be(true) }
114
+ end
115
+
116
+ describe "#errors" do
117
+ subject { @user.errors[:roles] }
118
+
119
+ it { should be_blank }
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
data/spec/rcov.opts ADDED
@@ -0,0 +1,6 @@
1
+ --exclude "spec,^/"
2
+ --sort coverage
3
+ --callsites
4
+ --xrefs
5
+ --profile
6
+ --text-summary
@@ -0,0 +1,19 @@
1
+ require 'dm-core/spec/setup'
2
+ require 'dm-core/spec/lib/adapter_helpers'
3
+
4
+ require 'dm-validations'
5
+ require 'dm-migrations'
6
+ require 'dm-validations-ext'
7
+
8
+ SPEC_ROOT = Pathname(__FILE__).dirname
9
+
10
+ DataMapper::Spec.setup
11
+ DataMapper.finalize
12
+
13
+ RSpec.configure do |config|
14
+ config.extend(DataMapper::Spec::Adapters::Helpers)
15
+
16
+ config.before :suite do
17
+ DataMapper.auto_migrate!
18
+ end
19
+ end
data/tasks/ci.rake ADDED
@@ -0,0 +1 @@
1
+ task :ci => [ :verify_measurements, 'metrics:all' ]
@@ -0,0 +1,16 @@
1
+ desc "Support bundling from local source code (allows BUNDLE_GEMFILE=Gemfile.local bundle foo)"
2
+ task :local_gemfile do |t|
3
+
4
+ root = Pathname(__FILE__).dirname.parent
5
+ datamapper = root.parent
6
+
7
+ root.join('Gemfile.local').open('w') do |f|
8
+ root.join('Gemfile').open.each do |line|
9
+ line.sub!(/DATAMAPPER = 'git:\/\/github.com\/datamapper'/, "DATAMAPPER = '#{datamapper}'")
10
+ line.sub!(/:git => \"#\{DATAMAPPER\}\/(.+?)(?:\.git)?\"/, ':path => "#{DATAMAPPER}/\1"')
11
+ line.sub!(/do_options\[:git\] = \"#\{DATAMAPPER\}\/(.+?)(?:\.git)?\"/, 'do_options[:path] = "#{DATAMAPPER}/\1"')
12
+ f.puts line
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,37 @@
1
+ begin
2
+ require 'metric_fu'
3
+ rescue LoadError
4
+ namespace :metrics do
5
+ task :all do
6
+ abort 'metric_fu is not available. In order to run metrics:all, you must: gem install metric_fu'
7
+ end
8
+ end
9
+ end
10
+
11
+ begin
12
+ require 'reek/adapters/rake_task'
13
+
14
+ Reek::RakeTask.new do |t|
15
+ t.fail_on_error = true
16
+ t.verbose = false
17
+ t.source_files = 'lib/**/*.rb'
18
+ end
19
+ rescue LoadError
20
+ task :reek do
21
+ abort 'Reek is not available. In order to run reek, you must: gem install reek'
22
+ end
23
+ end
24
+
25
+ begin
26
+ require 'roodi'
27
+ require 'rake/tasklib'
28
+ require 'roodi_task'
29
+
30
+ RoodiTask.new do |t|
31
+ t.verbose = false
32
+ end
33
+ rescue LoadError
34
+ task :roodi do
35
+ abort 'Roodi is not available. In order to run roodi, you must: gem install roodi'
36
+ end
37
+ end
data/tasks/spec.rake ADDED
@@ -0,0 +1,41 @@
1
+ spec_defaults = lambda do |spec|
2
+ spec.pattern = 'spec/**/*_spec.rb'
3
+ spec.libs << 'lib' << 'spec'
4
+ spec.spec_opts << '--options' << 'spec/spec.opts'
5
+ end
6
+
7
+ begin
8
+ require 'spec/rake/spectask'
9
+
10
+ Spec::Rake::SpecTask.new(:spec, &spec_defaults)
11
+ rescue LoadError
12
+ task :spec do
13
+ abort 'rspec is not available. In order to run spec, you must: gem install rspec'
14
+ end
15
+ end
16
+
17
+ begin
18
+ require 'rcov'
19
+ require 'spec/rake/verify_rcov'
20
+
21
+ Spec::Rake::SpecTask.new(:rcov) do |rcov|
22
+ spec_defaults.call(rcov)
23
+ rcov.rcov = true
24
+ rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/)
25
+ end
26
+
27
+ RCov::VerifyTask.new(:verify_rcov => :rcov) do |rcov|
28
+ rcov.threshold = 100
29
+ end
30
+ rescue LoadError
31
+ %w[ rcov verify_rcov ].each do |name|
32
+ task name do
33
+ abort "rcov is not available. In order to run #{name}, you must: gem install rcov"
34
+ end
35
+ end
36
+ end
37
+
38
+ task :spec => :check_dependencies
39
+ task :rcov => :check_dependencies
40
+
41
+ task :default => :spec
data/tasks/yard.rake ADDED
@@ -0,0 +1,9 @@
1
+ begin
2
+ require 'yard'
3
+
4
+ YARD::Rake::YardocTask.new
5
+ rescue LoadError
6
+ task :yard do
7
+ abort 'YARD is not available. In order to run yard, you must: gem install yard'
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ begin
2
+ require 'pathname'
3
+ require 'yardstick/rake/measurement'
4
+ require 'yardstick/rake/verify'
5
+
6
+ # yardstick_measure task
7
+ Yardstick::Rake::Measurement.new
8
+
9
+ # verify_measurements task
10
+ Yardstick::Rake::Verify.new do |verify|
11
+ verify.threshold = 100
12
+ end
13
+ rescue LoadError
14
+ %w[ yardstick_measure verify_measurements ].each do |name|
15
+ task name.to_s do
16
+ abort "Yardstick is not available. In order to run #{name}, you must: gem install yardstick"
17
+ end
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dm-validations-ext
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Piotr Solnica
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-10-26 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: dm-validations
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 1
30
+ - 0
31
+ - 2
32
+ version: 1.0.2
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rspec
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 2
45
+ - 0
46
+ - 1
47
+ version: 2.0.1
48
+ type: :development
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: jeweler
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 1
60
+ - 4
61
+ version: "1.4"
62
+ type: :development
63
+ version_requirements: *id003
64
+ description: DataMapper plugin providing better error messages handling.
65
+ email: piotr.solnica [a] gmail [d] com
66
+ executables: []
67
+
68
+ extensions: []
69
+
70
+ extra_rdoc_files:
71
+ - LICENSE
72
+ - README.rdoc
73
+ files:
74
+ - .gitignore
75
+ - Gemfile
76
+ - LICENSE
77
+ - README.rdoc
78
+ - Rakefile
79
+ - VERSION
80
+ - dm-validations-ext.gemspec
81
+ - lib/dm-validations-ext.rb
82
+ - spec/public/validations_ext_spec.rb
83
+ - spec/rcov.opts
84
+ - spec/spec_helper.rb
85
+ - tasks/ci.rake
86
+ - tasks/local_gemfile.rake
87
+ - tasks/metrics.rake
88
+ - tasks/spec.rake
89
+ - tasks/yard.rake
90
+ - tasks/yardstick.rake
91
+ has_rdoc: yard
92
+ homepage: http://github.com/solnic/dm-validations-ext
93
+ licenses: []
94
+
95
+ post_install_message:
96
+ rdoc_options:
97
+ - --charset=UTF-8
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ segments:
106
+ - 0
107
+ version: "0"
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ segments:
114
+ - 0
115
+ version: "0"
116
+ requirements: []
117
+
118
+ rubyforge_project:
119
+ rubygems_version: 1.3.7
120
+ signing_key:
121
+ specification_version: 3
122
+ summary: DataMapper plugin providing better error messages handling.
123
+ test_files:
124
+ - spec/spec_helper.rb
125
+ - spec/public/validations_ext_spec.rb