2006-06-25 10:44:22 -04:00
|
|
|
require 'rubygems'
|
|
|
|
require 'rake'
|
|
|
|
require 'rake/testtask'
|
|
|
|
require 'rake/rdoctask'
|
|
|
|
require 'rake/packagetask'
|
|
|
|
require 'rake/gempackagetask'
|
2008-03-18 00:46:51 -04:00
|
|
|
|
2006-06-25 10:44:22 -04:00
|
|
|
require File.join(File.dirname(__FILE__), 'lib', 'active_resource', 'version')
|
|
|
|
|
|
|
|
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
|
|
|
PKG_NAME = 'activeresource'
|
|
|
|
PKG_VERSION = ActiveResource::VERSION::STRING + PKG_BUILD
|
|
|
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
|
|
|
|
|
|
|
RELEASE_NAME = "REL #{PKG_VERSION}"
|
|
|
|
|
|
|
|
RUBY_FORGE_PROJECT = "activerecord"
|
|
|
|
RUBY_FORGE_USER = "webster132"
|
|
|
|
|
|
|
|
PKG_FILES = FileList[
|
2007-04-23 15:36:15 -04:00
|
|
|
"lib/**/*", "test/**/*", "[A-Z]*", "Rakefile"
|
2006-06-25 10:44:22 -04:00
|
|
|
].exclude(/\bCVS\b|~$/)
|
|
|
|
|
|
|
|
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|
|
|
|
|
system(ruby, '-w', "-Ilib:test:#{activesupport_path}", file)
|
|
|
|
end or raise "Failures"
|
|
|
|
end
|
2009-05-13 04:10:37 -04:00
|
|
|
end
|
2006-06-25 10:44:22 -04:00
|
|
|
|
|
|
|
# Generate the RDoc documentation
|
|
|
|
|
|
|
|
Rake::RDocTask.new { |rdoc|
|
|
|
|
rdoc.rdoc_dir = 'doc'
|
|
|
|
rdoc.title = "Active Resource -- Object-oriented REST services"
|
|
|
|
rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
|
2007-05-28 18:55:14 -04:00
|
|
|
rdoc.options << '--charset' << 'utf-8'
|
2008-06-22 13:38:25 -04:00
|
|
|
rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo'
|
2006-12-19 09:59:30 -05:00
|
|
|
rdoc.rdoc_files.include('README', 'CHANGELOG')
|
2006-06-25 10:44:22 -04:00
|
|
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
2008-06-18 23:12:25 -04:00
|
|
|
rdoc.rdoc_files.exclude('lib/activeresource.rb')
|
2006-06-25 10:44:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-25 01:46:04 -04:00
|
|
|
spec = eval(File.read('activeresource.gemspec'))
|
|
|
|
|
2006-06-25 10:44:22 -04:00
|
|
|
Rake::GemPackageTask.new(spec) do |p|
|
|
|
|
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 ------------------------------------------------------
|
|
|
|
|
|
|
|
desc "Publish the beta gem"
|
2009-10-16 14:56:59 -04:00
|
|
|
task :pgem => [:package] do
|
2009-05-07 21:27:50 -04:00
|
|
|
require 'rake/contrib/sshpublisher'
|
2008-10-23 14:18:11 -04:00
|
|
|
Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
|
2008-10-23 14:29:25 -04:00
|
|
|
`ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'`
|
2006-06-25 10:44:22 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Publish the API documentation"
|
2009-10-16 14:56:59 -04:00
|
|
|
task :pdoc => [:rdoc] do
|
2009-05-07 21:27:50 -04:00
|
|
|
require 'rake/contrib/sshpublisher'
|
2008-06-18 22:56:22 -04:00
|
|
|
Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/ar", "doc").upload
|
2006-06-25 10:44:22 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Publish the release files to RubyForge."
|
|
|
|
task :release => [ :package ] do
|
|
|
|
`rubyforge login`
|
|
|
|
|
|
|
|
for ext in %w( gem tgz zip )
|
|
|
|
release_command = "rubyforge add_release #{PKG_NAME} #{PKG_NAME} 'REL #{PKG_VERSION}' pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}"
|
|
|
|
puts release_command
|
|
|
|
system(release_command)
|
|
|
|
end
|
2007-10-05 01:20:37 -04:00
|
|
|
end
|