Module: Locomotive::Wagon::DeployFileConcern
- Included in:
- DeleteCommand, PullCommand, PushCommand, SyncCommand
- Defined in:
- lib/locomotive/wagon/commands/concerns/deploy_file_concern.rb
Instance Method Summary collapse
- #deploy_file(path) ⇒ Object
- #read_deploy_settings(env, path) ⇒ Object
- #write_deploy_settings(env, path, settings) ⇒ Object
Instance Method Details
#deploy_file(path) ⇒ Object
26 27 28 |
# File 'lib/locomotive/wagon/commands/concerns/deploy_file_concern.rb', line 26 def deploy_file(path) File.join(path, 'config', 'deploy.yml') end |
#read_deploy_settings(env, path) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/locomotive/wagon/commands/concerns/deploy_file_concern.rb', line 15 def read_deploy_settings(env, path) # pre-processing: erb code to parse and render? parsed_deploy_file = ERB.new(File.open(deploy_file(path)).read).result # finally, get the hash from the YAML file environments = YAML::load(parsed_deploy_file) (environments.is_a?(Hash) ? environments : {})[env.to_s] rescue Exception => e raise "Unable to read the config/deploy.yml file (#{e.})" end |
#write_deploy_settings(env, path, settings) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/locomotive/wagon/commands/concerns/deploy_file_concern.rb', line 7 def write_deploy_settings(env, path, settings) File.open(deploy_file(path), 'a+') do |f| f.write({ env => settings }.to_yaml.sub(/^---/, '')) end settings end |