Rakefile 1.8 KB
Newer Older
1
#!/usr/bin/env rake
D
Initial  
David Heinemeier Hansson 已提交
2 3
require 'rake/testtask'
require 'rake/packagetask'
4
require 'rubygems/package_task'
D
Initial  
David Heinemeier Hansson 已提交
5 6

desc "Default Task"
7
task :default => :test
8

D
Initial  
David Heinemeier Hansson 已提交
9 10
# Run the unit tests

11
desc "Run all unit tests"
12
task :test => [:test_action_pack, :test_active_record_integration]
13

J
Jeremy Kemper 已提交
14
Rake::TestTask.new(:test_action_pack) do |t|
15
  t.libs << 'test'
J
Jeremy Kemper 已提交
16 17 18

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

21
  t.warning = true
J
Jeremy Kemper 已提交
22
end
23

24 25 26 27
namespace :test do
  Rake::TestTask.new(:isolated) do |t|
    t.pattern = 'test/ts_isolated.rb'
  end
N
Nick Sutterer 已提交
28 29 30 31 32

  Rake::TestTask.new(:template) do |t|
    t.libs << 'test'
    t.pattern = 'test/template/**/*.rb'
  end
J
Jeremy Kemper 已提交
33
end
D
Initial  
David Heinemeier Hansson 已提交
34

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

41 42
spec = eval(File.read('actionpack.gemspec'))

43
Gem::PackageTask.new(spec) do |p|
D
Initial  
David Heinemeier Hansson 已提交
44 45 46
  p.gem_spec = spec
end

47
desc "Release to gemcutter"
48 49 50 51 52
task :release => :package do
  require 'rake/gemcutter'
  Rake::Gemcutter::Tasks.new(spec).define
  Rake::Task['gem:push'].invoke
end
53

54 55 56
task :lines do
  lines, codelines, total_lines, total_codelines = 0, 0, 0, 0

57
  FileList["lib/**/*.rb"].each do |file_name|
58
    next if file_name =~ /vendor/
59 60 61 62 63 64 65
    File.open(file_name, 'r') do |f|
      while line = f.gets
        lines += 1
        next if line =~ /^\s*$/
        next if line =~ /^\s*#/
        codelines += 1
      end
66 67
    end
    puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
68

69 70
    total_lines     += lines
    total_codelines += codelines
71

72 73 74 75
    lines, codelines = 0, 0
  end

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