Sha256: 48d809bd4f20b4bb0f5ae532d47701c4d9ed838b6ebf7b3f22b1e6b48c9ed30f
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
Contents
require 'rubygems' require 'ruby_parser' require 'yaml' module RailsBestPractices module Core class Runner DEFAULT_CONFIG = File.join(File.dirname(__FILE__), "..", "..", "..", "rails_best_practices.yml") def initialize(*checks) @config = DEFAULT_CONFIG @checks = checks unless checks.empty? @checks ||= load_checks @checker ||= CheckingVisitor.new(@checks) @parser = RubyParser.new end def check(filename, content) node = parse(filename, content) node.accept(@checker) if node end def check_content(content) check("dummy-file.rb", content) end def check_file(filename) check(filename, File.read(filename)) end def errors @checks ||= [] all_errors = @checks.collect {|check| check.errors} all_errors.flatten end private def parse(filename, content) begin @parser.parse(content, filename) rescue Exception => e puts "#{filename} looks like it's not a valid Ruby file. Skipping..." if ENV["ROODI_DEBUG"] nil end end def load_checks check_objects = [] checks = YAML.load_file @config checks.each do |check| klass = eval("RailsBestPractices::Checks::#{check[0]}") check_objects << (check[1].empty? ? klass.new : klass.new(check[1])) end check_objects end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_best_practices-0.1.2 | lib/rails_best_practices/core/runner.rb |