api-pagination 3.2.0 → 3.2.1

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: c9b48cddb3e2509595aa30dd7c836cde57a4a690
4
- data.tar.gz: 3fc62e5440d43d007d4b54d415be8e6f0011dd3d
3
+ metadata.gz: 5d731640c745b641b398f674974fad336835f430
4
+ data.tar.gz: 87f4e54a8e7f52bfc64110a9631435ca720381ed
5
5
  SHA512:
6
- metadata.gz: 5d74a30037b8433a10c00e127cdded4ff3c60164a1beb45ea5c66d8532cb2ed43971e73f6a32d5e886f09fa0a10d6f8013d79a1e067a44acf5746a57fcdd7744
7
- data.tar.gz: da3767bee2071943af66c7bc424d0a4b31504fc03d8d8109b08968adc8e7c6389a6f6f0f26de874a62961c1cb473aad3c5a24dcfab997f2fef1b42cc9981ebc1
6
+ metadata.gz: 3270038dc07c4e4fda06bd333d272c0c1825c27f0533e2d0881673eb0cacf166bc4a88fe98cbf20d7a0106f16abafd09f79c0b4a5bac51d1a0f02e40cbd1ae66
7
+ data.tar.gz: d4b48b49eadbd2a313018110a643d659df61c3d042804c6dbcfd64b1568f44f11eb18889fea6a6211d27190364f177916c07d48df68a263aa1cd7af27b2c8558
@@ -1,7 +1,5 @@
1
1
  module ApiPagination
2
2
  class Configuration
3
- attr_reader :paginator
4
-
5
3
  attr_accessor :total_header
6
4
 
7
5
  attr_accessor :per_page_header
@@ -13,11 +11,14 @@ module ApiPagination
13
11
  def initialize
14
12
  @total_header = 'Total'
15
13
  @per_page_header = 'Per-Page'
16
- set_paginator
14
+ end
15
+
16
+ def paginator
17
+ @paginator || set_paginator
17
18
  end
18
19
 
19
20
  def paginator=(paginator)
20
- case paginator
21
+ case paginator.to_sym
21
22
  when :kaminari
22
23
  use_kaminari
23
24
  when :will_paginate
@@ -34,39 +35,26 @@ module ApiPagination
34
35
  Kernel.warn <<-WARNING
35
36
  Warning: api-pagination relies on either Kaminari or WillPaginate, but both are
36
37
  currently active. If possible, you should remove one or the other. If you can't,
37
- you must configure api-pagination on your own. For example:
38
+ you _must_ configure api-pagination on your own. For example:
38
39
 
39
40
  ApiPagination.configure do |config|
40
- config.paginator = Kaminari
41
+ config.paginator = :kaminari
42
+ end
43
+
44
+ You should also configure Kaminari to use a different `per_page` method name as
45
+ using these gems together causes a conflict; some information can be found at
46
+ https://github.com/activeadmin/activeadmin/wiki/How-to-work-with-will_paginate
47
+
48
+ Kaminari.configure do |config|
49
+ config.page_method_name = :per_page_kaminari
41
50
  end
42
51
 
43
52
  WARNING
44
53
  elsif defined?(Kaminari)
45
- use_kaminari and return
54
+ return use_kaminari
46
55
  elsif defined?(WillPaginate::CollectionMethods)
47
- use_will_paginate and return
48
- end
49
-
50
- begin
51
- require 'kaminari'
52
- use_kaminari and return
53
- rescue LoadError
54
- end
55
-
56
- begin
57
- require 'will_paginate'
58
- use_will_paginate and return
59
- rescue LoadError
56
+ return use_will_paginate
60
57
  end
61
-
62
- Kernel.warn <<-WARNING
63
- Warning: api-pagination relies on either Kaminari or WillPaginate. Please
64
- install either dependency by adding one of the following to your Gemfile:
65
-
66
- gem 'kaminari'
67
- gem 'will_paginate'
68
-
69
- WARNING
70
58
  end
71
59
 
72
60
  def use_kaminari
@@ -15,3 +15,16 @@ if defined?(Grape::API)
15
15
  require 'grape/pagination'
16
16
  Grape::API.send(:include, Grape::Pagination)
17
17
  end
18
+
19
+ begin; require 'kaminari'; rescue LoadError; end
20
+ begin; require 'will_paginate'; rescue LoadError; end
21
+
22
+ unless defined?(Kaminari) || defined?(WillPaginate::CollectionMethods)
23
+ Kernel.warn <<-WARNING.gsub(/^\s{4}/, '')
24
+ Warning: api-pagination relies on either Kaminari or WillPaginate. Please
25
+ install either dependency by adding one of the following to your Gemfile:
26
+
27
+ gem 'kaminari'
28
+ gem 'will_paginate'
29
+ WARNING
30
+ end
@@ -2,7 +2,7 @@ module ApiPagination
2
2
  class Version
3
3
  MAJOR = 3
4
4
  MINOR = 2
5
- PATCH = 0
5
+ PATCH = 1
6
6
 
7
7
  def self.to_s
8
8
  [MAJOR, MINOR, PATCH].join('.')
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api-pagination
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.2.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: 2015-01-30 00:00:00.000000000 Z
11
+ date: 2015-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.0'
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
26
  version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: grape
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.10.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
40
  version: 0.10.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: railties
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: 3.0.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: 3.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: actionpack
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: 3.0.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
68
  version: 3.0.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sequel
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: 4.9.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 4.9.0
83
83
  description: Link header pagination for Rails and Grape APIs
@@ -87,10 +87,10 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - lib/api-pagination.rb
91
90
  - lib/api-pagination/configuration.rb
92
91
  - lib/api-pagination/hooks.rb
93
92
  - lib/api-pagination/version.rb
93
+ - lib/api-pagination.rb
94
94
  - lib/grape/pagination.rb
95
95
  - lib/rails/pagination.rb
96
96
  - spec/grape_spec.rb
@@ -113,17 +113,17 @@ require_paths:
113
113
  - lib
114
114
  required_ruby_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - ">="
116
+ - - '>='
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  requirements:
121
- - - ">="
121
+ - - '>='
122
122
  - !ruby/object:Gem::Version
123
123
  version: '0'
124
124
  requirements: []
125
125
  rubyforge_project:
126
- rubygems_version: 2.4.5
126
+ rubygems_version: 2.0.14
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: Link header pagination for Rails and Grape APIs. Don't use the request body.
@@ -138,4 +138,3 @@ test_files:
138
138
  - spec/support/shared_examples/first_page.rb
139
139
  - spec/support/shared_examples/last_page.rb
140
140
  - spec/support/shared_examples/middle_page.rb
141
- has_rdoc: