-
Notifications
You must be signed in to change notification settings - Fork 31
/
Rakefile
110 lines (88 loc) · 2.66 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
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
require 'bundler'
begin
Bundler.setup
rescue Bundler::BundlerError => e
warn e.message
warn 'Run `bundle install` to install missing gems'
exit e.status_code
end
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), './lib'))
require 'rake/clean'
require 'rake/testtask'
require 'bibtex/version'
require 'yard'
YARD::Rake::YardocTask.new
Rake::TestTask.new(:test_task) do |t|
t.libs << 'lib' << 'test'
t.test_files = FileList['test/**/test_*.rb']
# t.verbose = true
end
begin
require 'cucumber/rake/task'
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = '--format progress'
end
rescue LoadError
desc 'Cucumber rake task not available'
task :features do
abort 'Cucumber rake task is not available. Please install cucumber as a gem or plugin'
end
end
task default: %i[test features]
desc 'Generates the BibTeX parser'
task racc: ['lib/bibtex/parser.rb', 'lib/bibtex/name_parser.rb']
task test: %w[racc test_task]
file 'lib/bibtex/parser.output' => ['lib/bibtex/parser.rb']
file 'lib/bibtex/parser.rb' => ['lib/bibtex/bibtex.y'] do
# sh 'racc -v -g -o lib/bibtex/parser.rb lib/bibtex/bibtex.y'
sh 'bundle exec racc -o lib/bibtex/parser.rb lib/bibtex/bibtex.y'
end
file 'lib/bibtex/name_parser.rb' => ['lib/bibtex/names.y'] do
# sh 'racc -v -g -o lib/bibtex/name_parser.rb lib/bibtex/names.y'
sh 'bundle exec racc -o lib/bibtex/name_parser.rb lib/bibtex/names.y'
end
desc 'Run an IRB session with BibTeX-Ruby loaded'
task :console, [:script] do |_t, args|
ARGV.clear
require 'irb'
require 'bibtex'
IRB.conf[:SCRIPT] = args.script
IRB.start
end
task :check_warnings do
$VERBOSE = true
require 'bibtex'
puts BibTeX::Version::STRING
end
desc 'Runs the benchmarks (and plots the results)'
task benchmark: ['racc'] do
require File.expand_path('test/benchmark.rb', __dir__)
end
task bm: ['benchmark']
desc 'Runs the profiler'
task profile: ['racc'] do
require File.expand_path('test/profile.rb', __dir__)
end
desc 'Updates the Manifest file'
task manifest: %w[clean racc] do
m = File.open('Manifest', 'w')
m.print FileList['**/*'].reject { |f|
f.start_with?('coverage') || f =~ /(rbc|swp|~|lock)$/
}.join("\n")
m.close
end
desc 'Builds the gem file'
task build: ['manifest'] do
system 'gem build bibtex-ruby.gemspec'
end
desc 'Pushes the gem file to rubygems.org'
task release: ['build'] do
system %(git tag "#{BibTeX::Version::STRING}")
system 'git push --tags'
system "gem push bibtex-ruby-#{BibTeX::Version::STRING}.gem"
end
CLEAN.include('lib/bibtex/parser.rb')
CLEAN.include('lib/bibtex/parser.output')
CLEAN.include('lib/bibtex/name_parser.rb')
CLEAN.include('lib/bibtex/name_parser.output')
CLEAN.include('*.gem')