-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
40 lines (32 loc) · 877 Bytes
/
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
require "bundler/gem_tasks"
require 'rspec/core/rake_task'
desc 'Compile racc parser.y'
task :compile => 'lib/exp/parser.rb'
desc 'Test'
task :test => :spec
desc 'Run specs'
task :spec => :compile
task :default => :spec
rule '.rb' => '.y' do |t|
sh "racc -l -o #{t.name} #{t.source}"
end
RSpec::Core::RakeTask.new do |task|
task.rspec_opts = ["-c", "-f documentation", "-r ./spec/helper.rb"]
task.pattern = 'spec/**/*_spec.rb'
end
desc "Open an interactive session preloaded with this gem's code"
task :console => :compile do
if gem_available?("pry")
sh "pry -I lib -r exp.rb"
else
sh "irb -rubygems -I lib -r exp.rb"
end
end
# Determins if a gem is available at the current runtime
def gem_available?(name)
Gem::Specification.find_by_name(name)
rescue Gem::LoadError
false
rescue
Gem.available?(name) #for backwards compatibility
end