WIP
This commit is contained in:
parent
d7765dd223
commit
c5a6724c5c
@ -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
|
||||
|
@ -5,6 +5,8 @@ require "cache_store"
|
||||
# by the `brew linkage` command
|
||||
#
|
||||
class LinkageStore < CacheStore
|
||||
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
|
||||
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user