Class: ReporterHub

Inherits:
Object
  • Object
show all
Extended by:
Forwardable, T::Sig
Defined in:
cmd/update-report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializevoid



548
549
550
551
# File 'cmd/update-report.rb', line 548

def initialize
  @hash = {}
  @reporters = []
end

Instance Attribute Details

#reportersObject (readonly)

Returns the value of attribute reporters.



545
546
547
# File 'cmd/update-report.rb', line 545

def reporters
  @reporters
end

Instance Method Details

#add(reporter, preinstall: false) ⇒ Object



557
558
559
560
561
# File 'cmd/update-report.rb', line 557

def add(reporter, preinstall: false)
  @reporters << reporter
  report = reporter.report(preinstall: preinstall).delete_if { |_k, v| v.empty? }
  @hash.update(report) { |_key, oldval, newval| oldval.concat(newval) }
end

#dump(updated_formula_report: true) ⇒ Object



565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
# File 'cmd/update-report.rb', line 565

def dump(updated_formula_report: true)
  # Key Legend: Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R)

  dump_formula_report :A, "New Formulae"
  if updated_formula_report
    dump_formula_report :M, "Updated Formulae"
  else
    updated = select_formula(:M).count
    if updated.positive?
      ohai_stdout_or_stderr "Updated Formulae",
                            "Updated #{updated} #{"formula".pluralize(updated)}."
    end
  end
  dump_formula_report :R, "Renamed Formulae"
  dump_formula_report :D, "Deleted Formulae"
  dump_formula_report :AC, "New Casks"
  if updated_formula_report
    dump_formula_report :MC, "Updated Casks"
  else
    updated = select_formula(:MC).count
    if updated.positive?
      ohai_stdout_or_stderr "Updated Casks",
                            "Updated #{updated} #{"cask".pluralize(updated)}."
    end
  end
  dump_formula_report :DC, "Deleted Casks"
end

#select_formula(key) ⇒ Object



553
554
555
# File 'cmd/update-report.rb', line 553

def select_formula(key)
  @hash.fetch(key, [])
end