Parent

Files

RailsBestPractices::Core::Runner

Public Class Methods

new(*checks) click to toggle source
# File lib/rails_best_practices/core/runner.rb, line 12
def initialize(*checks)
  @config = File.exists?(CUSTOM_CONFIG) ? CUSTOM_CONFIG : DEFAULT_CONFIG
  @checks = checks unless checks.empty?
  @checks ||= load_checks
  @checker ||= CheckingVisitor.new(@checks)
  @debug = false
end

Public Instance Methods

check(filename, content) click to toggle source
# File lib/rails_best_practices/core/runner.rb, line 24
def check(filename, content)
  if filename =~ /.*erb/
    content = ERB.new(content).src
  end
  if filename =~ /.*haml/
    require 'haml'
    content = Haml::Engine.new(content).precompiled
    # remove \xxx characters
    content.gsub!(/\\\d{3}/, '')
  end
  node = parse(filename, content)
  node.accept(@checker) if node
end
check_content(content) click to toggle source
# File lib/rails_best_practices/core/runner.rb, line 38
def check_content(content)
  check("dummy-file.rb", content)
end
check_file(filename) click to toggle source
# File lib/rails_best_practices/core/runner.rb, line 42
def check_file(filename)
  check(filename, File.read(filename))
end
errors() click to toggle source
# File lib/rails_best_practices/core/runner.rb, line 46
def errors
  @checks ||= []
  all_errors = @checks.collect {|check| check.errors}
  all_errors.flatten
end
set_debug() click to toggle source
# File lib/rails_best_practices/core/runner.rb, line 20
def set_debug
  @debug = true
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.