chardane / ClarifaiRuby

Ruby client for Clarifai API
MIT License
12 stars 12 forks source link

add ability to configure gem #1

Closed chardane closed 8 years ago

chardane commented 8 years ago

This allows us to configure values for the gem to use later. Configuration values added were:

- client_id
- client_secret
- base_url
- version_path

The api_path is calculated based on the base_path and version_path

Now, we can put something like this in an initializer in a Rails application for example:

ClarifaiRuby.configure do |config|
   config.base_url = "https://api.clarifai.com/v1"
   config.version_path = "/v1"
   config.client_id = "THISISAN_ID"
   config.client_secret = "-123wedkfjnkj3"
end

and when we want to use these configured values in the gem itself:

ClarifaiRuby.configuration.client_id #=> will result in the configured value, "THISISAN_ID"

Try it out by running rake console and manually typing in the config, and seeing that you can access the configured value using ClarifaiRuby.configuration.whatever_config_value :D

maxcell commented 8 years ago

LGTM