Skip to content
Browse files

Adding TravisCI support for foodcritic

  • Loading branch information...
1 parent ccfa040 commit 3e9268e8825dc970eee350029cf65410668d7409 @mdxp mdxp committed
Showing with 44 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +6 −0 .travis.yml
  3. +2 −0 README.md
  4. +29 −0 Rakefile
  5. +5 −0 spec/Gemfile
View
2 .gitignore
@@ -0,0 +1,2 @@
+Gemfile.lock
+tmp/
View
6 .travis.yml
@@ -0,0 +1,6 @@
+language: ruby
+gemfile:
+- spec/Gemfile
+rvm:
+- 1.9.3
+script: bundle exec rake foodcritic
View
2 README.md
@@ -1,3 +1,5 @@
+# <a name="title"></a> drupal-cookbook [![Build Status](https://secure.travis-ci.org/mdxp/drupal-cookbook.png)](http://travis-ci.org/mdxp/drupal-cookbook)
+
Description
===========
View
29 Rakefile
@@ -0,0 +1,29 @@
+#!/usr/bin/env rake
+
+@cookbook = "drupal"
+
+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 --tags ~FC015 --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 providers
+recipes resources templates}
+
+ rm_rf sandbox
+ mkdir_p sandbox
+ cp_r Dir.glob("{#{files.join(',')}}"), sandbox
+ puts "\n\n"
+end
View
5 spec/Gemfile
@@ -0,0 +1,5 @@
+source "https://rubygems.org"
+
+gem 'rake'
+gem 'foodcritic'
+

0 comments on commit 3e9268e

Please sign in to comment.
Something went wrong with that request. Please try again.