Module: Utils
- Includes:
- Thor::Shell
- Included in:
- DEIS::Config, DEIS::Config, DEIS::Deploy, DEIS::Deploy
- Defined in:
- lib/utils.rb
Instance Method Summary collapse
- #config_data ⇒ Object
- #data_to_deis_config_set(config) ⇒ Object
- #file_store(dir) ⇒ Object
- #target_host(env) ⇒ Object
Instance Method Details
#config_data ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/utils.rb', line 20 def config_data "looking for data file".log name = DEIS::Git.repo file = DEIS::Config.config_storage+"#{name}.json" "data file: #{file}".log if File.exists?(file) && ( content = File.read(file) ) && (json = JSON.parse(content)) return json end return nil end |
#data_to_deis_config_set(config) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/utils.rb', line 32 def data_to_deis_config_set(config) if config.length > 0 string = "deis config:set " config.each{|k,v| string += "#{k}=\"#{v.strip}\" "} return string.strip end nil end |
#file_store(dir) ⇒ Object
15 16 17 18 |
# File 'lib/utils.rb', line 15 def file_store(dir) FileUtils.mkdir_p(dir) unless Dir.exists?(dir) dir end |
#target_host(env) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/utils.rb', line 5 def target_host(env) file = DEIS::HOSTS_STORE+env if ! File.exists?(file) host = ask "Hostname / IP for #{env}: ".colorize(:yellow) self.file_store(DEIS::HOSTS_STORE) File.open(file, "w"){|f| f.write(host) } end File.read(file) end |