paginate 1.0.1 → 2.0.0

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.
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -1,84 +1,108 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paginate (1.0.1)
4
+ paginate (2.0.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- abstract (1.0.0)
10
- actionpack (3.0.6)
11
- activemodel (= 3.0.6)
12
- activesupport (= 3.0.6)
13
- builder (~> 2.1.2)
14
- erubis (~> 2.6.6)
15
- i18n (~> 0.5.0)
16
- rack (~> 1.2.1)
17
- rack-mount (~> 0.6.14)
18
- rack-test (~> 0.5.7)
19
- tzinfo (~> 0.3.23)
20
- activemodel (3.0.6)
21
- activesupport (= 3.0.6)
22
- builder (~> 2.1.2)
23
- i18n (~> 0.5.0)
24
- activerecord (3.0.6)
25
- activemodel (= 3.0.6)
26
- activesupport (= 3.0.6)
27
- arel (~> 2.0.2)
28
- tzinfo (~> 0.3.23)
29
- activesupport (3.0.6)
30
- archive-tar-minitar (0.5.2)
31
- arel (2.0.9)
32
- builder (2.1.2)
33
- columnize (0.3.2)
34
- diff-lcs (1.1.2)
35
- erubis (2.6.6)
36
- abstract (>= 1.0.0)
37
- i18n (0.5.0)
38
- linecache19 (0.5.12)
39
- ruby_core_source (>= 0.1.4)
40
- nokogiri (1.4.4)
41
- notifier (0.1.3)
42
- rack (1.2.2)
43
- rack-mount (0.6.14)
44
- rack (>= 1.0.0)
45
- rack-test (0.5.7)
9
+ actionpack (3.2.11)
10
+ activemodel (= 3.2.11)
11
+ activesupport (= 3.2.11)
12
+ builder (~> 3.0.0)
13
+ erubis (~> 2.7.0)
14
+ journey (~> 1.0.4)
15
+ rack (~> 1.4.0)
16
+ rack-cache (~> 1.2)
17
+ rack-test (~> 0.6.1)
18
+ sprockets (~> 2.2.1)
19
+ activemodel (3.2.11)
20
+ activesupport (= 3.2.11)
21
+ builder (~> 3.0.0)
22
+ activerecord (3.2.11)
23
+ activemodel (= 3.2.11)
24
+ activesupport (= 3.2.11)
25
+ arel (~> 3.0.2)
26
+ tzinfo (~> 0.3.29)
27
+ activesupport (3.2.11)
28
+ i18n (~> 0.6)
29
+ multi_json (~> 1.0)
30
+ arel (3.0.2)
31
+ awesome_print (1.1.0)
32
+ binding_of_caller (0.6.8)
33
+ builder (3.0.4)
34
+ coderay (1.0.8)
35
+ diff-lcs (1.1.3)
36
+ erubis (2.7.0)
37
+ hike (1.2.1)
38
+ i18n (0.6.1)
39
+ interception (0.3)
40
+ journey (1.0.4)
41
+ method_source (0.8.1)
42
+ multi_json (1.5.0)
43
+ nokogiri (1.5.6)
44
+ notifier (0.4.1)
45
+ pry (0.9.11.4)
46
+ coderay (~> 1.0.5)
47
+ method_source (~> 0.8)
48
+ slop (~> 3.4)
49
+ pry-exception_explorer (0.2.3)
50
+ pry-stack_explorer (>= 0.4.6)
51
+ pry-meta (0.0.3)
52
+ awesome_print
53
+ pry
54
+ pry-exception_explorer
55
+ pry-nav
56
+ pry-remote
57
+ pry-rescue
58
+ pry-stack_explorer
59
+ pry-nav (0.2.3)
60
+ pry (~> 0.9.10)
61
+ pry-remote (0.1.6)
62
+ pry (~> 0.9)
63
+ slop (~> 3.0)
64
+ pry-rescue (0.16)
65
+ interception (>= 0.3)
66
+ pry
67
+ pry-stack_explorer (0.4.7)
68
+ binding_of_caller (~> 0.6.8)
69
+ rack (1.4.4)
70
+ rack-cache (1.2)
71
+ rack (>= 0.4)
72
+ rack-test (0.6.2)
46
73
  rack (>= 1.0)
47
- rspec (2.4.0)
48
- rspec-core (~> 2.4.0)
49
- rspec-expectations (~> 2.4.0)
50
- rspec-mocks (~> 2.4.0)
51
- rspec-core (2.4.0)
52
- rspec-expectations (2.4.0)
53
- diff-lcs (~> 1.1.2)
54
- rspec-mocks (2.4.0)
55
- ruby-debug-base19 (0.11.25)
56
- columnize (>= 0.3.1)
57
- linecache19 (>= 0.5.11)
58
- ruby_core_source (>= 0.1.4)
59
- ruby-debug19 (0.11.6)
60
- columnize (>= 0.3.1)
61
- linecache19 (>= 0.5.11)
62
- ruby-debug-base19 (>= 0.11.19)
63
- ruby_core_source (0.1.5)
64
- archive-tar-minitar (>= 0.5.2)
65
- sqlite3 (1.3.3)
74
+ rspec (2.12.0)
75
+ rspec-core (~> 2.12.0)
76
+ rspec-expectations (~> 2.12.0)
77
+ rspec-mocks (~> 2.12.0)
78
+ rspec-core (2.12.2)
79
+ rspec-expectations (2.12.1)
80
+ diff-lcs (~> 1.1.3)
81
+ rspec-mocks (2.12.1)
82
+ slop (3.4.3)
83
+ sprockets (2.2.2)
84
+ hike (~> 1.2)
85
+ multi_json (~> 1.0)
86
+ rack (~> 1.0)
87
+ tilt (~> 1.1, != 1.3.0)
88
+ sqlite3 (1.3.7)
66
89
  sqlite3-ruby (1.3.3)
67
90
  sqlite3 (>= 1.3.3)
68
- test_notifier (0.3.6)
91
+ test_notifier (1.0.1)
69
92
  notifier
70
- tzinfo (0.3.26)
93
+ tilt (1.3.3)
94
+ tzinfo (0.3.35)
71
95
 
72
96
  PLATFORMS
73
97
  ruby
74
98
 
75
99
  DEPENDENCIES
76
- actionpack (~> 3.0.0)
77
- activerecord (~> 3.0.0)
78
- activesupport (~> 3.0.0)
100
+ actionpack
101
+ activerecord
102
+ activesupport
79
103
  nokogiri
80
104
  paginate!
81
- rspec (~> 2.4.0)
82
- ruby-debug19
105
+ pry-meta
106
+ rspec
83
107
  sqlite3-ruby
84
108
  test_notifier
@@ -6,7 +6,7 @@ Works only with <b>Rails 3+</b>.
6
6
 
7
7
  == Install
8
8
 
9
- sudo gem install paginate
9
+ gem install paginate
10
10
 
11
11
  == Usage
12
12
 
@@ -40,7 +40,13 @@ More examples:
40
40
  <%= paginate @things, "/some/path" %>
41
41
  <%= paginate @things, :param_name => :p %>
42
42
 
43
- To iterate the collection, you must use a helper called <tt>iterate</tt>. This is required cause we're always considering SIZE + 1, so if you use the regular +each+ you end up rendering one additional item.
43
+ To render the collection, you must use the <tt>render</tt> helper, providing the <tt>:paginate => true</tt> option. This is required cause we're always considering SIZE + 1, so if you use the regular +each+ or don't pass this option, you end up rendering one additional item.
44
+
45
+ <%= render @things, :paginate => true %>
46
+ <%= render @things, :paginate => true, :size => 5 %>
47
+ <%= render "thing", :collection => @things, :paginate => true, :size => 5 %>
48
+
49
+ If you want to iterate and do something special, you can use the +iterate+ helper, which also accepts the +:size+ option.
44
50
 
45
51
  <% iterate @things do |thing| %>
46
52
  <% end %>
@@ -11,11 +11,6 @@ module Paginate
11
11
  def self.configure(&block)
12
12
  yield Config
13
13
  end
14
-
15
- def self.setup(&block)
16
- warn "Paginate.setup is deprecated; use Paginate.configure instead."
17
- configure(&block)
18
- end
19
14
  end
20
15
 
21
16
  Paginate.configure do |config|
@@ -32,6 +32,30 @@ module Paginate
32
32
  Paginate::Renderer.new(options).render
33
33
  end
34
34
 
35
+ # Override the original render method, so we can strip the additional
36
+ # item from the collection, without changing your workflow with the
37
+ # iterate "always felt dirty" method.
38
+ #
39
+ # To render a paginated set, just pass the <tt>:paginate => true</tt> option.
40
+ # You can also provide a custom size with <tt>:size => number</tt>
41
+ #
42
+ # <%= render @posts, :paginate => true %>
43
+ # <%= render @pots, :paginate => true, :size => 20 %>
44
+ # <%= render "post", :collection => @posts, :paginate => true, :size => 20 %>
45
+ #
46
+ def render(*args, &block)
47
+ options = args.extract_options!
48
+ paginated = options.delete(:paginate)
49
+ size = options.delete(:size) { Paginate::Config.size }
50
+
51
+ return super(*[*args, options], &block) unless paginated
52
+
53
+ collection = options.delete(:collection) { args.shift }
54
+ collection = collection[0, size]
55
+
56
+ super(collection, *[*args, options], &block)
57
+ end
58
+
35
59
  # In order to iterate the correct items you have to skip the last collection's item.
36
60
  # We added this helper to automatically skip the last item only if there's a next page.
37
61
  #
@@ -59,12 +83,13 @@ module Paginate
59
83
  #
60
84
  def iterate(collection, options = {}, &block)
61
85
  options.reverse_merge!(:size => Paginate::Config.size)
86
+ yield_index = block.arity == 2
62
87
 
63
88
  collection[0, options[:size]].each_with_index do |item, i|
64
- if block.arity == 1
65
- yield item
66
- else
89
+ if yield_index
67
90
  yield item, i
91
+ else
92
+ yield item
68
93
  end
69
94
  end
70
95
  end
@@ -1,8 +1,8 @@
1
1
  module Paginate
2
2
  module Version
3
- MAJOR = 1
3
+ MAJOR = 2
4
4
  MINOR = 0
5
- PATCH = 1
5
+ PATCH = 0
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
8
8
  end
@@ -20,9 +20,9 @@ Gem::Specification.new do |s|
20
20
  s.add_development_dependency "nokogiri"
21
21
  s.add_development_dependency "test_notifier"
22
22
  s.add_development_dependency "sqlite3-ruby"
23
- s.add_development_dependency "activesupport", "~> 3.0.0"
24
- s.add_development_dependency "activerecord", "~> 3.0.0"
25
- s.add_development_dependency "actionpack", "~> 3.0.0"
26
- s.add_development_dependency "rspec", "~> 2.4.0"
27
- s.add_development_dependency "ruby-debug19"
23
+ s.add_development_dependency "activesupport"
24
+ s.add_development_dependency "activerecord"
25
+ s.add_development_dependency "actionpack"
26
+ s.add_development_dependency "rspec"
27
+ s.add_development_dependency "pry-meta"
28
28
  end
@@ -9,7 +9,10 @@ describe "ActionView support" do
9
9
  @controller = ThingsController.new
10
10
  @controller.params = @params
11
11
 
12
- @view = ActionView::Base.new
12
+ @view = ActionView::Base.new(
13
+ File.expand_path("../../support/views", __FILE__)
14
+ )
15
+ @view.lookup_context.prefixes << "application"
13
16
  @view.controller = @controller
14
17
  @view.extend(Paginate::Helper)
15
18
  @view.stub :request => @request
@@ -25,97 +28,105 @@ describe "ActionView support" do
25
28
  I18n.locale = :en
26
29
  end
27
30
 
28
- it "should display pagination list" do
31
+ it "displays pagination list" do
29
32
  @request.fullpath = "/some/path?page=1"
30
33
  html = render(:default, [])
31
34
 
32
- html.css("ul.paginate").count.should == 1
33
- html.css("ul.paginate > li").count.should == 3
35
+ expect(html.css("ul.paginate").count).to eql(1)
36
+ expect(html.css("ul.paginate > li").count).to eql(3)
34
37
  end
35
38
 
36
- it "should add .disabled class when have no items" do
39
+ it "adds .disabled class when have no items" do
37
40
  @request.fullpath = "/some/path"
38
41
  html = render(:default, [])
39
42
 
40
- html.css("ul.paginate.disabled").first.should_not be_nil
43
+ expect(html.css("ul.paginate.disabled").first).to be
41
44
  end
42
45
 
43
- it "should display next page link" do
46
+ it "displays next page link" do
44
47
  @request.fullpath = "/some/path?page=1"
45
48
  html = render(:default, Array.new(11))
46
49
  link = html.css("li.next-page > a").first
47
50
 
48
- link.should_not be_nil
49
- link["href"].should == "/some/path?page=2"
50
- link.text.should == "Next page"
51
+ expect(link).to be
52
+ expect(link["href"]).to eql("/some/path?page=2")
53
+ expect(link.text).to eql("Next page")
51
54
  end
52
55
 
53
- it "should display next page link using proc as url" do
56
+ it "displays next page link using proc as url" do
54
57
  @request.fullpath = "/some/path?page=1"
55
58
  html = render(:block_as_url, Array.new(11))
56
59
  link = html.css("li.next-page > a").first
57
60
 
58
- link.should_not be_nil
59
- link["href"].should == "/some/path/2"
60
- link.text.should == "Next page"
61
+ expect(link).to be
62
+ expect(link["href"]).to eql("/some/path/2")
63
+ expect(link.text).to eql("Next page")
61
64
  end
62
65
 
63
- it "should display previous page link" do
66
+ it "displays previous page link" do
64
67
  @params[:page] = 2
65
68
  @request.fullpath = "/some/path?page=2"
66
69
  html = render(:default, Array.new(11))
67
70
  link = html.css("li.previous-page > a").first
68
71
 
69
- link.should_not be_nil
70
- link["href"].should == "/some/path?page=1"
71
- link.text.should == "Previous page"
72
+ expect(link).to be
73
+ expect(link["href"]).to eql("/some/path?page=1")
74
+ expect(link.text).to eql("Previous page")
72
75
  end
73
76
 
74
- it "should disable element when have no next page" do
77
+ it "disables element when have no next page" do
75
78
  @request.fullpath = "/some/path?page=1"
76
79
  html = render(:default, Array.new(10))
77
80
  link = html.css("li.next-page > a").first
78
81
  span = html.css("li.next-page.disabled > span").first
79
82
 
80
- link.should be_nil
81
- span.should_not be_nil
82
- span.text.should == "Next page"
83
+ expect(link).not_to be
84
+ expect(span).to be
85
+ expect(span.text).to eql("Next page")
83
86
  end
84
87
 
85
- it "should disable element when have no previous page" do
88
+ it "disables element when have no previous page" do
86
89
  @request.fullpath = "/some/path?page=1"
87
90
  html = render(:default, Array.new(10))
88
91
  link = html.css("li.previous-page > a").first
89
92
  span = html.css("li.previous-page.disabled > span").first
90
93
 
91
- link.should be_nil
92
- span.should_not be_nil
93
- span.text.should == "Previous page"
94
+ expect(link).not_to be
95
+ expect(span).to be
96
+ expect(span.text).to eql("Previous page")
94
97
  end
95
98
 
96
- it "should display current page" do
99
+ it "displays current page" do
97
100
  @params[:page] = 10
98
101
  @request.fullpath = "/some/path?page=10"
99
102
  html = render(:default, [])
100
103
  span = html.css("li.page > span").first
101
104
 
102
- span.should_not be_nil
103
- span.text.should == "Page 10"
105
+ expect(span).to be
106
+ expect(span.text).to eql("Page 10")
104
107
  end
105
108
 
106
- it "should translate strings" do
109
+ it "overrides render method" do
110
+ items = [*1..11].map do |i|
111
+ OpenStruct.new(:to_partial_path => "number", :value => i)
112
+ end
113
+
114
+ html = render(:render, items)
115
+ end
116
+
117
+ it "translates strings" do
107
118
  I18n.locale = :"pt-BR"
108
119
 
109
120
  @params[:page] = 10
110
121
  @request.fullpath = "/some/path?page=10"
111
122
  html = render(:default, Array.new(11))
112
123
 
113
- html.css("li.page > span").text.should == "Página 10"
114
- html.css("li.next-page > a").text.should == "Próxima página"
115
- html.css("li.previous-page > a").text.should == "Página anterior"
124
+ expect(html.css("li.page > span").text).to eql("Página 10")
125
+ expect(html.css("li.next-page > a").text).to eql("Próxima página")
126
+ expect(html.css("li.previous-page > a").text).to eql("Página anterior")
116
127
  end
117
128
 
118
- it "should skip the last item while iterating" do
129
+ it "skips the last item while iterating" do
119
130
  values = []
120
131
  items = Array.new(11) {|i| "User#{i}" }
121
132
 
@@ -123,10 +134,10 @@ describe "ActionView support" do
123
134
  values << item
124
135
  end
125
136
 
126
- values.should == items[0, 10]
137
+ expect(values).to eql(items[0, 10])
127
138
  end
128
139
 
129
- it "should iterate all items when have less records than size" do
140
+ it "iterates all items when have less records than size" do
130
141
  values = []
131
142
  items = Array.new(8) {|i| "User#{i}" }
132
143
 
@@ -134,10 +145,10 @@ describe "ActionView support" do
134
145
  values << item
135
146
  end
136
147
 
137
- values.should == items[0, 8]
148
+ expect(values).to eql(items[0, 8])
138
149
  end
139
150
 
140
- it "should yield iteration counter" do
151
+ it "yields iteration counter" do
141
152
  values = []
142
153
  indices = []
143
154
  items = Array.new(11) {|i| "User#{i}" }
@@ -147,13 +158,14 @@ describe "ActionView support" do
147
158
  indices << i
148
159
  end
149
160
 
150
- values.should == items[0, 10]
151
- indices.should == (0...10).to_a
161
+ expect(values).to eql(items[0, 10])
162
+ expect(indices).to eql([*0...10])
152
163
  end
153
164
 
154
165
  private
155
166
  def render(view_name, items)
156
- Nokogiri @view.render(:inline => load_view(view_name), :locals => {:items => items})
167
+ view_info = Struct.new(:to_partial_path).new("#{view_name}")
168
+ Nokogiri @view.render(view_info, :items => items)
157
169
  end
158
170
 
159
171
  def load_view(name)
@@ -1,18 +1,24 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Thing do
4
- let!(:things) { Array.new(15) {|i| Thing.create!(:name => "Thing #{i}") } }
4
+ let!(:things) { Array.new(15) {|i| Thing.create!(:name => "THING") } }
5
5
  before { Paginate::Config.size = 10 }
6
6
 
7
- specify { Thing.should respond_to(:paginate) }
7
+ it { expect(Thing).to respond_to(:paginate) }
8
8
 
9
- it "should use default options" do
10
- Thing.paginate.all.should == Thing.all(:limit => 11)
11
- Thing.paginate(:page => 2).all.should == Thing.all(:limit => 11, :offset => 10)
9
+ it "uses default options" do
10
+ items = Thing.limit(11).all
11
+ expect(Thing.paginate.all).to eql(items)
12
+
13
+ items = Thing.limit(11).offset(10).all
14
+ expect(Thing.paginate(:page => 2).all).to eql(items)
12
15
  end
13
16
 
14
- it "should use custom options" do
15
- Thing.paginate(:size => 5).should == Thing.all(:limit => 6)
16
- Thing.paginate(:size => 5, :page => 2).should == Thing.all(:limit => 6, :offset => 5)
17
+ it "uses custom options" do
18
+ items = Thing.limit(6).all
19
+ expect(Thing.paginate(:size => 5).all).to eql(items)
20
+
21
+ items = Thing.limit(6).offset(5).all
22
+ expect(Thing.paginate(:size => 5, :page => 2).all).to eql(items)
17
23
  end
18
24
  end
@@ -1,59 +1,61 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Paginate::Base do
4
- it "should return page from integer" do
5
- Paginate::Base.new(12).page.should == 12
4
+ it "returns page from integer" do
5
+ expect(Paginate::Base.new(12).page).to eql(12)
6
6
  end
7
7
 
8
- it "should return page from string" do
9
- Paginate::Base.new("12").page.should == 12
8
+ it "returns page from string" do
9
+ expect(Paginate::Base.new("12").page).to eql(12)
10
10
  end
11
11
 
12
- it "should default to page 1" do
13
- Paginate::Base.new.page == 1
12
+ it "defaults to page 1" do
13
+ expect(Paginate::Base.new.page).to eql(1)
14
14
  end
15
15
 
16
- it "should return page from options" do
17
- Paginate::Base.new(:page => 12).page == 12
16
+ it "returns page from options" do
17
+ expect(Paginate::Base.new(:page => 12).page).to eql(12)
18
18
  end
19
19
 
20
- it "should return limit from configuration" do
20
+ it "returns limit from configuration" do
21
21
  Paginate::Config.size = 25
22
- Paginate::Base.new.limit.should == 26
22
+ expect(Paginate::Base.new.limit).to eql(26)
23
23
  end
24
24
 
25
- it "should return limit from options" do
25
+ it "returns limit from options" do
26
26
  Paginate::Config.size = 25
27
- Paginate::Base.new(:size => 13).limit.should == 14
27
+ expect(Paginate::Base.new(:size => 13).limit).to eql(14)
28
28
  end
29
29
 
30
- it "should return default limit" do
30
+ it "returns default limit" do
31
31
  Paginate::Config.size = nil
32
- Paginate::Base.new.limit.should == 11
32
+ expect(Paginate::Base.new.limit).to eql(11)
33
33
  end
34
34
 
35
- it "should return offset from configuration" do
35
+ it "returns offset from configuration" do
36
36
  Paginate::Config.size = 15
37
- Paginate::Base.new(:page => 2).offset.should == 15
37
+ expect(Paginate::Base.new(:page => 2).offset).to eql(15)
38
38
  end
39
39
 
40
- it "should return offset from options" do
41
- Paginate::Base.new(:page => 2, :size => 5).offset.should == 5
40
+ it "returns offset from options" do
41
+ expect(Paginate::Base.new(:page => 2, :size => 5).offset).to eql(5)
42
42
  end
43
43
 
44
- it "should return finder options" do
44
+ it "returns finder options" do
45
45
  actual = Paginate::Base.new(:page => 3, :size => 5).to_options
46
46
  expected = {:limit => 6, :offset => 10}
47
47
 
48
- actual.should == expected
48
+ expect(actual).to eql(expected)
49
49
  end
50
50
 
51
51
  specify {
52
- Paginate::Base.new(:page => 1, :size => 5, :collection => Array.new(6)).should have_next_page
52
+ Paginate::Base.new(:page => 1, :size => 5, :collection => Array.new(6))
53
+ .should have_next_page
53
54
  }
54
55
 
55
56
  specify {
56
- Paginate::Base.new(:page => 1, :size => 5, :collection => Array.new(5)).should_not have_next_page
57
+ Paginate::Base.new(:page => 1, :size => 5, :collection => Array.new(5))
58
+ .should_not have_next_page
57
59
  }
58
60
 
59
61
  specify {
@@ -7,13 +7,8 @@ describe Paginate::Config do
7
7
  config.size = 50
8
8
  end
9
9
 
10
- Paginate::Config.param_name.should == :p
11
- Paginate::Config.size.should == 50
12
- end
13
-
14
- it "deprecates Paginate.setup method" do
15
- Paginate.should_receive(:warn).once
16
- Paginate.setup {}
10
+ expect(Paginate::Config.param_name).to eql(:p)
11
+ expect(Paginate::Config.size).to eql(50)
17
12
  end
18
13
 
19
14
  it "returns configuration as hash" do
@@ -23,6 +18,6 @@ describe Paginate::Config do
23
18
  end
24
19
 
25
20
  options = {:param_name => :p, :size => 25}
26
- Paginate::Config.to_hash.should == options
21
+ expect(Paginate::Config.to_hash).to eql(options)
27
22
  end
28
23
  end
@@ -18,38 +18,38 @@ describe Paginate::Renderer do
18
18
 
19
19
  specify { @renderer.render.should be_html_safe }
20
20
 
21
- it "should parse simple url" do
21
+ it "parses simple url" do
22
22
  @renderer.options[:url] = "/some/path"
23
- @renderer.url_for(1).should == "/some/path?page=1"
23
+ expect(@renderer.url_for(1)).to eql("/some/path?page=1")
24
24
  end
25
25
 
26
- it "should parse url with page param" do
26
+ it "parses url with page param" do
27
27
  @renderer.options[:url] = "/some/path?page=3"
28
- @renderer.url_for(1).should == "/some/path?page=1"
28
+ expect(@renderer.url_for(1)).to eql("/some/path?page=1")
29
29
  end
30
30
 
31
- it "should parse url with page as first param" do
31
+ it "parses url with page as first param" do
32
32
  @renderer.options[:url] = "/some/path?page=3&a=1&b=2&c=3"
33
- @renderer.url_for(1).should == "/some/path?a=1&amp;b=2&amp;c=3&amp;page=1"
33
+ expect(@renderer.url_for(1)).to eql("/some/path?a=1&amp;b=2&amp;c=3&amp;page=1")
34
34
  end
35
35
 
36
- it "should parse url with page as last param" do
36
+ it "parses url with page as last param" do
37
37
  @renderer.options[:url] = "/some/path?a=1&b=2&c=3&page=3"
38
- @renderer.url_for(1).should == "/some/path?a=1&amp;b=2&amp;c=3&amp;page=1"
38
+ expect(@renderer.url_for(1)).to eql("/some/path?a=1&amp;b=2&amp;c=3&amp;page=1")
39
39
  end
40
40
 
41
- it "should parse url with page param in the middle" do
41
+ it "parses url with page param in the middle" do
42
42
  @renderer.options[:url] = "/some/path?a=1&b=2&page=3&c=3"
43
- @renderer.url_for(1).should == "/some/path?a=1&amp;b=2&amp;c=3&amp;page=1"
43
+ expect(@renderer.url_for(1)).to eql("/some/path?a=1&amp;b=2&amp;c=3&amp;page=1")
44
44
  end
45
45
 
46
- it "should parse url with page as arbitrary string" do
46
+ it "parses url with page as arbitrary string" do
47
47
  @renderer.options[:url] = "/some/path?a=1&b=2&c=3&page=abc"
48
- @renderer.url_for(1).should == "/some/path?a=1&amp;b=2&amp;c=3&amp;page=1"
48
+ expect(@renderer.url_for(1)).to eql("/some/path?a=1&amp;b=2&amp;c=3&amp;page=1")
49
49
  end
50
50
 
51
- it "should escape url from blocks" do
51
+ it "escapes url from blocks" do
52
52
  @renderer.options[:url] = proc {|page| "/some/path/#{page}?a=1&b=2"}
53
- @renderer.url_for(1).should == "/some/path/1?a=1&amp;b=2"
53
+ expect(@renderer.url_for(1)).to eql("/some/path/1?a=1&amp;b=2")
54
54
  end
55
55
  end
@@ -12,7 +12,8 @@ require "active_support/all"
12
12
  require "action_view"
13
13
  require "action_controller"
14
14
 
15
- ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
15
+ ActiveRecord::Base
16
+ .establish_connection(:adapter => "sqlite3", :database => ":memory:")
16
17
  Rails = OpenStruct.new(:version => ActiveRecord::VERSION::STRING)
17
18
 
18
19
  require "paginate"
@@ -0,0 +1 @@
1
+ <p class="number"><%= number %></p>
@@ -0,0 +1 @@
1
+ <%= render items, :paginate => true, :partial => "number" %>
metadata CHANGED
@@ -1,116 +1,154 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: paginate
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
4
5
  prerelease:
5
- version: 1.0.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Nando Vieira
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-04-17 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2013-01-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: nokogiri
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
24
22
  type: :development
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: test_notifier
28
23
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
30
25
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: test_notifier
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
35
38
  type: :development
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: sqlite3-ruby
39
39
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: "0"
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: sqlite3-ruby
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
46
54
  type: :development
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: activesupport
50
55
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
52
57
  none: false
53
- requirements:
54
- - - ~>
55
- - !ruby/object:Gem::Version
56
- version: 3.0.0
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: activesupport
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
57
70
  type: :development
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
- name: activerecord
61
71
  prerelease: false
62
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: activerecord
80
+ requirement: !ruby/object:Gem::Requirement
63
81
  none: false
64
- requirements:
65
- - - ~>
66
- - !ruby/object:Gem::Version
67
- version: 3.0.0
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
68
86
  type: :development
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
71
- name: actionpack
72
87
  prerelease: false
73
- requirement: &id006 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: actionpack
96
+ requirement: !ruby/object:Gem::Requirement
74
97
  none: false
75
- requirements:
76
- - - ~>
77
- - !ruby/object:Gem::Version
78
- version: 3.0.0
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
79
102
  type: :development
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
82
- name: rspec
83
103
  prerelease: false
84
- requirement: &id007 !ruby/object:Gem::Requirement
104
+ version_requirements: !ruby/object:Gem::Requirement
85
105
  none: false
86
- requirements:
87
- - - ~>
88
- - !ruby/object:Gem::Version
89
- version: 2.4.0
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rspec
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
90
118
  type: :development
91
- version_requirements: *id007
92
- - !ruby/object:Gem::Dependency
93
- name: ruby-debug19
94
119
  prerelease: false
95
- requirement: &id008 !ruby/object:Gem::Requirement
120
+ version_requirements: !ruby/object:Gem::Requirement
96
121
  none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- version: "0"
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: pry-meta
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
101
134
  type: :development
102
- version_requirements: *id008
103
- description: Paginate collections using SIZE+1 to determine if there is a next page. Includes ActiveRecord and ActionView support.
104
- email:
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ description: Paginate collections using SIZE+1 to determine if there is a next page.
143
+ Includes ActiveRecord and ActionView support.
144
+ email:
105
145
  - fnando.vieira@gmail.com
106
146
  executables: []
107
-
108
147
  extensions: []
109
-
110
148
  extra_rdoc_files: []
111
-
112
- files:
149
+ files:
113
150
  - .gitignore
151
+ - .rspec
114
152
  - Gemfile
115
153
  - Gemfile.lock
116
154
  - README.rdoc
@@ -135,46 +173,33 @@ files:
135
173
  - spec/support/matchers.rb
136
174
  - spec/support/model.rb
137
175
  - spec/support/translations.yml
138
- - spec/support/views/block_as_url.erb
139
- - spec/support/views/default.erb
176
+ - spec/support/views/application/_block_as_url.erb
177
+ - spec/support/views/application/_default.erb
178
+ - spec/support/views/application/_number.erb
179
+ - spec/support/views/application/_render.erb
140
180
  homepage: http://rubygems.org/gems/paginate
141
181
  licenses: []
142
-
143
182
  post_install_message:
144
183
  rdoc_options: []
145
-
146
- require_paths:
184
+ require_paths:
147
185
  - lib
148
- required_ruby_version: !ruby/object:Gem::Requirement
186
+ required_ruby_version: !ruby/object:Gem::Requirement
149
187
  none: false
150
- requirements:
151
- - - ">="
152
- - !ruby/object:Gem::Version
153
- version: "0"
154
- required_rubygems_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ! '>='
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
193
  none: false
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: "0"
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
160
198
  requirements: []
161
-
162
199
  rubyforge_project:
163
- rubygems_version: 1.7.2
200
+ rubygems_version: 1.8.24
164
201
  signing_key:
165
202
  specification_version: 3
166
- summary: Paginate collections using SIZE+1 to determine if there is a next page. Includes ActiveRecord and ActionView support.
167
- test_files:
168
- - spec/paginate/action_view_spec.rb
169
- - spec/paginate/activerecord_spec.rb
170
- - spec/paginate/base_spec.rb
171
- - spec/paginate/config_spec.rb
172
- - spec/paginate/renderer_spec.rb
173
- - spec/schema.rb
174
- - spec/spec_helper.rb
175
- - spec/support/controller.rb
176
- - spec/support/matchers.rb
177
- - spec/support/model.rb
178
- - spec/support/translations.yml
179
- - spec/support/views/block_as_url.erb
180
- - spec/support/views/default.erb
203
+ summary: Paginate collections using SIZE+1 to determine if there is a next page. Includes
204
+ ActiveRecord and ActionView support.
205
+ test_files: []