Class: Licensed::Reporters::CacheReporter
- Defined in:
- lib/licensed/reporters/cache_reporter.rb
Instance Method Summary collapse
-
#report_app(app) ⇒ Object
Reports on an application configuration in a cache command run.
-
#report_dependency(dependency) ⇒ Object
Reports on a dependency in a cache command run.
-
#report_source(source) ⇒ Object
Reports on a dependency source enumerator in a cache command run.
Methods inherited from Reporter
Constructor Details
This class inherits a constructor from Licensed::Reporters::Reporter
Instance Method Details
#report_app(app) ⇒ Object
Reports on an application configuration in a cache command run
app - An application configuration
Returns the result of the yielded method Note - must be called from inside the ‘report_run` scope
11 12 13 14 15 16 |
# File 'lib/licensed/reporters/cache_reporter.rb', line 11 def report_app(app) super do |report| shell.info "Caching dependency records for #{app["name"]}" yield report end end |
#report_dependency(dependency) ⇒ Object
Reports on a dependency in a cache command run. Shows whether the dependency’s record was cached or reused.
dependency - An application dependency
Returns the result of the yielded method Note - must be called from inside the ‘report_run` scope
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/licensed/reporters/cache_reporter.rb', line 75 def report_dependency(dependency) super do |report| result = yield report if report.errors.any? shell.error " Error #{dependency.name} (#{dependency.version})" elsif report["cached"] shell.info " Caching #{dependency.name} (#{dependency.version})" else shell.info " Using #{dependency.name} (#{dependency.version})" end result end end |
#report_source(source) ⇒ Object
Reports on a dependency source enumerator in a cache command run. Shows the type and count of dependencies found by the source.
source - A dependency source enumerator
Returns the result of the yielded method Note - must be called from inside the ‘report_run` scope
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 61 62 63 64 65 66 |
# File 'lib/licensed/reporters/cache_reporter.rb', line 25 def report_source(source) super do |report| shell.info " #{source.class.type}" result = yield report warning_reports = report.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 = report.all_reports.select { |r| r.errors.any? }.to_a if errored_reports.any? 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 else shell.confirm " * #{report.reports.size} #{source.class.type} dependencies" end result end end |