Class: LintTrappings::Runner
- Inherits:
-
Object
- Object
- LintTrappings::Runner
- Defined in:
- lib/lint_trappings/runner.rb
Overview
Linter runner.
Runs linters against a set of files, ensuring the appropriate linters are run against the relevant files based on configuration.
Defined Under Namespace
Classes: FileToLint, Job
Instance Method Summary collapse
-
#initialize(application, config, output) ⇒ Runner
constructor
A new instance of Runner.
-
#run(options = {}) ⇒ LintTrappings::Report
Runs the appropriate linters against the set of specified files, return a report of all lints found.
Constructor Details
#initialize(application, config, output) ⇒ Runner
Returns a new instance of Runner.
11 12 13 14 15 |
# File 'lib/lint_trappings/runner.rb', line 11 def initialize(application, config, output) @application = application @config = config @output = output end |
Instance Method Details
#run(options = {}) ⇒ LintTrappings::Report
Runs the appropriate linters against the set of specified files, return a report of all lints found.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/lint_trappings/runner.rb', line 26 def run( = {}) @options = # Coalesce formatters into a single formatter which will forward calls formatters = FormatterLoader.new(@application, @config, @output).load() @formatter = FormatterForwarder.new(formatters) # We store the documents in a map so that if we're parallelizing the run # we don't need to pass serialized Document objects via IPC, just the path # string. Since forking will use copy-on-write semantics, we'll be able # to reuse the memory storing those documents for all workers, since we're # just reading. @paths_to_documents_map, parse_lints = load_documents_to_lint() # Extract all jobs we want to run as file/linter pairs linter_selector = LinterSelector.new(@application, @config, ) jobs = @paths_to_documents_map.keys.map do |path| linter_selector.linters_for_file(path).map { |linter| Job.new(linter, path) } end.flatten lints = find_all_lints(jobs) + parse_lints report = Report.new(@config, lints, @paths_to_documents_map.values) @formatter.finished(report) report end |