-
Notifications
You must be signed in to change notification settings - Fork 35
Configuration files
GutsyGusty edited this page Dec 5, 2014
·
2 revisions
This example is specific to Spark API Authentication. Be sure to use the correct method of authentication for your project.
#/path/to/my/project/config/my_custom_config_folder/settings.yml
development:
api_key: 'agent_key'
api_secret: 'agent_secret'
The configuration directory defaults to 'config/spark_api'
.
If you are working in rails SparkApi will assume that the project path will start at Rails.root. Otherwise it will be best to define the full config_path.
Also you need your configuration path to be different than Rails.root+'/config/spark_api'
you will want to specify the full config_path.
require 'spark_api'
# ENV['RAILS_ENV'] or ENV['RACK_ENV']
#if rack or rails is being used it will default to ENV['RAILS_ENV'] or ENV['RACK_ENV']
#if we want to always use the same environment we can define env["SPARK_API_ENV"]
ENV["SPARK_API_ENV"] = 'development' #this will force the use 'development' values in settings.yml
module SparkApi
module Configuration
class YamlConfig
def self.config_path
'/path/to/my/project/config/my_custom_config_folder' #defaults to 'config/spark_api'
end
end
end
end
SparkApi.activate(:settings) #settings is the name of our .yml file
response = SparkApi.get '/my/account'
puts response.to_yaml
You can also specify a config file when using the spark_api cli
user@host:~$ spark_api -f settings.yml
Some of the configuration settings can be inspected within the client.
puts SparkApi.client.inspect