From c5a6724c5cb2bbf9ae8967d8bbff434989c88da2 Mon Sep 17 00:00:00 2001 From: AndrewMcBurney Date: Tue, 6 Mar 2018 11:42:45 -0500 Subject: [PATCH] WIP --- Library/Homebrew/cache_store.rb | 2 +- Library/Homebrew/os/mac/linkage_cache_store.rb | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cache_store.rb b/Library/Homebrew/cache_store.rb index 07cc88363e..57b319248f 100644 --- a/Library/Homebrew/cache_store.rb +++ b/Library/Homebrew/cache_store.rb @@ -12,7 +12,7 @@ class DatabaseCache # Opens and yields a database in read/write mode. Closes the database after use # - # @yield [DBM] + # @yield [DBM] db # @return [nil] def initialize(name) # DBM::WRCREAT: Creates the database if it does not already exist diff --git a/Library/Homebrew/os/mac/linkage_cache_store.rb b/Library/Homebrew/os/mac/linkage_cache_store.rb index 5c5cfc65ca..4e2cb3ece5 100644 --- a/Library/Homebrew/os/mac/linkage_cache_store.rb +++ b/Library/Homebrew/os/mac/linkage_cache_store.rb @@ -5,7 +5,9 @@ require "cache_store" # by the `brew linkage` command # class LinkageStore < CacheStore - HASH_LINKAGE_TYPES = [:brewed_dylibs, :reverse_links].freeze + ARRAY_LINKAGE_TYPES = [:system_dylibs, :variable_dylibs, :broken_dylibs, + :indirect_deps, :undeclared_deps, :unnecessary_deps].freeze + HASH_LINKAGE_TYPES = [:brewed_dylibs, :reverse_links].freeze # @param [String] keg_name # @param [DBM] database_cache @@ -21,13 +23,16 @@ class LinkageStore < CacheStore # @param [Hash] array_values # @param [Hash] hash_values # @param [Array[Hash]] values + # @raise [TypeError] # @return [nil] def update!(array_values: {}, hash_values: {}, **values) values.each do |key, value| if value.is_a? Hash hash_values[key] = value - else + elsif value.is_a? Array array_values[key] = value + else + raise TypeError, "Can't store types that are not `Array` or `Hash` in the linkage store." end end @@ -37,13 +42,16 @@ class LinkageStore < CacheStore ) end - # @param [Symbol] type + # @param [Symbol] the type to fetch from the `LinkageStore` + # @raise [TypeError] # @return [Hash | Array] def fetch_type(type) if HASH_LINKAGE_TYPES.include?(type) fetch_hash_values(type) - else + elsif ARRAY_LINKAGE_TYPES.include?(type) fetch_array_values(type) + else + raise TypeError, "Can't fetch types that are not defined for the linkage store." end end