module CW::Cfg

Constants

CONFIG_METHODS

Public Class Methods

config() click to toggle source
# File lib/cw/config.rb, line 19
    def self.config
      unless @config
        @config = ParseConfig.new(CONFIG_PATH)
        CONFIG_METHODS.each do |method|
          unless @config[method.to_s]
            @config.add method.to_s, nil
          end
        end
        self.user_config
        @config.params["wpm"] = 50 if(ENV["CW_ENV"] == "test")
        @config.params["effective_wpm"] = 50 if(ENV["CW_ENV"] == "test")
#        puts " @config[wpm] = #{@config['wpm']}"
      end
#      puts "@config = #{@config.params}"
      @config
    end
get_param(param) click to toggle source
# File lib/cw/config.rb, line 56
def self.get_param param
  self.reset_if_nil param
  @config[param]
end
reset() click to toggle source
# File lib/cw/config.rb, line 44
def self.reset
  @config = nil
end
reset_if_nil(param) click to toggle source
# File lib/cw/config.rb, line 52
def self.reset_if_nil param
  self.reset_param param if @config[param].nil?
end
reset_param(param) click to toggle source
# File lib/cw/config.rb, line 48
def self.reset_param param
  @config.params[param] = false
end
user_config() click to toggle source
# File lib/cw/config.rb, line 36
def self.user_config
  user_cfg = File.join(WORK_DIR, CONFIG_FILENAME)
  if File.exist? user_cfg
    temp = ParseConfig.new(user_cfg);
    @config.params = @config.params.merge(temp.params)
  end
end