Rakefile 2.4 KB
Newer Older
1 2
gem 'rdoc', '= 2.2'
require 'rdoc'
D
Initial  
David Heinemeier Hansson 已提交
3 4 5 6 7 8 9
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/packagetask'
require 'rake/gempackagetask'

desc "Default Task"
10
task :default => :test
11

D
Initial  
David Heinemeier Hansson 已提交
12 13
# Run the unit tests

14
desc "Run all unit tests"
15
task :test => [:test_action_pack, :test_active_record_integration]
16

J
Jeremy Kemper 已提交
17
Rake::TestTask.new(:test_action_pack) do |t|
18
  t.libs << 'test'
J
Jeremy Kemper 已提交
19 20 21

  # 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
22
  t.test_files = Dir.glob('test/{abstract,controller,dispatch,template}/**/*_test.rb').sort
J
Jeremy Kemper 已提交
23

24
  # t.warning = true
J
Jeremy Kemper 已提交
25
end
26

27 28 29 30
namespace :test do
  Rake::TestTask.new(:isolated) do |t|
    t.pattern = 'test/ts_isolated.rb'
  end
J
Jeremy Kemper 已提交
31
end
D
Initial  
David Heinemeier Hansson 已提交
32

33 34
desc 'ActiveRecord Integration Tests'
Rake::TestTask.new(:test_active_record_integration) do |t|
35
  t.libs << 'test'
36 37 38
  t.test_files = Dir.glob("test/activerecord/*_test.rb")
end

D
Initial  
David Heinemeier Hansson 已提交
39 40 41 42 43
# 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 已提交
44
  rdoc.options << '--line-numbers' << '--inline-source'
45
  rdoc.options << '--charset' << 'utf-8'
J
Jeremy Kemper 已提交
46
  rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo'
47
  if ENV['DOC_FILES']
48 49
    rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
  else
50
    rdoc.rdoc_files.include('README.rdoc', 'RUNNING_UNIT_TESTS', 'CHANGELOG')
51
    rdoc.rdoc_files.include(Dir['lib/**/*.rb'] -
J
Jeremy Kemper 已提交
52 53
                            Dir['lib/*/vendor/**/*.rb'])
    rdoc.rdoc_files.exclude('lib/actionpack.rb')
54
  end
D
Initial  
David Heinemeier Hansson 已提交
55 56
}

57 58
spec = eval(File.read('actionpack.gemspec'))

D
Initial  
David Heinemeier Hansson 已提交
59 60 61 62
Rake::GemPackageTask.new(spec) do |p|
  p.gem_spec = spec
end

63
desc "Release to gemcutter"
64 65 66 67 68
task :release => :package do
  require 'rake/gemcutter'
  Rake::Gemcutter::Tasks.new(spec).define
  Rake::Task['gem:push'].invoke
end
69

70 71 72 73 74 75 76 77 78 79 80 81 82 83
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}"
84

85 86
    total_lines     += lines
    total_codelines += codelines
87

88 89 90 91
    lines, codelines = 0, 0
  end

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