3 require 'rake/testtask'
4 require 'rake/rdoctask'
5 require 'rake/packagetask'
6 require 'rake/gempackagetask'
7 require 'rake/contrib/rubyforgepublisher'
8 require File.join(File.dirname(__FILE__), 'lib', 'action_pack', 'version')
10 PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
11 PKG_NAME = 'actionpack'
12 PKG_VERSION = ActionPack::VERSION::STRING + PKG_BUILD
13 PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
15 RELEASE_NAME = "REL #{PKG_VERSION}"
17 RUBY_FORGE_PROJECT = "actionpack"
18 RUBY_FORGE_USER = "webster132"
21 task :default => [ :test ]
25 desc "Run all unit tests"
26 task :test => [:test_action_pack, :test_active_record_integration]
28 Rake::TestTask.new(:test_action_pack) { |t|
30 # make sure we include the controller tests (c*) first as on some systems
31 # this will not happen automatically and the tests (as a whole) will error
32 t.test_files=Dir.glob( "test/c*/**/*_test.rb" ) + Dir.glob( "test/[ft]*/*_test.rb" )
33 # t.pattern = 'test/*/*_test.rb'
37 desc 'ActiveRecord Integration Tests'
38 Rake::TestTask.new(:test_active_record_integration) do |t|
40 t.test_files = Dir.glob("test/activerecord/*_test.rb")
45 # Genereate the RDoc documentation
47 Rake::RDocTask.new { |rdoc|
49 rdoc.title = "Action Pack -- On rails from request to response"
50 rdoc.options << '--line-numbers' << '--inline-source'
51 rdoc.options << '--charset' << 'utf-8'
52 rdoc.template = "#{ENV['template']}.rb" if ENV['template']
54 rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
56 rdoc.rdoc_files.include('README', 'RUNNING_UNIT_TESTS', 'CHANGELOG')
57 rdoc.rdoc_files.include('lib/**/*.rb')
61 # Create compressed packages
62 dist_dirs = [ "lib", "test" ]
64 spec = Gem::Specification.new do |s|
65 s.platform = Gem::Platform::RUBY
67 s.version = PKG_VERSION
68 s.summary = "Web-flow and rendering framework putting the VC in MVC."
69 s.description = %q{Eases web-request routing, handling, and response as a half-way front, half-way page controller. Implemented with specific emphasis on enabling easy unit/integration testing that doesn't require a browser.} #'
71 s.author = "David Heinemeier Hansson"
72 s.email = "david@loudthinking.com"
73 s.rubyforge_project = "actionpack"
74 s.homepage = "http://www.rubyonrails.org"
77 s.requirements << 'none'
79 s.add_dependency('activesupport', '= 1.99.0' + PKG_BUILD)
81 s.require_path = 'lib'
82 s.autorequire = 'action_controller'
84 s.files = [ "Rakefile", "install.rb", "README", "RUNNING_UNIT_TESTS", "CHANGELOG", "MIT-LICENSE" ]
85 dist_dirs.each do |dir|
86 s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
90 Rake::GemPackageTask.new(spec) do |p|
97 lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
99 for file_name in FileList["lib/**/*.rb"]
100 next if file_name =~ /vendor/
101 f = File.open(file_name)
105 next if line =~ /^\s*$/
106 next if line =~ /^\s*#/
109 puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
112 total_codelines += codelines
114 lines, codelines = 0, 0
117 puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
120 # Publishing ------------------------------------------------------
122 task :update_scriptaculous do
123 for js in %w( controls dragdrop effects )
124 system("svn export --force http://dev.rubyonrails.org/svn/rails/spinoffs/scriptaculous/src/#{js}.js #{File.dirname(__FILE__)}/lib/action_view/helpers/javascripts/#{js}.js")
128 desc "Updates actionpack to the latest version of the javascript spinoffs"
129 task :update_js => [ :update_scriptaculous ]
131 # Publishing ------------------------------------------------------
133 desc "Publish the API documentation"
134 task :pgem => [:package] do
135 Rake::SshFilePublisher.new("davidhh@wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
136 `ssh davidhh@wrath.rubyonrails.org './gemupdate.sh'`
139 desc "Publish the API documentation"
140 task :pdoc => [:rdoc] do
141 Rake::SshDirPublisher.new("davidhh@wrath.rubyonrails.org", "public_html/ap", "doc").upload
144 desc "Publish the release files to RubyForge."
145 task :release => [ :package ] do
148 packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
150 rubyforge = RubyForge.new
152 rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)