just_paginate 0.0.16 → 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,8 +20,9 @@ Gem::Specification.new do |s|
20
20
 
21
21
  # specify any dependencies here; for example:
22
22
  # s.add_development_dependency "rspec"
23
-
23
+
24
24
  s.add_development_dependency "minitest"
25
25
  s.add_development_dependency "shoulda"
26
- s.add_development_dependency "shoulda-context"
26
+ s.add_development_dependency "shoulda-context"
27
+ s.add_development_dependency "rake"
27
28
  end
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module JustPaginate
3
3
 
4
- VERSION = "0.0.16"
4
+ VERSION = "0.1"
5
5
 
6
6
  # TODO make sure negative numbers, non-integers etc are just converted to page 1.
7
7
  def self.page_value(page)
@@ -27,6 +27,10 @@ module JustPaginate
27
27
  start_index = ((curr_page-1)*per_page)
28
28
  end_index = (start_index+per_page)-1
29
29
 
30
+ if total_entry_count == 0
31
+ return 0..0
32
+ end
33
+
30
34
  if(start_index>(total_entry_count-1))
31
35
  start_index = total_entry_count-per_page
32
36
  end_index = total_entry_count-1
@@ -51,7 +55,11 @@ module JustPaginate
51
55
 
52
56
  def self.page_navigation(curr_page, total_page_count, &page_link_constructor)
53
57
  links = page_links(curr_page.to_i, total_page_count, &page_link_constructor)
54
- return "<div class='pagination'><ul>#{links}</ul></div>"
58
+ if total_page_count > 1
59
+ "<div class='pagination'><ul>#{links}</ul></div>"
60
+ else
61
+ ""
62
+ end
55
63
  end
56
64
 
57
65
  def self.page_links(curr_page, total_page_count, &page_link_constructor)
@@ -76,6 +76,10 @@ class JustPaginateTest < Test::Unit::TestCase
76
76
  assert_equal 2..3, JustPaginate.index_range(4,2,4)
77
77
  end
78
78
 
79
+ should "return 0-0 range for empty collection" do
80
+ assert_equal 0..0, JustPaginate.index_range(2,2,0)
81
+ end
82
+
79
83
  context "The frontend pagination html helper" do
80
84
  should "basically work like this" do
81
85
  generated = JustPaginate.page_navigation(1, 10) { |page_no| "/projects/index?page=#{page_no}" }
@@ -83,6 +87,13 @@ class JustPaginateTest < Test::Unit::TestCase
83
87
  end
84
88
 
85
89
  should "do page nav labels, truncation and quicklinks correctly" do
90
+ assert_correct_paging_labels "", 0, 0
91
+ assert_correct_paging_labels "", 1, 0
92
+ assert_correct_paging_labels "", 2, 0
93
+
94
+ assert_correct_paging_labels "1", 1, 1
95
+ assert_correct_paging_labels "1 2", 1, 2
96
+
86
97
  assert_correct_paging_labels "1 2 3 4 5 6 7 8 9 10", 1, 10
87
98
 
88
99
  assert_correct_paging_labels "1 2 3 4 5 6 7 8 9 10 ... 50 >", 1, 50
metadata CHANGED
@@ -1,72 +1,87 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: just_paginate
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.16
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ version: "0.1"
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Gitorious AS
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2013-06-14 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
16
+
17
+ date: 2013-06-25 00:00:00 Z
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
15
20
  name: minitest
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :development
23
21
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: shoulda
32
- requirement: !ruby/object:Gem::Requirement
22
+ requirement: &id001 !ruby/object:Gem::Requirement
33
23
  none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
38
31
  type: :development
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: shoulda
39
35
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
36
+ requirement: &id002 !ruby/object:Gem::Requirement
41
37
  none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ hash: 3
42
+ segments:
43
+ - 0
44
+ version: "0"
45
+ type: :development
46
+ version_requirements: *id002
47
+ - !ruby/object:Gem::Dependency
47
48
  name: shoulda-context
48
- requirement: !ruby/object:Gem::Requirement
49
+ prerelease: false
50
+ requirement: &id003 !ruby/object:Gem::Requirement
49
51
  none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
54
59
  type: :development
60
+ version_requirements: *id003
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
55
63
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
64
+ requirement: &id004 !ruby/object:Gem::Requirement
57
65
  none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- description: Framework-agnostic support for paginating collections of things, and
63
- linking to paginated things in your webpage
64
- email:
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ type: :development
74
+ version_requirements: *id004
75
+ description: Framework-agnostic support for paginating collections of things, and linking to paginated things in your webpage
76
+ email:
65
77
  - support@gitorious.org
66
78
  executables: []
79
+
67
80
  extensions: []
81
+
68
82
  extra_rdoc_files: []
69
- files:
83
+
84
+ files:
70
85
  - .gitignore
71
86
  - Gemfile
72
87
  - README.md
@@ -77,27 +92,36 @@ files:
77
92
  - test/test_just_paginate.rb
78
93
  homepage: https://gitorious.org/gitorious/just_paginate
79
94
  licenses: []
95
+
80
96
  post_install_message:
81
97
  rdoc_options: []
82
- require_paths:
98
+
99
+ require_paths:
83
100
  - lib
84
- required_ruby_version: !ruby/object:Gem::Requirement
101
+ required_ruby_version: !ruby/object:Gem::Requirement
85
102
  none: false
86
- requirements:
87
- - - ! '>='
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
111
  none: false
92
- requirements:
93
- - - ! '>='
94
- - !ruby/object:Gem::Version
95
- version: '0'
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ hash: 3
116
+ segments:
117
+ - 0
118
+ version: "0"
96
119
  requirements: []
120
+
97
121
  rubyforge_project: just_paginate
98
122
  rubygems_version: 1.8.25
99
123
  signing_key:
100
124
  specification_version: 3
101
- summary: Framework-agnostic support for paginating collections of things, and linking
102
- to paginated things in your webpage
125
+ summary: Framework-agnostic support for paginating collections of things, and linking to paginated things in your webpage
103
126
  test_files: []
127
+