api-pagination 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/api-pagination.rb +5 -1
- data/lib/api-pagination/version.rb +1 -1
- data/lib/grape/pagination.rb +1 -1
- data/spec/sequel_spec.rb +31 -0
- metadata +32 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0a884f079d5228439b05823470d82b27a9fe253
|
4
|
+
data.tar.gz: b76f421e8921cf19b6ba8418a20058044718e7a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0890791df230ec465bf397265ab570ef251c28cee3134f6fe05972676bfa0493cd10d6a0cde0b9fc4ce063d4cac2956be11b848275b3b5e110c0497f7b980be4
|
7
|
+
data.tar.gz: f0b546d497bb139afaf1c09ce17ab7a4ed0423a4d962d0ea649cfdf6bbeb905554efc9679e932a6f9e6afd6e899f3693732a71a97994e8c0707eed4632f611ec
|
data/lib/api-pagination.rb
CHANGED
@@ -14,7 +14,11 @@ module ApiPagination
|
|
14
14
|
collection = Kaminari.paginate_array(collection) if collection.is_a?(Array)
|
15
15
|
collection.page(options[:page]).per(options[:per_page])
|
16
16
|
when :will_paginate
|
17
|
-
collection.
|
17
|
+
if defined?(Sequel::Dataset) && collection.kind_of?(Sequel::Dataset)
|
18
|
+
collection.paginate(options[:page], options[:per_page])
|
19
|
+
else
|
20
|
+
collection.paginate(:page => options[:page], :per_page => options[:per_page])
|
21
|
+
end
|
18
22
|
end
|
19
23
|
end
|
20
24
|
|
data/lib/grape/pagination.rb
CHANGED
data/spec/sequel_spec.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
if ApiPagination.paginator == :will_paginate
|
4
|
+
require 'sqlite3'
|
5
|
+
require 'sequel'
|
6
|
+
require 'will_paginate/sequel'
|
7
|
+
|
8
|
+
DB = Sequel.sqlite
|
9
|
+
DB.extension :pagination
|
10
|
+
DB.create_table :people do
|
11
|
+
primary_key :id
|
12
|
+
String :name
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'Using will_paginate with Sequel' do
|
16
|
+
let(:people) do
|
17
|
+
DB[:people]
|
18
|
+
end
|
19
|
+
|
20
|
+
before(:each) do
|
21
|
+
people.insert(name: 'John')
|
22
|
+
people.insert(name: 'Mary')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns a Sequel::Dataset' do
|
26
|
+
collection = ApiPagination.paginate(people)
|
27
|
+
expect(collection.kind_of?(Sequel::Dataset)).to be_true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api-pagination
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Celis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -66,6 +66,34 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 3.0.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sqlite3
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sequel
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 4.9.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 4.9.0
|
69
97
|
description: Link header pagination for Rails and Grape APIs
|
70
98
|
email:
|
71
99
|
- me@davidcel.is
|
@@ -80,6 +108,7 @@ files:
|
|
80
108
|
- lib/rails/pagination.rb
|
81
109
|
- spec/grape_spec.rb
|
82
110
|
- spec/rails_spec.rb
|
111
|
+
- spec/sequel_spec.rb
|
83
112
|
- spec/spec_helper.rb
|
84
113
|
- spec/support/numbers_api.rb
|
85
114
|
- spec/support/numbers_controller.rb
|
@@ -114,6 +143,7 @@ summary: Link header pagination for Rails and Grape APIs. Don't use the request
|
|
114
143
|
test_files:
|
115
144
|
- spec/grape_spec.rb
|
116
145
|
- spec/rails_spec.rb
|
146
|
+
- spec/sequel_spec.rb
|
117
147
|
- spec/spec_helper.rb
|
118
148
|
- spec/support/numbers_api.rb
|
119
149
|
- spec/support/numbers_controller.rb
|