Module: Fauna::Rack
- Defined in:
- lib/fauna_helper.rb
Class Method Summary collapse
- .connection(credentials, logger) ⇒ Object
- .credentials(config_file, local_config_file, app_name) ⇒ Object
Class Method Details
.connection(credentials, logger) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fauna_helper.rb', line 22 def self.connection(credentials, logger) root_connection = Connection.new( :email => credentials["email"], :password => credentials["password"], :logger => logger) publisher_key = root_connection.post("keys/publisher")["resource"]["key"] connection = Connection.new( publisher_key: publisher_key, logger: logger) { root_connection: root_connection, connection: connection } end |
.credentials(config_file, local_config_file, app_name) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fauna_helper.rb', line 5 def self.credentials(config_file, local_config_file, app_name) env = ENV['RACK_ENV'] || 'development' # FIXME: need this for tux. credentials = {} if File.exist? config_file credentials.merge!(YAML.load_file(config_file)[env] || {}) if File.exist? local_config_file credentials.merge!((YAML.load_file(local_config_file)[app_name] || {})[env] || {}) end else STDERR.puts ">> Fauna account not configured. You can add one in config/fauna.yml." end credentials end |