Sha256: 9629244b7e07c74b7cdc4d2647d4089483e504373f93bf6abc2902fcd61f7a81
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 KB
Contents
require 'rubygems' require 'ruby_parser' require 'ruby2ruby' 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.1 | lib/rails_best_practices/core/runner.rb |