Class: CC::Analyzer::Formatters::PlainTextFormatter
- Defined in:
- lib/cc/analyzer/formatters/plain_text_formatter.rb
Constant Summary
Constants inherited from Formatter
Formatter::InvalidFormatterError
Instance Method Summary collapse
- #engine_running(engine, &block) ⇒ Object
- #failed(output) ⇒ Object
- #finished ⇒ Object
- #started ⇒ Object
- #write(data) ⇒ Object
Methods inherited from Formatter
Constructor Details
This class inherits a constructor from CC::Analyzer::Formatters::Formatter
Instance Method Details
#engine_running(engine, &block) ⇒ Object
53 54 55 56 57 |
# File 'lib/cc/analyzer/formatters/plain_text_formatter.rb', line 53 def engine_running(engine, &block) super(engine) do with_spinner("Running #{current_engine.name}: ", &block) end end |
#failed(output) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/cc/analyzer/formatters/plain_text_formatter.rb', line 59 def failed(output) spinner.stop("Failed") puts colorize("\nAnalysis failed with the following output:", :red) puts output exit 1 end |
#finished ⇒ Object
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 |
# File 'lib/cc/analyzer/formatters/plain_text_formatter.rb', line 27 def finished puts issues_by_path.each do |path, file_issues| puts colorize("== #{path} (#{pluralize(file_issues.size, "issue")}) ==", :yellow) IssueSorter.new(file_issues).by_location.each do |issue| if (location = issue["location"]) source_buffer = @filesystem.source_buffer_for(location["path"]) print(colorize(LocationDescription.new(source_buffer, location, ": "), :cyan)) end print(issue["description"]) print(colorize(" [#{issue["engine_name"]}]", "#333333")) puts end puts end print(colorize("Analysis complete! Found #{pluralize(issues.size, "issue")}", :green)) if warnings.size > 0 print(colorize(" and #{pluralize(warnings.size, "warning")}", :green)) end puts(colorize(".", :green)) end |
#started ⇒ Object
9 10 11 |
# File 'lib/cc/analyzer/formatters/plain_text_formatter.rb', line 9 def started puts colorize("Starting analysis", :green) end |
#write(data) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cc/analyzer/formatters/plain_text_formatter.rb', line 13 def write(data) json = JSON.parse(data) json["engine_name"] = current_engine.name case json["type"].downcase when "issue" issues << json when "warning" warnings << json else raise "Invalid type found: #{json["type"]}" end end |