2004-11-23 20:04:44 -05:00
require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/contrib/rubyforgepublisher'
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
PKG_NAME = 'activerecord'
2005-03-06 20:52:15 -05:00
PKG_VERSION = '1.8.0' + PKG_BUILD
2004-11-23 20:04:44 -05:00
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
PKG_FILES = FileList[
"lib/**/*", "test/**/*", "examples/**/*", "doc/**/*", "[A-Z]*", "install.rb", "rakefile"
].exclude(/\bCVS\b|~$/)
desc "Default Task"
2005-01-10 18:09:51 -05:00
task :default => [ :test_ruby_mysql, :test_mysql_ruby, :test_sqlite, :test_sqlite3, :test_postgresql ]
2004-11-23 20:04:44 -05:00
# Run the unit tests
Rake::TestTask.new("test_ruby_mysql") { |t|
t.libs << "test" << "test/connections/native_mysql"
t.pattern = 'test/*_test.rb'
t.verbose = true
}
Rake::TestTask.new("test_mysql_ruby") { |t|
t.libs << "test" << "test/connections/native_mysql"
t.pattern = 'test/*_test.rb'
t.verbose = true
}
Rake::TestTask.new("test_postgresql") { |t|
t.libs << "test" << "test/connections/native_postgresql"
t.pattern = 'test/*_test.rb'
t.verbose = true
}
Rake::TestTask.new("test_sqlite") { |t|
t.libs << "test" << "test/connections/native_sqlite"
t.pattern = 'test/*_test.rb'
t.verbose = true
}
2005-01-10 18:09:51 -05:00
Rake::TestTask.new("test_sqlite3") { |t|
t.libs << "test" << "test/connections/native_sqlite3"
t.pattern = 'test/*_test.rb'
t.verbose = true
}
2005-01-01 13:55:04 -05:00
Rake::TestTask.new("test_sqlserver") { |t|
t.libs << "test" << "test/connections/native_sqlserver"
t.pattern = 'test/*_test.rb'
t.verbose = true
}
2005-01-01 14:22:16 -05:00
Rake::TestTask.new("test_db2") { |t|
t.libs << "test" << "test/connections/native_db2"
t.pattern = 'test/*_test.rb'
t.verbose = true
}
2005-02-07 09:06:00 -05:00
Rake::TestTask.new("test_oracle") { |t|
t.libs << "test" << "test/connections/native_oracle"
t.pattern = 'test/*_test.rb'
t.verbose = true
}
2005-02-23 08:34:57 -05:00
Rake::TestTask.new("test_oci") { |t|
t.libs << "test" << "test/connections/native_oci"
t.pattern = 'test/*_test.rb'
t.verbose = true
}
2004-11-23 20:04:44 -05:00
# Generate the RDoc documentation
Rake::RDocTask.new { |rdoc|
rdoc.rdoc_dir = 'doc'
rdoc.title = "Active Record -- Object-relation mapping put on rails"
rdoc.options << '--line-numbers --inline-source --accessor cattr_accessor=object'
rdoc.rdoc_files.include('README', 'RUNNING_UNIT_TESTS', 'CHANGELOG')
rdoc.rdoc_files.include('lib/**/*.rb')
rdoc.rdoc_files.exclude('lib/active_record/vendor/*')
rdoc.rdoc_files.include('dev-utils/*.rb')
}
# Publish beta gem
desc "Publish the beta gem"
task :pgem => [:package] do
2004-12-29 16:19:37 -05:00
Rake::SshFilePublisher.new("davidhh@comox.textdrive.com", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
`ssh davidhh@comox.textdrive.com './gemupdate.sh'`
2004-11-23 20:04:44 -05:00
end
# Publish documentation
desc "Publish the API documentation"
task :pdoc => [:rdoc] do
2004-12-29 16:19:37 -05:00
Rake::SshDirPublisher.new("davidhh@comox.textdrive.com", "public_html/ar", "doc").upload
2004-11-23 20:04:44 -05:00
end
# Create compressed packages
dist_dirs = [ "lib", "test", "examples", "dev-utils" ]
spec = Gem::Specification.new do |s|
s.name = PKG_NAME
s.version = PKG_VERSION
s.summary = "Implements the ActiveRecord pattern for ORM."
s.description = %q{Implements the ActiveRecord pattern (Fowler, PoEAA) for ORM. It ties database tables and classes together for business objects, like Customer or Subscription, that can find, save, and destroy themselves without resorting to manual SQL.}
s.files = [ "rakefile", "install.rb", "README", "RUNNING_UNIT_TESTS", "CHANGELOG" ]
dist_dirs.each do |dir|
2004-11-25 11:31:27 -05:00
s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
2004-11-23 20:04:44 -05:00
end
2005-02-15 10:57:44 -05:00
2005-03-06 20:52:15 -05:00
s.add_dependency('activesupport', '= 1.0.1' + PKG_BUILD)
2005-02-15 10:57:44 -05:00
2004-11-23 20:04:44 -05:00
s.files.delete "test/fixtures/fixture_database.sqlite"
2005-01-10 18:09:51 -05:00
s.files.delete "test/fixtures/fixture_database_2.sqlite"
s.files.delete "test/fixtures/fixture_database.sqlite3"
s.files.delete "test/fixtures/fixture_database_2.sqlite3"
2004-11-23 20:04:44 -05:00
s.require_path = 'lib'
s.autorequire = 'active_record'
s.has_rdoc = true
s.extra_rdoc_files = %w( README )
s.rdoc_options.concat ['--main', 'README']
s.author = "David Heinemeier Hansson"
s.email = "david@loudthinking.com"
2005-02-24 08:06:17 -05:00
s.homepage = "http://www.rubyonrails.org"
2004-11-23 20:04:44 -05:00
s.rubyforge_project = "activerecord"
end
Rake::GemPackageTask.new(spec) do |p|
p.gem_spec = spec
p.need_tar = true
p.need_zip = true
end
task :lines do
lines = 0
codelines = 0
Dir.foreach("lib/active_record") { |file_name|
next unless file_name =~ /.*rb/
f = File.open("lib/active_record/" + file_name)
while line = f.gets
lines += 1
next if line =~ /^\s*$/
next if line =~ /^\s*#/
codelines += 1
end
}
puts "Lines #{lines}, LOC #{codelines}"
end