-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathRakefile
27 lines (25 loc) · 822 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
desc 'check literal recipe includes'
task :validate_literal_includes do
Dir['**/*.rb'].each do |file|
recipes = File.read(file).scan(/(?:include_recipe\s+(['"])([\w:]+)\1)/).reject {|candidate| candidate.last.include?('#{}')}.map(&:last)
recipes.each do |recipe|
recipe_file = recipe.include?('::') ? recipe.sub('::', '/recipes/') + '.rb' : recipe + '/recipes/default.rb'
unless File.exists?(recipe_file)
puts "#{file} includes missing recipe #{recipe}"
exit 1
end
end
end
end
desc 'check syntax of ruby files'
task :validate_syntax do
Dir['**/*.rb'].each do |file|
`ruby -c #{file}`
if $?.exitstatus != 0
puts "syntax error in #{file}"
exit 1
end
end
end
desc 'run all checks'
task :default => [:validate_literal_includes, :validate_syntax]