2010-11-24 15:03:04 -05:00
|
|
|
#!/usr/bin/env rake
|
2006-06-25 10:44:22 -04:00
|
|
|
require 'rake/testtask'
|
|
|
|
require 'rake/packagetask'
|
2011-05-24 14:08:11 -04:00
|
|
|
require 'rubygems/package_task'
|
2008-03-18 00:46:51 -04:00
|
|
|
|
2006-06-25 10:44:22 -04:00
|
|
|
desc "Default Task"
|
|
|
|
task :default => [ :test ]
|
|
|
|
|
|
|
|
# Run the unit tests
|
|
|
|
|
|
|
|
Rake::TestTask.new { |t|
|
|
|
|
t.libs << "test"
|
2006-09-04 05:49:33 -04:00
|
|
|
t.pattern = 'test/**/*_test.rb'
|
|
|
|
t.warning = true
|
2006-06-25 10:44:22 -04:00
|
|
|
}
|
2009-09-05 20:24:43 -04:00
|
|
|
|
2009-11-10 19:50:15 -05:00
|
|
|
namespace :test do
|
|
|
|
task :isolated do
|
|
|
|
ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
|
|
|
|
activesupport_path = "#{File.dirname(__FILE__)}/../activesupport/lib"
|
|
|
|
Dir.glob("test/**/*_test.rb").all? do |file|
|
2011-01-13 07:55:41 -05:00
|
|
|
sh(ruby, '-w', "-Ilib:test:#{activesupport_path}", file)
|
2009-11-10 19:50:15 -05:00
|
|
|
end or raise "Failures"
|
|
|
|
end
|
2009-05-13 04:10:37 -04:00
|
|
|
end
|
2006-06-25 10:44:22 -04:00
|
|
|
|
2009-09-25 01:46:04 -04:00
|
|
|
spec = eval(File.read('activeresource.gemspec'))
|
|
|
|
|
2011-05-24 14:08:11 -04:00
|
|
|
Gem::PackageTask.new(spec) do |p|
|
2006-06-25 10:44:22 -04:00
|
|
|
p.gem_spec = spec
|
|
|
|
end
|
|
|
|
|
|
|
|
task :lines do
|
|
|
|
lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
|
|
|
|
|
2007-04-23 14:55:54 -04:00
|
|
|
for file_name in FileList["lib/active_resource/**/*.rb"]
|
2006-06-25 10:44:22 -04:00
|
|
|
next if file_name =~ /vendor/
|
|
|
|
f = File.open(file_name)
|
|
|
|
|
|
|
|
while line = f.gets
|
|
|
|
lines += 1
|
|
|
|
next if line =~ /^\s*$/
|
|
|
|
next if line =~ /^\s*#/
|
|
|
|
codelines += 1
|
|
|
|
end
|
|
|
|
puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
|
2009-10-16 14:56:59 -04:00
|
|
|
|
2006-06-25 10:44:22 -04:00
|
|
|
total_lines += lines
|
|
|
|
total_codelines += codelines
|
2009-10-16 14:56:59 -04:00
|
|
|
|
2006-06-25 10:44:22 -04:00
|
|
|
lines, codelines = 0, 0
|
|
|
|
end
|
|
|
|
|
|
|
|
puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Publishing ------------------------------------------------------
|
|
|
|
|
2010-02-04 21:28:45 -05:00
|
|
|
desc "Release to gemcutter"
|
2010-02-05 03:03:03 -05:00
|
|
|
task :release => :package do
|
|
|
|
require 'rake/gemcutter'
|
|
|
|
Rake::Gemcutter::Tasks.new(spec).define
|
|
|
|
Rake::Task['gem:push'].invoke
|
|
|
|
end
|