3 require 'rake/testtask'
4 require 'rake/rdoctask'
5 require 'rake/packagetask'
6 require 'rake/gempackagetask'
7 require 'rake/contrib/sshpublisher'
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) do |t|
31 # make sure we include the tests in alphabetical order as on some systems
32 # this will not happen automatically and the tests (as a whole) will error
33 t.test_files = Dir.glob( "test/[cft]*/**/*_test.rb" ).sort
39 desc 'ActiveRecord Integration Tests'
40 Rake::TestTask.new(:test_active_record_integration) do |t|
42 t.test_files = Dir.glob("test/activerecord/*_test.rb")
47 # Genereate the RDoc documentation
49 Rake::RDocTask.new { |rdoc|
51 rdoc.title = "Action Pack -- On rails from request to response"
52 rdoc.options << '--line-numbers' << '--inline-source'
53 rdoc.options << '--charset' << 'utf-8'
54 rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo'
56 rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
58 rdoc.rdoc_files.include('README', 'RUNNING_UNIT_TESTS', 'CHANGELOG')
59 rdoc.rdoc_files.include(Dir['lib/**/*.rb'] -
60 Dir['lib/*/vendor/**/*.rb'])
61 rdoc.rdoc_files.exclude('lib/actionpack.rb')
65 # Create compressed packages
66 dist_dirs = [ "lib", "test" ]
68 spec = Gem::Specification.new do |s|
69 s.platform = Gem::Platform::RUBY
71 s.version = PKG_VERSION
72 s.summary = "Web-flow and rendering framework putting the VC in MVC."
73 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.} #'
75 s.author = "David Heinemeier Hansson"
76 s.email = "david@loudthinking.com"
77 s.rubyforge_project = "actionpack"
78 s.homepage = "http://www.rubyonrails.org"
81 s.requirements << 'none'
83 s.add_dependency('activesupport', '= 2.2.2' + PKG_BUILD)
85 s.require_path = 'lib'
86 s.autorequire = 'action_controller'
88 s.files = [ "Rakefile", "install.rb", "README", "RUNNING_UNIT_TESTS", "CHANGELOG", "MIT-LICENSE" ]
89 dist_dirs.each do |dir|
90 s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
94 Rake::GemPackageTask.new(spec) do |p|
101 lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
103 for file_name in FileList["lib/**/*.rb"]
104 next if file_name =~ /vendor/
105 f = File.open(file_name)
109 next if line =~ /^\s*$/
110 next if line =~ /^\s*#/
113 puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
116 total_codelines += codelines
118 lines, codelines = 0, 0
121 puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
124 # Publishing ------------------------------------------------------
126 task :update_scriptaculous do
127 for js in %w( controls dragdrop effects )
128 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")
132 desc "Updates actionpack to the latest version of the javascript spinoffs"
133 task :update_js => [ :update_scriptaculous ]
135 # Publishing ------------------------------------------------------
137 desc "Publish the API documentation"
138 task :pgem => [:package] do
139 Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
140 `ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'`
143 desc "Publish the API documentation"
144 task :pdoc => [:rdoc] do
145 Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/ap", "doc").upload
148 desc "Publish the release files to RubyForge."
149 task :release => [ :package ] do
151 require 'rake/contrib/rubyforgepublisher'
153 packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
155 rubyforge = RubyForge.new
157 rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)