-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
55 lines (45 loc) · 1.42 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
require 'bundler/gem_tasks'
require 'rake/extensiontask'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'pry'
require 'yard'
# Reference to the gemspec used by rake-compiler and the package taks.
GEMSPEC = Gem::Specification.find_by_name('yabfi')
desc 'Compile the C virtual machine'
Rake::ExtensionTask.new do |task|
task.name = 'vm'
task.ext_dir = 'ext/yabfi'
task.lib_dir = 'lib/yabfi'
task.gem_spec = GEMSPEC
end
desc 'Make package tasks for the gem'
Gem::PackageTask.new(GEMSPEC)
desc 'Run the specs'
RSpec::Core::RakeTask.new(spec: :compile)
desc 'Run the code quality metrics'
RuboCop::RakeTask.new(:quality) do |task|
task.patterns = GEMSPEC.files.grep(/((\.rb)|(Rakefile))\z/)
end
desc 'Generate gem documentation'
YARD::Rake::YardocTask.new(:doc)
desc 'Load the gem source code'
task environment: :compile do
lib = File.expand_path('lib', File.dirname(__FILE__))
$LOAD_PATH << lib unless $LOAD_PATH.include?(lib)
require 'yabfi'
end
desc 'Start a pry shell in the context of the YABFI module'
task shell: :environment do
Pry.start(YABFI)
end
desc 'Clean the files generated by other tasks'
task blank: :clobber do
%w(coverage doc pkg tmp).each do |partial|
path = File.expand_path(partial, File.dirname(__FILE__))
next unless File.exist?(path)
FileUtils.rm_rf(path)
end
end
desc 'Run the specs, quality metrics, and documentation tasks'
task default: [:blank, :spec, :quality, :doc]