Skip to content

Commit

Permalink
Look for api keys in ENV if parse_resource.yml not present
Browse files Browse the repository at this point in the history
  • Loading branch information
jdmaresco committed Oct 3, 2013
1 parent 1c8b731 commit b926ceb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/parse_resource/base.rb
Expand Up @@ -276,7 +276,16 @@ def self.load_settings
@@settings ||= begin
path = "config/parse_resource.yml"
environment = defined?(Rails) && Rails.respond_to?(:env) ? Rails.env : ENV["RACK_ENV"]
YAML.load(ERB.new(File.new(path).read).result)[environment]
if FileTest.exist? (path)
YAML.load(ERB.new(File.new(path).read).result)[environment]
elsif ENV['app_id'] && ENV['master_key']
settings = HashWithIndifferentAccess.new
settings['app_id'] = ENV['app_id']
settings['master_key'] = ENV['master_key']
settings
else
raise "Cannot load parse_resource.yml and API keys are not set in environment"
end
end
@@settings
end
Expand Down

0 comments on commit b926ceb

Please sign in to comment.