class RanchHand::Config
Public Class Methods
create()
click to toggle source
# File lib/ranch_hand/config.rb, line 5 def self.create save(generate_config) RanchHand::Logger.info("Config file saved to #{project_config_path}") end
load()
click to toggle source
# File lib/ranch_hand/config.rb, line 10 def self.load begin YAML.load_file(project_config_path) rescue Errno::ENOENT {} end end
Private Class Methods
generate_config()
click to toggle source
# File lib/ranch_hand/config.rb, line 20 def self.generate_config namespace = prompt.ask('Namespace:') group = prompt.ask('Use group command by default? (Y/n):') group = %w(n N).include?(group) ? false : true pod = prompt.ask('Pod name:') { group: group, namespace: namespace, pod: pod } end
project_config_path()
click to toggle source
# File lib/ranch_hand/config.rb, line 41 def self.project_config_path File.join(Dir.pwd, ".ranch-hand") end
save(config)
click to toggle source
# File lib/ranch_hand/config.rb, line 33 def self.save(config) # File.new(project_config_path, 'w+', 0640) File.open(project_config_path, 'w', 0640) do |f| f.write(config.to_yaml) end end