Class: Popo::Init
Constant Summary
Constants included
from Constants
Constants::COLOR_GREEN, Constants::COLOR_NONE, Constants::COLOR_RED, Constants::COLOR_YELLOW, Constants::DEFAULT_CONFIG_FILE, Constants::DEFAULT_POPO_TARGET, Constants::POPORC, Constants::POPO_COMMANDS, Constants::POPO_CONFIG, Constants::POPO_DIR_KEY, Constants::POPO_KEY_VALUES, Constants::POPO_WORK_PATH, Constants::POPO_YML_FILE, Constants::POST_INSTALL_NOTE, Constants::REQUIRED_COMMANDS
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(runner) ⇒ Init
Returns a new instance of Init.
9
10
11
12
13
14
15
|
# File 'lib/popo/init.rb', line 9
def initialize(runner)
@db = runner.database
@options = runner.options
@location = @options[:location] || nil
@manifest = runner.config['manifests'][@options[:manifest]]
@deploy_path = File.absolute_path(@options[:path])
end
|
Class Method Details
.boot(runner) ⇒ Object
5
6
7
|
# File 'lib/popo/init.rb', line 5
def self.boot(runner)
self.new(runner)
end
|
Instance Method Details
#print_variables ⇒ Object
17
18
19
20
21
|
# File 'lib/popo/init.rb', line 17
def print_variables
instance_variables.each do |i|
say instance_variable_get(i)
end
end
|
#setup ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/popo/init.rb', line 23
def setup
print_variables if @options[:verbose]
clone_path = File.join(@deploy_path, POPO_WORK_PATH)
GitUtils.git_clone(@manifest['git'], clone_path, @manifest['branch'])
@db.boot_database
@db.migrate_database
repos = @db.get_children("repos")
repos.each do |r|
git = @db.get("repos.#{r}.git")
branch = @db.get("repos.#{r}.branch")
clone_path = File.join(@deploy_path, r)
GitUtils.git_clone(git, clone_path, branch)
end
write_config
end
|
#write_config ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/popo/init.rb', line 43
def write_config
popo = {}
popo['target'] = DEFAULT_POPO_TARGET
popo['path'] = @deploy_path
popo['location'] = @location if !@location.nil?
yml_path = File.join(@deploy_path, POPO_WORK_PATH, POPO_YML_FILE)
File.open(yml_path, "w") do |f|
YAML.dump(popo, f)
end
end
|