Sha256: 0dd14b62141423d29726f619bcc5cb9e193e30778c92b043bdcee66755570ddf

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

# cortex-snippets-client-ruby

[![Build Status](https://travis-ci.org/cortex-cms/cortex-snippets-client-ruby.svg?branch=master)](https://travis-ci.org/cortex-cms/cortex-snippets-client-ruby)
[![Dependency Status](https://gemnasium.com/cortex-cms/cortex-snippets-client-ruby.svg)](https://gemnasium.com/cortex-cms/cortex-snippets-client-ruby)

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](https://hueniverse.com/2010/09/29/oauth-bearer-tokens-are-a-terrible-idea/))
* `CORTEX_SNIPPET_SCOPES`: provide the necessary scopes to obtain Webpage/Snippet data (usually just `view:webpages`)

```ruby
use OmniAuth::Builder do
  provider :cortex, ENV['CORTEX_KEY'], ENV['CORTEX_SECRET'], scope: 'scope1, scope2, scope3'
end
```

## Rails Helpers

```haml
= 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.

```ruby
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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cortex-snippets-client-0.8.0 README.md