class Convoy::Setup::Configuration::Loader

Attributes

auto_options[R]
setup[R]

Public Class Methods

new(setup, auto_options) click to toggle source
# File lib/convoy/setup/configuration/loader.rb, line 7
def initialize(setup, auto_options)
    @setup        = setup
    @auto_options = auto_options
end

Public Instance Methods

configuration() click to toggle source
# File lib/convoy/setup/configuration/loader.rb, line 12
def configuration
    if setup.has_config_file?
        Writer.new(config_path, Generator.new(setup).default_data).write if setup.config_file_autocreatable?
        Reader.new(config_path).read
    else
        Instance.blank
    end
end
default_config_path() click to toggle source
# File lib/convoy/setup/configuration/loader.rb, line 21
def default_config_path
    @default_config_path ||= (config_filename ? File.join(File.expand_path(ENV["HOME"]), config_filename) : nil)
end

Private Instance Methods

config_filename() click to toggle source
# File lib/convoy/setup/configuration/loader.rb, line 27
def config_filename
    @config_filename ||= setup.config_file
end
config_path() click to toggle source
# File lib/convoy/setup/configuration/loader.rb, line 31
def config_path
    @config_path ||= (auto_options.non_default_config_path || locator.locate || default_config_path)
end
locator() click to toggle source
# File lib/convoy/setup/configuration/loader.rb, line 35
def locator
    Locator::Chaining.new(config_filename).
        add_locator(Locator::ExecutingScriptDirectory.new(config_filename)).
        add_locator(Locator::DescendingToHome.new(config_filename))
end