Skip to content

Commit 7e2120e

Browse files
author
Bennett Goble
committed
Initial
0 parents  commit 7e2120e

20 files changed

+383
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.bundle/

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source 'https://rubygems.org'
2+
3+
gemspec

Gemfile.lock

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
PATH
2+
remote: .
3+
specs:
4+
cortex-client (0.0.1)
5+
faraday (~> 0.8.9)
6+
faraday_middleware (~> 0.9.0)
7+
8+
GEM
9+
remote: https://rubygems.org/
10+
specs:
11+
diff-lcs (1.2.5)
12+
faraday (0.8.9)
13+
multipart-post (~> 1.2.0)
14+
faraday_middleware (0.9.0)
15+
faraday (>= 0.7.4, < 0.9)
16+
multipart-post (1.2.0)
17+
rake (10.2.2)
18+
rspec (2.14.1)
19+
rspec-core (~> 2.14.0)
20+
rspec-expectations (~> 2.14.0)
21+
rspec-mocks (~> 2.14.0)
22+
rspec-core (2.14.8)
23+
rspec-expectations (2.14.5)
24+
diff-lcs (>= 1.1.3, < 2.0)
25+
rspec-mocks (2.14.6)
26+
27+
PLATFORMS
28+
ruby
29+
30+
DEPENDENCIES
31+
cortex-client!
32+
rake
33+
rspec

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) 2014 CareerBuilder, LLC
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# cortex-client
2+
Ruby client library for [cortex](https://github.com/cb-talent-development/cortex)'s API.
3+
4+
cortex-client does not handle fetching or refreshing an OAuth access_token. For this use a library such as [OAuth](http://oauth.rubyforge.org/).
5+
6+
```ruby
7+
require 'cortex-client'
8+
9+
client = Cortex::Client.new(access_token)
10+
11+
client.posts.query().each do |post|
12+
puts post
13+
end
14+
```
15+
16+
### Supported Endpoints
17+
18+
- *Users* - me, get ,save
19+
- *Posts* - query, get, save, delete
20+
21+
### TODO
22+
- Handle pagination
23+
- Support for search queries
24+
- /media

Rakefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require 'bundler'
2+
require 'rspec/core/rake_task'
3+
4+
task :default => :test
5+
6+
RSpec::Core::RakeTask.new(:test) do |t|
7+
t.pattern = 'spec/**/*_spec.rb'
8+
end

cortex-client.gemspec

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# encoding: utf-8
2+
require './lib/cortex/version'
3+
4+
Gem::Specification.new do |s|
5+
s.name = 'cortex-client'
6+
s.version = Cortex::VERSION
7+
s.summary = 'Cortex API Client'
8+
s.homepage = 'https://github.com/cb-talent-development/cortex-client'
9+
s.authors = ['Bennett Goble']
10+
s.license = 'MIT'
11+
12+
s.files = `git ls-files`.split($/).reject { |f| f == '.gitignore' }
13+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
14+
s.require_paths = ['lib']
15+
16+
s.add_development_dependency 'rake'
17+
s.add_development_dependency 'rspec'
18+
19+
s.add_dependency 'faraday', '~> 0.8.9'
20+
s.add_dependency 'faraday_middleware', '~> 0.9.0'
21+
end

lib/cortex-client.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require 'cortex/client'
2+
require 'cortex/version'

lib/cortex/client.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require 'cortex/connection'
2+
require 'cortex/request'
3+
require 'cortex/resource'
4+
require 'cortex/posts'
5+
require 'cortex/users'
6+
7+
module Cortex
8+
class Client
9+
attr_reader :posts, :users
10+
attr_accessor :access_token, :base_url
11+
12+
include Cortex::Connection
13+
include Cortex::Request
14+
15+
def initialize(access_token, base_url = 'https://cbcortex.com/api/v1')
16+
@access_token = access_token
17+
@base_url = base_url
18+
@posts = Cortex::Posts.new(self)
19+
@users = Cortex::Users.new(self)
20+
end
21+
end
22+
end

lib/cortex/connection.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require 'faraday'
2+
require 'faraday_middleware'
3+
4+
module Cortex
5+
module Connection
6+
def connection
7+
options = {
8+
:headers => {
9+
:user_agent => "cortex-client (Ruby) - #{Cortex::VERSION}"
10+
},
11+
:url => base_url
12+
}
13+
Faraday.new options do |conn|
14+
conn.request :oauth2, access_token
15+
conn.request :json
16+
conn.response :json, :content_type => /\bjson$/
17+
conn.adapter Faraday.default_adapter
18+
end
19+
end
20+
end
21+
end

0 commit comments

Comments
 (0)