Skip to content

Instantly share code, notes, and snippets.

@nshenry03
Forked from jtimberman/Thorfile
Last active December 30, 2015 02:09
Show Gist options
  • Save nshenry03/7761275 to your computer and use it in GitHub Desktop.
Save nshenry03/7761275 to your computer and use it in GitHub Desktop.
# encoding: utf-8
require 'bundler'
require 'bundler/setup'
require 'thor/foodcritic'
require 'berkshelf/thor'
begin
require 'kitchen/thor_tasks'
Kitchen::ThorTasks.new
rescue LoadError
puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI']
end
class Cookbook < Thor
include Thor::Actions
require 'mixlib/shellout'
desc 'foodcritic', 'run foodcritic'
def foodcritic
f = Mixlib::ShellOut.new('foodcritic .')
f.run_command
raise "Foodcritic failed: " + f.stderr if f.exitstatus > 0
end
desc 'syntax', 'check syntax'
def syntax
s = Mixlib::ShellOut.new("knife cookbook test -o .. #{File.basename(Dir.pwd)}")
s.run_command
raise "Syntax check failed: " + s.stderr if s.exitstatus > 0
end
require 'tailor/cli'
desc "style", "check style"
def style
::Tailor::Logger.log = false
tailor = ::Tailor::CLI.new []
tailor.execute!
end
desc 'test', 'Run all the tests'
def test
syntax
foodcritic
lint
invoke 'kitchen:all'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment