module Yiban
Constants
- VERSION
Public Class Methods
config()
click to toggle source
configをyamlから@cofigに取得
# File lib/yiban/helper/config_helper.rb, line 34 def self.config yml_path = get_config_path + '/settings.yml' yml_file = YAML.load_file(yml_path) if yml_file @config = yml_file else File.open(yml_path, 'w') { |f| YAML.dump(@config, f) } end end
configure(opts = {})
click to toggle source
Configure through hash
# File lib/yiban/helper/config_helper.rb, line 13 def self.configure(opts = {}) config opts.each do |k, v| @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym end save_config end
get_config_path()
click to toggle source
# File lib/yiban/helper/config_helper.rb, line 21 def self.get_config_path config_path = Dir.home + '/.yiban' if Dir.exist?(config_path) # use user settings config_path else system "mkdir #{config_path}" config_path #raise "Can't find config directory. please init by command: 'mygem config'.'" end end
save_config()
click to toggle source
現在の@configをyamlに保存
# File lib/yiban/helper/config_helper.rb, line 45 def self.save_config yml_path = get_config_path + '/settings.yml' if File.exist?(yml_path) File.open(yml_path, 'w') { |f| YAML.dump(@config, f) } else raise "Can't find #{yml_path}. please set configure." end end