cortex-client 0.4.0 → 0.4.1

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: eaa5268c1114a575ce22ccdc485df37cce36406f
4
- data.tar.gz: 8ce35ce48d8492321bd9b36d78e61bbd833874fc
3
+ metadata.gz: 6da3b8a89c4c454bf8929a45eac330fa876e5eee
4
+ data.tar.gz: e813b04337f4fdcdb4ddc73871a7102175e58ffd
5
5
  SHA512:
6
- metadata.gz: c7bc04d21adbaa56dea175e3e912089195262254596c0a900ecd94f5c3a2339ddbaf5c95e8f0895b5e4f3ac421c421320050af69050041a0bc9d7a8ba148ea34
7
- data.tar.gz: f2a0af95a3a39e66b4c934538776a1a066ed55e58f3a8b5d8602bad3ac0d092e80d5d8ef8de9c81d9e24b0462f014f8c2b3b27dd7aaa6549af7a7331068b240a
6
+ metadata.gz: 1e00799e2ed81300041b6977f1a876b46b16d33475ed8f26bf8e14b7fb5ab80cc02cae9161427487319dea197146a24fcdbe3e28737f1fc57a1dc699710537e4
7
+ data.tar.gz: 5072c0626e3ac475805a91dade922a5c1cee1b0a6eedb6bf25ff94b500b0840dfe69f101fed1d3e063dd70355f4bed2417c9426aeb89f3964cbf284f0b53a8c7
@@ -19,16 +19,16 @@ module Cortex
19
19
  private
20
20
 
21
21
  def parse_headers(headers)
22
- if headers['x-total-items']
23
- @count = headers['x-total-items']
22
+ if headers['X-Total']
23
+ @count = headers['X-Total'].to_i
24
24
  end
25
- if headers['content-range']
26
- matches = headers['content-range'].match(/^(\w+) (\d+)\-(\d+):(\d+)\/\d+$/i)
27
- @per_page = matches[4].to_i
28
- @range_start = matches[2].to_i
29
- @range_end = matches[3].to_i
25
+ if headers['X-Total']
26
+ @page = headers['X-Page'].to_i
27
+ @per_page = headers['X-Per-Page'].to_i
28
+ @range_start = (@page-1) * @per_page
29
+ @range_end = @per_page * @page - 1
30
30
  @range = "#{@range_start}-#{@range_end}"
31
- @page = (@range_end / @per_page) + 1
31
+
32
32
  end
33
33
  end
34
34
 
@@ -1,3 +1,3 @@
1
1
  module Cortex
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe Cortex::Result do
4
- let(:result) { Cortex::Result.new('body', {'x-total-items' => 10, 'content-range' => "posts 0-9:10/200"}, 200) }
4
+ let(:result) { Cortex::Result.new('body', {'X-Total' => 10, 'X-Page' => "1", "X-Per-Page" => "10"}, 200) }
5
5
  let(:failed) { Cortex::Result.new('failed body', {}, 403) }
6
6
 
7
7
  it 'should construct' do
@@ -31,7 +31,7 @@ RSpec.describe Cortex::Result do
31
31
  end
32
32
 
33
33
  it 'should expose the headers' do
34
- expect(result.raw_headers).to eq({ 'x-total-items' => 10, 'content-range' => "posts 0-9:10/200" })
34
+ expect(result.raw_headers).to eq({ 'X-Total' => 10, 'X-Page' => "1", "X-Per-Page" => "10" })
35
35
  expect(failed.raw_headers).to eq({})
36
36
  end
37
37
 
@@ -40,4 +40,4 @@ RSpec.describe Cortex::Result do
40
40
  expect(failed.status).to eq 403
41
41
  end
42
42
 
43
- end
43
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cortex-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bennett Goble
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-05 00:00:00.000000000 Z
12
+ date: 2015-10-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake