Class: Discharger::SetupRunner::Commands::ConfigCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Discharger::SetupRunner::Commands::ConfigCommand
show all
- Defined in:
- lib/discharger/setup_runner/commands/config_command.rb
Instance Attribute Summary
Attributes inherited from BaseCommand
#app_root, #config, #logger
Instance Method Summary
collapse
Methods inherited from BaseCommand
#initialize
Instance Method Details
#can_execute? ⇒ Boolean
41
42
43
|
# File 'lib/discharger/setup_runner/commands/config_command.rb', line 41
def can_execute?
true
end
|
#description ⇒ Object
45
46
47
|
# File 'lib/discharger/setup_runner/commands/config_command.rb', line 45
def description
"Setup configuration files"
end
|
#execute ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/discharger/setup_runner/commands/config_command.rb', line 10
def execute
log "Ensuring configuration files are present"
database_yml = File.join(app_root, "config/database.yml")
database_yml_example = File.join(app_root, "config/database.yml.example")
if !File.exist?(database_yml) && File.exist?(database_yml_example)
FileUtils.cp(database_yml_example, database_yml)
log "Copied config/database.yml.example to config/database.yml"
end
procfile = File.join(app_root, "Procfile")
procfile_dev = File.join(app_root, "Procfile.dev")
if !File.exist?(procfile) && File.exist?(procfile_dev)
FileUtils.cp(procfile_dev, procfile)
log "Copied Procfile.dev to Procfile"
end
Dir.glob(File.join(app_root, "config/**/*.example")).each do |example_file|
config_file = example_file.sub(/\.example$/, "")
unless File.exist?(config_file)
FileUtils.cp(example_file, config_file)
log "Copied #{example_file.sub(app_root + "/", "")} to #{config_file.sub(app_root + "/", "")}"
end
end
end
|