rake-foodcritic 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Rake::Foodcritic
2
2
 
3
- TODO: Write a gem description
3
+ Rake task for chef cookbooks
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,13 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ load rake-foodcritic in your Rakefile:
22
+
23
+ require 'rake-foodcritic'
24
+
25
+ And then, run rake-task *chef:foodcritic*
26
+
27
+ $ rake chef:foodcritic
22
28
 
23
29
  ## Contributing
24
30
 
@@ -1,5 +1,5 @@
1
1
  module Rake
2
2
  module Foodcritic
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -1,29 +1,26 @@
1
1
  require "rake-foodcritic/version"
2
+ require "foodcritic"
2
3
 
3
4
  namespace :chef do
4
5
  desc "Run foodcritic"
5
6
  task :foodcritic do
6
7
  if Gem::Version.new("1.9.2") <= Gem::Version.new(RUBY_VERSION.dup)
7
- path = File.join(%w{tmp foodcritic})
8
- foodcritic_sandbox(path) do
9
- sh "foodcritic --epic-fail any #{path}"
8
+ print "Running foodcritic ... "
9
+ if File.exists?('cookbooks')
10
+ result = FoodCritic::Linter.new.check 'cookbooks', {}
11
+ else
12
+ result = FoodCritic::Linter.new.check '.', {}
13
+ end
14
+
15
+ if result.failed? or result.warnings.size > 0
16
+ puts "FAILED"
17
+ puts result
18
+ fail
19
+ else
20
+ puts "OK"
10
21
  end
11
22
  else
12
23
  puts "WARNING: Skipped running foodcritic. Ruby 1.9.2 or higher required"
13
24
  end
14
25
  end
15
-
16
- def foodcritic_sandbox(path)
17
- files = %w{*.md *.rb attributes definitions files
18
- libraries providers recipes resources templates}
19
-
20
- begin
21
- rm_rf path
22
- mkdir_p path
23
- cp_r Dir.glob("{#{files.join(',')}}"), path
24
- yield
25
- ensure
26
- rm_rf path
27
- end
28
- end
29
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-foodcritic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-11 00:00:00.000000000 Z
12
+ date: 2013-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake