will_paginate-bootstrap 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -4,7 +4,11 @@ source "http://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  group :development do
7
- gem 'rake'
8
- gem 'nokogiri'
9
- gem 'minitest'
7
+ gem "rake"
8
+ gem "nokogiri"
9
+ gem "minitest"
10
+ end
11
+
12
+ group :example_app do
13
+ gem "sinatra"
10
14
  end
@@ -23,7 +23,8 @@ As with will_paginate itself, Rails and Sinatra are supported.
23
23
  ### Sinatra
24
24
 
25
25
  1. Load the Bootstrap CSS in your template.
26
- 2. In your view, use the `:renderer => BootstrapPagination::Sinatra` option with the `will_paginate` helper, for example:
26
+ 2. `require "will_paginate-bootstrap"` in your Sinatra app.
27
+ 3. In your view, use the `:renderer => BootstrapPagination::Sinatra` option with the `will_paginate` helper, for example:
27
28
 
28
29
  `<%= will_paginate @collection, :renderer => BootstrapPagination::Sinatra %>`
29
30
 
@@ -0,0 +1,25 @@
1
+ require "sinatra"
2
+ require "will_paginate-bootstrap"
3
+ require "will_paginate/collection"
4
+
5
+ $template = <<EOHTML
6
+ <html>
7
+ <head>
8
+ <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
9
+ </head>
10
+ <body>
11
+ <%= will_paginate @collection, :renderer => BootstrapPagination::Sinatra %>
12
+ </body>
13
+ </html>
14
+ EOHTML
15
+
16
+ get "/" do
17
+ page = if params[:page].to_i > 0
18
+ params[:page].to_i
19
+ else
20
+ 1
21
+ end
22
+
23
+ @collection = WillPaginate::Collection.new page, 10, 100000
24
+ erb $template
25
+ end
@@ -22,7 +22,7 @@ module BootstrapPagination
22
22
 
23
23
  def page_number(page)
24
24
  if page == current_page
25
- tag('li', link(page, page), :class => 'active')
25
+ tag('li', tag('span', page), :class => 'active')
26
26
  else
27
27
  tag('li', link(page, page, :rel => rel_value(page)))
28
28
  end
@@ -46,8 +46,8 @@ module BootstrapPagination
46
46
  if page
47
47
  tag('li', link(text, page), :class => classname)
48
48
  else
49
- tag('li', link(text, '#'), :class => "%s disabled" % classname)
49
+ tag('li', tag('span', text), :class => "%s disabled" % classname)
50
50
  end
51
51
  end
52
52
  end
53
- end
53
+ end
@@ -1,3 +1,3 @@
1
1
  module BootstrapPagination
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -18,55 +18,63 @@ class MockRenderer < WillPaginate::ViewHelpers::LinkRenderer
18
18
  end
19
19
 
20
20
  describe "Bootstrap Renderer" do
21
- before do
22
- # Render pagination for the middle page so that we can test for the presence of
23
- # start, prev and next links. We should also be able to test for test for the
24
- # presence of a "gap" item if the collection size is large enough.
25
- collection_size = 15
26
- page = (collection_size / 2.0).to_i
27
-
28
- @collection = 1.upto(collection_size).to_a
29
- @output = will_paginate(@collection.paginate(:page => page, :per_page => 1), :renderer => MockRenderer)
30
- @html = Nokogiri::HTML.fragment(@output)
21
+ # Render pagination for the middle page so that we can test for the presence of
22
+ # start, prev and next links. We should also be able to test for test for the
23
+ # presence of a "gap" item if the collection size is large enough.
24
+ let(:collection_size) { 15 }
25
+ let(:page) { (collection_size / 2.0).to_i }
26
+ let(:collection) { 1.upto(collection_size).to_a }
27
+
28
+ let(:output) do
29
+ will_paginate(
30
+ collection.paginate(:page => page, :per_page => 1),
31
+ :renderer => MockRenderer
32
+ )
31
33
  end
32
34
 
35
+ let(:html) { Nokogiri::HTML.fragment(output) }
36
+
33
37
  it "returns a string" do
34
- @output.must_be_kind_of String
38
+ output.must_be_kind_of String
35
39
  end
36
40
 
37
41
  it "returns a string containing HTML" do
38
- @html.must_be_kind_of Nokogiri::HTML::DocumentFragment
42
+ html.must_be_kind_of Nokogiri::HTML::DocumentFragment
39
43
  end
40
44
 
41
45
  it "has an outer pagination div" do
42
- @html.at_css('div.pagination').wont_be_nil
46
+ html.at_css('div.pagination').wont_be_nil
43
47
  end
44
48
 
45
49
  it "has an unordered list within the pagination div" do
46
- @html.at_css('div.pagination ul').wont_be_nil
50
+ html.at_css('div.pagination ul').wont_be_nil
47
51
  end
48
52
 
49
53
  it "has an active list item" do
50
- @html.at_css('ul li.active').wont_be_nil
54
+ html.at_css('ul li.active').wont_be_nil
51
55
  end
52
56
 
53
57
  it "has a gap item with class disabled" do
54
- @html.at_css('ul li.disabled').wont_be_nil
58
+ html.at_css('ul li.disabled').wont_be_nil
55
59
  end
56
60
 
57
61
  it "has one item with rel start value" do
58
- @html.css('[rel~=start]').size.must_equal 1
62
+ html.css('[rel~=start]').size.must_equal 1
59
63
  end
60
64
 
61
65
  it "has two items with rel prev value" do
62
- @html.css('[rel~=prev]').size.must_equal 2
66
+ html.css('[rel~=prev]').size.must_equal 2
63
67
  end
64
68
 
65
69
  it "has two items with rel next value" do
66
- @html.css('[rel~=next]').size.must_equal 2
70
+ html.css('[rel~=next]').size.must_equal 2
71
+ end
72
+
73
+ it "has an anchor within each non-active list item" do
74
+ html.css('ul li:not(.active)').each { |li| li.at_css('a').wont_be_nil }
67
75
  end
68
76
 
69
- it "has anchors within each list item" do
70
- @html.css('ul li').each { |li| li.at_css('a').wont_be_nil }
77
+ it "uses a span element for the active page" do
78
+ html.at_css('ul li.active span').wont_be_nil
71
79
  end
72
- end
80
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: will_paginate-bootstrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-25 00:00:00.000000000 Z
12
+ date: 2012-12-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: will_paginate
16
- requirement: &70351248293000 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: 3.0.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70351248293000
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.3
25
30
  description: This gem integrates the Twitter Bootstrap pagination component with the
26
31
  will_paginate pagination gem. Supports Rails and Sinatra.
27
32
  email:
@@ -35,6 +40,7 @@ files:
35
40
  - MIT-LICENSE
36
41
  - README.markdown
37
42
  - Rakefile
43
+ - example/app.rb
38
44
  - lib/bootstrap_pagination/action_view.rb
39
45
  - lib/bootstrap_pagination/bootstrap_renderer.rb
40
46
  - lib/bootstrap_pagination/sinatra.rb
@@ -56,15 +62,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
56
62
  - - ! '>='
57
63
  - !ruby/object:Gem::Version
58
64
  version: '0'
65
+ segments:
66
+ - 0
67
+ hash: -3359177914669589572
59
68
  required_rubygems_version: !ruby/object:Gem::Requirement
60
69
  none: false
61
70
  requirements:
62
71
  - - ! '>='
63
72
  - !ruby/object:Gem::Version
64
73
  version: '0'
74
+ segments:
75
+ - 0
76
+ hash: -3359177914669589572
65
77
  requirements: []
66
78
  rubyforge_project: will_paginate-bootstrap
67
- rubygems_version: 1.8.11
79
+ rubygems_version: 1.8.23
68
80
  signing_key:
69
81
  specification_version: 3
70
82
  summary: Integrates the Twitter Bootstrap pagination component with will_paginate