Class: Licensed::Reporters::ListReporter

Inherits:
Reporter
  • Object
show all
Defined in:
lib/licensed/reporters/list_reporter.rb

Instance Method Summary collapse

Methods inherited from Reporter

#begin_report_command, #begin_report_dependency, #end_report_app, #end_report_command, #initialize

Constructor Details

This class inherits a constructor from Licensed::Reporters::Reporter

Instance Method Details

#begin_report_app(app, report) ⇒ Object

Reports the start of application configuration in a list command run

app - An application configuration report - A report object containing information about the app evaluation



10
11
12
# File 'lib/licensed/reporters/list_reporter.rb', line 10

def begin_report_app(app, report)
  shell.info "Listing dependencies for #{app["name"]}"
end

#begin_report_source(source, report) ⇒ Object

Reports the start of a source evaluation

source - A dependency source enumerator report - A report object containing information about the source evaluation



18
19
20
# File 'lib/licensed/reporters/list_reporter.rb', line 18

def begin_report_source(source, report)
  shell.info "  #{source.class.type}"
end

#end_report_dependency(dependency, report) ⇒ Object

Reports on a dependency in a list command run.

dependency - An application dependency report - A report object containing information about the dependency evaluation



67
68
69
70
71
# File 'lib/licensed/reporters/list_reporter.rb', line 67

def end_report_dependency(dependency, report)
  info = "#{dependency.name} (#{dependency.version})"
  info = "#{info}: #{report["license"]}" if report["license"]
  shell.info "    #{info}"
end

#end_report_source(source, report) ⇒ Object

Report the type and count of dependencies found by the source, along with any warnings and errors

source - A dependency source enumerator report - A report object containing information about the source evaluation



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
# File 'lib/licensed/reporters/list_reporter.rb', line 27

def end_report_source(source, 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
end