Skip to content
This repository has been archived by the owner on Apr 16, 2020. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
reset committed Jun 23, 2012
0 parents commit cb69f71
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.gem
.bundle
Gemfile.lock
pkg/*
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source "http://rubygems.org"

gemspec
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Thor FoodCritic

FoodCritic Thor tasks for your Cookbook projects

# Installation

gem install thor-foodcritic

# Usage

To add the FoodCritic tasks to any Thorfile just require this gem

require 'thor/foodcritic'

And then get a list of your thor tasks

$ thor list

foodcritic
----------
thor foodcritic:lint # Run a lint test against the Cookbook in your current working directory.

Run the lint task to get a review

$ thor foodcritic:lint

FC002: Avoid string interpolation where not required: ...
FC003: Check whether you are running with chef server before using server-specific features: ...
FC011: Missing README in markdown format: ...

If any epic failure tags are specified with the `-f` flag, Thor will exit with a status code of `100`.

# License and Author

Author:: Jamie Winsor (<jamie@vialstudios.com>)

Copyright 2012, Jamie Winsor

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
26 changes: 26 additions & 0 deletions Thorfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# encoding: utf-8
$:.push File.expand_path("../lib", __FILE__)

require 'bundler'
require 'bundler/setup'
require 'thor/rake_compat'

class Default < Thor
include Thor::RakeCompat
Bundler::GemHelper.install_tasks

desc "build", "Build berkshelf-#{ThorFoodCritic::VERSION}.gem into the pkg directory"
def build
Rake::Task["build"].execute
end

desc "install", "Build and install berkshelf-#{ThorFoodCritic::VERSION}.gem into system gems"
def install
Rake::Task["install"].execute
end

desc "release", "Create tag v#{ThorFoodCritic::VERSION} and build and push berkshelf-#{ThorFoodCritic::VERSION}.gem to Rubygems"
def release
Rake::Task["release"].execute
end
end
41 changes: 41 additions & 0 deletions lib/thor-foodcritic.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
require 'thor-foodcritic/version'
require 'foodcritic'

module ThorFoodCritic
class Tasks < Thor
namespace "foodcritic"

method_option :tags,
type: :array,
aliases: "-t",
desc: "Only check against rules with the specified tags.",
default: ["~FC001"]
method_option :include_rules,
type: :array,
aliases: "-I",
desc: "Additional rule file path(s) to load.",
default: Array.new
method_option :fail_tags,
type: :array,
aliases: "-f",
desc: "Fail the build if any of the specified tags are matched.",
default: Array.new
method_option :exclude_paths,
type: :array,
aliases: "-e",
desc: "Paths to exclude when running tests.",
default: ['test/**/*', 'spec/**/*', 'features/**/*']
desc "lint", "Run a lint test against the Cookbook in your current working directory."
def lint
review = ::FoodCritic::Linter.new.check(Dir.pwd, options)
say(review, :red)
exit_with_review(review)
end

private

def exit_with_review(review)
review.failed? ? exit(100) : exit(0)
end
end
end
3 changes: 3 additions & 0 deletions lib/thor-foodcritic/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module ThorFoodCritic
VERSION = "0.1.0"
end
1 change: 1 addition & 0 deletions lib/thor/foodcritic.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'thor-foodcritic'
19 changes: 19 additions & 0 deletions thor-foodcritic.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "thor-foodcritic/version"

Gem::Specification.new do |s|
s.name = "thor-foodcritic"
s.version = ThorFoodCritic::VERSION
s.authors = ["Jamie Winsor"]
s.email = ["jamie@vialstudios.com"]
s.homepage = "https://github.com/reset/thor-foodcritic"
s.description = %q{FoodCritic Thor tasks for your Cookbook projects}
s.summary = s.description
s.files = `git ls-files`.split("\n")
s.require_paths = ["lib"]
s.required_ruby_version = ">= 1.9.1"

s.add_runtime_dependency 'thor'
s.add_runtime_dependency 'foodcritic'
end

0 comments on commit cb69f71

Please sign in to comment.