Class: RailsBestPractices::Core::Runner

### Home Classes Methods

### In Files

- lib/rails_best_practices/core/runner.rb

### Parent

Object

### Methods

- ::new
- #check
- #check_content
- #check_file
- #errors
- #set_debug

### Files

- LICENSE

### Class/Module Index

Quicksearch

- RailsBestPractices
- RailsBestPractices::Checks
- RailsBestPractices::Checks::AddModelVirtualAttributeCheck
- RailsBestPractices::Checks::AlwaysAddDbIndexCheck
- RailsBestPractices::Checks::Check
- RailsBestPractices::Checks::IsolateSeedDataCheck
- RailsBestPractices::Checks::KeepFindersOnTheirOwnModelCheck
- RailsBestPractices::Checks::LawOfDemeterCheck
- RailsBestPractices::Checks::ManyToManyCollectionCheck
- RailsBestPractices::Checks::MoveCodeIntoControllerCheck
- RailsBestPractices::Checks::MoveCodeIntoHelperCheck
- RailsBestPractices::Checks::MoveCodeIntoModelCheck
- RailsBestPractices::Checks::MoveFinderToNamedScopeCheck
- RailsBestPractices::Checks::MoveModelLogicIntoModelCheck
- RailsBestPractices::Checks::NeedlessDeepNestingCheck
- RailsBestPractices::Checks::NestedModelFormsCheck
- RailsBestPractices::Checks::NotUseDefaultRouteCheck
- RailsBestPractices::Checks::OveruseRouteCustomizationsCheck
- RailsBestPractices::Checks::ReplaceComplexCreationWithFactoryMethodCheck
- RailsBestPractices::Checks::ReplaceInstanceVariableWithLocalVariableCheck
- RailsBestPractices::Checks::UseBeforeFilterCheck
- RailsBestPractices::Checks::UseModelAssociationCheck
- RailsBestPractices::Checks::UseModelCallbackCheck
- RailsBestPractices::Checks::UseObserverCheck
- RailsBestPractices::Checks::UseScopeAccessCheck
- RailsBestPractices::Core
- RailsBestPractices::Core::CheckingVisitor
- RailsBestPractices::Core::Error
- RailsBestPractices::Core::Runner
- Enumerable
- NilClass
- Sexp
- String

No matching classes.

# RailsBestPractices::Core::Runner

### Constants

CUSTOM_CONFIG
DEFAULT_CONFIG

### 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.