class Redk::CapnPanda::Config
Public Class Methods
config_file()
click to toggle source
# File lib/redk/capn_panda/config.rb, line 6 def self.config_file ENV['CAPN_PANDA_CONFIG'] || ENV['HOME'] + "/.config/capn_panda.yaml" end
default_config()
click to toggle source
# File lib/redk/capn_panda/config.rb, line 26 def self.default_config { jira_domain: "jira.atlassian.com", jira_username: "jsmith", jira_default_project_key: "PROJ", jira_default_issuetype_name: "Task", jira_gerrit_field: "customfield_10403", jira_new_issue_fields: { # customfield_12700: { # value: "platform" # } }, gerrit_domain: "gerrit.changeme.com", firework_domain: false } end
load()
click to toggle source
# File lib/redk/capn_panda/config.rb, line 10 def self.load unless File.exist?(Config.config_file) self.save(Config.config_file, Config.default_config) end self.new(Config.config_file) end
new(config_file)
click to toggle source
# File lib/redk/capn_panda/config.rb, line 44 def initialize(config_file) @default_config = Config.default_config @config = @default_config.merge(::YAML::load(File.open(config_file))) end
nuke()
click to toggle source
# File lib/redk/capn_panda/config.rb, line 18 def self.nuke File.delete(Config.config_file) if File.exist?(Config.config_file) end
save(config_file, config)
click to toggle source
# File lib/redk/capn_panda/config.rb, line 22 def self.save(config_file, config) File.open(Config.config_file, 'w+') {|f| f.write(config.to_yaml) } end
Public Instance Methods
method_missing(m, *args, &block)
click to toggle source
# File lib/redk/capn_panda/config.rb, line 65 def method_missing(m, *args, &block) return @config[m.to_sym] if @config.has_key?(m.to_sym) raise "no such config property: #{m}" end
set(key, value)
click to toggle source
# File lib/redk/capn_panda/config.rb, line 53 def set(key, value) @config[key.to_sym] = value end
to_ary()
click to toggle source
# File lib/redk/capn_panda/config.rb, line 57 def to_ary return @config.values end
to_hash()
click to toggle source
# File lib/redk/capn_panda/config.rb, line 61 def to_hash return @config end
write()
click to toggle source
# File lib/redk/capn_panda/config.rb, line 49 def write Config.save(Config.config_file, @config) end