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



489
490
491
492
# File 'cmd/update-report.rb', line 489

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

Instance Attribute Details

#reportersObject (readonly)

Returns the value of attribute reporters.



486
487
488
# File 'cmd/update-report.rb', line 486

def reporters
  @reporters
end

Instance Method Details

#add(reporter, preinstall: false) ⇒ Object



498
499
500
501
502
# File 'cmd/update-report.rb', line 498

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



506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
# File 'cmd/update-report.rb', line 506

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



494
495
496
# File 'cmd/update-report.rb', line 494

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