class Codewars::Configuration

Constants

CONFIG_NAME

Public Class Methods

config() click to toggle source
# File lib/codewars/configuration.rb, line 16
def self.config
  File.exist?(config_path) ? YAML.load_file(config_path) : {}
end
config_path() click to toggle source
# File lib/codewars/configuration.rb, line 20
def self.config_path
  "#{ENV['HOME']}/#{CONFIG_NAME}"
end
option(option) click to toggle source
# File lib/codewars/configuration.rb, line 24
def self.option(option)
  config[option]
end
write_option_to_config(option, value) click to toggle source
# File lib/codewars/configuration.rb, line 7
def self.write_option_to_config(option, value)
  config_hash = config
  config_hash[option] = value

  config_str = ''
  config_hash.each { |k, v| config_str += "#{k}: #{v}\n" }
  File.write(config_path, config_str)
end