class Bookwatch::Config::ConfigurationDecorator
Attributes
config_filename[R]
loader[R]
Public Class Methods
new(loader: nil, config_filename: nil)
click to toggle source
# File lib/bookwatch/config/configuration_decorator.rb, line 6 def initialize(loader: nil, config_filename: nil) @loader = loader @config_filename = config_filename end
Public Instance Methods
generate(base_config, sections)
click to toggle source
# File lib/bookwatch/config/configuration_decorator.rb, line 11 def generate(base_config, sections) base_config.merge( Configuration.new( repo_links: repo_link_config(base_config, sections), archive_menu: root_config(base_config).merge(section_config(sections))) ) end
Private Instance Methods
repo_link_config(base_config, sections)
click to toggle source
# File lib/bookwatch/config/configuration_decorator.rb, line 23 def repo_link_config(base_config, sections) if base_config.repo_link_enabled sections.reduce({}) {|config, section| config.merge( section.destination_directory.to_s => { 'repo' => section.repo_name, 'ref' => section.source_ref, 'at_path' => section.at_repo_path } ) } end end
root_config(base_config)
click to toggle source
# File lib/bookwatch/config/configuration_decorator.rb, line 37 def root_config(base_config) { '.' => base_config.archive_menu } end
section_config(sections)
click to toggle source
# File lib/bookwatch/config/configuration_decorator.rb, line 41 def section_config(sections) sections.reduce({}) {|config, section| config_path = section.path_to_repo_dir.join(config_filename) archive_config = loader.load_key(config_path, 'archive_menu') if archive_config config.merge(section.desired_directory_name => archive_config) else config end } end