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

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

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

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

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

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

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

23
namespace :test do
A
Arun Agrawal 已提交
24 25
  task :isolated do
    ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
26
    Dir.glob("test/{abstract,controller,dispatch}/**/*_test.rb").all? do |file|
A
Arun Agrawal 已提交
27
      sh(ruby, '-w', '-Ilib:test', file)
A
Arun Agrawal 已提交
28
    end or raise "Failures"
29
  end
A
Arun Agrawal 已提交
30
end
N
Nick Sutterer 已提交
31

32 33
spec = eval(File.read('actionpack.gemspec'))

34
Gem::PackageTask.new(spec) do |p|
D
Initial  
David Heinemeier Hansson 已提交
35 36 37
  p.gem_spec = spec
end

38
desc "Release to rubygems"
39 40 41 42 43
task :release => :package do
  require 'rake/gemcutter'
  Rake::Gemcutter::Tasks.new(spec).define
  Rake::Task['gem:push'].invoke
end
44

45 46 47
task :lines do
  lines, codelines, total_lines, total_codelines = 0, 0, 0, 0

48
  FileList["lib/**/*.rb"].each do |file_name|
49
    next if file_name =~ /vendor/
50 51 52 53 54 55 56
    File.open(file_name, 'r') do |f|
      while line = f.gets
        lines += 1
        next if line =~ /^\s*$/
        next if line =~ /^\s*#/
        codelines += 1
      end
57 58
    end
    puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
59

60 61
    total_lines     += lines
    total_codelines += codelines
62

63 64 65 66
    lines, codelines = 0, 0
  end

  puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
67
end
68 69 70 71 72

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

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