Config
item type
The Hash of Hglib::Config::Items from the config, keyed by name.
Create a new Config
object from the given config_items
.
# File lib/hglib/config.rb, line 21
def initialize( *config_items )
@items = self.expand_config_items( config_items )
end
Fetch the value of the config item key
.
# File lib/hglib/config.rb, line 36
def []( key )
return self.items[ key ]&.value
end
Call the block once for each config item, yielding the key and the Item
.
# File lib/hglib/config.rb, line 42
def each( &block )
return self.items.each( &block )
end
Expand the Array of configuration items
such as that returned by the JSON template of `hg showconfig` and return a hierarchical Hash.
# File lib/hglib/config.rb, line 49
def expand_config_items( items )
return items.flatten.each_with_object( {} ) do |item, hash|
self.log.debug "Expanding %p" % [ item ]
hash[ item[:name] ] = Item.new( item[:value], item[:source] )
end
end