2004-11-24 09:04:44 +08: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-01-26 04:10:24 +08:00
PKG_VERSION = '1.6.0' + PKG_BUILD
2004-11-24 09:04:44 +08: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-11 07:09:51 +08:00
task :default = > [ :test_ruby_mysql , :test_mysql_ruby , :test_sqlite , :test_sqlite3 , :test_postgresql ]
2004-11-24 09:04:44 +08: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-11 07:09:51 +08:00
Rake :: TestTask . new ( " test_sqlite3 " ) { | t |
t . libs << " test " << " test/connections/native_sqlite3 "
t . pattern = 'test/*_test.rb'
t . verbose = true
}
2005-01-02 02:55:04 +08:00
Rake :: TestTask . new ( " test_sqlserver " ) { | t |
t . libs << " test " << " test/connections/native_sqlserver "
t . pattern = 'test/*_test.rb'
t . verbose = true
}
2005-01-02 03:22:16 +08: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 22:06:00 +08:00
Rake :: TestTask . new ( " test_oracle " ) { | t |
t . libs << " test " << " test/connections/native_oracle "
t . pattern = 'test/*_test.rb'
t . verbose = true
}
2004-11-24 09:04:44 +08: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-30 05:19:37 +08: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-24 09:04:44 +08:00
end
# Publish documentation
desc " Publish the API documentation "
task :pdoc = > [ :rdoc ] do
2004-12-30 05:19:37 +08:00
Rake :: SshDirPublisher . new ( " davidhh@comox.textdrive.com " , " public_html/ar " , " doc " ) . upload
2004-11-24 09:04:44 +08: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-26 00:31:27 +08:00
s . files = s . files + Dir . glob ( " #{ dir } /**/* " ) . delete_if { | item | item . include? ( " \ .svn " ) }
2004-11-24 09:04:44 +08:00
end
2005-02-15 23:57:44 +08:00
2005-02-16 00:43:13 +08:00
s . add_dependency ( 'activesupport' , '>= 0.9.0' )
2005-02-15 23:57:44 +08:00
2004-11-24 09:04:44 +08:00
s . files . delete " test/fixtures/fixture_database.sqlite "
2005-01-11 07:09:51 +08: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-24 09:04:44 +08: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 "
2004-12-30 05:19:37 +08:00
s . homepage = " http://www.rubyonrails.com "
2004-11-24 09:04:44 +08: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