Class: Pelusa::Runner
- Inherits:
-
Object
- Object
- Pelusa::Runner
- Defined in:
- lib/pelusa/runner.rb
Instance Method Summary (collapse)
-
- (Runner) initialize(lints, reporter)
constructor
Public: Initializes an Analyzer.
-
- (Object) run(files)
Public: Runs the analyzer on a set of files.
-
- (Object) run_file(file)
Public: Runs the analyzer on a single file.
Constructor Details
- (Runner) initialize(lints, reporter)
Public: Initializes an Analyzer.
lints - The lints to check the code for. reporter - The Reporter to use. Will be used to report back the results in
methods such as #run.
8 9 10 11 |
# File 'lib/pelusa/runner.rb', line 8 def initialize(lints, reporter) @lints = lints @reporter = reporter end |
Instance Method Details
- (Object) run(files)
Public: Runs the analyzer on a set of files.
Returns an Array of Reports of those file runs.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pelusa/runner.rb', line 16 def run(files) reporters = Array(files).map do |file| run_file(file) end @reporter. exit_code = 0 reporters.each do |reporter| reporter.report exit_code = 1 unless reporter.successful? end exit_code end |
- (Object) run_file(file)
Public: Runs the analyzer on a single file.
Returns a Report of the single run.
34 35 36 37 38 |
# File 'lib/pelusa/runner.rb', line 34 def run_file(file) ast = parser.parse_file(file) analyzer = Analyzer.new(@lints, @reporter, file) analyzer.analyze(ast) end |