rails_best_practices 0.3.21 → 0.3.22
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rails_best_practices.rb +1 -1
- data/lib/rails_best_practices/checks/check.rb +5 -5
- data/lib/rails_best_practices/core/runner.rb +2 -2
- data/rails_best_practices.gemspec +19 -19
- metadata +19 -19
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.22
|
data/lib/rails_best_practices.rb
CHANGED
@@ -8,7 +8,7 @@ module RailsBestPractices
|
|
8
8
|
files = expand_dirs_to_files(dir)
|
9
9
|
files = model_first_sort(files)
|
10
10
|
files = add_duplicate_migrations(files)
|
11
|
-
['vendor', 'spec', 'test', 'stories'].each do |pattern|
|
11
|
+
['vendor', 'spec', 'test', 'stories', 'features'].each do |pattern|
|
12
12
|
files = ignore_files(files, "#{pattern}/") unless options[pattern]
|
13
13
|
end
|
14
14
|
files
|
@@ -5,11 +5,11 @@ module RailsBestPractices
|
|
5
5
|
class Check
|
6
6
|
NODE_TYPES = [:call, :defn, :defs, :if, :unless, :class, :lasgn, :ivar, :block]
|
7
7
|
|
8
|
-
CONTROLLER_FILES = /_controller
|
9
|
-
MIGRATION_FILES = /db\/migrate
|
10
|
-
MODLE_FILES = /models
|
11
|
-
VIEW_FILES = /views
|
12
|
-
PARTIAL_VIEW_FILES = /views\/.*\/_
|
8
|
+
CONTROLLER_FILES = /_controller\.rb$/
|
9
|
+
MIGRATION_FILES = /db\/migrate\/.*\.rb/
|
10
|
+
MODLE_FILES = /models\/.*\.rb/
|
11
|
+
VIEW_FILES = /views\/.*\.(erb|haml)/
|
12
|
+
PARTIAL_VIEW_FILES = /views\/.*\/_.*\.(erb|haml)/
|
13
13
|
|
14
14
|
attr_reader :errors
|
15
15
|
|
@@ -22,10 +22,10 @@ module RailsBestPractices
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def check(filename, content)
|
25
|
-
if filename =~
|
25
|
+
if filename =~ /.*\.erb/
|
26
26
|
content = ERB.new(content).src
|
27
27
|
end
|
28
|
-
if filename =~
|
28
|
+
if filename =~ /.*\.haml/
|
29
29
|
require 'haml'
|
30
30
|
content = Haml::Engine.new(content).precompiled
|
31
31
|
# remove \xxx characters
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rails_best_practices}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.22"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Richard Huang"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-07-21}
|
13
13
|
s.default_executable = %q{rails_best_practices}
|
14
14
|
s.description = %q{check rails files according to ihower's presentation 'rails best practices'}
|
15
15
|
s.email = %q{flyerhzm@gmail.com}
|
@@ -91,28 +91,28 @@ Gem::Specification.new do |s|
|
|
91
91
|
s.rubygems_version = %q{1.3.6}
|
92
92
|
s.summary = %q{check rails files according to ihower's presentation 'rails best practices'}
|
93
93
|
s.test_files = [
|
94
|
-
"spec/rails_best_practices/checks/
|
95
|
-
"spec/rails_best_practices/checks/move_model_logic_into_model_check_spec.rb",
|
96
|
-
"spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb",
|
97
|
-
"spec/rails_best_practices/checks/move_code_into_controller_check_spec.rb",
|
98
|
-
"spec/rails_best_practices/checks/use_observer_check_spec.rb",
|
99
|
-
"spec/rails_best_practices/checks/overuse_route_customizations_check_spec.rb",
|
100
|
-
"spec/rails_best_practices/checks/nested_model_forms_check_spec.rb",
|
94
|
+
"spec/rails_best_practices/checks/add_model_virtual_attribute_check_spec.rb",
|
101
95
|
"spec/rails_best_practices/checks/always_add_db_index_check_spec.rb",
|
102
|
-
"spec/rails_best_practices/checks/
|
103
|
-
"spec/rails_best_practices/checks/
|
96
|
+
"spec/rails_best_practices/checks/isolate_seed_data_check_spec.rb",
|
97
|
+
"spec/rails_best_practices/checks/keep_finders_on_their_own_model_check_spec.rb",
|
104
98
|
"spec/rails_best_practices/checks/law_of_demeter_check_spec.rb",
|
105
|
-
"spec/rails_best_practices/checks/
|
106
|
-
"spec/rails_best_practices/checks/
|
107
|
-
"spec/rails_best_practices/checks/
|
99
|
+
"spec/rails_best_practices/checks/many_to_many_collection_check_spec.rb",
|
100
|
+
"spec/rails_best_practices/checks/move_code_into_controller_check_spec.rb",
|
101
|
+
"spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb",
|
102
|
+
"spec/rails_best_practices/checks/move_code_into_model_check_spec.rb",
|
108
103
|
"spec/rails_best_practices/checks/move_finder_to_named_scope_check_spec.rb",
|
109
|
-
"spec/rails_best_practices/checks/
|
110
|
-
"spec/rails_best_practices/checks/
|
104
|
+
"spec/rails_best_practices/checks/move_model_logic_into_model_check_spec.rb",
|
105
|
+
"spec/rails_best_practices/checks/needless_deep_nesting_check_spec.rb",
|
106
|
+
"spec/rails_best_practices/checks/nested_model_forms_check_spec.rb",
|
107
|
+
"spec/rails_best_practices/checks/not_use_default_route_check_spec.rb",
|
108
|
+
"spec/rails_best_practices/checks/overuse_route_customizations_check_spec.rb",
|
109
|
+
"spec/rails_best_practices/checks/replace_complex_creation_with_factory_method_check_spec.rb",
|
111
110
|
"spec/rails_best_practices/checks/replace_instance_variable_with_local_variable_check_spec.rb",
|
111
|
+
"spec/rails_best_practices/checks/use_before_filter_check_spec.rb",
|
112
112
|
"spec/rails_best_practices/checks/use_model_association_check_spec.rb",
|
113
|
-
"spec/rails_best_practices/checks/
|
114
|
-
"spec/rails_best_practices/checks/
|
115
|
-
"spec/rails_best_practices/checks/
|
113
|
+
"spec/rails_best_practices/checks/use_model_callback_check_spec.rb",
|
114
|
+
"spec/rails_best_practices/checks/use_observer_check_spec.rb",
|
115
|
+
"spec/rails_best_practices/checks/use_scope_access_check_spec.rb",
|
116
116
|
"spec/spec_helper.rb"
|
117
117
|
]
|
118
118
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 22
|
9
|
+
version: 0.3.22
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Richard Huang
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-07-21 00:00:00 +08:00
|
18
18
|
default_executable: rails_best_practices
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -151,26 +151,26 @@ signing_key:
|
|
151
151
|
specification_version: 3
|
152
152
|
summary: check rails files according to ihower's presentation 'rails best practices'
|
153
153
|
test_files:
|
154
|
+
- spec/rails_best_practices/checks/add_model_virtual_attribute_check_spec.rb
|
155
|
+
- spec/rails_best_practices/checks/always_add_db_index_check_spec.rb
|
154
156
|
- spec/rails_best_practices/checks/isolate_seed_data_check_spec.rb
|
155
|
-
- spec/rails_best_practices/checks/
|
156
|
-
- spec/rails_best_practices/checks/
|
157
|
+
- spec/rails_best_practices/checks/keep_finders_on_their_own_model_check_spec.rb
|
158
|
+
- spec/rails_best_practices/checks/law_of_demeter_check_spec.rb
|
159
|
+
- spec/rails_best_practices/checks/many_to_many_collection_check_spec.rb
|
157
160
|
- spec/rails_best_practices/checks/move_code_into_controller_check_spec.rb
|
158
|
-
- spec/rails_best_practices/checks/
|
159
|
-
- spec/rails_best_practices/checks/
|
161
|
+
- spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
|
162
|
+
- spec/rails_best_practices/checks/move_code_into_model_check_spec.rb
|
163
|
+
- spec/rails_best_practices/checks/move_finder_to_named_scope_check_spec.rb
|
164
|
+
- spec/rails_best_practices/checks/move_model_logic_into_model_check_spec.rb
|
165
|
+
- spec/rails_best_practices/checks/needless_deep_nesting_check_spec.rb
|
160
166
|
- spec/rails_best_practices/checks/nested_model_forms_check_spec.rb
|
161
|
-
- spec/rails_best_practices/checks/always_add_db_index_check_spec.rb
|
162
|
-
- spec/rails_best_practices/checks/many_to_many_collection_check_spec.rb
|
163
|
-
- spec/rails_best_practices/checks/use_before_filter_check_spec.rb
|
164
|
-
- spec/rails_best_practices/checks/law_of_demeter_check_spec.rb
|
165
|
-
- spec/rails_best_practices/checks/use_scope_access_check_spec.rb
|
166
|
-
- spec/rails_best_practices/checks/replace_complex_creation_with_factory_method_check_spec.rb
|
167
167
|
- spec/rails_best_practices/checks/not_use_default_route_check_spec.rb
|
168
|
-
- spec/rails_best_practices/checks/
|
169
|
-
- spec/rails_best_practices/checks/
|
170
|
-
- spec/rails_best_practices/checks/add_model_virtual_attribute_check_spec.rb
|
168
|
+
- spec/rails_best_practices/checks/overuse_route_customizations_check_spec.rb
|
169
|
+
- spec/rails_best_practices/checks/replace_complex_creation_with_factory_method_check_spec.rb
|
171
170
|
- spec/rails_best_practices/checks/replace_instance_variable_with_local_variable_check_spec.rb
|
171
|
+
- spec/rails_best_practices/checks/use_before_filter_check_spec.rb
|
172
172
|
- spec/rails_best_practices/checks/use_model_association_check_spec.rb
|
173
|
-
- spec/rails_best_practices/checks/
|
174
|
-
- spec/rails_best_practices/checks/
|
175
|
-
- spec/rails_best_practices/checks/
|
173
|
+
- spec/rails_best_practices/checks/use_model_callback_check_spec.rb
|
174
|
+
- spec/rails_best_practices/checks/use_observer_check_spec.rb
|
175
|
+
- spec/rails_best_practices/checks/use_scope_access_check_spec.rb
|
176
176
|
- spec/spec_helper.rb
|