Skip to content

Commit 334b0eb

Browse files
committed
Merge branch 'develop'
2 parents 0606bb2 + 0d91750 commit 334b0eb

File tree

9 files changed

+28
-13
lines changed

9 files changed

+28
-13
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: ruby
22
rvm:
3-
- 2.2.3
3+
- 2.3.0
44
notifications:
55
recipients:
66

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Version History
2+
====
3+
* All Version bumps are required to update this file as well!!
4+
----
5+
6+
* 0.7.0 - Implement ability to specify OAuth scopes
7+
* 0.6.1 - Update various dependencies
8+
* 0.6.0 - Implement ETag-based caching flow for all endpoints
9+
* 0.5.0 - Update OAuth2 gem to 1.0.0

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Alternatively, cortex-client will handle OAuth2 authentication for you:
2222
```ruby
2323
require 'cortex-client'
2424

25-
client = Cortex::Client.new(key: 'my-app-id', secret: 'secrey-key-ssh', base_url: 'base_url')
25+
client = Cortex::Client.new(key: 'my-app-id', secret: 'secrey-key-ssh', base_url: 'base_url', scopes: 'view:posts view:media')
2626

2727
client.posts.query().each do |post|
2828
puts post
@@ -51,5 +51,4 @@ Cortex::Client will return a Cortex::Result object. The following methods are av
5151
- *Webpages* - feed
5252

5353
### TODO
54-
- Handle pagination
55-
- /media
54+
- Support *Media* endpoint

cortex-client.gemspec

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@ Gem::Specification.new do |s|
88
s.homepage = 'https://github.com/cortex-cms/cortex-client-ruby'
99
s.authors = ['CB Content Enablement']
1010
s.email = '[email protected]'
11-
s.license = 'Apache 2.0'
11+
s.license = 'Apache-2.0'
1212

1313
s.files = `git ls-files`.split($/).reject { |f| f == '.gitignore' }
1414
s.test_files = s.files.grep(%r{^(test|spec|features)/})
1515
s.require_paths = ['lib']
1616

17-
s.add_development_dependency 'rake', '~> 10.4'
18-
s.add_development_dependency 'rspec', '~> 3.3'
17+
s.add_development_dependency 'rake', '~> 11.1'
18+
s.add_development_dependency 'rspec', '~> 3.4'
1919
s.add_development_dependency 'mocha', '~> 1.1'
2020

2121
s.add_dependency 'faraday', '~> 0.9'
2222
s.add_dependency 'faraday_middleware', '~> 0.10'
23-
s.add_dependency 'oauth2', '~> 0.9'
23+
s.add_dependency 'faraday-http-cache', '~> 1.3.0'
24+
s.add_dependency 'oauth2', '~> 1.1.0'
2425
s.add_dependency 'cortex-exceptions', '~> 0.0.4'
2526
s.add_dependency 'hashie', '~> 3.4'
2627
end

lib/cortex/client.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Client
1414
attr_accessor :access_token, :base_url, :auth_method
1515
@key = ''
1616
@secret = ''
17+
@scopes = ''
1718

1819
include Cortex::Connection
1920
include Cortex::Request
@@ -25,6 +26,7 @@ def initialize(hasharg)
2526
else
2627
@key = hasharg[:key]
2728
@secret = hasharg[:secret]
29+
@scopes ||= hasharg[:scopes]
2830
@access_token = get_cc_token
2931
end
3032
@posts = Cortex::Posts.new(self)
@@ -35,7 +37,7 @@ def initialize(hasharg)
3537
def get_cc_token
3638
begin
3739
client = OAuth2::Client.new(@key, @secret, site: @base_url)
38-
client.client_credentials.get_token
40+
client.client_credentials.get_token({scope: @scopes})
3941
rescue Faraday::ConnectionFailed
4042
raise Cortex::Exceptions::ConnectionFailed.new(base_url: @base_url)
4143
end

lib/cortex/connection.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
require 'faraday'
22
require 'faraday_middleware'
33
require 'cortex/faraday_middleware'
4+
require 'faraday-http-cache'
45

56
module Cortex
67
module Connection
78
def connection
89
options = {
910
:headers => {
10-
:user_agent => "cortex-client (Ruby) - #{Cortex::VERSION}"
11+
:user_agent => "cortex-client-ruby - #{Cortex::VERSION}"
1112
},
1213
:url => base_url
1314
}
@@ -18,6 +19,8 @@ def connection
1819

1920
Faraday.new options do |conn|
2021
conn.use Cortex::FaradayMiddleware
22+
23+
conn.use Faraday::HttpCache, store: Rails.cache, logger: Rails.logger if defined? Rails
2124
conn.request :oauth2, access_token.is_a?(OAuth2::AccessToken) ? access_token.token : access_token
2225
conn.request :json
2326
conn.response :json, :content_type => /\bjson$/

lib/cortex/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Cortex
2-
VERSION = '0.4.6'
2+
VERSION = '0.7.0'
33
end

lib/cortex/webpages.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Cortex
22
class Webpages < Cortex::Resource
33
def get_feed(id)
4-
client.get("/webpages/feed", {:url => id})
4+
client.get('/webpages/feed', {:url => id})
55
end
66
end
77
end

spec/client_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
let(:access_token) { '123' }
66
let(:base_url) { 'http://localhost:3000' }
7+
let(:scopes) { 'view:posts view:media' }
78
let(:client) do
8-
Cortex::Client.new(access_token: access_token, base_url: base_url)
9+
Cortex::Client.new(access_token: access_token, base_url: base_url, scopes: scopes)
910
end
1011

1112
it 'should preserve settings' do

0 commit comments

Comments
 (0)