Class: Licensed::Reporters::StatusReporter
- Defined in:
- lib/licensed/reporters/status_reporter.rb
Instance Method Summary collapse
-
#report_app(app) ⇒ Object
Generate a report for a licensed status command run Shows the errors found when checking status, as well as overall number of dependencies checked.
-
#report_dependency(dependency) ⇒ Object
Reports on a dependency in a status command run.
Methods inherited from Reporter
#initialize, #report_run, #report_source
Constructor Details
This class inherits a constructor from Licensed::Reporters::Reporter
Instance Method Details
#report_app(app) ⇒ Object
Generate a report for a licensed status command run Shows the errors found when checking status, as well as overall number of dependencies checked
Returns the result of the yielded method
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 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 53 54 55 56 57 58 59 60 |
# File 'lib/licensed/reporters/status_reporter.rb', line 11 def report_app(app) super do |report| shell.info "Checking cached dependency records for #{app["name"]}" result = yield report all_reports = report.all_reports warning_reports = all_reports.select { |r| r.warnings.any? }.to_a if warning_reports.any? shell.newline shell.warn "Warnings:" warning_reports.each do |r| = r.map { |k, v| "#{k}: #{v}" }.join(", ") shell.warn "* #{r.name}" shell.warn " #{}" unless .empty? r.warnings.each do |warning| shell.warn " - #{warning}" end shell.newline end end errored_reports = all_reports.select { |r| r.errors.any? }.to_a dependency_count = all_reports.select { |r| r.target.is_a?(Licensed::Dependency) }.size error_count = errored_reports.sum { |r| r.errors.size } if error_count > 0 shell.newline shell.error "Errors:" errored_reports.each do |r| = r.map { |k, v| "#{k}: #{v}" }.join(", ") shell.error "* #{r.name}" shell.error " #{}" unless .empty? r.errors.each do |error| shell.error " - #{error}" end shell.newline end end shell.newline shell.info "#{dependency_count} dependencies checked, #{error_count} errors found." result end end |
#report_dependency(dependency) ⇒ Object
Reports on a dependency in a status command run. Shows whether the dependency’s status is valid in dot format
dependency - An application dependency
Returns the result of the yielded method Note - must be called from inside the ‘report_run` scope
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/licensed/reporters/status_reporter.rb', line 69 def report_dependency(dependency) super do |report| result = yield report if report.errors.empty? shell.confirm(".", false) else shell.error("F", false) end result end end |