wor-paginate 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +5 -0
- data/README.md +1 -0
- data/lib/generators/templates/wor_paginate.rb +12 -0
- data/lib/wor/paginate/adapters/base.rb +7 -0
- data/lib/wor/paginate/adapters/helpers/total_count.rb +3 -4
- data/lib/wor/paginate/adapters/kaminari.rb +4 -0
- data/lib/wor/paginate/adapters/will_paginate.rb +1 -1
- data/lib/wor/paginate/config.rb +2 -1
- data/lib/wor/paginate/formatter.rb +2 -1
- data/lib/wor/paginate/paginate.rb +3 -2
- data/lib/wor/paginate/rspec.rb +9 -3
- data/lib/wor/paginate/version.rb +1 -1
- data/test.sqlite3 +0 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c6a4d0f06558e5204961f4db988546335b5e51b3
|
4
|
+
data.tar.gz: b56ec43ef75a22e28c255c9ca0a7f4054a66fbed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a75d8db76635df594ad2870088cc12b151c7dc4c65af4029c3dc92a527f6eb370fa2a0744e9a704fc47776d913df6c744128abebecd9f278e555b8810be7c7a7
|
7
|
+
data.tar.gz: b40078aee535d5c676afd501b96e9bfbd781c17143dbb7ac3923ea8593f98c5db66be41f8ab7c4e477e7e748a57c6a5ee494c0ac19a8eccad2473b569444d47e
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
## Change log
|
2
2
|
|
3
|
+
### V0.1.9
|
4
|
+
* [#88](https://github.com/Wolox/wor-paginate/pull/88) Default adapter - [@mtejedorwolox](https://github.com/mtejedorwolox).
|
5
|
+
* [#87](https://github.com/Wolox/wor-paginate/pull/87) Supporting expect(response).to be_paginated - [@mnmallea](https://github.com/mnmallea).
|
6
|
+
* [#86](https://github.com/Wolox/wor-paginate/pull/86) Added previous_page parameter - [@juanpablo-rojas](https://github.com/juanpablo-rojas).
|
7
|
+
|
3
8
|
### V0.1.8
|
4
9
|
* [#85](https://github.com/Wolox/wor-paginate/pull/85) Delete max Railties dependency in gemspec - [@lucasvoboril](https://github.com/lucasvoboril).
|
5
10
|
|
data/README.md
CHANGED
@@ -10,4 +10,16 @@ Wor::Paginate.configure do |config|
|
|
10
10
|
# For more info about available methods for formatters see:
|
11
11
|
# https://github.com/Wolox/wor-paginate/blob/master/lib/wor/paginate/formatter.rb
|
12
12
|
# config.formatter = Wor::Paginate::Formatter
|
13
|
+
|
14
|
+
# Configure a default adapter to use on pagination
|
15
|
+
# config.default_adapter = nil
|
16
|
+
|
17
|
+
# Default: nil
|
18
|
+
# Possible values:
|
19
|
+
# Wor::Paginate::Adapters::KaminariAlreadyPaginated
|
20
|
+
# Wor::Paginate::Adapters::WillPaginateAlreadyPaginated
|
21
|
+
# Wor::Paginate::Adapters::WillPaginate
|
22
|
+
# Wor::Paginate::Adapters::Kaminari
|
23
|
+
# Wor::Paginate::Adapters::ActiveRecord
|
24
|
+
# Wor::Paginate::Adapters::Enumerable
|
13
25
|
end
|
@@ -4,11 +4,10 @@ module Wor
|
|
4
4
|
module Helpers
|
5
5
|
module TotalCount
|
6
6
|
def total_count
|
7
|
-
|
8
|
-
content_size
|
9
|
-
return content.to_a.size if content_size.is_a? Hash
|
7
|
+
@content_size ||= @content.reorder(nil).size
|
8
|
+
return @content_size.keys.size if @content_size.is_a? Hash
|
10
9
|
|
11
|
-
content_size
|
10
|
+
@content_size
|
12
11
|
end
|
13
12
|
end
|
14
13
|
end
|
data/lib/wor/paginate/config.rb
CHANGED
@@ -15,13 +15,14 @@ module Wor
|
|
15
15
|
total_pages: total_pages,
|
16
16
|
total_count: total_count,
|
17
17
|
current_page: current_page,
|
18
|
+
previous_page: previous_page,
|
18
19
|
next_page: next_page
|
19
20
|
}
|
20
21
|
end
|
21
22
|
|
22
23
|
protected
|
23
24
|
|
24
|
-
delegate :count, :total_count, :total_pages, :next_page, to: :adapter
|
25
|
+
delegate :count, :total_count, :total_pages, :previous_page, :next_page, to: :adapter
|
25
26
|
|
26
27
|
def current_page
|
27
28
|
adapter.page.to_i
|
@@ -32,8 +32,9 @@ module Wor
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def find_adapter_for_content(content, options)
|
35
|
-
|
36
|
-
|
35
|
+
Config.default_adapter&.new(content, page(options), limit(options)) ||
|
36
|
+
ADAPTERS.map { |adapter| adapter.new(content, page(options), limit(options)) }
|
37
|
+
.find(&:adapt?)
|
37
38
|
end
|
38
39
|
|
39
40
|
def page(options)
|
data/lib/wor/paginate/rspec.rb
CHANGED
@@ -28,9 +28,14 @@ end
|
|
28
28
|
|
29
29
|
RSpec::Matchers.define :be_paginated do
|
30
30
|
match do |actual_response|
|
31
|
+
response = parse_response(actual_response)
|
31
32
|
formatter = @custom_formatter || Wor::Paginate::Formatter
|
32
33
|
@formatted_keys = formatter.new(MockedAdapter.new).format.as_json.keys
|
33
|
-
|
34
|
+
response.keys == @formatted_keys
|
35
|
+
end
|
36
|
+
|
37
|
+
def parse_response(response)
|
38
|
+
response.is_a?(Hash) ? response : JSON.parse(response.body)
|
34
39
|
end
|
35
40
|
|
36
41
|
chain :with do |custom_formatter|
|
@@ -38,10 +43,11 @@ RSpec::Matchers.define :be_paginated do
|
|
38
43
|
end
|
39
44
|
|
40
45
|
failure_message do |actual_response|
|
41
|
-
"expected that #{actual_response} to be paginated with keys #{@formatted_keys}"
|
46
|
+
"expected that #{parse_response(actual_response)} to be paginated with keys #{@formatted_keys}"
|
42
47
|
end
|
43
48
|
|
44
49
|
failure_message_when_negated do |actual_response|
|
45
|
-
"expected that #{actual_response} not
|
50
|
+
"expected that #{parse_response(actual_response)} not " \
|
51
|
+
"to be paginated with keys #{@formatted_keys}"
|
46
52
|
end
|
47
53
|
end
|
data/lib/wor/paginate/version.rb
CHANGED
data/test.sqlite3
ADDED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wor-paginate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- icoluccio
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2019-11-
|
14
|
+
date: 2019-11-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: railties
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- lib/wor/paginate/rspec.rb
|
83
83
|
- lib/wor/paginate/version.rb
|
84
84
|
- pull_request_template.md
|
85
|
+
- test.sqlite3
|
85
86
|
- wor-paginate.gemspec
|
86
87
|
homepage: https://github.com/Wolox/wor-paginate
|
87
88
|
licenses:
|
@@ -102,7 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
103
|
- !ruby/object:Gem::Version
|
103
104
|
version: '0'
|
104
105
|
requirements: []
|
105
|
-
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.5.2.1
|
106
108
|
signing_key:
|
107
109
|
specification_version: 4
|
108
110
|
summary: Simplified pagination for Rails API controllers
|