1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
# -*- ruby -*-
require 'rubygems'
require 'hoe'
Hoe.plugin :seattlerb
Hoe.plugin :racc
Hoe.plugin :isolate
Hoe.add_include_dirs "../../sexp_processor/dev/lib"
Hoe.spec 'ruby_parser' do
developer 'Ryan Davis', 'ryand-ruby@zenspider.com'
self.rubyforge_name = 'parsetree'
dependency 'sexp_processor', '~> 3.0'
self.perforce_ignore << "lib/ruby_parser.rb" if plugin? :perforce
self.racc_flags << " -g" if plugin?(:racc) && ENV["DEBUG"]
end
task :clean do
rm_rf(Dir["**/*~"] +
Dir["**/*.diff"] +
Dir["coverage.info"] +
Dir["coverage"] +
Dir["lib/*.output"])
end
def next_num(glob)
num = Dir[glob].max[/\d+/].to_i + 1
end
desc "Compares PT to RP and deletes all files that match"
task :compare do
files = Dir["unit/**/*.rb"]
puts "Parsing #{files.size} files"
files.each do |file|
puts file
system "./cmp.rb -q #{file} && rm #{file}"
end
system 'find -d unit -type d -empty -exec rmdir {} \;'
end
desc "Compares PT to RP and stops on first failure"
task :find_bug do
files = Dir["unit/**/*.rb"]
puts "Parsing #{files.size} files"
files.each do |file|
puts file
sh "./cmp.rb -q #{file}"
end
end
task :sort do
sh 'grepsort "^ +def" lib/ruby_lexer.rb'
sh 'grepsort "^ +def (test|util)" test/test_ruby_lexer.rb'
end
task :loc do
loc1 = `wc -l ../1.0.0/lib/ruby_lexer.rb`[/\d+/]
flog1 = `flog -s ../1.0.0/lib/ruby_lexer.rb`[/\d+\.\d+/]
loc2 = `cat lib/ruby_lexer.rb lib/ruby_parser_extras.rb | wc -l`[/\d+/]
flog2 = `flog -s lib/ruby_lexer.rb lib/ruby_parser_extras.rb`[/\d+\.\d+/]
loc1, loc2, flog1, flog2 = loc1.to_i, loc2.to_i, flog1.to_f, flog2.to_f
puts "1.0.0: loc = #{loc1} flog = #{flog1}"
puts "dev : loc = #{loc2} flog = #{flog2}"
puts "delta: loc = #{loc2-loc1} flog = #{flog2-flog1}"
end
desc "Validate against all normal files in unit dir"
task :validate do
sh "./cmp.rb unit/*.rb"
end
def run_and_log cmd, prefix
files = ENV['FILES'] || 'unit/*.rb'
p, x = prefix, "txt"
n = Dir["#{p}.*.#{x}"].map { |s| s[/\d+/].to_i }.max + 1 rescue 1
f = "#{p}.#{n}.#{x}"
sh "#{cmd} #{Hoe::RUBY_FLAGS} bin/ruby_parse -q -g #{files} &> #{f}"
puts File.read(f)
end
desc "Benchmark against all normal files in unit dir"
task :benchmark do
run_and_log "ruby", "benchmark"
end
desc "Profile against all normal files in unit dir"
task :profile do
run_and_log "zenprofile", "profile"
end
desc "what was that command again?"
task :huh? do
puts "ruby #{Hoe::RUBY_FLAGS} bin/ruby_parse -q -g ..."
end
task :irb => [:isolate] do
sh "GEM_HOME=#{Gem.path.first} irb -rubygems -Ilib -rruby_parser;"
end
# vim: syntax=Ruby
|