Rakefile 6.3 KB
Newer Older
D
Initial  
David Heinemeier Hansson 已提交
1 2 3 4 5 6
require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/packagetask'
require 'rake/gempackagetask'
7
require File.join(File.dirname(__FILE__), 'lib', 'action_pack', 'version')
D
Initial  
David Heinemeier Hansson 已提交
8 9 10

PKG_BUILD     = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
PKG_NAME      = 'actionpack'
11
PKG_VERSION   = ActionPack::VERSION::STRING + PKG_BUILD
D
Initial  
David Heinemeier Hansson 已提交
12 13
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"

14 15 16 17 18
RELEASE_NAME  = "REL #{PKG_VERSION}"

RUBY_FORGE_PROJECT = "actionpack"
RUBY_FORGE_USER    = "webster132"

D
Initial  
David Heinemeier Hansson 已提交
19 20 21 22 23
desc "Default Task"
task :default => [ :test ]

# Run the unit tests

24
desc "Run all unit tests"
25
task :test => [:test_action_pack, :test_active_record_integration, :test_new_base, :test_new_base_on_old_tests]
26

27
test_lib_dirs = [ENV["NEW"] ? "test/new_base" : "test", "test/lib"]
J
Jeremy Kemper 已提交
28
Rake::TestTask.new(:test_action_pack) do |t|
29
  t.libs.concat test_lib_dirs
J
Jeremy Kemper 已提交
30 31 32

  # make sure we include the tests in alphabetical order as on some systems
  # this will not happen automatically and the tests (as a whole) will error
P
Pratik Naik 已提交
33
  t.test_files = Dir.glob( "test/{controller,dispatch,template,html-scanner}/**/*_test.rb" ).sort
J
Jeremy Kemper 已提交
34

D
Initial  
David Heinemeier Hansson 已提交
35
  t.verbose = true
J
Jeremy Kemper 已提交
36 37
  #t.warning = true
end
J
Jeremy Kemper 已提交
38 39 40
task :isolated_test do
  ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
  Dir.glob("test/{controller,dispatch,template}/**/*_test.rb").all? do |file|
41
    system(ruby, "-Ilib:#{test_lib_dirs * ':'}", file)
J
Jeremy Kemper 已提交
42 43
  end or raise "Failures"
end
D
Initial  
David Heinemeier Hansson 已提交
44

45 46
desc 'ActiveRecord Integration Tests'
Rake::TestTask.new(:test_active_record_integration) do |t|
47
  t.libs.concat test_lib_dirs
48 49 50 51
  t.test_files = Dir.glob("test/activerecord/*_test.rb")
  t.verbose = true
end

Y
Yehuda Katz + Carl Lerche 已提交
52 53
desc 'New Controller Tests'
Rake::TestTask.new(:test_new_base) do |t|
54
  t.libs << "test/new_base" << "test/lib"
Y
Yehuda Katz + Carl Lerche 已提交
55 56 57 58
  t.test_files = Dir.glob("test/{abstract_controller,new_base}/*_test.rb")
  t.verbose = true
end

59 60
desc 'Old Controller Tests on New Base'
Rake::TestTask.new(:test_new_base_on_old_tests) do |t|
61
  t.libs << "test/new_base" << "test/lib"
62

63
  t.verbose = true
64 65
  # ==== Not ported
  # * filters
66

67
  t.test_files = Dir.glob( "test/{dispatch,template}/**/*_test.rb" ).sort + %w(
68
    action_pack_assertions addresses_render assert_select
J
Jeremy Kemper 已提交
69
    base benchmark caching capture content_type cookie dispatcher
70
    filter_params flash helper http_basic_authentication
71
    http_digest_authentication integration layout logging mime_responds
72 73
    record_identifier redirect render render_js render_json
    render_other render_xml request_forgery_protection rescue
74
    resources routing selector send_file test url_rewriter
75
    verification view_paths webservice
76 77 78
  ).map { |name| "test/controller/#{name}_test.rb" }
end

D
Initial  
David Heinemeier Hansson 已提交
79 80 81 82 83
# Genereate the RDoc documentation

Rake::RDocTask.new { |rdoc|
  rdoc.rdoc_dir = 'doc'
  rdoc.title    = "Action Pack -- On rails from request to response"
D
David Heinemeier Hansson 已提交
84
  rdoc.options << '--line-numbers' << '--inline-source'
85
  rdoc.options << '--charset' << 'utf-8'
J
Jeremy Kemper 已提交
86
  rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo'
87 88 89 90
  if ENV['DOC_FILES'] 
    rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
  else
    rdoc.rdoc_files.include('README', 'RUNNING_UNIT_TESTS', 'CHANGELOG')
91
    rdoc.rdoc_files.include(Dir['lib/**/*.rb'] -
J
Jeremy Kemper 已提交
92 93
                            Dir['lib/*/vendor/**/*.rb'])
    rdoc.rdoc_files.exclude('lib/actionpack.rb')
94
  end
D
Initial  
David Heinemeier Hansson 已提交
95 96 97
}

# Create compressed packages
98
dist_dirs = [ "lib", "test" ]
D
Initial  
David Heinemeier Hansson 已提交
99 100 101 102 103 104

spec = Gem::Specification.new do |s|
  s.platform = Gem::Platform::RUBY
  s.name = PKG_NAME
  s.version = PKG_VERSION
  s.summary = "Web-flow and rendering framework putting the VC in MVC."
105
  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.} #'
D
Initial  
David Heinemeier Hansson 已提交
106 107 108 109

  s.author = "David Heinemeier Hansson"
  s.email = "david@loudthinking.com"
  s.rubyforge_project = "actionpack"
110
  s.homepage = "http://www.rubyonrails.org"
D
Initial  
David Heinemeier Hansson 已提交
111 112 113

  s.has_rdoc = true
  s.requirements << 'none'
114

115
  s.add_dependency('activesupport', '= 2.3.2' + PKG_BUILD)
116

D
Initial  
David Heinemeier Hansson 已提交
117 118 119
  s.require_path = 'lib'
  s.autorequire = 'action_controller'

120
  s.files = [ "Rakefile", "install.rb", "README", "RUNNING_UNIT_TESTS", "CHANGELOG", "MIT-LICENSE" ]
D
Initial  
David Heinemeier Hansson 已提交
121
  dist_dirs.each do |dir|
122
    s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
D
Initial  
David Heinemeier Hansson 已提交
123 124 125 126 127 128 129 130 131
  end
end
  
Rake::GemPackageTask.new(spec) do |p|
  p.gem_spec = spec
  p.need_tar = true
  p.need_zip = true
end

132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
task :lines do
  lines, codelines, total_lines, total_codelines = 0, 0, 0, 0

  for file_name in FileList["lib/**/*.rb"]
    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}"
    
    total_lines     += lines
    total_codelines += codelines
    
    lines, codelines = 0, 0
  end

  puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
end

156 157 158
# Publishing ------------------------------------------------------

task :update_scriptaculous do
159
  for js in %w( controls dragdrop effects )
160
    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")
161
  end
162 163 164
end

desc "Updates actionpack to the latest version of the javascript spinoffs"
165
task :update_js => [ :update_scriptaculous ]
D
Initial  
David Heinemeier Hansson 已提交
166

167 168
# Publishing ------------------------------------------------------

D
Initial  
David Heinemeier Hansson 已提交
169 170
desc "Publish the API documentation"
task :pgem => [:package] do 
171
  require 'rake/contrib/sshpublisher'
D
David Heinemeier Hansson 已提交
172
  Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
173
  `ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'`
D
Initial  
David Heinemeier Hansson 已提交
174 175 176 177
end

desc "Publish the API documentation"
task :pdoc => [:rdoc] do 
178
  require 'rake/contrib/sshpublisher'
179
  Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/ap", "doc").upload
D
Initial  
David Heinemeier Hansson 已提交
180 181
end

182
desc "Publish the release files to RubyForge."
183
task :release => [ :package ] do
184
  require 'rubyforge'
J
Jeremy Kemper 已提交
185
  require 'rake/contrib/rubyforgepublisher'
186

187 188 189 190 191
  packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }

  rubyforge = RubyForge.new
  rubyforge.login
  rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
J
Jeremy Kemper 已提交
192
end