module CLI::Config
Methods for configuring Robot Sweatshop
Public Class Methods
compile_to_file()
click to toggle source
# File lib/robot_sweatshop/cli/config.rb, line 31 def self.compile_to_file config = expand_paths_in configatron.to_h config[:working_path] = Dir.pwd write config end
default()
click to toggle source
# File lib/robot_sweatshop/cli/config.rb, line 7 def self.default File.read "#{__dir__}/../../../config.defaults.yaml" end
expand_paths_in(config_hash)
click to toggle source
# File lib/robot_sweatshop/cli/config.rb, line 19 def self.expand_paths_in(config_hash) config_hash.each do |key, value| config_hash[key] = File.expand_path value if key.to_s.match(/_path/) end end
path(for_user: false)
click to toggle source
# File lib/robot_sweatshop/cli/config.rb, line 11 def self.path(for_user: false) if for_user '~/.robot_sweatshop/config.yaml' else '.robot_sweatshop/config.yaml' end end
write(config_hash)
click to toggle source
# File lib/robot_sweatshop/cli/config.rb, line 25 def self.write(config_hash) config_home = File.expand_path('~/.robot_sweatshop') FileUtils.mkpath config_home File.write "#{config_home}/compiled_config.yaml", config_hash.to_yaml end