Rakefile 2.0 KB
Newer Older
D
Initial  
David Heinemeier Hansson 已提交
1 2
require 'rake/testtask'
require 'rake/packagetask'
3
require 'rubygems/package_task'
D
Initial  
David Heinemeier Hansson 已提交
4 5

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

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

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

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

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

20
  t.warning = true
A
Arun Agrawal 已提交
21
  t.verbose = true
J
Jeremy Kemper 已提交
22
end
23

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

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

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

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

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

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

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

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

70 71
    total_lines     += lines
    total_codelines += codelines
72

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

  puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
77
end
78 79 80 81 82

rule '.rb' => '.y' do |t|
  sh "racc -l -o #{t.name} #{t.source}"
end

83
task compile: 'lib/action_dispatch/journey/parser.rb'