cortex-snippets-client-ruby

Build Status Dependency Status

Ruby client library that provides helpers to assist with loading and displaying Cortex Snippets.

Installation

Add this line to your application's Gemfile:

gem 'cortex-snippets-client'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cortex-snippets-client

Configuration

Several environmental variables must be set before using the library:

  • CORTEX_SNIPPET_KEY
  • CORTEX_SNIPPET_SECRET
  • CORTEX_SNIPPET_BASE_URL: provide the Cortex API base URL
  • CORTEX_SNIPPET_ACCESS_TOKEN: only use this if you have been granted a bearer token (but don't)
  • CORTEX_SNIPPET_SCOPES: provide the necessary scopes to obtain Webpage/Snippet data (usually just view:webpages)
use OmniAuth::Builder do
  provider :cortex, ENV['CORTEX_KEY'], ENV['CORTEX_SECRET'], scope: 'scope1, scope2, scope3'
end

Rails Helpers

= snippet :id => "subhero-button1__text" do

Sinatra Helpers

Override Environment

If you would like to change the URLs used by cortex-snippets-client-ruby, override :client_options in the provider config step.

provider :cortex, ENV['CORTEX_KEY'], ENV['CORTEX_SECRET'], scope: 'scope1, scope2, scope3',
  {
    :client_options => {
      :site => 'http://localhost:3000/api/v1',
      :authorize_url => 'http://localhost:3000/oauth/authorize',
      :token_url => 'http://localhost:3000/oauth/token'
    }
  }

Caching