rails_best_practices 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/README.textile +5 -1
  2. data/lib/rails_best_practices.rb +1 -0
  3. data/lib/rails_best_practices/checks.rb +2 -0
  4. data/lib/rails_best_practices/checks/add_model_virtual_attribute_check.rb +1 -0
  5. data/lib/rails_best_practices/checks/always_add_db_index_check.rb +1 -0
  6. data/lib/rails_best_practices/checks/check.rb +1 -0
  7. data/lib/rails_best_practices/checks/dry_bundler_in_capistrano_check.rb +27 -0
  8. data/lib/rails_best_practices/checks/isolate_seed_data_check.rb +1 -0
  9. data/lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb +1 -0
  10. data/lib/rails_best_practices/checks/law_of_demeter_check.rb +1 -0
  11. data/lib/rails_best_practices/checks/move_code_into_controller_check.rb +1 -0
  12. data/lib/rails_best_practices/checks/move_code_into_helper_check.rb +1 -0
  13. data/lib/rails_best_practices/checks/move_code_into_model_check.rb +1 -0
  14. data/lib/rails_best_practices/checks/move_finder_to_named_scope_check.rb +1 -0
  15. data/lib/rails_best_practices/checks/move_model_logic_into_model_check.rb +1 -0
  16. data/lib/rails_best_practices/checks/needless_deep_nesting_check.rb +1 -0
  17. data/lib/rails_best_practices/checks/not_use_default_route_check.rb +1 -0
  18. data/lib/rails_best_practices/checks/overuse_route_customizations_check.rb +1 -0
  19. data/lib/rails_best_practices/checks/replace_complex_creation_with_factory_method_check.rb +1 -0
  20. data/lib/rails_best_practices/checks/replace_instance_variable_with_local_variable_check.rb +1 -0
  21. data/lib/rails_best_practices/checks/use_before_filter_check.rb +1 -0
  22. data/lib/rails_best_practices/checks/use_model_association_check.rb +1 -0
  23. data/lib/rails_best_practices/checks/use_observer_check.rb +1 -0
  24. data/lib/rails_best_practices/checks/use_scope_access_check.rb +1 -0
  25. data/lib/rails_best_practices/command.rb +1 -0
  26. data/lib/rails_best_practices/core.rb +1 -0
  27. data/lib/rails_best_practices/core/checking_visitor.rb +1 -0
  28. data/lib/rails_best_practices/core/core_ext.rb +1 -0
  29. data/lib/rails_best_practices/core/error.rb +1 -0
  30. data/lib/rails_best_practices/core/runner.rb +3 -0
  31. data/lib/rails_best_practices/core/visitable_sexp.rb +1 -0
  32. data/lib/rails_best_practices/version.rb +2 -1
  33. data/rails_best_practices.yml +1 -0
  34. metadata +4 -3
data/README.textile CHANGED
@@ -40,7 +40,7 @@ Wiki: "http://github.com/flyerhzm/rails_best_practices/wiki":http://github.com/f
40
40
  h2. Install
41
41
 
42
42
  <pre><code>
43
- sudo gem install rails_best_practices
43
+ gem install rails_best_practices
44
44
  </code></pre>
45
45
 
46
46
  *************************************************
@@ -84,6 +84,7 @@ MoveCodeIntoControllerCheck: { }
84
84
  MoveCodeIntoModelCheck: { }
85
85
  MoveCodeIntoHelperCheck: { array_count: 3 }
86
86
  ReplaceInstanceVariableWithLocalVariableCheck: { }
87
+ DryBundlerInCapistranoCheck: { }
87
88
  </code></pre>
88
89
 
89
90
  *************************************************
@@ -121,6 +122,9 @@ h2. Implementation
121
122
  ## Move code into helper
122
123
  ## Replace instance variable with local variable
123
124
 
125
+ * Deployment
126
+ ## Dry bundler in capistrano
127
+
124
128
  *************************************************
125
129
 
126
130
  h2. Contribute
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks'
2
3
  require 'rails_best_practices/core'
3
4
 
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/move_finder_to_named_scope_check'
2
3
  require 'rails_best_practices/checks/use_model_association_check'
3
4
  require 'rails_best_practices/checks/use_scope_access_check'
@@ -17,3 +18,4 @@ require 'rails_best_practices/checks/move_code_into_controller_check'
17
18
  require 'rails_best_practices/checks/move_code_into_model_check'
18
19
  require 'rails_best_practices/checks/move_code_into_helper_check'
19
20
  require 'rails_best_practices/checks/replace_instance_variable_with_local_variable_check'
21
+ require 'rails_best_practices/checks/dry_bundler_in_capistrano_check'
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/check'
2
3
 
3
4
  module RailsBestPractices
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/check'
2
3
 
3
4
  module RailsBestPractices
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/core/error'
2
3
 
3
4
  module RailsBestPractices
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+ require 'rails_best_practices/checks/check'
3
+
4
+ module RailsBestPractices
5
+ module Checks
6
+ # Check config/deploy.rb file to make sure using the bundler's capistrano recipe.
7
+ #
8
+ # Implementation: check the method call,
9
+ # if there is a call "namespace :bundler", then it should use bundler's capistrano recipe.
10
+ class DryBundlerInCapistranoCheck < Check
11
+
12
+ def interesting_nodes
13
+ [:call]
14
+ end
15
+
16
+ def interesting_file
17
+ 'config/deploy.rb'
18
+ end
19
+
20
+ def evaluate_start(node)
21
+ if :namespace == node.message and "bundler" == node.arguments.to_ruby_string
22
+ add_error "dry bundler in capistrano"
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/check'
2
3
 
3
4
  module RailsBestPractices
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/check'
2
3
 
3
4
  module RailsBestPractices
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/check'
2
3
 
3
4
  module RailsBestPractices
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/check'
2
3
 
3
4
  module RailsBestPractices
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/check'
2
3
 
3
4
  module RailsBestPractices
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/check'
2
3
 
3
4
  module RailsBestPractices
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/check'
2
3
 
3
4
  module RailsBestPractices
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/check'
2
3
 
3
4
  module RailsBestPractices
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/check'
2
3
 
3
4
  module RailsBestPractices
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/check'
2
3
 
3
4
  module RailsBestPractices
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/check'
2
3
 
3
4
  module RailsBestPractices
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/check'
2
3
 
3
4
  module RailsBestPractices
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/check'
2
3
 
3
4
  module RailsBestPractices
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/check'
2
3
 
3
4
  module RailsBestPractices
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/check'
2
3
 
3
4
  module RailsBestPractices
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/check'
2
3
 
3
4
  module RailsBestPractices
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/checks/check'
2
3
 
3
4
  module RailsBestPractices
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'optparse'
2
3
  require 'progressbar'
3
4
  require 'colored'
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rails_best_practices/core/core_ext'
2
3
  require 'rails_best_practices/core/runner'
3
4
  require 'rails_best_practices/core/checking_visitor'
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module RailsBestPractices
2
3
  module Core
3
4
  class CheckingVisitor
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Enumerable
2
3
  def dups
3
4
  inject({}) {|h,v| h[v]=h[v].to_i+1; h}.reject{|k,v| v==1}.keys
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module RailsBestPractices
2
3
  module Core
3
4
  class Error
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rubygems'
2
3
  require 'ruby_parser'
3
4
  require 'erb'
@@ -24,6 +25,8 @@ module RailsBestPractices
24
25
  def check(filename, content)
25
26
  if filename =~ /.*\.erb/
26
27
  content = ERB.new(content).src
28
+ # remove the coding line which exists in Ruby 1.9
29
+ content.gsub!(/#coding:US-ASCII\n/, '')
27
30
  end
28
31
  if filename =~ /.*\.haml/
29
32
  require 'haml'
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'rubygems'
2
3
  require 'sexp'
3
4
  require 'ruby2ruby'
@@ -1,4 +1,5 @@
1
+ # encoding: utf-8
1
2
  module RailsBestPractices
2
- VERSION = "0.4.2"
3
+ VERSION = "0.4.3"
3
4
  end
4
5
 
@@ -17,3 +17,4 @@ MoveCodeIntoControllerCheck: { }
17
17
  MoveCodeIntoModelCheck: { }
18
18
  MoveCodeIntoHelperCheck: { array_count: 3 }
19
19
  ReplaceInstanceVariableWithLocalVariableCheck: { }
20
+ DryBundlerInCapistranoCheck: { }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_best_practices
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 2
10
- version: 0.4.2
9
+ - 3
10
+ version: 0.4.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Richard Huang
@@ -138,6 +138,7 @@ files:
138
138
  - lib/rails_best_practices/checks/move_model_logic_into_model_check.rb
139
139
  - lib/rails_best_practices/checks/not_use_default_route_check.rb
140
140
  - lib/rails_best_practices/checks/replace_complex_creation_with_factory_method_check.rb
141
+ - lib/rails_best_practices/checks/dry_bundler_in_capistrano_check.rb
141
142
  - lib/rails_best_practices/checks/isolate_seed_data_check.rb
142
143
  - lib/rails_best_practices/checks/always_add_db_index_check.rb
143
144
  - lib/rails_best_practices/checks/replace_instance_variable_with_local_variable_check.rb