cortex-client 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e419c4728ee8a406508ab98228d7cdfc45bcd48f
4
- data.tar.gz: 120729a62acb477abf196d7f7c2da88130d1295e
3
+ metadata.gz: 6805c6198532fcdecc61d871214291b3c3f39fde
4
+ data.tar.gz: 44d36a2e77e4209d9e13781a91a0e21c01999c40
5
5
  SHA512:
6
- metadata.gz: a68e6b55b256c909b96a9d3800945b949908ec1c127eab6a0d8973a9b8e69994e7a5fd53143c11f3356711767c588b0a23641a1b12189f67e1021ab8155f1561
7
- data.tar.gz: ca68f9520ab68818e46cb4443217601d73aa740e40ec454ac4ba2c452696db20d61e98def54f2fa787f4d2b1b7e21b3f6f223e4b7d724fe0480b98e5cf15382a
6
+ metadata.gz: 51aa66d9bf0284a96513c6107e76f720bc5a6aba36217aefe24fe942a44226ba4297eaeeeb293a3b1113cb2428a4b1bd265be4bdcc87cd6f4416824df62ec18e
7
+ data.tar.gz: 5bd75cfa5bf7c91c1777471e43db74575776193a30ebe68162d0f48e46c344e09a1a3c95744c5901a2153f759b75617afb851f98470d87dfd8637bd45df2a7d3
@@ -1,7 +1,7 @@
1
1
  module Cortex
2
2
  class Posts < Cortex::Resource
3
- def query
4
- client.get('/posts')
3
+ def query(params = nil)
4
+ client.get('/posts', params)
5
5
  end
6
6
 
7
7
  def feed(params = nil)
@@ -24,8 +24,12 @@ module Cortex
24
24
  client.get('/posts/filters')
25
25
  end
26
26
 
27
- def related(id)
28
- client.get("/posts/feed/#{id}/related")
27
+ def related(id, params = nil)
28
+ client.get("/posts/feed/#{id}/related", params)
29
+ end
30
+
31
+ def authors
32
+ client.get('/posts/feed/authors')
29
33
  end
30
34
  end
31
35
  end
@@ -50,7 +50,7 @@ module Cortex
50
50
 
51
51
  def parse_response(response)
52
52
  if response.status < 300 || (response.body.kind_of?(Hash) && response.body['error'])
53
- response.body
53
+ OpenStruct.new({body: response.body, headers: response.headers.select { |k| ["Content-Range", "X-Total-Items"].include? k } })
54
54
  else
55
55
  OpenStruct.new({:error => response.body, :status => response.status, :original => response})
56
56
  end
@@ -1,3 +1,3 @@
1
1
  module Cortex
2
- VERSION = '0.1.3'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -50,7 +50,7 @@ describe Cortex::Posts do
50
50
 
51
51
  describe :related do
52
52
  it 'should correctly make the request' do
53
- client.should_receive(:get).with('/posts/feed/1/related').and_return('success')
53
+ client.should_receive(:get).with('/posts/feed/1/related', nil).and_return('success')
54
54
  client.posts.related(1).should == 'success'
55
55
  end
56
56
  end
@@ -6,15 +6,15 @@ describe Cortex::Request do
6
6
  context 'with a cortex error response' do
7
7
  it 'should return the error object' do
8
8
  body = {'error' => 'Validation error or something'}
9
- response = OpenStruct.new(:status => 422, :body => body)
10
- client.parse_response(response).should == body
9
+ response = OpenStruct.new(:status => 422, :body => body, :headers => { :whatever => "Whatever"})
10
+ client.parse_response(response).to_h.should == { :body => body, :headers => {}}
11
11
  end
12
12
  end
13
13
 
14
14
  context 'with a non-cortex error response' do
15
15
  it 'should return a wrapped response' do
16
16
  body = 'Catastrophic error'
17
- response = OpenStruct.new(:status => 500, :body => body)
17
+ response = OpenStruct.new(:status => 500, :body => body, :headers => { :whatever => "Whatever" })
18
18
  parsed = client.parse_response(response)
19
19
  parsed.error.should == body
20
20
  parsed.status.should == 500
@@ -25,8 +25,8 @@ describe Cortex::Request do
25
25
  context 'with a successful response' do
26
26
  it 'should return the parsed body' do
27
27
  body = {:id => 1, title: 'A post'}
28
- response = OpenStruct.new(:status => 200, :body => body)
29
- client.parse_response(response).should == body
28
+ response = OpenStruct.new(:status => 200, :body => body, :headers => { :whatever => "Whatever" })
29
+ client.parse_response(response).to_h.should == { :body => body, :headers => {}}
30
30
  end
31
31
  end
32
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cortex-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bennett Goble
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-28 00:00:00.000000000 Z
11
+ date: 2014-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake