Class: Codeqa::Runner
- Inherits:
-
Object
- Object
- Codeqa::Runner
- Defined in:
- lib/codeqa/runner.rb
Constant Summary collapse
- @@registered_checkers =
reset_checkers
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
the results (checker instances of the run).
-
#sourcefile ⇒ Object
readonly
Returns the value of attribute sourcefile.
Class Method Summary collapse
- .register_checker(checker_class) ⇒ Object
- .registered_checkers ⇒ Object
- .reset_checkers ⇒ Object
-
.run(sourcefile) ⇒ Object
run the checks on source.
Instance Method Summary collapse
- #display_result(options = {}) ⇒ Object
- #failures ⇒ Object
-
#initialize(sourcefile) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(sourcefile) ⇒ Runner
Returns a new instance of Runner.
27 28 29 30 |
# File 'lib/codeqa/runner.rb', line 27 def initialize(sourcefile) @sourcefile = sourcefile @results = [] end |
Instance Attribute Details
#results ⇒ Object (readonly)
the results (checker instances of the run)
47 48 49 |
# File 'lib/codeqa/runner.rb', line 47 def results @results end |
#sourcefile ⇒ Object (readonly)
Returns the value of attribute sourcefile.
31 32 33 |
# File 'lib/codeqa/runner.rb', line 31 def sourcefile @sourcefile end |
Class Method Details
.register_checker(checker_class) ⇒ Object
14 15 16 |
# File 'lib/codeqa/runner.rb', line 14 def register_checker(checker_class) @@registered_checkers << checker_class end |
.registered_checkers ⇒ Object
6 7 8 |
# File 'lib/codeqa/runner.rb', line 6 def registered_checkers @@registered_checkers end |
.reset_checkers ⇒ Object
10 11 12 |
# File 'lib/codeqa/runner.rb', line 10 def reset_checkers @@registered_checkers = Set.new end |
.run(sourcefile) ⇒ Object
run the checks on source
21 22 23 24 25 |
# File 'lib/codeqa/runner.rb', line 21 def self.run(sourcefile) runner = new(sourcefile) runner.run runner end |
Instance Method Details
#display_result(options = {}) ⇒ Object
57 58 59 |
# File 'lib/codeqa/runner.rb', line 57 def display_result(={}) RunnerDecorator.new(self, ) end |
#failures ⇒ Object
49 50 51 |
# File 'lib/codeqa/runner.rb', line 49 def failures @failures ||= @results.reject(&:success?) end |
#run ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/codeqa/runner.rb', line 33 def run return @results unless @results.empty? @results = @@registered_checkers.map do |checker_klass| next unless checker_klass.check?(sourcefile) checker = checker_klass.new(sourcefile) checker.before_check if checker.respond_to?(:before_check) checker.check checker.after_check if checker.respond_to?(:after_check) checker end.compact end |
#success? ⇒ Boolean
53 54 55 |
# File 'lib/codeqa/runner.rb', line 53 def success? failures.empty? end |