Rakefile 1.7 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
# Run the unit tests
8
Rake::TestTask.new do |t|
9
  t.libs << 'test'
J
Jeremy Kemper 已提交
10 11 12

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

15
  t.warning = true
A
Arun Agrawal 已提交
16
  t.verbose = true
J
Jeremy Kemper 已提交
17
end
18

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

28 29
spec = eval(File.read('actionpack.gemspec'))

30
Gem::PackageTask.new(spec) do |p|
D
Initial  
David Heinemeier Hansson 已提交
31 32 33
  p.gem_spec = spec
end

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

41 42 43
task :lines do
  lines, codelines, total_lines, total_codelines = 0, 0, 0, 0

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

56 57
    total_lines     += lines
    total_codelines += codelines
58

59 60 61 62
    lines, codelines = 0, 0
  end

  puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
63
end
64 65 66 67 68

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

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