kaminari 0.15.0 → 0.15.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of kaminari might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.travis.yml +15 -10
- data/{CHANGELOG → CHANGELOG.rdoc} +9 -0
- data/README.rdoc +6 -0
- data/Rakefile +11 -7
- data/gemfiles/active_record_30.gemfile +17 -0
- data/gemfiles/active_record_31.gemfile +19 -0
- data/gemfiles/active_record_32.gemfile +19 -3
- data/gemfiles/active_record_40.gemfile +13 -0
- data/gemfiles/active_record_edge.gemfile +16 -1
- data/gemfiles/data_mapper_12.gemfile +19 -3
- data/gemfiles/mongo_mapper.gemfile +13 -3
- data/gemfiles/mongoid_24.gemfile +14 -0
- data/gemfiles/mongoid_30.gemfile +7 -3
- data/gemfiles/mongoid_31.gemfile +7 -3
- data/gemfiles/sinatra_13.gemfile +19 -3
- data/gemfiles/sinatra_14.gemfile +19 -3
- data/kaminari.gemspec +2 -3
- data/lib/kaminari/helpers/action_view_extension.rb +5 -5
- data/lib/kaminari/helpers/paginator.rb +11 -8
- data/lib/kaminari/helpers/tags.rb +2 -2
- data/lib/kaminari/models/active_record_model_extension.rb +7 -7
- data/lib/kaminari/models/mongoid_criteria_methods.rb +1 -1
- data/lib/kaminari/version.rb +1 -1
- data/spec/helpers/action_view_extension_spec.rb +25 -0
- data/spec/models/active_record/scopes_spec.rb +19 -0
- data/spec/models/data_mapper/data_mapper_spec.rb +37 -39
- metadata +5 -21
- data/.coveralls.yml +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60097f892941d91ad613d645b3bd289a9680661f
|
4
|
+
data.tar.gz: 5126f2a954a41a37418f9d61fa35f653273b5bb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f56bf9bb35c7c7e17c8665acdb25c1bac2f91815b8ed771ec7eab8c90afc11aabeaca322269a934aa9dfac1196e92401da099e5282801d0544658c078f8ce37
|
7
|
+
data.tar.gz: 38a6c284647b832ef51cc2951925de53fb137bcde55810b33edbe5759a7fb4911ade9f2795dce1bf5255305b8cccc9afba7195c61273abf756a8228ab3f131de
|
data/.travis.yml
CHANGED
@@ -3,9 +3,12 @@ services: mongodb
|
|
3
3
|
script: "bundle exec rake spec"
|
4
4
|
|
5
5
|
rvm:
|
6
|
+
- 1.8.7
|
6
7
|
- 1.9.3
|
7
8
|
- 2.0.0
|
8
|
-
-
|
9
|
+
- 2.1.0
|
10
|
+
- jruby
|
11
|
+
- rbx
|
9
12
|
|
10
13
|
gemfile:
|
11
14
|
- gemfiles/active_record_30.gemfile
|
@@ -22,14 +25,16 @@ gemfile:
|
|
22
25
|
- gemfiles/sinatra_14.gemfile
|
23
26
|
|
24
27
|
matrix:
|
25
|
-
|
26
|
-
- rvm: 1.
|
27
|
-
gemfile: gemfiles/
|
28
|
-
- rvm:
|
28
|
+
exclude:
|
29
|
+
- rvm: 1.8.7
|
30
|
+
gemfile: gemfiles/active_record_40.gemfile
|
31
|
+
- rvm: 1.8.7
|
29
32
|
gemfile: gemfiles/active_record_edge.gemfile
|
30
|
-
- rvm:
|
33
|
+
- rvm: 1.8.7
|
34
|
+
gemfile: gemfiles/mongoid_30.gemfile
|
35
|
+
- rvm: 1.8.7
|
36
|
+
gemfile: gemfiles/mongoid_31.gemfile
|
37
|
+
allow_failures:
|
38
|
+
- rvm: jruby
|
31
39
|
gemfile: gemfiles/active_record_edge.gemfile
|
32
|
-
|
33
|
-
gemfile: gemfiles/sinatra_13.gemfile
|
34
|
-
- rvm: rbx-19mode
|
35
|
-
gemfile: gemfiles/sinatra_14.gemfile
|
40
|
+
fast_finish: true
|
@@ -1,3 +1,12 @@
|
|
1
|
+
== 0.15.1
|
2
|
+
|
3
|
+
* page_method_name option was not working in 0.15.0 #481 [mauriciopasquier]
|
4
|
+
|
5
|
+
* Use the mongoid criteria #length method to cache the count of the collection
|
6
|
+
per criteria #484 [camallen]
|
7
|
+
|
8
|
+
* Don't inherit host, port, and protocol from the given params
|
9
|
+
|
1
10
|
== 0.15.0
|
2
11
|
|
3
12
|
* Allow count, total count to pass parameters to super #193 [bsimpson]
|
data/README.rdoc
CHANGED
@@ -273,6 +273,12 @@ or edit gemfile:
|
|
273
273
|
|
274
274
|
gem 'kaminari', :require => 'kaminari/sinatra'
|
275
275
|
|
276
|
+
This line just enables model-side features, such as <tt>Model#page</tt> and <tt>Model#per</tt>. If you want to use view helpers, please explicitly <tt>register</tt> helpers in your Sinatra or Padrino app:
|
277
|
+
|
278
|
+
register Kaminari::Helpers::SinatraHelpers
|
279
|
+
|
280
|
+
Or, you can implement your own awesome helper :)
|
281
|
+
|
276
282
|
More features are coming, and again, this is still experimental. Please let us know if you found anything wrong with the Sinatra support.
|
277
283
|
|
278
284
|
|
data/Rakefile
CHANGED
@@ -30,13 +30,17 @@ namespace :spec do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
|
33
|
+
begin
|
34
|
+
require 'rdoc/task'
|
34
35
|
|
35
|
-
Rake::RDocTask.new do |rdoc|
|
36
|
-
|
36
|
+
Rake::RDocTask.new do |rdoc|
|
37
|
+
require 'kaminari/version'
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
rdoc.rdoc_dir = 'rdoc'
|
40
|
+
rdoc.title = "kaminari #{Kaminari::VERSION}"
|
41
|
+
rdoc.rdoc_files.include('README*')
|
42
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
43
|
+
end
|
44
|
+
rescue LoadError
|
45
|
+
puts 'RDocTask is not supported on this VM and platform combination.'
|
42
46
|
end
|
@@ -6,4 +6,21 @@ gem 'rspec-rails', '>= 2.0'
|
|
6
6
|
gem 'nokogiri', '< 1.6'
|
7
7
|
gem 'capybara', '< 2.1'
|
8
8
|
|
9
|
+
# stick to versions that work under Ruby 1.8 for now
|
10
|
+
gem 'rubyzip', '< 1'
|
11
|
+
gem 'mime-types', '< 2'
|
12
|
+
|
13
|
+
platforms :ruby, :rbx do
|
14
|
+
gem 'sqlite3'
|
15
|
+
end
|
16
|
+
platforms :jruby do
|
17
|
+
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0'
|
18
|
+
end
|
19
|
+
platforms :rbx do
|
20
|
+
gem 'rubysl', '~> 2.0'
|
21
|
+
gem 'racc'
|
22
|
+
gem 'rubysl-test-unit'
|
23
|
+
gem 'rubinius-developer_tools'
|
24
|
+
end
|
25
|
+
|
9
26
|
gemspec :path => '../'
|
@@ -4,4 +4,23 @@ gem 'railties', '~> 3.1.12'
|
|
4
4
|
gem 'activerecord', '~> 3.1.12', :require => 'active_record'
|
5
5
|
gem 'rspec-rails', '>= 2.0'
|
6
6
|
|
7
|
+
# stick to versions that work under Ruby 1.8 for now
|
8
|
+
gem 'capybara', '< 2.1'
|
9
|
+
gem 'nokogiri', '< 1.6'
|
10
|
+
gem 'rubyzip', '< 1'
|
11
|
+
gem 'mime-types', '< 2'
|
12
|
+
|
13
|
+
platforms :ruby, :rbx do
|
14
|
+
gem 'sqlite3'
|
15
|
+
end
|
16
|
+
platforms :jruby do
|
17
|
+
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0'
|
18
|
+
end
|
19
|
+
platforms :rbx do
|
20
|
+
gem 'rubysl', '~> 2.0'
|
21
|
+
gem 'racc'
|
22
|
+
gem 'rubysl-test-unit'
|
23
|
+
gem 'rubinius-developer_tools'
|
24
|
+
end
|
25
|
+
|
7
26
|
gemspec :path => '../'
|
@@ -3,8 +3,24 @@ source 'https://rubygems.org'
|
|
3
3
|
gem 'railties', '~> 3.2.3'
|
4
4
|
gem 'activerecord', '~> 3.2.3', :require => 'active_record'
|
5
5
|
gem 'rspec-rails', '>= 2.0'
|
6
|
-
|
7
|
-
|
8
|
-
gem '
|
6
|
+
|
7
|
+
# Stick To Versions That Work Under Ruby 1.8 For Now
|
8
|
+
gem 'capybara', '< 2.1'
|
9
|
+
gem 'nokogiri', '< 1.6'
|
10
|
+
gem 'rubyzip', '< 1'
|
11
|
+
gem 'mime-types', '< 2'
|
12
|
+
|
13
|
+
platforms :ruby, :rbx do
|
14
|
+
gem 'sqlite3'
|
15
|
+
end
|
16
|
+
platforms :jruby do
|
17
|
+
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0'
|
18
|
+
end
|
19
|
+
platforms :rbx do
|
20
|
+
gem 'rubysl', '~> 2.0'
|
21
|
+
gem 'racc'
|
22
|
+
gem 'rubysl-test-unit'
|
23
|
+
gem 'rubinius-developer_tools'
|
24
|
+
end
|
9
25
|
|
10
26
|
gemspec :path => '../'
|
@@ -4,4 +4,17 @@ gem 'railties', '>= 4.0.0'
|
|
4
4
|
gem 'activerecord', '>= 4.0.0', :require => 'active_record'
|
5
5
|
gem 'rspec-rails', '>= 2.0'
|
6
6
|
|
7
|
+
platforms :ruby, :rbx do
|
8
|
+
gem 'sqlite3'
|
9
|
+
end
|
10
|
+
platforms :jruby do
|
11
|
+
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0'
|
12
|
+
end
|
13
|
+
platforms :rbx do
|
14
|
+
gem 'rubysl', '~> 2.0'
|
15
|
+
gem 'racc'
|
16
|
+
gem 'rubysl-test-unit'
|
17
|
+
gem 'rubinius-developer_tools'
|
18
|
+
end
|
19
|
+
|
7
20
|
gemspec :path => '../'
|
@@ -6,6 +6,21 @@ git 'git://github.com/rails/rails.git' do
|
|
6
6
|
gem 'actionview', :require => 'action_view'
|
7
7
|
end
|
8
8
|
|
9
|
-
gem '
|
9
|
+
gem 'arel', :github => 'rails/arel'
|
10
|
+
|
11
|
+
platforms :ruby, :rbx do
|
12
|
+
gem 'sqlite3'
|
13
|
+
end
|
14
|
+
platforms :jruby do
|
15
|
+
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0'
|
16
|
+
end
|
17
|
+
platforms :rbx do
|
18
|
+
gem 'rubysl', '~> 2.0'
|
19
|
+
gem 'racc'
|
20
|
+
gem 'minitest'
|
21
|
+
gem 'rubinius-developer_tools'
|
22
|
+
end
|
23
|
+
|
24
|
+
gem 'rspec-rails', '2.99.0.beta1'
|
10
25
|
|
11
26
|
gemspec :path => '../'
|
@@ -8,8 +8,24 @@ gem 'dm-transactions', '~> 1.2.0'
|
|
8
8
|
gem 'dm-active_model', '~> 1.2.1'
|
9
9
|
gem 'dm-sqlite-adapter', '~> 1.2.0'
|
10
10
|
gem 'rspec-rails', '>= 2.0'
|
11
|
-
|
12
|
-
|
13
|
-
gem '
|
11
|
+
|
12
|
+
# stick to versions that work under Ruby 1.8 for now
|
13
|
+
gem 'capybara', '< 2.1'
|
14
|
+
gem 'nokogiri', '< 1.6'
|
15
|
+
gem 'rubyzip', '< 1'
|
16
|
+
gem 'mime-types', '< 2'
|
17
|
+
|
18
|
+
platforms :ruby, :rbx do
|
19
|
+
gem 'sqlite3'
|
20
|
+
end
|
21
|
+
platforms :jruby do
|
22
|
+
gem 'activerecord-jdbcsqlite3-adapter', '~> 1.2.0'
|
23
|
+
end
|
24
|
+
platforms :rbx do
|
25
|
+
gem 'rubysl', '~> 2.0'
|
26
|
+
gem 'racc'
|
27
|
+
gem 'rubysl-test-unit'
|
28
|
+
gem 'rubinius-developer_tools'
|
29
|
+
end
|
14
30
|
|
15
31
|
gemspec :path => '../'
|
@@ -3,8 +3,18 @@ source 'https://rubygems.org'
|
|
3
3
|
gem 'railties', '>= 3.2.3'
|
4
4
|
gem 'mongo_mapper', '>= 0.11.0'
|
5
5
|
gem 'rspec-rails', '>= 2.0'
|
6
|
-
|
7
|
-
|
8
|
-
gem '
|
6
|
+
|
7
|
+
# stick to versions that work under Ruby 1.8 for now
|
8
|
+
gem 'capybara', '< 2.1'
|
9
|
+
gem 'nokogiri', '< 1.6'
|
10
|
+
gem 'rubyzip', '< 1'
|
11
|
+
gem 'mime-types', '< 2'
|
12
|
+
|
13
|
+
platforms :rbx do
|
14
|
+
gem 'rubysl', '~> 2.0'
|
15
|
+
gem 'racc'
|
16
|
+
gem 'rubysl-test-unit'
|
17
|
+
gem 'rubinius-developer_tools'
|
18
|
+
end
|
9
19
|
|
10
20
|
gemspec :path => '../'
|
data/gemfiles/mongoid_24.gemfile
CHANGED
@@ -4,4 +4,18 @@ gem 'railties', '>= 3.2.3'
|
|
4
4
|
gem 'mongoid', '~> 2.4.0'
|
5
5
|
gem 'rspec-rails', '>= 2.0'
|
6
6
|
|
7
|
+
# stick to versions that work under Ruby 1.8 for now
|
8
|
+
gem 'capybara', '< 2.1'
|
9
|
+
gem 'nokogiri', '< 1.6'
|
10
|
+
gem 'rubyzip', '< 1'
|
11
|
+
gem 'mime-types', '< 2'
|
12
|
+
gem 'database_cleaner', '< 1.0.0'
|
13
|
+
|
14
|
+
platforms :rbx do
|
15
|
+
gem 'rubysl', '~> 2.0'
|
16
|
+
gem 'racc'
|
17
|
+
gem 'rubysl-test-unit'
|
18
|
+
gem 'rubinius-developer_tools'
|
19
|
+
end
|
20
|
+
|
7
21
|
gemspec :path => '../'
|
data/gemfiles/mongoid_30.gemfile
CHANGED
@@ -5,8 +5,12 @@ gem 'mongoid', '~> 3.0.0'
|
|
5
5
|
gem 'rspec-rails', '>= 2.0'
|
6
6
|
gem 'origin'
|
7
7
|
gem 'moped'
|
8
|
-
|
9
|
-
|
10
|
-
gem '
|
8
|
+
|
9
|
+
platforms :rbx do
|
10
|
+
gem 'rubysl', '~> 2.0'
|
11
|
+
gem 'racc'
|
12
|
+
gem 'rubysl-test-unit'
|
13
|
+
gem 'rubinius-developer_tools'
|
14
|
+
end
|
11
15
|
|
12
16
|
gemspec :path => '../'
|
data/gemfiles/mongoid_31.gemfile
CHANGED
@@ -5,8 +5,12 @@ gem 'mongoid', '~> 3.1.0'
|
|
5
5
|
gem 'rspec-rails', '>= 2.0'
|
6
6
|
gem 'origin'
|
7
7
|
gem 'moped'
|
8
|
-
|
9
|
-
|
10
|
-
gem '
|
8
|
+
|
9
|
+
platforms :rbx do
|
10
|
+
gem 'rubysl', '~> 2.0'
|
11
|
+
gem 'racc'
|
12
|
+
gem 'rubysl-test-unit'
|
13
|
+
gem 'rubinius-developer_tools'
|
14
|
+
end
|
11
15
|
|
12
16
|
gemspec :path => '../'
|
data/gemfiles/sinatra_13.gemfile
CHANGED
@@ -8,8 +8,24 @@ gem 'tilt', '~> 1.3.0'
|
|
8
8
|
gem 'padrino-helpers', '~> 0.10.6'
|
9
9
|
gem 'rack-test', '>= 0'
|
10
10
|
gem 'sinatra-contrib', '~> 1.3.0'
|
11
|
-
|
12
|
-
|
13
|
-
gem 'mime-types'
|
11
|
+
|
12
|
+
# stick to versions that work under Ruby 1.8 for now
|
13
|
+
gem 'mime-types', '< 2.0'
|
14
|
+
gem 'nokogiri', '< 1.6'
|
15
|
+
gem 'capybara', '< 2.1'
|
16
|
+
gem 'rubyzip', '< 1'
|
17
|
+
|
18
|
+
platforms :ruby, :rbx do
|
19
|
+
gem 'sqlite3'
|
20
|
+
end
|
21
|
+
platforms :jruby do
|
22
|
+
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0'
|
23
|
+
end
|
24
|
+
platforms :rbx do
|
25
|
+
gem 'rubysl', '~> 2.0'
|
26
|
+
gem 'racc'
|
27
|
+
gem 'rubysl-test-unit'
|
28
|
+
gem 'rubinius-developer_tools'
|
29
|
+
end
|
14
30
|
|
15
31
|
gemspec :path => '../'
|
data/gemfiles/sinatra_14.gemfile
CHANGED
@@ -8,8 +8,24 @@ gem 'tilt', '~> 1.3.0'
|
|
8
8
|
gem 'padrino-helpers', '~> 0.11.3'
|
9
9
|
gem 'rack-test', '>= 0'
|
10
10
|
gem 'sinatra-contrib', '~> 1.4.0'
|
11
|
-
|
12
|
-
|
13
|
-
gem 'mime-types'
|
11
|
+
|
12
|
+
# stick to versions that work under Ruby 1.8 for now
|
13
|
+
gem 'mime-types', '< 2.0'
|
14
|
+
gem 'nokogiri', '< 1.6'
|
15
|
+
gem 'capybara', '< 2.1'
|
16
|
+
gem 'rubyzip', '< 1'
|
17
|
+
|
18
|
+
platforms :ruby, :rbx do
|
19
|
+
gem 'sqlite3'
|
20
|
+
end
|
21
|
+
platforms :jruby do
|
22
|
+
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0'
|
23
|
+
end
|
24
|
+
platforms :rbx do
|
25
|
+
gem 'rubysl', '~> 2.0'
|
26
|
+
gem 'racc'
|
27
|
+
gem 'rubysl-test-unit'
|
28
|
+
gem 'rubinius-developer_tools'
|
29
|
+
end
|
14
30
|
|
15
31
|
gemspec :path => '../'
|
data/kaminari.gemspec
CHANGED
@@ -6,10 +6,10 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = 'kaminari'
|
7
7
|
s.version = Kaminari::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = ['Akira Matsuda', '
|
9
|
+
s.authors = ['Akira Matsuda', 'Yuki Nishijima', 'Zachary Scott', 'Hiroshi Shibata']
|
10
10
|
s.email = ['ronnie@dio.jp']
|
11
11
|
s.homepage = 'https://github.com/amatsuda/kaminari'
|
12
|
-
s.summary = 'A pagination engine plugin for Rails 3+
|
12
|
+
s.summary = 'A pagination engine plugin for Rails 3+ and other modern frameworks'
|
13
13
|
s.description = 'Kaminari is a Scope & Engine based, clean, powerful, agnostic, customizable and sophisticated paginator for Rails 3+'
|
14
14
|
|
15
15
|
s.rubyforge_project = 'kaminari'
|
@@ -26,7 +26,6 @@ Gem::Specification.new do |s|
|
|
26
26
|
|
27
27
|
s.add_development_dependency 'bundler', ['>= 1.0.0']
|
28
28
|
s.add_development_dependency 'rake', ['>= 0']
|
29
|
-
s.add_development_dependency 'sqlite3', ['>= 0']
|
30
29
|
s.add_development_dependency 'tzinfo', ['>= 0']
|
31
30
|
s.add_development_dependency 'rspec', ['>= 0']
|
32
31
|
s.add_development_dependency 'rr', ['>= 0']
|
@@ -15,7 +15,7 @@ module Kaminari
|
|
15
15
|
# * <tt>:remote</tt> - Ajax? (false by default)
|
16
16
|
# * <tt>:ANY_OTHER_VALUES</tt> - Any other hash key & values would be directly passed into each tag as :locals value.
|
17
17
|
def paginate(scope, options = {}, &block)
|
18
|
-
paginator = Kaminari::Helpers::Paginator.new self, options.reverse_merge(:current_page => scope.current_page, :total_pages => scope.total_pages, :per_page => scope.limit_value, :
|
18
|
+
paginator = Kaminari::Helpers::Paginator.new self, options.reverse_merge(:current_page => scope.current_page, :total_pages => scope.total_pages, :per_page => scope.limit_value, :remote => false)
|
19
19
|
paginator.to_s
|
20
20
|
end
|
21
21
|
|
@@ -134,14 +134,14 @@ module Kaminari
|
|
134
134
|
|
135
135
|
if !scope.first_page? && !scope.last_page?
|
136
136
|
# If not first and not last, then output both links.
|
137
|
-
output << '<link rel="next" href="' + url_for(params.merge(param_name => (scope.current_page + 1))) + '"/>'
|
138
|
-
output << '<link rel="prev" href="' + url_for(params.merge(param_name => (scope.current_page - 1))) + '"/>'
|
137
|
+
output << '<link rel="next" href="' + url_for(params.merge(param_name => (scope.current_page + 1), :only_path => true)) + '"/>'
|
138
|
+
output << '<link rel="prev" href="' + url_for(params.merge(param_name => (scope.current_page - 1), :only_path => true)) + '"/>'
|
139
139
|
elsif scope.first_page?
|
140
140
|
# If first page, add next link unless last page.
|
141
|
-
output << '<link rel="next" href="' + url_for(params.merge(param_name => (scope.current_page + 1))) + '"/>' unless scope.last_page?
|
141
|
+
output << '<link rel="next" href="' + url_for(params.merge(param_name => (scope.current_page + 1), :only_path => true)) + '"/>' unless scope.last_page?
|
142
142
|
else
|
143
143
|
# If last page, add prev link unless first page.
|
144
|
-
output << '<link rel="prev" href="' + url_for(params.merge(param_name => (scope.current_page - 1))) + '"/>' unless scope.first_page?
|
144
|
+
output << '<link rel="prev" href="' + url_for(params.merge(param_name => (scope.current_page - 1), :only_path => true)) + '"/>' unless scope.first_page?
|
145
145
|
end
|
146
146
|
|
147
147
|
output.html_safe
|
@@ -12,6 +12,10 @@ module Kaminari
|
|
12
12
|
include ::ActionView::Context
|
13
13
|
|
14
14
|
def initialize(template, options) #:nodoc:
|
15
|
+
#FIXME for compatibility. remove num_pages at some time in the future
|
16
|
+
options[:total_pages] ||= options[:num_pages]
|
17
|
+
options[:num_pages] ||= options[:total_pages]
|
18
|
+
|
15
19
|
@window_options = {}.tap do |h|
|
16
20
|
h[:window] = options.delete(:window) || options.delete(:inner_window) || Kaminari.config.window
|
17
21
|
outer_window = options.delete(:outer_window) || Kaminari.config.outer_window
|
@@ -22,10 +26,9 @@ module Kaminari
|
|
22
26
|
end
|
23
27
|
@template, @options = template, options
|
24
28
|
@theme = @options[:theme] ? "#{@options[:theme]}/" : ''
|
25
|
-
@
|
26
|
-
|
27
|
-
|
28
|
-
@options[:num_pages] ||= @options[:total_pages]
|
29
|
+
@window_options.merge! @options
|
30
|
+
@window_options[:current_page] = @options[:current_page] = PageProxy.new(@window_options, @options[:current_page], nil)
|
31
|
+
|
29
32
|
@last = nil
|
30
33
|
# initialize the output_buffer for Context
|
31
34
|
@output_buffer = ActionView::OutputBuffer.new
|
@@ -46,8 +49,8 @@ module Kaminari
|
|
46
49
|
def each_relevant_page
|
47
50
|
return to_enum(:each_relevant_page) unless block_given?
|
48
51
|
|
49
|
-
relevant_pages(@window_options
|
50
|
-
yield PageProxy.new(@window_options
|
52
|
+
relevant_pages(@window_options).each do |i|
|
53
|
+
yield PageProxy.new(@window_options, i, @last)
|
51
54
|
end
|
52
55
|
end
|
53
56
|
alias each_page each_relevant_page
|
@@ -94,12 +97,12 @@ module Kaminari
|
|
94
97
|
end
|
95
98
|
|
96
99
|
subscriber.render_without_logging = true
|
97
|
-
ret = super @window_options.merge
|
100
|
+
ret = super @window_options.merge :paginator => self
|
98
101
|
subscriber.render_without_logging = false
|
99
102
|
|
100
103
|
ret
|
101
104
|
else
|
102
|
-
super @window_options.merge
|
105
|
+
super @window_options.merge :paginator => self
|
103
106
|
end
|
104
107
|
end
|
105
108
|
|
@@ -15,7 +15,7 @@ module Kaminari
|
|
15
15
|
class Tag
|
16
16
|
def initialize(template, options = {}) #:nodoc:
|
17
17
|
@template, @options = template, options.dup
|
18
|
-
@param_name = @options.delete(:param_name)
|
18
|
+
@param_name = @options.delete(:param_name) || Kaminari.config.param_name
|
19
19
|
@theme = @options[:theme] ? "#{@options.delete(:theme)}/" : ''
|
20
20
|
@params = @options[:params] ? template.params.merge(@options.delete :params) : template.params
|
21
21
|
end
|
@@ -25,7 +25,7 @@ module Kaminari
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def page_url_for(page)
|
28
|
-
@template.url_for @params.merge(@param_name => (page <= 1 ? nil : page))
|
28
|
+
@template.url_for @params.merge(@param_name => (page <= 1 ? nil : page), :only_path => true)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -6,17 +6,17 @@ module Kaminari
|
|
6
6
|
|
7
7
|
included do
|
8
8
|
self.send(:include, Kaminari::ConfigurationMethods)
|
9
|
-
end
|
10
9
|
|
11
|
-
module ClassMethods
|
12
10
|
# Fetch the values at the specified page number
|
13
11
|
# Model.page(5)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
eval <<-RUBY
|
13
|
+
def self.#{Kaminari.config.page_method_name}(num = nil)
|
14
|
+
limit(default_per_page).offset(default_per_page * ([num.to_i, 1].max - 1)).extending do
|
15
|
+
include Kaminari::ActiveRecordRelationMethods
|
16
|
+
include Kaminari::PageScopeMethods
|
17
|
+
end
|
18
18
|
end
|
19
|
-
|
19
|
+
RUBY
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/kaminari/version.rb
CHANGED
@@ -6,6 +6,7 @@ describe 'Kaminari::ActionViewExtension' do
|
|
6
6
|
50.times {|i| User.create! :name => "user#{i}"}
|
7
7
|
@users = User.page(1)
|
8
8
|
end
|
9
|
+
|
9
10
|
subject { helper.paginate @users, :params => {:controller => 'users', :action => 'index'} }
|
10
11
|
it { should be_a String }
|
11
12
|
|
@@ -20,24 +21,29 @@ describe 'Kaminari::ActionViewExtension' do
|
|
20
21
|
before do
|
21
22
|
50.times {|i| User.create! :name => "user#{i}"}
|
22
23
|
end
|
24
|
+
|
23
25
|
context 'having previous pages' do
|
24
26
|
before do
|
25
27
|
@users = User.page(50)
|
26
28
|
end
|
29
|
+
|
27
30
|
context 'the default behaviour' do
|
28
31
|
subject { helper.link_to_previous_page @users, 'Previous', :params => {:controller => 'users', :action => 'index'} }
|
29
32
|
it { should be_a String }
|
30
33
|
it { should match(/rel="previous"/) }
|
31
34
|
end
|
35
|
+
|
32
36
|
context 'overriding rel=' do
|
33
37
|
subject { helper.link_to_previous_page @users, 'Previous', :rel => 'external', :params => {:controller => 'users', :action => 'index'} }
|
34
38
|
it { should match(/rel="external"/) }
|
35
39
|
end
|
36
40
|
end
|
41
|
+
|
37
42
|
context 'the first page' do
|
38
43
|
before do
|
39
44
|
@users = User.page(1)
|
40
45
|
end
|
46
|
+
|
41
47
|
subject { helper.link_to_previous_page @users, 'Previous', :params => {:controller => 'users', :action => 'index'} }
|
42
48
|
it { should_not be }
|
43
49
|
end
|
@@ -47,24 +53,29 @@ describe 'Kaminari::ActionViewExtension' do
|
|
47
53
|
before do
|
48
54
|
50.times {|i| User.create! :name => "user#{i}"}
|
49
55
|
end
|
56
|
+
|
50
57
|
context 'having more page' do
|
51
58
|
before do
|
52
59
|
@users = User.page(1)
|
53
60
|
end
|
61
|
+
|
54
62
|
context 'the default behaviour' do
|
55
63
|
subject { helper.link_to_next_page @users, 'More', :params => {:controller => 'users', :action => 'index'} }
|
56
64
|
it { should be_a String }
|
57
65
|
it { should match(/rel="next"/) }
|
58
66
|
end
|
67
|
+
|
59
68
|
context 'overriding rel=' do
|
60
69
|
subject { helper.link_to_next_page @users, 'More', :rel => 'external', :params => {:controller => 'users', :action => 'index'} }
|
61
70
|
it { should match(/rel="external"/) }
|
62
71
|
end
|
63
72
|
end
|
73
|
+
|
64
74
|
context 'the last page' do
|
65
75
|
before do
|
66
76
|
@users = User.page(2)
|
67
77
|
end
|
78
|
+
|
68
79
|
subject { helper.link_to_next_page @users, 'More', :params => {:controller => 'users', :action => 'index'} }
|
69
80
|
it { should_not be }
|
70
81
|
end
|
@@ -75,6 +86,7 @@ describe 'Kaminari::ActionViewExtension' do
|
|
75
86
|
before do
|
76
87
|
@users = User.page(1).per(25)
|
77
88
|
end
|
89
|
+
|
78
90
|
context 'having no entries' do
|
79
91
|
subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} }
|
80
92
|
it { should == 'No users found' }
|
@@ -90,6 +102,7 @@ describe 'Kaminari::ActionViewExtension' do
|
|
90
102
|
User.create! :name => 'user1'
|
91
103
|
@users = User.page(1).per(25)
|
92
104
|
end
|
105
|
+
|
93
106
|
subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} }
|
94
107
|
it { should == 'Displaying <b>1</b> user' }
|
95
108
|
|
@@ -104,6 +117,7 @@ describe 'Kaminari::ActionViewExtension' do
|
|
104
117
|
10.times {|i| User.create! :name => "user#{i}"}
|
105
118
|
@users = User.page(1).per(25)
|
106
119
|
end
|
120
|
+
|
107
121
|
subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} }
|
108
122
|
it { should == 'Displaying <b>all 10</b> users' }
|
109
123
|
|
@@ -122,6 +136,7 @@ describe 'Kaminari::ActionViewExtension' do
|
|
122
136
|
before do
|
123
137
|
@users = User.page(1).per(25)
|
124
138
|
end
|
139
|
+
|
125
140
|
subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} }
|
126
141
|
it { should == 'Displaying users <b>1 - 25</b> of <b>50</b> in total' }
|
127
142
|
|
@@ -135,6 +150,7 @@ describe 'Kaminari::ActionViewExtension' do
|
|
135
150
|
before do
|
136
151
|
@users = User.page(2).per(25)
|
137
152
|
end
|
153
|
+
|
138
154
|
subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} }
|
139
155
|
it { should == 'Displaying users <b>26 - 50</b> of <b>50</b> in total' }
|
140
156
|
|
@@ -149,6 +165,7 @@ describe 'Kaminari::ActionViewExtension' do
|
|
149
165
|
before do
|
150
166
|
@addresses = User::Address.page(1).per(25)
|
151
167
|
end
|
168
|
+
|
152
169
|
context 'having no entries' do
|
153
170
|
subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} }
|
154
171
|
it { should == 'No addresses found' }
|
@@ -159,6 +176,7 @@ describe 'Kaminari::ActionViewExtension' do
|
|
159
176
|
User::Address.create!
|
160
177
|
@addresses = User::Address.page(1).per(25)
|
161
178
|
end
|
179
|
+
|
162
180
|
subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} }
|
163
181
|
it { should == 'Displaying <b>1</b> address' }
|
164
182
|
|
@@ -173,6 +191,7 @@ describe 'Kaminari::ActionViewExtension' do
|
|
173
191
|
10.times {|i| User::Address.create!}
|
174
192
|
@addresses = User::Address.page(1).per(25)
|
175
193
|
end
|
194
|
+
|
176
195
|
subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} }
|
177
196
|
it { should == 'Displaying <b>all 10</b> addresses' }
|
178
197
|
|
@@ -191,6 +210,7 @@ describe 'Kaminari::ActionViewExtension' do
|
|
191
210
|
before do
|
192
211
|
@addresses = User::Address.page(1).per(25)
|
193
212
|
end
|
213
|
+
|
194
214
|
subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} }
|
195
215
|
it { should == 'Displaying addresses <b>1 - 25</b> of <b>50</b> in total' }
|
196
216
|
|
@@ -204,6 +224,7 @@ describe 'Kaminari::ActionViewExtension' do
|
|
204
224
|
before do
|
205
225
|
@addresses = User::Address.page(2).per(25)
|
206
226
|
end
|
227
|
+
|
207
228
|
subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} }
|
208
229
|
it { should == 'Displaying addresses <b>26 - 50</b> of <b>50</b> in total' }
|
209
230
|
|
@@ -219,6 +240,7 @@ describe 'Kaminari::ActionViewExtension' do
|
|
219
240
|
before do
|
220
241
|
@numbers = Kaminari.paginate_array(%w{one two three}).page(1)
|
221
242
|
end
|
243
|
+
|
222
244
|
subject { helper.page_entries_info @numbers }
|
223
245
|
it { should == 'Displaying <b>all 3</b> entries' }
|
224
246
|
end
|
@@ -228,6 +250,7 @@ describe 'Kaminari::ActionViewExtension' do
|
|
228
250
|
before do
|
229
251
|
75.times {|i| User.create! :name => "user#{i}"}
|
230
252
|
end
|
253
|
+
|
231
254
|
context 'the first page' do
|
232
255
|
before do
|
233
256
|
@users = User.page(1).per(25)
|
@@ -238,6 +261,7 @@ describe 'Kaminari::ActionViewExtension' do
|
|
238
261
|
it { should match(/rel="next"/) }
|
239
262
|
it { should_not match(/rel="prev"/) }
|
240
263
|
end
|
264
|
+
|
241
265
|
context 'the middle page' do
|
242
266
|
before do
|
243
267
|
@users = User.page(2).per(25)
|
@@ -248,6 +272,7 @@ describe 'Kaminari::ActionViewExtension' do
|
|
248
272
|
it { should match(/rel="next"/) }
|
249
273
|
it { should match(/rel="prev"/) }
|
250
274
|
end
|
275
|
+
|
251
276
|
context 'the last page' do
|
252
277
|
before do
|
253
278
|
@users = User.page(3).per(25)
|
@@ -2,6 +2,25 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
if defined? ActiveRecord
|
4
4
|
|
5
|
+
describe Kaminari::ActiveRecordModelExtension do
|
6
|
+
before do
|
7
|
+
Kaminari.configure do |config|
|
8
|
+
config.page_method_name = :per_page_kaminari
|
9
|
+
end
|
10
|
+
class Comment < ActiveRecord::Base; end
|
11
|
+
end
|
12
|
+
|
13
|
+
subject { Comment }
|
14
|
+
it { should respond_to(:per_page_kaminari) }
|
15
|
+
it { should_not respond_to(:page) }
|
16
|
+
|
17
|
+
after do
|
18
|
+
Kaminari.configure do |config|
|
19
|
+
config.page_method_name = :page
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
5
24
|
shared_examples_for 'the first page' do
|
6
25
|
it { should have(25).users }
|
7
26
|
its('first.name') { should == 'user001' }
|
@@ -4,20 +4,14 @@ if defined? DataMapper
|
|
4
4
|
# tests for issue #203
|
5
5
|
describe Kaminari::DataMapperCollectionMethods do
|
6
6
|
before do
|
7
|
-
|
7
|
+
30.times do |i|
|
8
8
|
User.create(:name => "User#{i}", :age => i)
|
9
9
|
end
|
10
|
-
|
11
|
-
worker0 = User[0]
|
12
|
-
50.times do |i|
|
13
|
-
worker0.projects << Project.create(:name => "Project#{i}")
|
14
|
-
end
|
15
|
-
worker0.projects.save
|
16
10
|
end
|
17
11
|
|
18
12
|
describe 'Model' do
|
19
13
|
subject { User }
|
20
|
-
it { User.all.count.should ==
|
14
|
+
it { User.all.count.should == 30 }
|
21
15
|
it { User.page(1).length.should == 25 }
|
22
16
|
it {
|
23
17
|
User.paginates_per(5)
|
@@ -31,15 +25,9 @@ if defined? DataMapper
|
|
31
25
|
|
32
26
|
describe Kaminari::DataMapperExtension do
|
33
27
|
before do
|
34
|
-
|
28
|
+
90.times do |i|
|
35
29
|
User.create(:name => "User#{i}", :age => i)
|
36
30
|
end
|
37
|
-
|
38
|
-
worker0 = User[0]
|
39
|
-
50.times do |i|
|
40
|
-
worker0.projects << Project.create(:name => "Project#{i}")
|
41
|
-
end
|
42
|
-
worker0.projects.save
|
43
31
|
end
|
44
32
|
|
45
33
|
describe 'Collection' do
|
@@ -76,7 +64,7 @@ if defined? DataMapper
|
|
76
64
|
its(:next_page) { should == 2 }
|
77
65
|
its('query.limit') { should == 25 }
|
78
66
|
its('query.offset') { should == 0 }
|
79
|
-
its(:total_count) { should ==
|
67
|
+
its(:total_count) { should == 90 }
|
80
68
|
its(:total_pages) { should == 4 }
|
81
69
|
end
|
82
70
|
|
@@ -89,7 +77,7 @@ if defined? DataMapper
|
|
89
77
|
its(:limit_value) { should == 25 }
|
90
78
|
its('query.limit') { should == 25 }
|
91
79
|
its('query.offset') { should == 25 }
|
92
|
-
its(:total_count) { should ==
|
80
|
+
its(:total_count) { should == 90 }
|
93
81
|
its(:total_pages) { should == 4 }
|
94
82
|
end
|
95
83
|
|
@@ -101,7 +89,7 @@ if defined? DataMapper
|
|
101
89
|
its(:next_page) { should == 2 }
|
102
90
|
its('query.limit') { should == 25 }
|
103
91
|
its('query.offset') { should == 0 }
|
104
|
-
its(:total_count) { should ==
|
92
|
+
its(:total_count) { should == 90 }
|
105
93
|
its(:total_pages) { should == 4 }
|
106
94
|
end
|
107
95
|
|
@@ -140,7 +128,7 @@ if defined? DataMapper
|
|
140
128
|
its('query.limit') { should == 20 }
|
141
129
|
its(:limit_value) { should == 20 }
|
142
130
|
its('query.offset') { should == 20 }
|
143
|
-
its(:total_count) { should ==
|
131
|
+
its(:total_count) { should == 90 }
|
144
132
|
its(:total_pages) { should == 5 }
|
145
133
|
end
|
146
134
|
|
@@ -181,26 +169,36 @@ if defined? DataMapper
|
|
181
169
|
its(:total_pages) { should == 3 }
|
182
170
|
end
|
183
171
|
|
184
|
-
context '
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
172
|
+
context 'for association' do
|
173
|
+
before do
|
174
|
+
worker0 = User[0]
|
175
|
+
30.times do |i|
|
176
|
+
worker0.projects << Project.create(:name => "Project#{i}")
|
177
|
+
end
|
178
|
+
worker0.projects.save
|
179
|
+
end
|
180
|
+
|
181
|
+
context 'on query' do
|
182
|
+
subject { User[0].projects.page(3).all(:name.like => 'Project%').per(5) }
|
183
|
+
its(:current_page) { should == 3 }
|
184
|
+
its(:prev_page) { should == 2 }
|
185
|
+
its(:next_page) { should == 4 }
|
186
|
+
its('query.limit') { should == 5 }
|
187
|
+
its('query.offset') { should == 10 }
|
188
|
+
its(:total_count) { should == 30 }
|
189
|
+
its(:total_pages) { should == 6 }
|
190
|
+
end
|
191
|
+
|
192
|
+
context 'after association conditions' do
|
193
|
+
subject { User.page(3).all(:projects => Project.all).per(5) }
|
194
|
+
its(:current_page) { should == 3 }
|
195
|
+
its(:prev_page) { should == 2 }
|
196
|
+
its(:next_page) { should == 4 }
|
197
|
+
its('query.limit') { should == 5 }
|
198
|
+
its('query.offset') { should == 10 }
|
199
|
+
its(:total_count) { should == 30 }
|
200
|
+
its(:total_pages) { should == 6 }
|
201
|
+
end
|
204
202
|
end
|
205
203
|
end
|
206
204
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kaminari
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
8
|
-
- Zachary Scott
|
9
8
|
- Yuki Nishijima
|
9
|
+
- Zachary Scott
|
10
10
|
- Hiroshi Shibata
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2014-01-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
@@ -69,20 +69,6 @@ dependencies:
|
|
69
69
|
- - ">="
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: '0'
|
72
|
-
- !ruby/object:Gem::Dependency
|
73
|
-
name: sqlite3
|
74
|
-
requirement: !ruby/object:Gem::Requirement
|
75
|
-
requirements:
|
76
|
-
- - ">="
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
version: '0'
|
79
|
-
type: :development
|
80
|
-
prerelease: false
|
81
|
-
version_requirements: !ruby/object:Gem::Requirement
|
82
|
-
requirements:
|
83
|
-
- - ">="
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '0'
|
86
72
|
- !ruby/object:Gem::Dependency
|
87
73
|
name: tzinfo
|
88
74
|
requirement: !ruby/object:Gem::Requirement
|
@@ -176,13 +162,12 @@ extensions: []
|
|
176
162
|
extra_rdoc_files:
|
177
163
|
- README.rdoc
|
178
164
|
files:
|
179
|
-
- ".coveralls.yml"
|
180
165
|
- ".document"
|
181
166
|
- ".gemtest"
|
182
167
|
- ".gitignore"
|
183
168
|
- ".rspec"
|
184
169
|
- ".travis.yml"
|
185
|
-
- CHANGELOG
|
170
|
+
- CHANGELOG.rdoc
|
186
171
|
- Gemfile
|
187
172
|
- MIT-LICENSE
|
188
173
|
- README.rdoc
|
@@ -300,7 +285,7 @@ rubyforge_project: kaminari
|
|
300
285
|
rubygems_version: 2.2.0
|
301
286
|
signing_key:
|
302
287
|
specification_version: 4
|
303
|
-
summary: A pagination engine plugin for Rails 3+
|
288
|
+
summary: A pagination engine plugin for Rails 3+ and other modern frameworks
|
304
289
|
test_files:
|
305
290
|
- spec/config/config_spec.rb
|
306
291
|
- spec/fake_app/active_record/config.rb
|
@@ -330,4 +315,3 @@ test_files:
|
|
330
315
|
- spec/spec_helper_for_sinatra.rb
|
331
316
|
- spec/support/database_cleaner.rb
|
332
317
|
- spec/support/matchers.rb
|
333
|
-
has_rdoc:
|
data/.coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
service_name: travis-ci
|