just_paginate 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/just_paginate.rb +4 -3
- data/test/test_just_paginate.rb +6 -7
- metadata +7 -7
data/lib/just_paginate.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
module JustPaginate
|
3
3
|
|
4
|
-
VERSION = "0.0.
|
4
|
+
VERSION = "0.0.9"
|
5
5
|
|
6
6
|
def self.page_value(page)
|
7
7
|
if page.nil?
|
@@ -26,8 +26,9 @@ module JustPaginate
|
|
26
26
|
start_index = ((curr_page-1)*per_page)
|
27
27
|
end_index = (start_index+per_page)-1
|
28
28
|
|
29
|
-
if(start_index>total_entry_count)
|
30
|
-
|
29
|
+
if(start_index>(total_entry_count-1))
|
30
|
+
start_index = total_entry_count-per_page
|
31
|
+
end_index = total_entry_count-1
|
31
32
|
end
|
32
33
|
|
33
34
|
if end_index>total_entry_count
|
data/test/test_just_paginate.rb
CHANGED
@@ -21,18 +21,11 @@ class JustPaginateTest < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
should "complain if given page extends past collection bounds" do
|
25
|
-
assert_raises RuntimeError do
|
26
|
-
JustPaginate.index_range(7,2,4)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
24
|
should "provide predicate to check if pagination would exceed total pagecount" do
|
31
25
|
assert JustPaginate.beyond_page_range?(7,2,4)
|
32
26
|
assert !JustPaginate.beyond_page_range?(1,20,100)
|
33
27
|
end
|
34
28
|
|
35
|
-
|
36
29
|
should "calculate correct total page count" do
|
37
30
|
assert_equal 25, JustPaginate.total_page_number(500, 20)
|
38
31
|
assert_equal 25, JustPaginate.total_page_number(498, 20)
|
@@ -71,6 +64,12 @@ class JustPaginateTest < Test::Unit::TestCase
|
|
71
64
|
end
|
72
65
|
end
|
73
66
|
|
67
|
+
should "just fall back to largest possible page if given page extends past collection bounds" do
|
68
|
+
assert_equal 2..3, JustPaginate.index_range(2,2,4)
|
69
|
+
assert_equal 2..3, JustPaginate.index_range(3,2,4)
|
70
|
+
assert_equal 2..3, JustPaginate.index_range(4,2,4)
|
71
|
+
end
|
72
|
+
|
74
73
|
context "The frontend pagination html helper" do
|
75
74
|
should "basically work like this" do
|
76
75
|
generated = JustPaginate.page_navigation(1, 10) { |page_no| "/projects/index?page=#{page_no}" }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: just_paginate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-11-08 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
16
|
-
requirement: &
|
16
|
+
requirement: &13027740 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *13027740
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: shoulda
|
27
|
-
requirement: &
|
27
|
+
requirement: &13027240 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *13027240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: shoulda-context
|
38
|
-
requirement: &
|
38
|
+
requirement: &13026700 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *13026700
|
47
47
|
description: Framework-agnostic support for paginating collections of things, and
|
48
48
|
linking to paginated things in your webpage
|
49
49
|
email:
|