restpack_serializer 0.5.2 → 0.5.3

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: 6e057f9443e4458620f07fe24d2c231caac2aab7
4
- data.tar.gz: e84c048d7a562944581eaec14e353147df4b0398
3
+ metadata.gz: dfbd8796c92fa7467d0ffac9b47477668189212b
4
+ data.tar.gz: 41d7e43eb3cd37b6bebdd491e3c278d084effc1d
5
5
  SHA512:
6
- metadata.gz: cc7334b9da94b802974a40351c7be43860d5691129cdd1d8f84aa56c3e7ea68ba83ce454144c192bd64d439f9fb36e32551361f852ef512d80d260d51ee04f9f
7
- data.tar.gz: e08a930f72863feffacea046f8e5fbaacf6a941416f2302a68eef87ba0b7bbe99397fbff40f3d916e46fd2541d8ad21d1e74e1ed4355cfa49f22710c0a6fc492
6
+ metadata.gz: a0b65750fcc4de192ff9841a9c7f406a78339116fe6daa0c8ab94cf37f2d655140c87b06a23e923d4c493579e15e2a206e3f50982291783fde1e3e316ca9b533
7
+ data.tar.gz: 998f3f1cdd6cdcdfbfb7cf3678a37c677e468ea1163e632acdd27368b1925718d35d029dbc8f8290db9fc9ffb21f123c07d756003ba687475a2ac1d74b33f3d7
data/README.md CHANGED
@@ -168,8 +168,10 @@ http://restpack-serializer-sample.herokuapp.com/api/v1/songs.json?page=2&page_si
168
168
  "page_count": 14,
169
169
  "previous_page": 1,
170
170
  "next_page": 3,
171
- "previous_href": "/api/v1/songs?page_size=3",
172
- "next_href": "/api/v1/songs?page=3&page_size=3"
171
+ "first_href": "/songs?page_size=3",
172
+ "previous_href": "/songs?page_size=3",
173
+ "next_href": "/songs?page=3&page_size=3",
174
+ "last_href": "/songs?page=14&page_size=3"
173
175
  }
174
176
  },
175
177
  "links": {
@@ -266,8 +268,10 @@ which yields:
266
268
  "page_count": 1,
267
269
  "previous_page": null,
268
270
  "next_page": null,
271
+ "first_href": '/albums',
269
272
  "previous_href": null,
270
- "next_href": null
273
+ "next_href": null,
274
+ "last_href": '/albums'
271
275
  }
272
276
  },
273
277
  "links": {
@@ -35,18 +35,19 @@ module RestPack::Serializer::Paging
35
35
 
36
36
  def serialize_meta(page, options)
37
37
  meta = {
38
- page: options.page,
39
- page_size: options.page_size,
40
- count: page.total_count,
41
- include: options.include
38
+ page: page.current_page,
39
+ page_size: page.limit_value,
40
+ count: page.total_count,
41
+ include: options.include,
42
+ page_count: page.total_pages,
43
+ previous_page: page.prev_page,
44
+ next_page: page.next_page
42
45
  }
43
46
 
44
- meta[:page_count] = ((page.total_count - 1) / options.page_size) + 1
45
- meta[:previous_page] = meta[:page] > 1 ? meta[:page] - 1 : nil
46
- meta[:next_page] = meta[:page] < meta[:page_count] ? meta[:page] + 1 : nil
47
-
47
+ meta[:first_href] = page_href(1, options)
48
48
  meta[:previous_href] = page_href(meta[:previous_page], options)
49
49
  meta[:next_href] = page_href(meta[:next_page], options)
50
+ meta[:last_href] = page_href(meta[:page_count], options)
50
51
  meta
51
52
  end
52
53
 
@@ -1,5 +1,5 @@
1
1
  module RestPack
2
2
  module Serializer
3
- VERSION = '0.5.2'
3
+ VERSION = '0.5.3'
4
4
  end
5
5
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
19
19
 
20
20
  gem.add_dependency 'activesupport', ['>= 4.0.3', '< 5.0']
21
21
  gem.add_dependency 'activerecord', ['>= 4.0.3', '< 5.0']
22
- gem.add_dependency 'kaminari', '~> 0.15.1'
22
+ gem.add_dependency 'kaminari', '~> 0.16.1'
23
23
 
24
24
  gem.add_development_dependency 'restpack_gem', '~> 0.0.9'
25
25
  gem.add_development_dependency 'rake', '~> 10.0.3'
@@ -22,10 +22,12 @@ describe RestPack::Serializer::Paging do
22
22
  it "includes valid paging meta data" do
23
23
  page[:meta][:songs][:count].should == 18
24
24
  page[:meta][:songs][:page_count].should == 2
25
+ page[:meta][:songs][:first_href].should == '/songs'
25
26
  page[:meta][:songs][:previous_page].should == nil
26
27
  page[:meta][:songs][:previous_href].should == nil
27
28
  page[:meta][:songs][:next_page].should == 2
28
29
  page[:meta][:songs][:next_href].should == '/songs?page=2'
30
+ page[:meta][:songs][:last_href].should == '/songs?page=2'
29
31
  end
30
32
  it "includes links" do
31
33
  page[:links].should == {
@@ -44,6 +46,7 @@ describe RestPack::Serializer::Paging do
44
46
  it "includes the custom page size in the page hrefs" do
45
47
  page[:meta][:songs][:next_page].should == 2
46
48
  page[:meta][:songs][:next_href].should == '/songs?page=2&page_size=3'
49
+ page[:meta][:songs][:last_href].should == '/songs?page=6&page_size=3'
47
50
  end
48
51
  end
49
52
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restpack_serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Joyce
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-14 00:00:00.000000000 Z
11
+ date: 2014-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -56,14 +56,14 @@ dependencies:
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: 0.15.1
59
+ version: 0.16.1
60
60
  type: :runtime
61
61
  prerelease: false
62
62
  version_requirements: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: 0.15.1
66
+ version: 0.16.1
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: restpack_gem
69
69
  requirement: !ruby/object:Gem::Requirement