Class: Disloku::BaseCoreCommand

Inherits:
BaseCommand show all
Defined in:
lib/disloku/BaseCoreCommand.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseCommand

#processGlobalOptions

Constructor Details

#initialize(cliOptions) ⇒ BaseCoreCommand

Returns a new instance of BaseCoreCommand.



16
17
18
19
20
21
22
23
24
25
26
27
# 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

Instance Attribute Details

#configObject

Returns the value of attribute config.



14
15
16
# File 'lib/disloku/BaseCoreCommand.rb', line 14

def config
  @config
end

#optionsObject

Returns the value of attribute options.



14
15
16
# File 'lib/disloku/BaseCoreCommand.rb', line 14

def options
  @options
end

#repositoryObject

Returns the value of attribute repository.



14
15
16
# File 'lib/disloku/BaseCoreCommand.rb', line 14

def repository
  @repository
end

Instance Method Details

#execute(*args) ⇒ Object



66
67
68
# File 'lib/disloku/BaseCoreCommand.rb', line 66

def execute(*args)
	send(:executeCommand, *args)
end

#loadConfigurationObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# 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) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# 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