rails_best_practices 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rails_best_practices/core.rb +1 -0
- data/lib/rails_best_practices/core/mailers.rb +7 -0
- data/lib/rails_best_practices/prepares.rb +15 -7
- data/lib/rails_best_practices/prepares/mailer_prepare.rb +3 -3
- data/lib/rails_best_practices/reviews/use_observer_review.rb +4 -4
- data/lib/rails_best_practices/version.rb +1 -1
- data/spec/rails_best_practices/prepares/mailer_prepare_spec.rb +1 -1
- metadata +4 -3
@@ -8,5 +8,6 @@ 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
10
|
require 'rails_best_practices/core/model_attributes'
|
11
|
+
require 'rails_best_practices/core/mailers'
|
11
12
|
|
12
13
|
require 'rails_best_practices/core_ext/enumerable'
|
@@ -6,14 +6,22 @@ require 'rails_best_practices/prepares/schema_prepare'
|
|
6
6
|
module RailsBestPractices
|
7
7
|
module Prepares
|
8
8
|
class <<self
|
9
|
-
attr_writer :models, :model_associations, :model_attributes, :
|
9
|
+
attr_writer :models, :model_associations, :model_attributes, :mailers
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
def models
|
12
|
+
@models ||= Core::Models.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def model_associations
|
16
|
+
@model_associations ||= Core::ModelAssociations.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def model_attributes
|
20
|
+
@model_attributes ||= Core::ModelAttributes.new
|
21
|
+
end
|
22
|
+
|
23
|
+
def mailers
|
24
|
+
@mailers ||= Core::Mailers.new
|
17
25
|
end
|
18
26
|
end
|
19
27
|
end
|
@@ -15,7 +15,7 @@ module RailsBestPractices
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def initialize
|
18
|
-
@
|
18
|
+
@mailers = Core::Mailers.new
|
19
19
|
end
|
20
20
|
|
21
21
|
# check class node.
|
@@ -24,8 +24,8 @@ module RailsBestPractices
|
|
24
24
|
# then remember its class name.
|
25
25
|
def start_class(class_node)
|
26
26
|
if s(:colon2, s(:const, :ActionMailer), :Base) == class_node.base_class
|
27
|
-
@
|
28
|
-
Prepares.
|
27
|
+
@mailers << class_node.class_name.to_s
|
28
|
+
Prepares.mailers = @mailers
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -112,15 +112,15 @@ module RailsBestPractices
|
|
112
112
|
def deliver_mailer?(node)
|
113
113
|
node.grep_nodes(:node_type => :call) do |child_node|
|
114
114
|
# rails2 actionmailer deliver
|
115
|
-
return true if child_node.message.to_s =~ /^deliver_/ &&
|
115
|
+
return true if child_node.message.to_s =~ /^deliver_/ && mailers.include?(child_node.subject.to_s)
|
116
116
|
# rails3 actionmailer deliver
|
117
|
-
return true if :deliver == child_node.message &&
|
117
|
+
return true if :deliver == child_node.message && mailers.include?(child_node.subject.subject.to_s)
|
118
118
|
end
|
119
119
|
false
|
120
120
|
end
|
121
121
|
|
122
|
-
def
|
123
|
-
@
|
122
|
+
def mailers
|
123
|
+
@mailers ||= Prepares.mailers
|
124
124
|
end
|
125
125
|
end
|
126
126
|
end
|
@@ -9,6 +9,6 @@ describe RailsBestPractices::Prepares::MailerPrepare do
|
|
9
9
|
end
|
10
10
|
EOF
|
11
11
|
runner.prepare('app/mailers/project_mailer.rb', content)
|
12
|
-
RailsBestPractices::Prepares.
|
12
|
+
RailsBestPractices::Prepares.mailers.should == ["ProjectMailer"]
|
13
13
|
end
|
14
14
|
end
|
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: 61
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 1
|
10
|
+
version: 0.8.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Richard Huang
|
@@ -216,6 +216,7 @@ files:
|
|
216
216
|
- lib/rails_best_practices/core/check.rb
|
217
217
|
- lib/rails_best_practices/core/checking_visitor.rb
|
218
218
|
- lib/rails_best_practices/core/error.rb
|
219
|
+
- lib/rails_best_practices/core/mailers.rb
|
219
220
|
- lib/rails_best_practices/core/model_associations.rb
|
220
221
|
- lib/rails_best_practices/core/model_attributes.rb
|
221
222
|
- lib/rails_best_practices/core/models.rb
|