-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
55 lines (44 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
#!/usr/bin/env rake
#require 'rake/clean'
#CLOBBER.include("foodcritic")
#task "cheftest" => ["init", "compile"]
BASE_DIR = File.dirname(__FILE__)
TARGET_COOKBOOKS_NAME = [ "rbenv", "test_recipe" ]
TARGET_COOKBOOKS_PATH = "#{File.dirname(__FILE__)}/{#{TARGET_COOKBOOKS_NAME.join(',')}}"
desc "chefspec to target cookbooks"
task :rspec do |t|
puts "-- #{t.name} running -- "
if Gem::Version.new("1.9.2") <= Gem::Version.new(RUBY_VERSION.dup)
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:rspec) do |t|
spec_files_path = "#{TARGET_COOKBOOKS_PATH}/spec/*_spec.rb"
t.pattern = spec_files_path
t.rspec_opts = ['-c']
end
end
end
desc "Runs foodcritic linter"
task :foodcritic do |t|
puts "-- #{t.name} running -- "
if Gem::Version.new("1.9.2") <= Gem::Version.new(RUBY_VERSION.dup)
TARGET_COOKBOOKS_NAME.each do |cookbook|
file_path = File.join(BASE_DIR, cookbook)
sh "foodcritic --epic-fail any #{file_path}"
end
else
puts "WARN: foodcritic run is skipped as Ruby #{RUBY_VERSION} is < 1.9.2."
end
end
desc "detect awful code"
task :flay do |t|
puts "-- #{t.name} running -- "
require "rake/tasklib"
require "flay"
require "flay_task"
puts BASE_DIR
threshold = 25
flay = Flay.new({:fuzzy => false, :verbose => false, :mass => threshold})
flay.process(*Flay.expand_dirs_to_files([BASE_DIR]))
flay.report
end
task :default => [:rspec, :foodcritic, :flay]