rails_best_practices 0.7.3 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rails_best_practices/core/check.rb +2 -1
- data/lib/rails_best_practices/core/model_associations.rb +1 -1
- data/lib/rails_best_practices/core/model_attributes.rb +25 -0
- data/lib/rails_best_practices/core/runner.rb +1 -1
- data/lib/rails_best_practices/core.rb +1 -0
- data/lib/rails_best_practices/prepares/model_prepare.rb +1 -1
- data/lib/rails_best_practices/prepares/schema_prepare.rb +44 -0
- data/lib/rails_best_practices/prepares.rb +2 -1
- data/lib/rails_best_practices/reviews/always_add_db_index_review.rb +1 -1
- data/lib/rails_best_practices/reviews/law_of_demeter_review.rb +18 -2
- data/lib/rails_best_practices/reviews/move_code_into_helper_review.rb +25 -25
- data/lib/rails_best_practices/reviews/review.rb +7 -0
- data/lib/rails_best_practices/reviews/use_query_attribute_review.rb +8 -13
- data/lib/rails_best_practices/version.rb +1 -1
- data/lib/rails_best_practices.rb +2 -2
- data/spec/rails_best_practices/core/model_associations_spec.rb +4 -4
- data/spec/rails_best_practices/core/model_attributes_spec.rb +22 -0
- data/spec/rails_best_practices/prepares/schema_prepare_spec.rb +28 -0
- data/spec/rails_best_practices/reviews/law_of_demeter_review_spec.rb +58 -1
- data/spec/rails_best_practices/reviews/use_query_attribute_review_spec.rb +21 -1
- metadata +33 -27
@@ -12,7 +12,8 @@ module RailsBestPractices
|
|
12
12
|
MAILER_FILES = /models\/.*mailer\.rb$|mailers\/.*mailer\.rb/
|
13
13
|
VIEW_FILES = /views\/.*\.(erb|haml)$/
|
14
14
|
PARTIAL_VIEW_FILES = /views\/.*\/_.*\.(erb|haml)$/
|
15
|
-
ROUTE_FILE = /config\/routes
|
15
|
+
ROUTE_FILE = /config\/routes\.rb/
|
16
|
+
SCHEMA_FILE = /db\/schema\.rb/
|
16
17
|
|
17
18
|
attr_reader :errors
|
18
19
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module RailsBestPractices
|
3
|
+
module Core
|
4
|
+
class ModelAttributes
|
5
|
+
def initialize
|
6
|
+
@attributes = {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def add_attribute(model_name, attribute_name, attribute_type)
|
10
|
+
@attributes[model_name] ||= {}
|
11
|
+
@attributes[model_name][attribute_name] = attribute_type
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_attribute_type(model_name, attribute_name)
|
15
|
+
@attributes[model_name] ||= {}
|
16
|
+
@attributes[model_name][attribute_name]
|
17
|
+
end
|
18
|
+
|
19
|
+
def is_attribute?(model_name, attribute_name)
|
20
|
+
@attributes[model_name] ||= {}
|
21
|
+
!!@attributes[model_name][attribute_name]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -148,7 +148,7 @@ module RailsBestPractices
|
|
148
148
|
|
149
149
|
# load all prepares.
|
150
150
|
def load_prepares
|
151
|
-
[
|
151
|
+
[Prepares::ModelPrepare.new, Prepares::MailerPrepare.new, Prepares::SchemaPrepare.new]
|
152
152
|
end
|
153
153
|
|
154
154
|
# load all reviews according to configuration.
|
@@ -7,5 +7,6 @@ require 'rails_best_practices/core/nil'
|
|
7
7
|
require 'rails_best_practices/core/visitable_sexp'
|
8
8
|
require 'rails_best_practices/core/models'
|
9
9
|
require 'rails_best_practices/core/model_associations'
|
10
|
+
require 'rails_best_practices/core/model_attributes'
|
10
11
|
|
11
12
|
require 'rails_best_practices/core_ext/enumerable'
|
@@ -25,7 +25,7 @@ module RailsBestPractices
|
|
25
25
|
@models << @last_klazz
|
26
26
|
end
|
27
27
|
|
28
|
-
# assign @model_associations to
|
28
|
+
# assign @model_associations to Prepares.model_associations.
|
29
29
|
def end_class(class_node)
|
30
30
|
Prepares.models = @models
|
31
31
|
Prepares.model_associations = @model_associations
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rails_best_practices/core/check'
|
3
|
+
|
4
|
+
module RailsBestPractices
|
5
|
+
module Prepares
|
6
|
+
# Remember the model attributes.
|
7
|
+
class SchemaPrepare < Core::Check
|
8
|
+
# all attribute types
|
9
|
+
ATTRIBUTE_TYPES = [:integer, :float, :boolean, :string, :text, :date, :time, :datetime, :binary]
|
10
|
+
|
11
|
+
def interesting_nodes
|
12
|
+
[:call]
|
13
|
+
end
|
14
|
+
|
15
|
+
def interesting_files
|
16
|
+
SCHEMA_FILE
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
@model_attributes = Core::ModelAttributes.new
|
21
|
+
end
|
22
|
+
|
23
|
+
# check call node to remember the model attributes.
|
24
|
+
def start_call(call_node)
|
25
|
+
case call_node.message
|
26
|
+
when :create_table
|
27
|
+
@last_klazz = call_node.arguments[1].to_s.classify
|
28
|
+
when *ATTRIBUTE_TYPES
|
29
|
+
attribute_name = call_node.arguments[1].to_s
|
30
|
+
@model_attributes.add_attribute(@last_klazz, attribute_name, call_node.message)
|
31
|
+
else
|
32
|
+
# nothing to do
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# assign @model_attributes to Prepares.model_attributes.
|
37
|
+
def end_call(call_node)
|
38
|
+
if :create_table == call_node.message
|
39
|
+
Prepares.model_attributes = @model_attributes
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'rails_best_practices/prepares/model_prepare'
|
3
3
|
require 'rails_best_practices/prepares/mailer_prepare'
|
4
|
+
require 'rails_best_practices/prepares/schema_prepare'
|
4
5
|
|
5
6
|
module RailsBestPractices
|
6
7
|
module Prepares
|
7
8
|
class <<self
|
8
|
-
attr_accessor :models, :model_associations, :mailer_names
|
9
|
+
attr_accessor :models, :model_associations, :model_attributes, :mailer_names
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -63,14 +63,30 @@ module RailsBestPractices
|
|
63
63
|
# and the message of subject of the call node is :user
|
64
64
|
def need_delegate?(node)
|
65
65
|
class_name = node.subject.subject.to_s(:remove_at => true).classify
|
66
|
-
|
67
|
-
association
|
66
|
+
association_name = node.subject.message.to_s
|
67
|
+
association = model_associations.get_association(class_name, association_name)
|
68
|
+
attribute_name = node.message.to_s
|
69
|
+
association && association_methods.include?(association[:meta]) &&
|
70
|
+
is_association_attribute?(association[:class_name], association_name, attribute_name)
|
68
71
|
end
|
69
72
|
|
70
73
|
# only check belongs_to and has_one association.
|
71
74
|
def association_methods
|
72
75
|
[:belongs_to, :has_one]
|
73
76
|
end
|
77
|
+
|
78
|
+
def is_association_attribute?(association_class, association_name, attribute_name)
|
79
|
+
if association_name =~ /able$/
|
80
|
+
models.each do |class_name|
|
81
|
+
if model_associations.is_association?(class_name, association_name.sub(/able$/, '')) ||
|
82
|
+
model_associations.is_association?(class_name, association_name.sub(/able$/, 's'))
|
83
|
+
return true if model_attributes.is_attribute?(class_name, attribute_name)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
else
|
87
|
+
model_attributes.is_attribute?(association_class, attribute_name)
|
88
|
+
end
|
89
|
+
end
|
74
90
|
end
|
75
91
|
end
|
76
92
|
end
|
@@ -47,32 +47,32 @@ module RailsBestPractices
|
|
47
47
|
|
48
48
|
private
|
49
49
|
# check if the arguments of options_for_select are complex.
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
50
|
+
#
|
51
|
+
# if the first argument is an array,
|
52
|
+
# and the size of array is greater than @array_count you defined,
|
53
|
+
# then it is complext, e.g.
|
54
|
+
#
|
55
|
+
# s(:call, nil, :options_for_select,
|
56
|
+
# s(:arglist,
|
57
|
+
# s(:array,
|
58
|
+
# s(:array,
|
59
|
+
# s(:call, nil, :t, s(:arglist, s(:lit, :draft))),
|
60
|
+
# s(:str, "draft")
|
61
|
+
# ),
|
62
|
+
# s(:array,
|
63
|
+
# s(:call, nil, :t, s(:arglist, s(:lit, :published))),
|
64
|
+
# s(:str, "published")
|
65
|
+
# )
|
66
|
+
# ),
|
67
|
+
# s(:call,
|
68
|
+
# s(:call, nil, :params, s(:arglist)),
|
69
|
+
# :[],
|
70
|
+
# s(:arglist, s(:lit, :default_state))
|
71
|
+
# )
|
72
|
+
# )
|
73
|
+
# )
|
74
74
|
def complex_select_options?(node)
|
75
|
-
:options_for_select == node.message
|
75
|
+
:options_for_select == node.message && :array == node.arguments[1].node_type && node.arguments[1].size > @array_count
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -74,6 +74,13 @@ module RailsBestPractices
|
|
74
74
|
@model_associations ||= Prepares.model_associations
|
75
75
|
end
|
76
76
|
|
77
|
+
# get the model attributes from Prepares.
|
78
|
+
#
|
79
|
+
# @return [Hash]
|
80
|
+
def model_attributes
|
81
|
+
@model_attributes ||= Prepares.model_attributes
|
82
|
+
end
|
83
|
+
|
77
84
|
# compare two sexp nodes' to_s.
|
78
85
|
#
|
79
86
|
# equal?(":test", :test) => true
|
@@ -65,7 +65,7 @@ module RailsBestPractices
|
|
65
65
|
# if the node contains two method calls, e.g. @user.login.nil?
|
66
66
|
#
|
67
67
|
# for the first call, the subject should be one of the class names and
|
68
|
-
# the message should
|
68
|
+
# the message should be one of the attribute name.
|
69
69
|
#
|
70
70
|
# for the second call, the message should be one of nil?, blank? or present? or
|
71
71
|
# it is compared with an empty string.
|
@@ -81,8 +81,8 @@ module RailsBestPractices
|
|
81
81
|
return false unless subject
|
82
82
|
message = node.subject.message
|
83
83
|
|
84
|
-
[:arglist] == node.subject.arguments && is_model?(subject) &&
|
85
|
-
|
84
|
+
[:arglist] == node.subject.arguments && is_model?(subject) && model_attribute?(subject, message) &&
|
85
|
+
(QUERY_METHODS.include?(node.message) || compare_with_empty_string?(node))
|
86
86
|
end
|
87
87
|
|
88
88
|
# check if the subject is one of the models.
|
@@ -95,23 +95,18 @@ module RailsBestPractices
|
|
95
95
|
models.include?(class_name)
|
96
96
|
end
|
97
97
|
|
98
|
-
# check if the subject and message is one of the model's
|
99
|
-
# the subject should match one of the class model name, and the message should match one of
|
98
|
+
# check if the subject and message is one of the model's attribute.
|
99
|
+
# the subject should match one of the class model name, and the message should match one of attribute name.
|
100
100
|
#
|
101
101
|
# subject, subject of call node, like
|
102
102
|
# s(:ivar, @user)
|
103
103
|
#
|
104
104
|
# message, message of call node, like
|
105
105
|
# :login
|
106
|
-
def
|
106
|
+
def model_attribute?(subject, message)
|
107
107
|
class_name = subject.to_s(:remove_at => true).classify
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
# check if the str is a pluralize string.
|
113
|
-
def pluralize?(str)
|
114
|
-
str.pluralize == str
|
108
|
+
attribute_type = model_attributes.get_attribute_type(class_name, message.to_s)
|
109
|
+
attribute_type && ![:integer, :float].include?(attribute_type)
|
115
110
|
end
|
116
111
|
|
117
112
|
# check if the node is with node type :call, node message :== and node arguments {:arglist, (:str, "")}
|
data/lib/rails_best_practices.rb
CHANGED
@@ -113,8 +113,8 @@ module RailsBestPractices
|
|
113
113
|
# @return [Array] all files for prepare process
|
114
114
|
def prepare_files
|
115
115
|
@prepare_files ||= begin
|
116
|
-
['models', 'mailers'].inject([]) { |files, name|
|
117
|
-
files += expand_dirs_to_files(File.join(@path,
|
116
|
+
['app/models', 'app/mailers', 'db/schema.rb'].inject([]) { |files, name|
|
117
|
+
files += expand_dirs_to_files(File.join(@path, name))
|
118
118
|
}.compact
|
119
119
|
end
|
120
120
|
end
|
@@ -15,8 +15,8 @@ describe RailsBestPractices::Core::ModelAssociations do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should check is model associatiosn" do
|
18
|
-
model_associations.
|
19
|
-
model_associations.
|
20
|
-
model_associations.
|
18
|
+
model_associations.is_association?("Project", "project_manager").should be_true
|
19
|
+
model_associations.is_association?("Project", "people").should be_true
|
20
|
+
model_associations.is_association?("Project", "unknown").should be_false
|
21
21
|
end
|
22
|
-
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RailsBestPractices::Core::ModelAttributes do
|
4
|
+
let(:model_attributes) { RailsBestPractices::Core::ModelAttributes.new }
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
model_attributes.add_attribute("Post", "title", :string)
|
8
|
+
model_attributes.add_attribute("Post", "user_id", :integer)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should get model attributes" do
|
12
|
+
model_attributes.get_attribute_type("Post", "title").should == :string
|
13
|
+
model_attributes.get_attribute_type("Post", "user_id").should == :integer
|
14
|
+
model_attributes.get_attribute_type("Post", "unknonw").should be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should check is model attributes" do
|
18
|
+
model_attributes.is_attribute?("Post", "title").should be_true
|
19
|
+
model_attributes.is_attribute?("Post", "user_id").should be_true
|
20
|
+
model_attributes.is_attribute?("Post", "unknonw").should be_false
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RailsBestPractices::Prepares::SchemaPrepare do
|
4
|
+
let(:runner) { RailsBestPractices::Core::Runner.new(:prepares => RailsBestPractices::Prepares::SchemaPrepare.new) }
|
5
|
+
|
6
|
+
it "should parse model attributes" do
|
7
|
+
content =<<-EOF
|
8
|
+
ActiveRecord::Schema.define(:version => 20110319172136) do
|
9
|
+
create_table "posts", :force => true do |t|
|
10
|
+
t.string "title"
|
11
|
+
t.text "body", :limit => 16777215
|
12
|
+
t.datetime "created_at"
|
13
|
+
t.integer "user_id"
|
14
|
+
t.integer "comments_count", :default => 0
|
15
|
+
t.boolean "published", :default => false, :null => false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
EOF
|
19
|
+
runner.prepare("db/schema.rb", content)
|
20
|
+
model_attributes = RailsBestPractices::Prepares.model_attributes
|
21
|
+
model_attributes.get_attribute_type("Post", "title").should == :string
|
22
|
+
model_attributes.get_attribute_type("Post", "body").should == :text
|
23
|
+
model_attributes.get_attribute_type("Post", "created_at").should == :datetime
|
24
|
+
model_attributes.get_attribute_type("Post", "user_id").should == :integer
|
25
|
+
model_attributes.get_attribute_type("Post", "comments_count").should == :integer
|
26
|
+
model_attributes.get_attribute_type("Post", "published").should == :boolean
|
27
|
+
end
|
28
|
+
end
|
@@ -4,7 +4,7 @@ describe RailsBestPractices::Reviews::LawOfDemeterReview do
|
|
4
4
|
|
5
5
|
let(:runner) {
|
6
6
|
RailsBestPractices::Core::Runner.new(
|
7
|
-
:prepares => RailsBestPractices::Prepares::ModelPrepare.new,
|
7
|
+
:prepares => [RailsBestPractices::Prepares::ModelPrepare.new, RailsBestPractices::Prepares::SchemaPrepare.new],
|
8
8
|
:reviews => RailsBestPractices::Reviews::LawOfDemeterReview.new
|
9
9
|
)
|
10
10
|
}
|
@@ -17,6 +17,17 @@ describe RailsBestPractices::Reviews::LawOfDemeterReview do
|
|
17
17
|
end
|
18
18
|
EOF
|
19
19
|
runner.prepare('app/models/invoice.rb', content)
|
20
|
+
|
21
|
+
content = <<-EOF
|
22
|
+
ActiveRecord::Schema.define(:version => 20110216150853) do
|
23
|
+
create_table "users", force => true do |t|
|
24
|
+
t.string :name
|
25
|
+
t.string :address
|
26
|
+
t.string :cellphone
|
27
|
+
end
|
28
|
+
end
|
29
|
+
EOF
|
30
|
+
runner.prepare('db/schema.rb', content)
|
20
31
|
end
|
21
32
|
|
22
33
|
it "should law of demeter" do
|
@@ -60,6 +71,16 @@ describe RailsBestPractices::Reviews::LawOfDemeterReview do
|
|
60
71
|
end
|
61
72
|
EOF
|
62
73
|
runner.prepare('app/models/invoice.rb', content)
|
74
|
+
|
75
|
+
content = <<-EOF
|
76
|
+
ActiveRecord::Schema.define(:version => 20110216150853) do
|
77
|
+
create_table "prices", force => true do |t|
|
78
|
+
t.string :currency
|
79
|
+
t.integer :number
|
80
|
+
end
|
81
|
+
end
|
82
|
+
EOF
|
83
|
+
runner.prepare('db/schema.rb', content)
|
63
84
|
end
|
64
85
|
|
65
86
|
it "should law of demeter" do
|
@@ -73,6 +94,42 @@ describe RailsBestPractices::Reviews::LawOfDemeterReview do
|
|
73
94
|
end
|
74
95
|
end
|
75
96
|
|
97
|
+
context "polymorphic association" do
|
98
|
+
before :each do
|
99
|
+
content = <<-EOF
|
100
|
+
class Comment < ActiveRecord::Base
|
101
|
+
belongs_to :commentable, :polymorphic => true
|
102
|
+
end
|
103
|
+
EOF
|
104
|
+
runner.prepare('app/models/comment.rb', content)
|
105
|
+
|
106
|
+
content = <<-EOF
|
107
|
+
class Post < ActiveRecord::Base
|
108
|
+
has_many :comments
|
109
|
+
end
|
110
|
+
EOF
|
111
|
+
runner.prepare('app/models/comment.rb', content)
|
112
|
+
|
113
|
+
content = <<-EOF
|
114
|
+
ActiveRecord::Schema.define(:version => 20110216150853) do
|
115
|
+
create_table "posts", force => true do |t|
|
116
|
+
t.string :title
|
117
|
+
end
|
118
|
+
end
|
119
|
+
EOF
|
120
|
+
runner.prepare('db/schema.rb', content)
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should law of demeter" do
|
124
|
+
content = <<-EOF
|
125
|
+
<%= @comment.commentable.title %>
|
126
|
+
EOF
|
127
|
+
runner.review('app/views/comments/index.html.erb', content)
|
128
|
+
runner.should have(1).errors
|
129
|
+
runner.errors[0].to_s.should == "app/views/comments/index.html.erb:1 - law of demeter"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
76
133
|
it "should no law of demeter with method call" do
|
77
134
|
content = <<-EOF
|
78
135
|
class Question < ActiveRecord::Base
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe RailsBestPractices::Reviews::UseQueryAttributeReview do
|
4
4
|
let(:runner) {
|
5
5
|
RailsBestPractices::Core::Runner.new(
|
6
|
-
:prepares => RailsBestPractices::Prepares::ModelPrepare.new,
|
6
|
+
:prepares => [RailsBestPractices::Prepares::ModelPrepare.new, RailsBestPractices::Prepares::SchemaPrepare.new],
|
7
7
|
:reviews => RailsBestPractices::Reviews::UseQueryAttributeReview.new
|
8
8
|
)
|
9
9
|
}
|
@@ -19,6 +19,16 @@ describe RailsBestPractices::Reviews::UseQueryAttributeReview do
|
|
19
19
|
end
|
20
20
|
EOF
|
21
21
|
runner.prepare('app/models/user.rb', content)
|
22
|
+
|
23
|
+
content = <<-EOF
|
24
|
+
ActiveRecord::Schema.define(:version => 20110216150853) do
|
25
|
+
create_table "users", force => true do |t|
|
26
|
+
t.string :login
|
27
|
+
t.integer :age
|
28
|
+
end
|
29
|
+
end
|
30
|
+
EOF
|
31
|
+
runner.prepare('db/schema.rb', content)
|
22
32
|
end
|
23
33
|
|
24
34
|
it "should use query attribute by blank call" do
|
@@ -97,6 +107,16 @@ describe RailsBestPractices::Reviews::UseQueryAttributeReview do
|
|
97
107
|
runner.should have(0).errors
|
98
108
|
end
|
99
109
|
|
110
|
+
it "should not use query attribute for number" do
|
111
|
+
content =<<-EOF
|
112
|
+
<% unless @user.age.blank? %>
|
113
|
+
<%= @user.age %>
|
114
|
+
<% end %>
|
115
|
+
EOF
|
116
|
+
runner.review('app/views/users/show.html.erb', content)
|
117
|
+
runner.should have(0).errors
|
118
|
+
end
|
119
|
+
|
100
120
|
it "should not review for pluralize attribute" do
|
101
121
|
content = <<-EOF
|
102
122
|
<% if @user.roles.blank? %>
|
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:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 4
|
10
|
+
version: 0.7.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Richard Huang
|
@@ -15,10 +15,12 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-25 00:00:00 +08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
+
prerelease: false
|
23
|
+
type: :runtime
|
22
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
23
25
|
none: false
|
24
26
|
requirements:
|
@@ -30,11 +32,11 @@ dependencies:
|
|
30
32
|
- 0
|
31
33
|
- 4
|
32
34
|
version: 2.0.4
|
33
|
-
prerelease: false
|
34
35
|
version_requirements: *id001
|
35
|
-
type: :runtime
|
36
36
|
name: ruby_parser
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
+
prerelease: false
|
39
|
+
type: :runtime
|
38
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
41
|
none: false
|
40
42
|
requirements:
|
@@ -46,11 +48,11 @@ dependencies:
|
|
46
48
|
- 0
|
47
49
|
- 9
|
48
50
|
version: 0.0.9
|
49
|
-
prerelease: false
|
50
51
|
version_requirements: *id002
|
51
|
-
type: :runtime
|
52
52
|
name: ruby-progressbar
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
|
+
prerelease: false
|
55
|
+
type: :runtime
|
54
56
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
57
|
none: false
|
56
58
|
requirements:
|
@@ -61,11 +63,11 @@ dependencies:
|
|
61
63
|
- 1
|
62
64
|
- 2
|
63
65
|
version: "1.2"
|
64
|
-
prerelease: false
|
65
66
|
version_requirements: *id003
|
66
|
-
type: :runtime
|
67
67
|
name: colored
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
|
+
prerelease: false
|
70
|
+
type: :runtime
|
69
71
|
requirement: &id004 !ruby/object:Gem::Requirement
|
70
72
|
none: false
|
71
73
|
requirements:
|
@@ -77,11 +79,11 @@ dependencies:
|
|
77
79
|
- 6
|
78
80
|
- 6
|
79
81
|
version: 2.6.6
|
80
|
-
prerelease: false
|
81
82
|
version_requirements: *id004
|
82
|
-
type: :runtime
|
83
83
|
name: erubis
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
|
+
prerelease: false
|
86
|
+
type: :runtime
|
85
87
|
requirement: &id005 !ruby/object:Gem::Requirement
|
86
88
|
none: false
|
87
89
|
requirements:
|
@@ -93,11 +95,11 @@ dependencies:
|
|
93
95
|
- 0
|
94
96
|
- 18
|
95
97
|
version: 3.0.18
|
96
|
-
prerelease: false
|
97
98
|
version_requirements: *id005
|
98
|
-
type: :runtime
|
99
99
|
name: haml
|
100
100
|
- !ruby/object:Gem::Dependency
|
101
|
+
prerelease: false
|
102
|
+
type: :runtime
|
101
103
|
requirement: &id006 !ruby/object:Gem::Requirement
|
102
104
|
none: false
|
103
105
|
requirements:
|
@@ -107,11 +109,11 @@ dependencies:
|
|
107
109
|
segments:
|
108
110
|
- 0
|
109
111
|
version: "0"
|
110
|
-
prerelease: false
|
111
112
|
version_requirements: *id006
|
112
|
-
type: :runtime
|
113
113
|
name: i18n
|
114
114
|
- !ruby/object:Gem::Dependency
|
115
|
+
prerelease: false
|
116
|
+
type: :runtime
|
115
117
|
requirement: &id007 !ruby/object:Gem::Requirement
|
116
118
|
none: false
|
117
119
|
requirements:
|
@@ -121,11 +123,11 @@ dependencies:
|
|
121
123
|
segments:
|
122
124
|
- 0
|
123
125
|
version: "0"
|
124
|
-
prerelease: false
|
125
126
|
version_requirements: *id007
|
126
|
-
type: :runtime
|
127
127
|
name: activesupport
|
128
128
|
- !ruby/object:Gem::Dependency
|
129
|
+
prerelease: false
|
130
|
+
type: :development
|
129
131
|
requirement: &id008 !ruby/object:Gem::Requirement
|
130
132
|
none: false
|
131
133
|
requirements:
|
@@ -135,11 +137,11 @@ dependencies:
|
|
135
137
|
segments:
|
136
138
|
- 0
|
137
139
|
version: "0"
|
138
|
-
prerelease: false
|
139
140
|
version_requirements: *id008
|
140
|
-
type: :development
|
141
141
|
name: rake
|
142
142
|
- !ruby/object:Gem::Dependency
|
143
|
+
prerelease: false
|
144
|
+
type: :development
|
143
145
|
requirement: &id009 !ruby/object:Gem::Requirement
|
144
146
|
none: false
|
145
147
|
requirements:
|
@@ -151,11 +153,11 @@ dependencies:
|
|
151
153
|
- 4
|
152
154
|
- 0
|
153
155
|
version: 2.4.0
|
154
|
-
prerelease: false
|
155
156
|
version_requirements: *id009
|
156
|
-
type: :development
|
157
157
|
name: rspec
|
158
158
|
- !ruby/object:Gem::Dependency
|
159
|
+
prerelease: false
|
160
|
+
type: :development
|
159
161
|
requirement: &id010 !ruby/object:Gem::Requirement
|
160
162
|
none: false
|
161
163
|
requirements:
|
@@ -166,11 +168,11 @@ dependencies:
|
|
166
168
|
- 0
|
167
169
|
- 6
|
168
170
|
version: "0.6"
|
169
|
-
prerelease: false
|
170
171
|
version_requirements: *id010
|
171
|
-
type: :development
|
172
172
|
name: watchr
|
173
173
|
- !ruby/object:Gem::Dependency
|
174
|
+
prerelease: false
|
175
|
+
type: :development
|
174
176
|
requirement: &id011 !ruby/object:Gem::Requirement
|
175
177
|
none: false
|
176
178
|
requirements:
|
@@ -182,9 +184,7 @@ dependencies:
|
|
182
184
|
- 0
|
183
185
|
- 0
|
184
186
|
version: 1.0.0
|
185
|
-
prerelease: false
|
186
187
|
version_requirements: *id011
|
187
|
-
type: :development
|
188
188
|
name: bundler
|
189
189
|
description: a code metric tool for rails codes, written in Ruby.
|
190
190
|
email:
|
@@ -217,6 +217,7 @@ files:
|
|
217
217
|
- lib/rails_best_practices/core/checking_visitor.rb
|
218
218
|
- lib/rails_best_practices/core/error.rb
|
219
219
|
- lib/rails_best_practices/core/model_associations.rb
|
220
|
+
- lib/rails_best_practices/core/model_attributes.rb
|
220
221
|
- lib/rails_best_practices/core/models.rb
|
221
222
|
- lib/rails_best_practices/core/nil.rb
|
222
223
|
- lib/rails_best_practices/core/runner.rb
|
@@ -227,6 +228,7 @@ files:
|
|
227
228
|
- lib/rails_best_practices/prepares.rb
|
228
229
|
- lib/rails_best_practices/prepares/mailer_prepare.rb
|
229
230
|
- lib/rails_best_practices/prepares/model_prepare.rb
|
231
|
+
- lib/rails_best_practices/prepares/schema_prepare.rb
|
230
232
|
- lib/rails_best_practices/reviews.rb
|
231
233
|
- lib/rails_best_practices/reviews/add_model_virtual_attribute_review.rb
|
232
234
|
- lib/rails_best_practices/reviews/always_add_db_index_review.rb
|
@@ -260,6 +262,7 @@ files:
|
|
260
262
|
- spec/rails_best_practices/core/checking_visitor_spec.rb
|
261
263
|
- spec/rails_best_practices/core/error_spec.rb
|
262
264
|
- spec/rails_best_practices/core/model_associations_spec.rb
|
265
|
+
- spec/rails_best_practices/core/model_attributes_spec.rb
|
263
266
|
- spec/rails_best_practices/core/models_spec.rb
|
264
267
|
- spec/rails_best_practices/core/nil_spec.rb
|
265
268
|
- spec/rails_best_practices/core/visitable_sexp_spec.rb
|
@@ -267,6 +270,7 @@ files:
|
|
267
270
|
- spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb
|
268
271
|
- spec/rails_best_practices/prepares/mailer_prepare_spec.rb
|
269
272
|
- spec/rails_best_practices/prepares/model_prepare_spec.rb
|
273
|
+
- spec/rails_best_practices/prepares/schema_prepare_spec.rb
|
270
274
|
- spec/rails_best_practices/reviews/add_model_virtual_attribute_review_spec.rb
|
271
275
|
- spec/rails_best_practices/reviews/always_add_db_index_review_spec.rb
|
272
276
|
- spec/rails_best_practices/reviews/dry_bundler_in_capistrano_review_spec.rb
|
@@ -339,7 +343,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
339
343
|
requirements: []
|
340
344
|
|
341
345
|
rubyforge_project:
|
342
|
-
rubygems_version: 1.
|
346
|
+
rubygems_version: 1.5.2
|
343
347
|
signing_key:
|
344
348
|
specification_version: 3
|
345
349
|
summary: a code metric tool for rails codes.
|
@@ -348,6 +352,7 @@ test_files:
|
|
348
352
|
- spec/rails_best_practices/core/checking_visitor_spec.rb
|
349
353
|
- spec/rails_best_practices/core/error_spec.rb
|
350
354
|
- spec/rails_best_practices/core/model_associations_spec.rb
|
355
|
+
- spec/rails_best_practices/core/model_attributes_spec.rb
|
351
356
|
- spec/rails_best_practices/core/models_spec.rb
|
352
357
|
- spec/rails_best_practices/core/nil_spec.rb
|
353
358
|
- spec/rails_best_practices/core/visitable_sexp_spec.rb
|
@@ -355,6 +360,7 @@ test_files:
|
|
355
360
|
- spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb
|
356
361
|
- spec/rails_best_practices/prepares/mailer_prepare_spec.rb
|
357
362
|
- spec/rails_best_practices/prepares/model_prepare_spec.rb
|
363
|
+
- spec/rails_best_practices/prepares/schema_prepare_spec.rb
|
358
364
|
- spec/rails_best_practices/reviews/add_model_virtual_attribute_review_spec.rb
|
359
365
|
- spec/rails_best_practices/reviews/always_add_db_index_review_spec.rb
|
360
366
|
- spec/rails_best_practices/reviews/dry_bundler_in_capistrano_review_spec.rb
|