Class: ReporterHub

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
Library/Homebrew/cmd/update-report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeReporterHub

Returns a new instance of ReporterHub.


419
420
421
422
# File 'Library/Homebrew/cmd/update-report.rb', line 419

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

Instance Attribute Details

#reportersObject (readonly)

Returns the value of attribute reporters


417
418
419
# File 'Library/Homebrew/cmd/update-report.rb', line 417

def reporters
  @reporters
end

Instance Method Details

#add(reporter, preinstall: false) ⇒ Object


428
429
430
431
432
# File 'Library/Homebrew/cmd/update-report.rb', line 428

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


436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# File 'Library/Homebrew/cmd/update-report.rb', line 436

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 "Updated Formulae"
      puts "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"
  dump_formula_report :MC, "Updated Casks"
  dump_formula_report :DC, "Deleted Casks"
end

#select_formula(key) ⇒ Object


424
425
426
# File 'Library/Homebrew/cmd/update-report.rb', line 424

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