-
Notifications
You must be signed in to change notification settings - Fork 8
/
Rakefile
58 lines (53 loc) · 2.04 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
require 'rubygems'
require 'fileutils'
require 'rake/clean'
class Rake::Task
def overwrite(&block)
@actions.clear
enhance(&block)
end
end
desc 'Build quanty'
task :quanty do
parse_rb_name = File.join(File.dirname(__FILE__), 'src/util/quanty/parse.rb')
quanty_rb_name = File.join(File.dirname(__FILE__), 'src/util/quanty.rb')
unless File.exist?(parse_rb_name) and File.exist?(quanty_rb_name)
puts "Rebuilding #{parse_rb_name } and #{quanty_rb_name}"
FileUtils.makedirs(File.join(File.dirname(__FILE__), 'data/pdf'))
Dir.chdir(File.join(File.dirname(__FILE__), 'data/quanty'))
exit 2 unless system('ruby extconf.rb')
src='parse.y'
dst=parse_rb_name
tmp='lib/quanty/parse.backup'
FileUtils.rm_f(dst)
FileUtils.makedirs(File.dirname(dst))
cmd = "ruby `which racc` -E -o #{dst} #{src}"
exit 2 unless system(cmd)
inhalt = IO.read(dst)
ausgabe = "# encoding: utf-8\n"+inhalt
aus = File.open(dst, 'w+')
aus.puts(ausgabe)
aus.close
exit 2 unless system("make")
exit 2 unless system("make install")
else
puts "Files #{parse_rb_name} and #{quanty_rb_name} already present"
end
end
desc "Generate documentation"
task :docs do
FileUtils.rm_rf('documentation', :verbose => true)
system("rdoc --main README.txt --format=darkfish --exclude 'js' --exclude 'Gemfile*' --exclude 'sql.in' --exclude 'csv' --exclude 'bak' --exclude 'coverage' --exclude 'log' --exclude 'xml' --exclude 'yaml' --exclude 'yml' --exclude 'patch' --exclude '~' --exclude 'html' --exclude 'test' --exclude 'data' --exclude 'pdf' --exclude 'vendor' --op documentation/")
end
Rake::Task[:test].overwrite do
puts "Instead of calling Rake::Test we call test/suite.rb"
cov = File.expand_path(File.join(File.dirname(__FILE__), 'coverage'))
FileUtils.rm_rf(cov, :verbose => true)
res = system(File.join(File.dirname(__FILE__), 'test', 'suite.rb'))
puts "Calling from rake test/suite.rb returned #{res.inspect}"
exit(4) unless res
end
task :test => :quanty
CLEAN.include('*.yaml')
CLEAN.include('*.html')
# vim: syntax=ruby