Permalink
Browse files

rakefile to run foodcritic tests

  • Loading branch information...
1 parent f051bcb commit dff24ebb7503522d620023c9b0eefec9bfedc8e0 Jonathon W. Marshall committed Oct 30, 2013
Showing with 27 additions and 0 deletions.
  1. +27 −0 Rakefile
View
27 Rakefile
@@ -0,0 +1,27 @@
+#!/usr/bin/env rake
+
+desc "Runs foodcritic linter"
+task :foodcritic do
+ if Gem::Version.new("1.9.2") <= Gem::Version.new(RUBY_VERSION.dup)
+ sandbox = File.join(File.dirname(__FILE__), %w{tmp foodcritic cookbook})
+ prepare_foodcritic_sandbox(sandbox)
+
+ sh "foodcritic --epic-fail any #{File.dirname(sandbox)}"
+ else
+ puts "WARN: foodcritic run is skipped as Ruby #{RUBY_VERSION} is < 1.9.2."
+ end
+end
+
+task :default => 'foodcritic'
+
+private
+
+def prepare_foodcritic_sandbox(sandbox)
+ files = %w{*.md *.rb attributes definitions files libraries providers
+recipes resources templates}
+
+ rm_rf sandbox
+ mkdir_p sandbox
+ cp_r Dir.glob("{#{files.join(',')}}"), sandbox
+ puts "\n\n"
+end

0 comments on commit dff24eb

Please sign in to comment.