guard-rails_best_practices 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'guard', '>= 0.8.4'
4
+ gem 'rails_best_practices', '>= 1.1.0'
5
+
6
+ # Specify your gem's dependencies in guard-rails_best_practices.gemspec
7
+ gemspec
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Guard - Rails Best Practices
2
+
3
+ BDD your [Rails Best Practices](http://rails-bestpractices.com/) checklist alongside your specs
4
+ with [Guard](https://github.com/guard/guard).
5
+
6
+ By adding your own checklists, this can be a great way to enforce those code style documents that everyone on your
7
+ team has forgotten!
8
+
9
+ ## Install
10
+
11
+ In your Rails 3.0+ application, add the `guard`, `rails_best_practices`, and `guard-rails_best_practices` gems to your `Gemfile`:
12
+
13
+ group :development do
14
+ gem 'rails_best_practices'
15
+ gem 'guard'
16
+ gem 'guard-rails_best_practices'
17
+ end
18
+
19
+ Add guard definitions to your `Guardfile` by running:
20
+
21
+ guard init rails_best_practices
22
+
23
+ Guard will now inform you of Rails Best Practices warnings.
24
+
25
+ ## Options
26
+
27
+ These options are available (with the following defaults):
28
+
29
+ options[:vendor] = true # Include vendor/
30
+ options[:spec] = true # Include spec/
31
+ options[:test] = true # Include test/
32
+ options[:features] = true # Include features/
33
+ options[:exclude] = '' # Exclude [PATTERN]
34
+ options[:run_at_start] = true # Run checklist when guard starts
35
+
36
+ See https://github.com/flyerhzm/rails_best_practices for details.
37
+
38
+ It is recommended that you run `rails_best_practices -g` to generate a `rails_best_practices.yml` file for your application,
39
+ so you can tune the checklists to your own unique tastes.
40
+
41
+ You can also extend `rails_best_practices` by [writing your own checklists](https://github.com/flyerhzm/rails_best_practices/wiki/How-to-write-your-own-check-list) .
42
+
43
+ ## Authors
44
+
45
+ [Logan Koester](http://github.com/logankoester)
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :default => :build
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "guard/guard-rails_best_practices/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "guard-rails_best_practices"
7
+ s.version = Guard::Rails_best_practices::VERSION
8
+ s.authors = ["Logan Koester"]
9
+ s.email = ["lkoester@agoragames.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Guard for rails_best_practices, a code metric tool to check the quality of rails code.}
12
+ s.description = %q{Guard for rails_best_practices, a code metric tool to check the quality of rails code.}
13
+
14
+ s.rubyforge_project = "guard-rails_best_practices"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ s.add_runtime_dependency "rails_best_practices"
23
+ s.add_runtime_dependency "guard"
24
+ end
@@ -0,0 +1,3 @@
1
+ guard 'rails_best_practices' do
2
+ watch(%r{^app/(.+)\.rb$})
3
+ end
@@ -0,0 +1,5 @@
1
+ module Guard
2
+ class Rails_best_practices
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,65 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+ require File.join(File.dirname(__FILE__), "guard-rails_best_practices/version")
4
+
5
+ module Guard
6
+ class Rails_best_practices < Guard
7
+ autoload :Notifier, 'guard/annotate/notifier'
8
+
9
+ def initialize(watchers = [], options = {})
10
+ super
11
+ options[:vendor] = true if options[:vendor].nil?
12
+ options[:spec] = true if options[:spec].nil?
13
+ options[:test] = true if options[:test].nil?
14
+ options[:features] = true if options[:features].nil?
15
+ options[:exclude] = '' if options[:exclude].nil?
16
+
17
+ options[:run_at_start] = true if options[:run_at_start].nil?
18
+ end
19
+
20
+ def start
21
+ run_bestpractices if options[:run_at_start]
22
+ end
23
+
24
+ def stop
25
+ true
26
+ end
27
+
28
+ def reload
29
+ run_bestpractices
30
+ end
31
+
32
+ def run_all
33
+ run_bestpractices
34
+ end
35
+
36
+ def run_on_change(paths)
37
+ run_bestpractices
38
+ end
39
+
40
+ def run_on_deletion(paths)
41
+ end
42
+
43
+ def notify?
44
+ !!options[:notify]
45
+ end
46
+
47
+ private
48
+ def run_bestpractices
49
+ UI.info 'Running Rails Best Practices checklist', :reset => true
50
+ started_at = Time.now
51
+
52
+ cmd = 'rails_best_practices'
53
+ cmd += ' --vendor' if options[:vendor]
54
+ cmd += ' --spec' if options[:spec]
55
+ cmd += ' --test' if options[:test]
56
+ cmd += ' --features' if options[:features]
57
+ cmd += " --exclude #{options[:exclude]}" unless options[:exclude].blank?
58
+ @result = system(cmd)
59
+
60
+ Notifier::notify( @result, Time.now - started_at ) if notify?
61
+ @result
62
+ end
63
+
64
+ end
65
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-rails_best_practices
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Logan Koester
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-06 00:00:00.000000000 -04:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails_best_practices
17
+ requirement: &14030460 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *14030460
26
+ - !ruby/object:Gem::Dependency
27
+ name: guard
28
+ requirement: &14029980 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *14029980
37
+ description: Guard for rails_best_practices, a code metric tool to check the quality
38
+ of rails code.
39
+ email:
40
+ - lkoester@agoragames.com
41
+ executables: []
42
+ extensions: []
43
+ extra_rdoc_files: []
44
+ files:
45
+ - .gitignore
46
+ - Gemfile
47
+ - README.md
48
+ - Rakefile
49
+ - guard-rails_best_practices.gemspec
50
+ - lib/guard/guard-rails_best_practices/templates/Guardfile
51
+ - lib/guard/guard-rails_best_practices/version.rb
52
+ - lib/guard/rails_best_practices.rb
53
+ has_rdoc: true
54
+ homepage: ''
55
+ licenses: []
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project: guard-rails_best_practices
74
+ rubygems_version: 1.6.2
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: Guard for rails_best_practices, a code metric tool to check the quality of
78
+ rails code.
79
+ test_files: []