paginate-responder 1.5.0 → 1.6.0.b0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +13 -7
- data/Appraisals +15 -0
- data/Gemfile +0 -6
- data/Rakefile +6 -10
- data/gemfiles/rails_3_2.gemfile +7 -0
- data/gemfiles/rails_4_2.gemfile +7 -0
- data/gemfiles/rails_5_0.gemfile +7 -0
- data/gemfiles/rails_head.gemfile +7 -0
- data/lib/paginate-responder.rb +5 -10
- data/lib/paginate-responder/base.rb +129 -0
- data/lib/paginate-responder/kaminari_adapter.rb +37 -0
- data/lib/paginate-responder/version.rb +2 -2
- data/lib/paginate-responder/will_paginate_adapter.rb +36 -0
- data/lib/responders/paginate_responder.rb +25 -5
- data/paginate-responder.gemspec +9 -4
- data/spec/paginate_responder_spec.rb +158 -0
- data/spec/spec_helper.rb +46 -0
- data/spec/support/05-setup-and-teardown-adapter.rb +38 -0
- data/{test/test_helper.rb → spec/support/10-application.rb} +28 -28
- metadata +101 -26
- data/gemfiles/Gemfile.rails-4-1 +0 -7
- data/gemfiles/Gemfile.rails-4-2 +0 -8
- data/gemfiles/Gemfile.rails-head +0 -6
- data/lib/paginate-responder/adapter/base.rb +0 -46
- data/lib/paginate-responder/adapter/kaminari_adapter.rb +0 -34
- data/lib/paginate-responder/adapter/paginate_adapter.rb +0 -31
- data/lib/paginate-responder/paginator.rb +0 -99
- data/test/paginate_responder_test.rb +0 -247
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
# Configure Rails
|
5
|
+
ENV['RAILS_ENV'] = 'test'
|
6
|
+
|
7
|
+
require 'rails'
|
8
|
+
require 'active_support'
|
9
|
+
require 'action_controller'
|
10
|
+
require 'active_record'
|
11
|
+
|
12
|
+
require 'rspec'
|
13
|
+
|
14
|
+
require 'responders'
|
15
|
+
|
16
|
+
require 'paginate-responder'
|
17
|
+
|
18
|
+
require 'pry'
|
19
|
+
require 'pry-byebug'
|
20
|
+
|
21
|
+
Dir[File.expand_path('spec/support/**/*.rb')].each {|f| require f }
|
22
|
+
|
23
|
+
$gem = ENV['GEM'].to_s
|
24
|
+
$gem = 'will_paginate' if $gem.empty?
|
25
|
+
|
26
|
+
case $gem
|
27
|
+
when 'will_paginate'
|
28
|
+
require 'will_paginate/array'
|
29
|
+
require 'will_paginate/active_record'
|
30
|
+
when 'kaminari'
|
31
|
+
require 'kaminari'
|
32
|
+
require 'kaminari/models/array_extension'
|
33
|
+
|
34
|
+
Kaminari::Hooks.init
|
35
|
+
|
36
|
+
Kaminari.configure do |config|
|
37
|
+
config.default_per_page = 50
|
38
|
+
config.max_per_page = 50
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
RSpec.configure do |config|
|
43
|
+
config.order = 'random'
|
44
|
+
config.include SetupAndTeardownAdapter
|
45
|
+
config.include ActionController::TestCase::Behavior
|
46
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module SetupAndTeardownAdapter
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
module ClassMethods
|
5
|
+
# Wraps `setup` calls from within Rails' testing framework in `before`
|
6
|
+
# hooks.
|
7
|
+
def setup(*methods, &block)
|
8
|
+
methods.each do |method|
|
9
|
+
if method.to_s =~ /^setup_(with_controller|fixtures|controller_request_and_response)$/
|
10
|
+
prepend_before { __send__ method }
|
11
|
+
else
|
12
|
+
before { __send__ method }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
before(&block) if block
|
16
|
+
end
|
17
|
+
|
18
|
+
# @api private
|
19
|
+
#
|
20
|
+
# Wraps `teardown` calls from within Rails' testing framework in
|
21
|
+
# `after` hooks.
|
22
|
+
def teardown(*methods, &block)
|
23
|
+
methods.each { |method| after { __send__ method } }
|
24
|
+
after(&block) if block
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(*args)
|
29
|
+
super
|
30
|
+
@example = nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def method_name
|
34
|
+
@example
|
35
|
+
end
|
36
|
+
|
37
|
+
attr_accessor :request, :params
|
38
|
+
end
|
@@ -1,34 +1,12 @@
|
|
1
|
-
require 'minitest/autorun'
|
2
|
-
require 'bundler'
|
3
1
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
ENV['RAILS_ENV'] = 'test'
|
8
|
-
|
9
|
-
require 'active_support'
|
10
|
-
require 'action_controller'
|
11
|
-
require 'active_record'
|
12
|
-
|
13
|
-
begin
|
14
|
-
require 'responders'
|
15
|
-
rescue LoadError
|
16
|
-
end
|
17
|
-
|
18
|
-
require 'minitest/reporters'
|
19
|
-
MiniTest::Reporters.use!
|
20
|
-
|
21
|
-
|
22
|
-
require 'paginate-responder'
|
23
|
-
|
24
|
-
Responders::Routes = ActionDispatch::Routing::RouteSet.new
|
25
|
-
Responders::Routes.draw do
|
26
|
-
get '/index' => 'paginate#index'
|
2
|
+
$routes = ActionDispatch::Routing::RouteSet.new
|
3
|
+
$routes.draw do
|
4
|
+
get '/index' => 'test#index'
|
27
5
|
end
|
28
6
|
|
29
7
|
class ActiveSupport::TestCase
|
30
8
|
setup do
|
31
|
-
@routes =
|
9
|
+
@routes = $routes
|
32
10
|
end
|
33
11
|
end
|
34
12
|
|
@@ -70,13 +48,35 @@ class TestResponder < ActionController::Responder
|
|
70
48
|
include Responders::PaginateResponder
|
71
49
|
end
|
72
50
|
|
73
|
-
class
|
51
|
+
class TestController < ActionController::Base
|
52
|
+
include $routes.url_helpers
|
53
|
+
|
74
54
|
attr_accessor :resource
|
75
|
-
|
55
|
+
|
76
56
|
self.responder = TestResponder
|
57
|
+
|
77
58
|
respond_to :json
|
78
59
|
|
79
60
|
def index
|
80
61
|
respond_with resource
|
81
62
|
end
|
82
63
|
end
|
64
|
+
|
65
|
+
module TestSpecConfiguration
|
66
|
+
extend ActiveSupport::Concern
|
67
|
+
|
68
|
+
included do
|
69
|
+
before do
|
70
|
+
@routes = $routes
|
71
|
+
@controller = TestController.new
|
72
|
+
end
|
73
|
+
|
74
|
+
def resource=(resource)
|
75
|
+
@controller.resource = resource
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
RSpec.configure do |config|
|
81
|
+
config.include TestSpecConfiguration
|
82
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paginate-responder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0.b0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack-link_headers
|
@@ -25,21 +25,21 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: actionpack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 3.2.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:
|
40
|
+
version: 3.2.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: activerecord
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,21 +53,21 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 3.2.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: appraisal
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: kaminari
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: pry
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -95,7 +95,77 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: pry-byebug
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: responders
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rspec
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rspec-rails
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: sqlite3
|
99
169
|
requirement: !ruby/object:Gem::Requirement
|
100
170
|
requirements:
|
101
171
|
- - ">="
|
@@ -123,7 +193,7 @@ dependencies:
|
|
123
193
|
- !ruby/object:Gem::Version
|
124
194
|
version: '0'
|
125
195
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
196
|
+
name: test-unit
|
127
197
|
requirement: !ruby/object:Gem::Requirement
|
128
198
|
requirements:
|
129
199
|
- - ">="
|
@@ -145,23 +215,26 @@ extra_rdoc_files: []
|
|
145
215
|
files:
|
146
216
|
- ".gitignore"
|
147
217
|
- ".travis.yml"
|
218
|
+
- Appraisals
|
148
219
|
- Gemfile
|
149
220
|
- LICENSE.txt
|
150
221
|
- README.md
|
151
222
|
- Rakefile
|
152
|
-
- gemfiles/
|
153
|
-
- gemfiles/
|
154
|
-
- gemfiles/
|
223
|
+
- gemfiles/rails_3_2.gemfile
|
224
|
+
- gemfiles/rails_4_2.gemfile
|
225
|
+
- gemfiles/rails_5_0.gemfile
|
226
|
+
- gemfiles/rails_head.gemfile
|
155
227
|
- lib/paginate-responder.rb
|
156
|
-
- lib/paginate-responder/
|
157
|
-
- lib/paginate-responder/
|
158
|
-
- lib/paginate-responder/adapter/paginate_adapter.rb
|
159
|
-
- lib/paginate-responder/paginator.rb
|
228
|
+
- lib/paginate-responder/base.rb
|
229
|
+
- lib/paginate-responder/kaminari_adapter.rb
|
160
230
|
- lib/paginate-responder/version.rb
|
231
|
+
- lib/paginate-responder/will_paginate_adapter.rb
|
161
232
|
- lib/responders/paginate_responder.rb
|
162
233
|
- paginate-responder.gemspec
|
163
|
-
-
|
164
|
-
-
|
234
|
+
- spec/paginate_responder_spec.rb
|
235
|
+
- spec/spec_helper.rb
|
236
|
+
- spec/support/05-setup-and-teardown-adapter.rb
|
237
|
+
- spec/support/10-application.rb
|
165
238
|
homepage: https://github.com/jgraichen/paginate-responder
|
166
239
|
licenses:
|
167
240
|
- MIT
|
@@ -177,9 +250,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
250
|
version: '0'
|
178
251
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
252
|
requirements:
|
180
|
-
- - "
|
253
|
+
- - ">"
|
181
254
|
- !ruby/object:Gem::Version
|
182
|
-
version:
|
255
|
+
version: 1.3.1
|
183
256
|
requirements: []
|
184
257
|
rubyforge_project:
|
185
258
|
rubygems_version: 2.5.1
|
@@ -187,5 +260,7 @@ signing_key:
|
|
187
260
|
specification_version: 4
|
188
261
|
summary: A Rails pagination responder with link header support.
|
189
262
|
test_files:
|
190
|
-
-
|
191
|
-
-
|
263
|
+
- spec/paginate_responder_spec.rb
|
264
|
+
- spec/spec_helper.rb
|
265
|
+
- spec/support/05-setup-and-teardown-adapter.rb
|
266
|
+
- spec/support/10-application.rb
|
data/gemfiles/Gemfile.rails-4-1
DELETED
data/gemfiles/Gemfile.rails-4-2
DELETED
data/gemfiles/Gemfile.rails-head
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
module PaginateResponder::Adapter
|
2
|
-
class Base
|
3
|
-
attr_reader :resource
|
4
|
-
|
5
|
-
def initialize(resource)
|
6
|
-
@resource = resource
|
7
|
-
end
|
8
|
-
|
9
|
-
def paginate!(opts)
|
10
|
-
@resource = paginate(opts)
|
11
|
-
end
|
12
|
-
|
13
|
-
# If pagination for current resource is supported.
|
14
|
-
#
|
15
|
-
def suitable?
|
16
|
-
false
|
17
|
-
end
|
18
|
-
|
19
|
-
# Return paginated resource.
|
20
|
-
# Option hash will contain at least <tt>:per_page</tt>
|
21
|
-
# and <tt>:page</tt>.
|
22
|
-
#
|
23
|
-
def paginate(opts)
|
24
|
-
resource
|
25
|
-
end
|
26
|
-
|
27
|
-
# Return number of total pages for current resource.
|
28
|
-
#
|
29
|
-
def total_pages
|
30
|
-
nil
|
31
|
-
end
|
32
|
-
|
33
|
-
# Return number of total items.
|
34
|
-
#
|
35
|
-
def total_count
|
36
|
-
nil
|
37
|
-
end
|
38
|
-
|
39
|
-
# Return default values for items per page and maximum
|
40
|
-
# items per page.
|
41
|
-
#
|
42
|
-
def defaults
|
43
|
-
{ :per_page => 50, :max_per_page => 100 }
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|