diff options
| author | Jack Nagel | 2014-06-27 21:58:15 -0500 |
|---|---|---|
| committer | Jack Nagel | 2014-06-27 21:58:15 -0500 |
| commit | 7cd31377a4969b96ed8da9d87f5a70f5a16aed61 (patch) | |
| tree | e3388b22e40073ce475174eddff8857cde31a3ec | |
| parent | 346fa5098fdb36cfb97a954c50059de15a28f952 (diff) | |
| download | brew-7cd31377a4969b96ed8da9d87f5a70f5a16aed61.tar.bz2 | |
Convert update report to use composition
| -rw-r--r-- | Library/Homebrew/cmd/update.rb | 24 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_updater.rb | 2 |
2 files changed, 19 insertions, 7 deletions
diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb index 042214ee3..7bced13a9 100644 --- a/Library/Homebrew/cmd/update.rb +++ b/Library/Homebrew/cmd/update.rb @@ -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 diff --git a/Library/Homebrew/test/test_updater.rb b/Library/Homebrew/test/test_updater.rb index 410e54423..48ad066d7 100644 --- a/Library/Homebrew/test/test_updater.rb +++ b/Library/Homebrew/test/test_updater.rb @@ -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 |
