Class: RailsBestPractices::Core::CheckingVisitor
- Inherits:
-
Object
- Object
- RailsBestPractices::Core::CheckingVisitor
- Defined in:
- lib/rails_best_practices/core/checking_visitor.rb
Overview
CheckingVisitor is a visitor class.
it remembers all the checks for prepare and review processes according to interesting_nodes and interesting_nodes, then recursively iterate all sexp nodes,
for prepare process if the sexp_type and the node filename match the interesting_prepare_nodes and interesting_files, then run the prepare for that node.
for review process if the sexp_type and the node filename match the interesting_review_nodes and interesting_files, then run the reivew for that node.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ CheckingVisitor
constructor
remember all the checks for prepare and review processes according to interesting_nodes.
-
#lexical(filename, content) ⇒ Object
for lexical process check the content of files one by one.
Constructor Details
#initialize(options = {}) ⇒ CheckingVisitor
remember all the checks for prepare and review processes according to interesting_nodes.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rails_best_practices/core/checking_visitor.rb', line 21 def initialize(={}) @lexicals = [:lexicals] [:prepare, :review].each do |process| instance_variable_set("@#{process}_checks", {}) # @review_checks = {} ["#{process}s".to_sym].each do |check| # options[:reviews].each do |check| check.send("interesting_nodes").each do |node| # check.interesting_nodes.each do |node| instance_variable_get("@#{process}_checks")[node] ||= [] # @review_checks[node] ||= [] instance_variable_get("@#{process}_checks")[node] << check # @review_checks[node] << check instance_variable_get("@#{process}_checks")[node].uniq! # @review_checks[node].uniq! end # end end # end end end |
Instance Method Details
#lexical(filename, content) ⇒ Object
for lexical process check the content of files one by one.
37 38 39 40 41 42 |
# File 'lib/rails_best_practices/core/checking_visitor.rb', line 37 def lexical(filename, content) @lexicals.each do |lexical| lexical.check(filename, content) lexical.increment_total_files_checked! end end |