2009-08-06 18:22:10 -04:00
|
|
|
require "rubygems"
|
2007-12-30 14:35:44 -05:00
|
|
|
|
2010-03-23 14:23:21 -04:00
|
|
|
def gemspec
|
|
|
|
@gemspec ||= begin
|
|
|
|
gemspec_file = File.expand_path('../arel.gemspec', __FILE__)
|
|
|
|
gemspec = eval(File.read(gemspec_file), binding, gemspec_file)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-09-20 12:12:55 -04:00
|
|
|
begin
|
|
|
|
require "spec/rake/spectask"
|
|
|
|
rescue LoadError
|
|
|
|
desc "Run specs"
|
|
|
|
task(:spec) { $stderr.puts '`gem install rspec` to run specs' }
|
|
|
|
else
|
|
|
|
desc "Run specs using RCov (uses mysql database adapter)"
|
|
|
|
Spec::Rake::SpecTask.new(:coverage) do |t|
|
|
|
|
t.spec_files =
|
|
|
|
["spec/connections/mysql_connection.rb"] +
|
|
|
|
FileList['spec/**/*_spec.rb']
|
|
|
|
|
|
|
|
t.rcov = true
|
|
|
|
t.rcov_opts << '--exclude' << "spec,gems"
|
|
|
|
t.rcov_opts << '--text-summary'
|
|
|
|
t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
|
|
|
|
t.rcov_opts << '--only-uncovered'
|
|
|
|
end
|
2008-01-14 11:09:46 -05:00
|
|
|
|
2009-09-20 12:12:55 -04:00
|
|
|
namespace :spec do
|
2010-03-23 15:05:35 -04:00
|
|
|
%w[mysql sqlite3 postgresql oracle].each do |adapter|
|
|
|
|
task "set_env_for_#{adapter}" do
|
|
|
|
ENV['ADAPTER'] = adapter
|
|
|
|
end
|
|
|
|
|
2009-09-20 12:12:55 -04:00
|
|
|
Spec::Rake::SpecTask.new(adapter) do |t|
|
2009-10-01 00:13:56 -04:00
|
|
|
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
2009-09-20 12:12:55 -04:00
|
|
|
t.libs << "#{File.dirname(__FILE__)}/spec"
|
2010-02-10 12:50:59 -05:00
|
|
|
# t.warning = true
|
2010-03-23 15:05:35 -04:00
|
|
|
t.spec_files = FileList['spec/**/*_spec.rb']
|
2009-09-20 12:12:55 -04:00
|
|
|
end
|
2010-03-23 15:05:35 -04:00
|
|
|
|
|
|
|
desc "Run specs with the #{adapter} database adapter"
|
|
|
|
task adapter => "set_env_for_#{adapter}"
|
2010-08-16 17:42:20 -04:00
|
|
|
|
|
|
|
namespace :v1 do
|
|
|
|
Spec::Rake::SpecTask.new(adapter) do |t|
|
|
|
|
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
|
|
|
t.libs << "#{File.dirname(__FILE__)}/spec"
|
|
|
|
t.warning = true
|
|
|
|
t.spec_files = FileList['spec/arel/**/*_spec.rb']
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Run specs with the #{adapter} database adapter"
|
|
|
|
task adapter => "set_env_for_#{adapter}"
|
|
|
|
end
|
2009-05-16 21:13:32 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-09-20 12:12:55 -04:00
|
|
|
desc "Run specs with mysql and sqlite3 database adapters (default)"
|
2009-11-09 19:38:44 -05:00
|
|
|
task :spec => ["spec:sqlite3", "spec:mysql", "spec:postgresql"]
|
2009-05-16 21:13:32 -04:00
|
|
|
|
2009-09-20 12:12:55 -04:00
|
|
|
desc "Default task is to run specs"
|
|
|
|
task :default => :spec
|
|
|
|
end
|
2009-05-17 14:59:06 -04:00
|
|
|
|
|
|
|
desc 'Removes trailing whitespace'
|
|
|
|
task :whitespace do
|
|
|
|
sh %{find . -name '*.rb' -exec sed -i '' 's/ *$//g' {} \\;}
|
|
|
|
end
|
2010-03-23 14:23:21 -04:00
|
|
|
|
|
|
|
desc "Build pkg/#{gemspec.full_name}.gem"
|
|
|
|
task :build => "gemspec:validate" do
|
|
|
|
sh %{gem build arel.gemspec}
|
|
|
|
FileUtils.mkdir_p "pkg"
|
|
|
|
FileUtils.mv gemspec.file_name, "pkg"
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Install the latest built gem"
|
|
|
|
task :install => :build do
|
|
|
|
sh "gem install --local pkg/#{gemspec.file_name}"
|
|
|
|
end
|
|
|
|
|
|
|
|
namespace :release do
|
|
|
|
task :tag do
|
|
|
|
release_tag = "v#{gemspec.version}"
|
|
|
|
sh "git tag -a #{release_tag} -m 'Tagging #{release_tag}'"
|
|
|
|
sh "git push origin #{release_tag}"
|
|
|
|
end
|
|
|
|
|
|
|
|
task :gem => :build do
|
|
|
|
sh "gem push pkg/#{gemspec.file_name}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Release the current branch to GitHub and Gemcutter"
|
|
|
|
task :release => %w(release:tag release:gem)
|
|
|
|
|
|
|
|
namespace :gemspec do
|
|
|
|
desc 'Validate the gemspec'
|
|
|
|
task :validate do
|
|
|
|
gemspec.validate
|
|
|
|
end
|
2010-07-20 12:14:00 -04:00
|
|
|
end
|