2013-12-09 18:03:22 +00:00
|
|
|
defaults = {
|
|
|
|
CARRIERWAVE_STORAGE: 'file',
|
|
|
|
HOME_CAST_ID: nil,
|
|
|
|
AIRBRAKE_API_KEY: nil,
|
|
|
|
AIRBRAKE_HOST: nil,
|
|
|
|
GOOGLE_ANALYTICS_ID: nil,
|
|
|
|
TWITTER_CONSUMER_KEY: nil,
|
|
|
|
TWITTER_CONSUMER_SECRET: nil,
|
|
|
|
GITHUB_CONSUMER_KEY: nil,
|
|
|
|
GITHUB_CONSUMER_SECRET: nil,
|
|
|
|
AWS_ACCESS_KEY_ID: nil,
|
|
|
|
AWS_SECRET_ACCESS_KEY: nil,
|
|
|
|
AWS_REGION: nil,
|
|
|
|
AWS_BUCKET: nil,
|
|
|
|
SECRET_TOKEN: '21deaa1a1228e119434aa783ecb4af21be7513ff1f5b8c1d8894241e5fc70ad395db72c8c1b0508a0ebb994ed88a8d73f6c84e44f7a4bc554a40d77f9844d2f4'
|
|
|
|
}.stringify_keys!
|
2012-02-20 20:52:21 +00:00
|
|
|
|
2013-12-09 18:03:22 +00:00
|
|
|
cfg_file = File.expand_path(File.dirname(__FILE__) + '/asciinema.yml')
|
|
|
|
cfg_hash = YAML.load_file(cfg_file) || {} rescue {}
|
2012-02-20 20:52:21 +00:00
|
|
|
|
2013-12-09 18:03:22 +00:00
|
|
|
cfg = {}
|
|
|
|
cfg.merge!(defaults)
|
|
|
|
cfg.merge!(cfg_hash)
|
|
|
|
cfg.merge!(ENV)
|
2012-02-20 20:52:21 +00:00
|
|
|
|
2013-12-09 18:03:22 +00:00
|
|
|
module Asciinema
|
|
|
|
class Configuration
|
|
|
|
def initialize(cfg)
|
|
|
|
@cfg = cfg
|
|
|
|
end
|
|
|
|
|
|
|
|
def method_missing(name, *args, &block)
|
|
|
|
key = normalize_key(name)
|
|
|
|
@cfg.key?(key) ? @cfg[key] : super
|
|
|
|
end
|
|
|
|
|
|
|
|
def respond_to_missing?(name, include_private = false)
|
|
|
|
key = normalize_key(name)
|
|
|
|
@cfg.key?(key) || super
|
|
|
|
end
|
|
|
|
|
|
|
|
def [](key)
|
|
|
|
send(key)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def normalize_key(key)
|
|
|
|
key.to_s.upcase
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
::CFG = Asciinema::Configuration.new(cfg)
|