rb_pager 0.1.0 → 0.2.3
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/.github/workflows/ruby.yml +50 -0
- data/Gemfile +0 -3
- data/Gemfile.lock +56 -0
- data/README.md +25 -8
- data/Rakefile +12 -0
- data/lib/config/rb_pager.rb +1 -1
- data/lib/rb_pager.rb +4 -2
- data/lib/rb_pager/base64_encoder.rb +20 -0
- data/lib/rb_pager/orm/active_record_relation_methods.rb +36 -0
- data/lib/rb_pager/orm/pager_active_record.rb +87 -91
- data/lib/rb_pager/version.rb +1 -1
- data/rb_pager.gemspec +8 -5
- metadata +32 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bb67cee0939ed57f6c150aac90522fee9be658c61a8d2885b2951cc8a9aee6b
|
4
|
+
data.tar.gz: 03f7db5037f0e0704b6b28029e4949158cdaa1f06fadfe05fac0f3bb29dceaf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6037bde51524e650d1c47ef421f6a4184abf81c94ff5cfb352cc7eb08ebbf272cdbe8447d92b3e8582bd47ac71b7502d90aede5b695f0d24e02ac1f2cb792d40
|
7
|
+
data.tar.gz: 39aca68ff3d20fde8157abac9daf19c1eb493e8e8f83f5c146a3c8acc0ca34b28507ec0a701f4f504500634317c2cafcb861bb54a424ccde36d68b971add12e4
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: build
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
|
21
|
+
services:
|
22
|
+
db:
|
23
|
+
image: postgres:11.6-alpine
|
24
|
+
env:
|
25
|
+
POSTGRES_PASSWORD: password
|
26
|
+
POSTGRES_DB: rb_pager_test
|
27
|
+
ports:
|
28
|
+
- 5432:5432
|
29
|
+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
30
|
+
|
31
|
+
steps:
|
32
|
+
- uses: actions/checkout@v2
|
33
|
+
- name: Set up Ruby
|
34
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
35
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
36
|
+
# uses: ruby/setup-ruby@v1
|
37
|
+
uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
|
38
|
+
with:
|
39
|
+
ruby-version: 2.6
|
40
|
+
- name: Setup System
|
41
|
+
run: |
|
42
|
+
sudo apt-get -y install libpq-dev
|
43
|
+
- name: Install dependencies
|
44
|
+
run: bundle install
|
45
|
+
- name: Run tests
|
46
|
+
env:
|
47
|
+
DATABASE_URL: postgres://postgres:password@localhost:5432/rb_pager_test
|
48
|
+
run: |
|
49
|
+
bundle exec rake db:create
|
50
|
+
bundle exec rspec
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rb_pager (0.2.3)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (6.0.3.2)
|
10
|
+
activesupport (= 6.0.3.2)
|
11
|
+
activerecord (6.0.3.2)
|
12
|
+
activemodel (= 6.0.3.2)
|
13
|
+
activesupport (= 6.0.3.2)
|
14
|
+
activesupport (6.0.3.2)
|
15
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
|
+
i18n (>= 0.7, < 2)
|
17
|
+
minitest (~> 5.1)
|
18
|
+
tzinfo (~> 1.1)
|
19
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
20
|
+
concurrent-ruby (1.1.6)
|
21
|
+
diff-lcs (1.4.4)
|
22
|
+
i18n (1.8.3)
|
23
|
+
concurrent-ruby (~> 1.0)
|
24
|
+
minitest (5.14.1)
|
25
|
+
pg (1.2.3)
|
26
|
+
rake (13.0.1)
|
27
|
+
rspec (3.9.0)
|
28
|
+
rspec-core (~> 3.9.0)
|
29
|
+
rspec-expectations (~> 3.9.0)
|
30
|
+
rspec-mocks (~> 3.9.0)
|
31
|
+
rspec-core (3.9.2)
|
32
|
+
rspec-support (~> 3.9.3)
|
33
|
+
rspec-expectations (3.9.2)
|
34
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
+
rspec-support (~> 3.9.0)
|
36
|
+
rspec-mocks (3.9.1)
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
+
rspec-support (~> 3.9.0)
|
39
|
+
rspec-support (3.9.3)
|
40
|
+
thread_safe (0.3.6)
|
41
|
+
tzinfo (1.2.7)
|
42
|
+
thread_safe (~> 0.1)
|
43
|
+
zeitwerk (2.3.1)
|
44
|
+
|
45
|
+
PLATFORMS
|
46
|
+
ruby
|
47
|
+
|
48
|
+
DEPENDENCIES
|
49
|
+
activerecord (>= 5.2)
|
50
|
+
pg
|
51
|
+
rake (~> 13.0)
|
52
|
+
rb_pager!
|
53
|
+
rspec (~> 3.0)
|
54
|
+
|
55
|
+
BUNDLED WITH
|
56
|
+
2.1.4
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
|
2
2
|
# Pager
|
3
|
-
|
3
|
+
[](https://badge.fury.io/rb/rb_pager)
|
4
|
+

|
4
5
|
|
5
6
|
Cursor-based pagination (aka keyset pagination) is a [common](https://slack.engineering/evolving-api-pagination-at-slack-1c1f644f8e12) [pagination strategy](https://www.citusdata.com/blog/2016/03/30/five-ways-to-paginate/) that avoids many of the pitfalls of “offset–limit” pagination.
|
6
7
|
|
@@ -8,7 +9,7 @@ For example, with offset–limit pagination, if an item from a prior page is del
|
|
8
9
|
|
9
10
|
Cursor-based pagination also performs better for large data sets under most implementations.
|
10
11
|
|
11
|
-
To support cursor-based pagination, this specification defines
|
12
|
+
To support cursor-based pagination, this specification defines four query parameters `after`, `before`, `limit`, and `sort`
|
12
13
|
|
13
14
|
## Installation
|
14
15
|
|
@@ -37,24 +38,40 @@ The system use `Base64.strict_decode64` and `Base64.strict_encode64` for cursor
|
|
37
38
|
|
38
39
|
```ruby
|
39
40
|
# return first 20 employee records, by default limit set to 20
|
40
|
-
Employee.pager
|
41
|
+
Employee.pager
|
41
42
|
|
42
43
|
# return first 15 employee records
|
43
|
-
Employee.pager(
|
44
|
+
Employee.pager(limit: 15)
|
44
45
|
|
45
46
|
# return first 10 employee records order by created_at asc
|
46
47
|
# /employee?limit=10&sort=created_at
|
47
|
-
Employee.pager(after:
|
48
|
+
Employee.pager(after: 'w33t44==', limit: 10, sort: 'created_at')
|
48
49
|
|
49
50
|
# return first 10 employee records order by created_at desc
|
50
51
|
# /employee?limit=10&sort=-created_at
|
51
|
-
Employee.pager(after:
|
52
|
+
Employee.pager(after: 'w33t44==', limit: 10, sort: '-created_at')
|
52
53
|
|
53
54
|
# [order by non uniq column](https://engineering.shopify.com/blogs/engineering/pagination-relative-cursors)
|
54
|
-
# /employee?limit=10&sort=name,id
|
55
|
-
Employee.pager(after:
|
55
|
+
# /employee?limit=10&sort=name,id&after=w33t44==
|
56
|
+
Employee.pager(after: 'w33t44==', limit: 10, sort: 'name,id')
|
57
|
+
|
58
|
+
# /employee?limit=10&sort=name,id&before=w33t44==
|
59
|
+
Employee.pager(before: 'w33t44==', limit: 10, sort: 'name,id')
|
60
|
+
|
61
|
+
# on EmployeesController
|
62
|
+
records, meta = Employee.pager(limit: 15)
|
63
|
+
# meta => { prev_cursor => 'ergOW==' next_cursor => 'uahOI==' }
|
64
|
+
render json: EmployeeSerializer.new(records, meta: meta).serialized_json, status: :ok
|
56
65
|
```
|
57
66
|
|
67
|
+
## On progress
|
68
|
+
|
69
|
+
- [x] implement `before` cursor
|
70
|
+
- [x] meta url for next and previous page
|
71
|
+
- [ ] meta url for first, last and collection size
|
72
|
+
- [ ] [error-cases](https://jsonapi.org/profiles/ethanresnick/cursor-pagination/#auto-id-error-cases)
|
73
|
+
- [ ] custom encoder
|
74
|
+
|
58
75
|
## Development
|
59
76
|
|
60
77
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/Rakefile
CHANGED
@@ -4,3 +4,15 @@ require "rspec/core/rake_task"
|
|
4
4
|
RSpec::Core::RakeTask.new(:spec)
|
5
5
|
|
6
6
|
task :default => :spec
|
7
|
+
|
8
|
+
namespace :db do
|
9
|
+
desc "Create the test DB"
|
10
|
+
task :create do
|
11
|
+
`createdb rb_pager_test`
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Drop the test DB"
|
15
|
+
task :drop do
|
16
|
+
`dropdb rb_pager_test`
|
17
|
+
end
|
18
|
+
end
|
data/lib/config/rb_pager.rb
CHANGED
data/lib/rb_pager.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'active_record'
|
2
2
|
require 'rb_pager/version'
|
3
|
-
require
|
3
|
+
require 'rb_pager/configuration'
|
4
|
+
require 'rb_pager/base64_encoder'
|
4
5
|
|
5
6
|
module RbPager
|
6
|
-
class
|
7
|
+
class InvalidLimitValueError < StandardError; end
|
7
8
|
|
8
9
|
class << self
|
9
10
|
attr_accessor :configuration
|
@@ -17,5 +18,6 @@ end
|
|
17
18
|
|
18
19
|
if defined?(ActiveRecord)
|
19
20
|
require 'rb_pager/orm/pager_active_record'
|
21
|
+
require 'rb_pager/orm/active_record_relation_methods'
|
20
22
|
ActiveRecord::Base.send :include, RbPager::ActiveRecord
|
21
23
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'base64'
|
2
|
+
module RbPager
|
3
|
+
module Base64Encoder
|
4
|
+
def encode(data)
|
5
|
+
return nil if data.to_s.empty?
|
6
|
+
Base64.strict_encode64(data)
|
7
|
+
end
|
8
|
+
|
9
|
+
def decode(data)
|
10
|
+
return nil if data.to_s.empty?
|
11
|
+
|
12
|
+
decoded_data = Base64.strict_decode64(data)
|
13
|
+
Hash[
|
14
|
+
decoded_data.split(',').map do |pair|
|
15
|
+
k, v = pair.split(':', 2)
|
16
|
+
end
|
17
|
+
]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module RbPager
|
2
|
+
module ActiveRecord
|
3
|
+
module ActiveRecordRelationMethods
|
4
|
+
def left_over?
|
5
|
+
@left_over ||= begin
|
6
|
+
# Cache #size otherwise multiple calls to the database will occur.
|
7
|
+
records.size.positive? && records.size < total_size
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# Returns number of records that exist in scope of the current cursor
|
12
|
+
def total_size(column_name = :all) #:nodoc:
|
13
|
+
# #count overrides the #select which could include generated columns
|
14
|
+
# referenced in #order, so skip #order here, where it's irrelevant to the
|
15
|
+
# result anyway.
|
16
|
+
@total_size ||= begin
|
17
|
+
context = except(:offset, :limit, :order)
|
18
|
+
|
19
|
+
# Remove includes only if they are irrelevant
|
20
|
+
context = context.except(:includes) unless references_eager_loaded_tables?
|
21
|
+
|
22
|
+
args = [column_name]
|
23
|
+
|
24
|
+
# .group returns an OrderedHash that responds to #count
|
25
|
+
context = context.count(*args)
|
26
|
+
|
27
|
+
if context.is_a?(Hash) || context.is_a?(ActiveSupport::OrderedHash)
|
28
|
+
context.count
|
29
|
+
else
|
30
|
+
context.respond_to?(:count) ? context.count(*args) : context
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -3,130 +3,126 @@ module RbPager
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
module ClassMethods
|
6
|
+
include ::RbPager::Base64Encoder
|
7
|
+
|
6
8
|
AR_ORDER = { '+' => :asc, '-' => :desc }
|
7
|
-
AREL_ORDER = { asc: :gt, desc: :lt }
|
8
|
-
|
9
|
-
def pager(after:, limit: nil, sort: nil)
|
10
|
-
page_limit = limit || RbPager.configuration.limit
|
11
|
-
sort_params = sort
|
12
|
-
sorted_columns, sorter = build_order_expression(sort)
|
13
|
-
collection = if after.nil?
|
14
|
-
order(sorter).extending(ActiveRecordRelationMethods).limit(page_limit)
|
15
|
-
else
|
16
|
-
custom_expression = create_custom_expression(after, sorted_columns)
|
17
|
-
where(custom_expression).order(sorter).extending(ActiveRecordRelationMethods).limit(page_limit)
|
18
|
-
end
|
19
|
-
|
20
|
-
create_paginate_meta(collection, sorted_columns)
|
21
|
-
end
|
22
9
|
|
23
|
-
|
10
|
+
def pager(after: nil, before: nil, limit: nil, sort: nil)
|
11
|
+
instance_variable_set(:@sorted_columns, nil)
|
12
|
+
instance_variable_set(:@collection, nil)
|
13
|
+
instance_variable_set(:@records, nil)
|
24
14
|
|
25
|
-
|
26
|
-
|
27
|
-
|
15
|
+
limit = nil if limit && limit < 2
|
16
|
+
@page_limit = limit || RbPager.configuration.limit
|
17
|
+
raise InvalidLimitValueError if @page_limit && @page_limit < 1
|
18
|
+
@sort = sort
|
28
19
|
|
29
|
-
|
30
|
-
|
20
|
+
@after = decode(after)
|
21
|
+
@before = decode(before)
|
22
|
+
@direction = :next
|
31
23
|
|
32
|
-
|
24
|
+
create_paginate_meta
|
33
25
|
end
|
34
26
|
|
35
|
-
|
36
|
-
result = self
|
37
|
-
sorted_columns.each_with_index do |(column, type), index|
|
38
|
-
result = if index.zero?
|
39
|
-
result.arel_table[column].send(AREL_ORDER[type])
|
40
|
-
else
|
41
|
-
result.or(arel_table[column].send(AREL_ORDER[type]))
|
42
|
-
end
|
43
|
-
end
|
27
|
+
private
|
44
28
|
|
45
|
-
|
29
|
+
def apply_after
|
30
|
+
return nil if @after.nil?
|
31
|
+
|
32
|
+
if sorted_columns.values.all? :asc
|
33
|
+
Arel::Nodes::GreaterThan.new(
|
34
|
+
Arel::Nodes::Grouping.new(@after.keys.map{ |col| arel_table[col] }),
|
35
|
+
Arel::Nodes::Grouping.new(@after.values.map{ |col| Arel::Nodes.build_quoted(col) })
|
36
|
+
)
|
37
|
+
else
|
38
|
+
@direction = :prev
|
39
|
+
Arel::Nodes::LessThan.new(
|
40
|
+
Arel::Nodes::Grouping.new(@after.keys.map{|col| arel_table[col]}),
|
41
|
+
Arel::Nodes::Grouping.new(@after.values.map{ |col| Arel::Nodes.build_quoted(col) })
|
42
|
+
)
|
43
|
+
end
|
46
44
|
end
|
47
45
|
|
48
|
-
def
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
46
|
+
def apply_before
|
47
|
+
return nil if @before.nil?
|
48
|
+
|
49
|
+
if sorted_columns.values.all? :asc
|
50
|
+
@direction = :prev
|
51
|
+
Arel::Nodes::LessThan.new(
|
52
|
+
Arel::Nodes::Grouping.new(@before.keys.map{ |col| arel_table[col] }),
|
53
|
+
Arel::Nodes::Grouping.new(@before.values.map{ |col| Arel::Nodes.build_quoted(col) })
|
54
|
+
)
|
55
|
+
else
|
56
|
+
Arel::Nodes::GreaterThan.new(
|
57
|
+
Arel::Nodes::Grouping.new(@before.keys.map{|col| arel_table[col]}),
|
58
|
+
Arel::Nodes::Grouping.new(@before.values.map{ |col| Arel::Nodes.build_quoted(col) })
|
59
|
+
)
|
57
60
|
end
|
58
|
-
|
59
|
-
result
|
60
61
|
end
|
61
62
|
|
62
|
-
def
|
63
|
-
|
63
|
+
def sorted_columns
|
64
|
+
@sorted_columns ||= begin
|
65
|
+
sorted_columns = {} if @sort.nil?
|
66
|
+
sorted_columns ||= construct_sorted_columns
|
67
|
+
end
|
68
|
+
end
|
64
69
|
|
65
|
-
|
70
|
+
def construct_sorted_columns
|
66
71
|
sorted_params = {}
|
67
|
-
|
68
|
-
|
69
|
-
sort_params.split(',').each do |field|
|
70
|
-
next unless attribute_names.include?(field)
|
72
|
+
fields = @sort.split(',')
|
71
73
|
|
74
|
+
fields.each do |field|
|
72
75
|
sort_sign = field =~ /\A[+-]/ ? field.slice!(0) : '+'
|
73
|
-
|
74
|
-
sorted_params[field] = AR_ORDER[sort_sign]
|
76
|
+
sorted_params[field] = AR_ORDER[sort_sign] if attribute_names.include?(field)
|
75
77
|
end
|
76
78
|
|
77
|
-
|
79
|
+
sorted_params
|
78
80
|
end
|
79
81
|
|
80
|
-
def create_paginate_meta
|
81
|
-
|
82
|
+
def create_paginate_meta
|
83
|
+
cursor = cursor(collection)
|
82
84
|
|
83
|
-
meta = {
|
84
|
-
[collection
|
85
|
+
meta = { prev_cursor: cursor.first, next_cursor: cursor.last }
|
86
|
+
[collection, meta]
|
85
87
|
end
|
86
88
|
|
87
|
-
def
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
next_cursor.merge!(Hash[key, collection.last.send(key)])
|
94
|
-
end
|
95
|
-
|
96
|
-
Base64.strict_encode64(next_cursor.to_json)
|
89
|
+
def collection
|
90
|
+
@collection ||= where(apply_after)
|
91
|
+
.where(apply_before)
|
92
|
+
.order(sorted_columns)
|
93
|
+
.extending(ActiveRecordRelationMethods)
|
94
|
+
.limit(@page_limit)
|
97
95
|
end
|
98
|
-
end
|
99
96
|
|
100
|
-
|
101
|
-
|
102
|
-
@left_over ||= begin
|
103
|
-
# Cache #size otherwise multiple calls to the database will occur.
|
104
|
-
size.positive? && size < total_size
|
105
|
-
end
|
97
|
+
def records
|
98
|
+
@records || collection.to_a
|
106
99
|
end
|
107
100
|
|
108
|
-
|
109
|
-
|
110
|
-
# #count overrides the #select which could include generated columns
|
111
|
-
# referenced in #order, so skip #order here, where it's irrelevant to the
|
112
|
-
# result anyway.
|
113
|
-
@total_size ||= begin
|
114
|
-
context = except(:offset, :limit, :order)
|
115
|
-
|
116
|
-
# Remove includes only if they are irrelevant
|
117
|
-
context = context.except(:includes) unless references_eager_loaded_tables?
|
101
|
+
def cursor(collection)
|
102
|
+
return ['', ''] if collection.total_size.zero?
|
118
103
|
|
119
|
-
|
104
|
+
prev_cursor, next_cursor = [], []
|
120
105
|
|
121
|
-
|
122
|
-
|
106
|
+
if sorted_columns.blank?
|
107
|
+
prev_cursor = ["#{primary_key}:#{records.first.send(primary_key)}"]
|
108
|
+
next_cursor = ["#{primary_key}:#{records.last.send(primary_key)}"]
|
109
|
+
else
|
110
|
+
sorted_columns.each do |key, _value|
|
111
|
+
if type_for_attribute(key).type.eql? :datetime
|
112
|
+
prev_cursor << "#{key}:#{records.first.send(key).rfc3339(9)}"
|
113
|
+
next_cursor << "#{key}:#{records.last.send(key).rfc3339(9)}"
|
114
|
+
next
|
115
|
+
end
|
123
116
|
|
124
|
-
|
125
|
-
|
126
|
-
else
|
127
|
-
context.respond_to?(:count) ? context.count(*args) : context
|
117
|
+
prev_cursor << "#{key}:#{records.first.send(key)}"
|
118
|
+
next_cursor << "#{key}:#{records.last.send(key)}"
|
128
119
|
end
|
129
120
|
end
|
121
|
+
|
122
|
+
return ['', encode(next_cursor.join(','))] if (@after.nil? && @before.nil?) && collection.left_over?
|
123
|
+
return [encode(prev_cursor.join(',')), ''] if !collection.left_over?
|
124
|
+
|
125
|
+
[encode(prev_cursor.join(',')), encode(next_cursor.join(','))]
|
130
126
|
end
|
131
127
|
end
|
132
128
|
end
|
data/lib/rb_pager/version.rb
CHANGED
data/rb_pager.gemspec
CHANGED
@@ -7,8 +7,10 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.email = ["mejbambang@gmail.com"]
|
8
8
|
|
9
9
|
spec.summary = "Cursor based pagination for active_record currently"
|
10
|
-
spec.description =
|
11
|
-
|
10
|
+
spec.description = <<~DESC
|
11
|
+
ActiveRecord plugin for cursor based pagination for Ruby on Rails.
|
12
|
+
Cursor-based pagination (aka keyset pagination) is a common pagination strategy that avoids many of the pitfalls of “offset–limit” pagination.
|
13
|
+
DESC
|
12
14
|
spec.homepage = "https://github.com/BambangSinaga/rb_pager"
|
13
15
|
spec.license = "MIT"
|
14
16
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
@@ -19,9 +21,10 @@ Gem::Specification.new do |spec|
|
|
19
21
|
spec.metadata["source_code_uri"] = "https://github.com/BambangSinaga/rb_pager"
|
20
22
|
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
21
23
|
|
22
|
-
spec.add_development_dependency "
|
23
|
-
spec.add_development_dependency "
|
24
|
-
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "activerecord", ">= 5.2"
|
25
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
spec.add_development_dependency "pg"
|
25
28
|
|
26
29
|
# Specify which files should be added to the gem when it is released.
|
27
30
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
metadata
CHANGED
@@ -1,45 +1,59 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb_pager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BambangSinaga
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.2'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pg
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - ">="
|
@@ -52,19 +66,21 @@ dependencies:
|
|
52
66
|
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
|
-
description:
|
56
|
-
ActiveRecord plugin for cursor based pagination for Ruby on Rails.
|
57
|
-
|
69
|
+
description: |
|
70
|
+
ActiveRecord plugin for cursor based pagination for Ruby on Rails.
|
71
|
+
Cursor-based pagination (aka keyset pagination) is a common pagination strategy that avoids many of the pitfalls of “offset–limit” pagination.
|
58
72
|
email:
|
59
73
|
- mejbambang@gmail.com
|
60
74
|
executables: []
|
61
75
|
extensions: []
|
62
76
|
extra_rdoc_files: []
|
63
77
|
files:
|
78
|
+
- ".github/workflows/ruby.yml"
|
64
79
|
- ".gitignore"
|
65
80
|
- ".rspec"
|
66
81
|
- ".travis.yml"
|
67
82
|
- Gemfile
|
83
|
+
- Gemfile.lock
|
68
84
|
- LICENSE.txt
|
69
85
|
- README.md
|
70
86
|
- Rakefile
|
@@ -72,7 +88,9 @@ files:
|
|
72
88
|
- bin/setup
|
73
89
|
- lib/config/rb_pager.rb
|
74
90
|
- lib/rb_pager.rb
|
91
|
+
- lib/rb_pager/base64_encoder.rb
|
75
92
|
- lib/rb_pager/configuration.rb
|
93
|
+
- lib/rb_pager/orm/active_record_relation_methods.rb
|
76
94
|
- lib/rb_pager/orm/pager_active_record.rb
|
77
95
|
- lib/rb_pager/version.rb
|
78
96
|
- rb_pager.gemspec
|
@@ -98,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
116
|
- !ruby/object:Gem::Version
|
99
117
|
version: '0'
|
100
118
|
requirements: []
|
101
|
-
rubygems_version: 3.
|
119
|
+
rubygems_version: 3.1.2
|
102
120
|
signing_key:
|
103
121
|
specification_version: 4
|
104
122
|
summary: Cursor based pagination for active_record currently
|