class Disloku::BaseCoreCommand

Attributes

config[RW]
options[RW]
repository[RW]

Public Class Methods

new(cliOptions) click to toggle source
Calls superclass method Disloku::BaseCommand::new
# File lib/disloku/BaseCoreCommand.rb, line 16
def initialize(cliOptions)
        super(cliOptions)

        @repository = @scmImplementation.new(cliOptions[:dir])
        @config = loadConfiguration()
        @options = Config::Options.new(@config["options"], cliOptions)
        @mappingStore = Config::MappingStore.new(@config["mappings"])
        @connectionStore = Config::ConnectionStore.new(@config["connections"])

        Log.instance.addLogTarget(:logfile, File.join(repository.root, "disloku.log"), Logger::INFO)
        CliAdapter.setYesNoBehavior(@options.inputDefault)
end

Public Instance Methods

execute(*args) click to toggle source
# File lib/disloku/BaseCoreCommand.rb, line 66
def execute(*args)
        send(:executeCommand, *args)
end
loadConfiguration() click to toggle source
# File lib/disloku/BaseCoreCommand.rb, line 29
def loadConfiguration()
        repoConfig = File.join(repository.root, 'disloku.config')
        if (!File.exists?(repoConfig))
                raise DislokuError.new("There is no disloku.config file in #{repository.root}")
        end

        config = Config::YamlConfig.new(repoConfig)

        userHome = File.expand_path("~")
        userConfig = File.join(userHome, ".disloku.config")
        if (File.exists?(userConfig))
                base = Config::YamlConfig.new(userConfig)
                config.merge(base)
        end

        return config
end
resolveTargets(targets) click to toggle source
# File lib/disloku/BaseCoreCommand.rb, line 47
def resolveTargets(targets)
        actualTargets = []

        while (targets.count > 0)
                current = targets.shift()
                targetConfig = @config["targets"][current]
                if (targetConfig != nil)
                        if (targetConfig["targets"] != nil)
                                targetConfig["targets"].value().each() { |x| targets.push(x.value()) }
                                next
                        end

                        actualTargets.push(Config::Target.new(current, targetConfig, @mappingStore, @connectionStore))
                end
        end

        return actualTargets
end