Sha256: e5e9fe42c330c04cdd6994c3893c4b2acd53436820552ff2326bebcc3cfdf72e
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
module TestingBot @@config = nil def self.get_config @@config = TestingBot::Config.new if @@config.nil? @@config end class Config attr_reader :options def initialize(options = {}) @options = options @options = @options.merge(load_config_file) @options = @options.merge(load_config_environment) end def [](key) @options[key] end def []=(key, value) @options[key] = value end def client_key @options[:client_key] end def client_secret @options[:client_secret] end private def load_config_file options = {} is_windows = (RUBY_PLATFORM =~ /w.*32/) if is_windows config_file = "#{ENV['HOMEDRIVE']}\\.testingbot" else config_file = File.expand_path("~/.testingbot") end if File.exists?(config_file) str = File.open(config_file) { |f| f.readline }.chomp options[:client_key], options[:client_secret] = str.split(':') end options end def load_config_environment options = {} options[:client_key] = ENV['TESTINGBOT_CLIENTKEY'] options[:client_secret] = ENV['TESTINGBOT_CLIENTSECRET'] options.delete_if { |key, value| value.nil?} options end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
testingbot-0.0.9 | lib/testingbot/config.rb |