api-pagination 4.1.0 → 4.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c24620f87870aa113532b4e5b68ac39d48196a8
4
- data.tar.gz: c5b6ebc23e6db9248dcedfa86ae6def3ddd91b0f
3
+ metadata.gz: a5be5003544e0eb53e5149d0ce0e1062f081834a
4
+ data.tar.gz: b3df8c7d6d0fd12721c32283a27c1f5c05b40ab6
5
5
  SHA512:
6
- metadata.gz: fe232ed61e1987363a1da75f58480f1f5d0485364180c08b9a3ce3ebf5079a1ec34c5448b43e2e94b019b29a72b820539371274cefde5835e96476204c9c3e70
7
- data.tar.gz: 33bbf495e991be605c548d6f20c804a79339f1a45ec47eca36c469fb544389e6918daa7f9eb9fb9cfb8ef567a6be2945379b1168cfe46d780f499fb7a61e69ac
6
+ metadata.gz: 2a1b6e4a3cac799cfc8da269937defa9e309001502e156a66b571eaa465f67fd1681ab443c43eeac1c63d1ee39c03e8c77561136e9295da58f31dafa4b04c119
7
+ data.tar.gz: ed859205ed82ea72ac784e658ad25d5c92d55d0d47a5a34e745f0903b9ddb3708dff75117f2b46bc13b6f598ffb32b0124aaec989e025b33433048a2133933be
@@ -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 = 4
4
4
  MINOR = 1
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: 4.1.0
4
+ version: 4.1.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: