-
Notifications
You must be signed in to change notification settings - Fork 16
/
Rakefile
59 lines (47 loc) · 1.59 KB
/
Rakefile
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
# coding: utf-8
require 'bundler/setup'
require 'infoboxer'
require 'rubygems/tasks'
Gem::Tasks.new
require 'yard-junk/rake'
YardJunk::Rake.define_task
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new
require 'rubocop/rake_task'
RuboCop::RakeTask.new
task default: %w[spec rubocop yard:junk]
namespace :dev do
desc "Run regression check (just parsed/error) on set of large and dirty pages"
task :regression do
Dir['regression/pages/*.wiki'].each do |f|
start = Time.now
text = File.read(f)
begin
Infoboxer::Parser.document(text)
tm = Time.now - start
puts '%s successfully parsed in %.3f' % [File.basename(f), tm]
rescue Infoboxer::Parser::ParsingError => e
tm = Time.now - start
puts "%s: parsing error after %.3f: %s:\n\t%s" % [File.basename(f), tm, e.message, e.backtrace.first(5).join("\n\t")]
rescue => e
tm = Time.now - start
puts "%s: error %s after %.3f: %s:\n\t%s" % [File.basename(f), e.class, tm, e.message, e.backtrace.first(5).join("\n\t")]
end
end
end
desc "Run profiling on several pages and dump results to HTML"
task :profile do
require 'ruby-prof'
Dir['profile/pages/*.wiki'].each do |f|
name = File.basename(f).sub('.wiki', '')
out = "profile/out/#{name}.html"
text = File.read(f)
RubyProf.start
Infoboxer::Parser.document(text)
res = RubyProf.stop
printer = RubyProf::GraphHtmlPrinter.new(res)
printer.print(File.open(out, 'w'))
puts '%s successfully parsed, see res: %s' % [File.basename(f), out]
end
end
end