Convert update report to use composition

This commit is contained in:
Jack Nagel 2014-06-27 21:58:15 -05:00
parent 346fa5098f
commit 7cd31377a4
2 changed files with 19 additions and 7 deletions

View File

@ -31,7 +31,7 @@ module Homebrew
ensure
link_tap_formula(tapped_formulae)
end
report.merge!(master_updater.report)
report.update(master_updater.report)
# rename Taps directories
# this procedure will be removed in the future if it seems unnecessasry
@ -46,7 +46,7 @@ module Homebrew
rescue
onoe "Failed to update tap: #{user.basename}/#{repo.basename.sub("homebrew-", "")}"
else
report.merge!(updater.report) do |key, oldval, newval|
report.update(updater.report) do |key, oldval, newval|
oldval.concat(newval)
end
end
@ -207,7 +207,22 @@ class Updater
end
class Report < Hash
class Report
def initialize
@hash = {}
end
def fetch(*args, &block)
@hash.fetch(*args, &block)
end
def update(*args, &block)
@hash.update(*args, &block)
end
def empty?
@hash.empty?
end
def dump
# Key Legend: Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R)
@ -216,8 +231,6 @@ class Report < Hash
dump_formula_report :M, "Updated Formulae"
dump_formula_report :D, "Deleted Formulae"
dump_formula_report :R, "Renamed Formulae"
# dump_new_commands
# dump_deleted_commands
end
def tapped_formula_for key
@ -268,5 +281,4 @@ class Report < Hash
puts_columns formula.uniq
end
end
end

View File

@ -54,7 +54,7 @@ class UpdaterTests < Homebrew::TestCase
@updater.in_repo_expect("git rev-parse -q --verify HEAD", "3456cdef")
@updater.in_repo_expect("git diff-tree -r --raw -M85% 1234abcd 3456cdef", diff_output)
@updater.pull!
@report.merge!(@updater.report)
@report.update(@updater.report)
end
end