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
|
# Opens and yields a database in read/write mode. Closes the database after use
|
||||||
#
|
#
|
||||||
# @yield [DBM]
|
# @yield [DBM] db
|
||||||
# @return [nil]
|
# @return [nil]
|
||||||
def initialize(name)
|
def initialize(name)
|
||||||
# DBM::WRCREAT: Creates the database if it does not already exist
|
# DBM::WRCREAT: Creates the database if it does not already exist
|
||||||
|
@ -5,7 +5,9 @@ require "cache_store"
|
|||||||
# by the `brew linkage` command
|
# by the `brew linkage` command
|
||||||
#
|
#
|
||||||
class LinkageStore < CacheStore
|
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 [String] keg_name
|
||||||
# @param [DBM] database_cache
|
# @param [DBM] database_cache
|
||||||
@ -21,13 +23,16 @@ class LinkageStore < CacheStore
|
|||||||
# @param [Hash] array_values
|
# @param [Hash] array_values
|
||||||
# @param [Hash] hash_values
|
# @param [Hash] hash_values
|
||||||
# @param [Array[Hash]] values
|
# @param [Array[Hash]] values
|
||||||
|
# @raise [TypeError]
|
||||||
# @return [nil]
|
# @return [nil]
|
||||||
def update!(array_values: {}, hash_values: {}, **values)
|
def update!(array_values: {}, hash_values: {}, **values)
|
||||||
values.each do |key, value|
|
values.each do |key, value|
|
||||||
if value.is_a? Hash
|
if value.is_a? Hash
|
||||||
hash_values[key] = value
|
hash_values[key] = value
|
||||||
else
|
elsif value.is_a? Array
|
||||||
array_values[key] = value
|
array_values[key] = value
|
||||||
|
else
|
||||||
|
raise TypeError, "Can't store types that are not `Array` or `Hash` in the linkage store."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -37,13 +42,16 @@ class LinkageStore < CacheStore
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# @param [Symbol] type
|
# @param [Symbol] the type to fetch from the `LinkageStore`
|
||||||
|
# @raise [TypeError]
|
||||||
# @return [Hash | Array]
|
# @return [Hash | Array]
|
||||||
def fetch_type(type)
|
def fetch_type(type)
|
||||||
if HASH_LINKAGE_TYPES.include?(type)
|
if HASH_LINKAGE_TYPES.include?(type)
|
||||||
fetch_hash_values(type)
|
fetch_hash_values(type)
|
||||||
else
|
elsif ARRAY_LINKAGE_TYPES.include?(type)
|
||||||
fetch_array_values(type)
|
fetch_array_values(type)
|
||||||
|
else
|
||||||
|
raise TypeError, "Can't fetch types that are not defined for the linkage store."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user