paginate 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c122d332a59eb59bc6a94ce31e7a25624d393576
4
+ data.tar.gz: 46386bd9e2a7da62795e2e8e8356db989eeb5e70
5
+ SHA512:
6
+ metadata.gz: 56666d66b1e21753568e9649271b7e17a744c53ccb197968419622edbf790999ba19da9ac1c842b263d5608f314b371ea27ba4722e3311bc570e347efe84a9dd
7
+ data.tar.gz: d5553b0e3e5ce9dcad6d17accdcab1760748bcb85ac507606f13109e7a461dbad2d1e85b46d76d2da15391728f4695a65ee53c71d38b052e05dda8286a022fe0
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+
6
+ gemfile:
7
+ - gemfiles/rails3.gemfile
8
+ - Gemfile
9
+
10
+ script: "bundle exec rspec"
11
+
12
+ notifications:
13
+ email:
14
+ - fnando.vieira@gmail.com
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source :rubygems
1
+ source "http://rubygems.org"
2
2
  gemspec
@@ -1,108 +1,127 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paginate (2.0.0)
4
+ paginate (3.0.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- actionpack (3.2.11)
10
- activemodel (= 3.2.11)
11
- activesupport (= 3.2.11)
12
- builder (~> 3.0.0)
9
+ actionmailer (4.0.0)
10
+ actionpack (= 4.0.0)
11
+ mail (~> 2.5.3)
12
+ actionpack (4.0.0)
13
+ activesupport (= 4.0.0)
14
+ builder (~> 3.1.0)
13
15
  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)
16
+ rack (~> 1.5.2)
17
+ rack-test (~> 0.6.2)
18
+ activemodel (4.0.0)
19
+ activesupport (= 4.0.0)
20
+ builder (~> 3.1.0)
21
+ activerecord (4.0.0)
22
+ activemodel (= 4.0.0)
23
+ activerecord-deprecated_finders (~> 1.0.2)
24
+ activesupport (= 4.0.0)
25
+ arel (~> 4.0.0)
26
+ activerecord-deprecated_finders (1.0.3)
27
+ activesupport (4.0.0)
28
+ i18n (~> 0.6, >= 0.6.4)
29
+ minitest (~> 4.2)
30
+ multi_json (~> 1.3)
31
+ thread_safe (~> 0.1)
32
+ tzinfo (~> 0.3.37)
33
+ arel (4.0.0)
34
+ atomic (1.1.10)
31
35
  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
+ builder (3.1.4)
37
+ coderay (1.0.9)
38
+ diff-lcs (1.2.4)
36
39
  erubis (2.7.0)
37
- hike (1.2.1)
38
- i18n (0.6.1)
39
- interception (0.3)
40
- journey (1.0.4)
40
+ hike (1.2.3)
41
+ i18n (0.6.4)
42
+ mail (2.5.4)
43
+ mime-types (~> 1.16)
44
+ treetop (~> 1.4.8)
41
45
  method_source (0.8.1)
42
- multi_json (1.5.0)
43
- nokogiri (1.5.6)
46
+ mime-types (1.23)
47
+ mini_portile (0.5.0)
48
+ minitest (4.7.5)
49
+ multi_json (1.7.7)
50
+ nokogiri (1.6.0)
51
+ mini_portile (~> 0.5.0)
44
52
  notifier (0.4.1)
45
- pry (0.9.11.4)
53
+ polyglot (0.3.3)
54
+ pry (0.9.12.2)
46
55
  coderay (~> 1.0.5)
47
56
  method_source (~> 0.8)
48
57
  slop (~> 3.4)
49
- pry-exception_explorer (0.2.3)
50
- pry-stack_explorer (>= 0.4.6)
51
- pry-meta (0.0.3)
58
+ pry-meta (0.0.5)
52
59
  awesome_print
53
60
  pry
54
- pry-exception_explorer
55
61
  pry-nav
56
62
  pry-remote
57
- pry-rescue
58
- pry-stack_explorer
59
63
  pry-nav (0.2.3)
60
64
  pry (~> 0.9.10)
61
- pry-remote (0.1.6)
65
+ pry-remote (0.1.7)
62
66
  pry (~> 0.9)
63
67
  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)
68
+ rack (1.5.2)
72
69
  rack-test (0.6.2)
73
70
  rack (>= 1.0)
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)
71
+ rails (4.0.0)
72
+ actionmailer (= 4.0.0)
73
+ actionpack (= 4.0.0)
74
+ activerecord (= 4.0.0)
75
+ activesupport (= 4.0.0)
76
+ bundler (>= 1.3.0, < 2.0)
77
+ railties (= 4.0.0)
78
+ sprockets-rails (~> 2.0.0)
79
+ railties (4.0.0)
80
+ actionpack (= 4.0.0)
81
+ activesupport (= 4.0.0)
82
+ rake (>= 0.8.7)
83
+ thor (>= 0.18.1, < 2.0)
84
+ rake (10.1.0)
85
+ rspec (2.14.0.rc1)
86
+ rspec-core (= 2.14.0.rc1)
87
+ rspec-expectations (= 2.14.0.rc1)
88
+ rspec-mocks (= 2.14.0.rc1)
89
+ rspec-core (2.14.0.rc1)
90
+ rspec-expectations (2.14.0.rc1)
91
+ diff-lcs (>= 1.1.3, < 2.0)
92
+ rspec-mocks (2.14.0.rc1)
93
+ slop (3.4.5)
94
+ sprockets (2.10.0)
84
95
  hike (~> 1.2)
85
96
  multi_json (~> 1.0)
86
97
  rack (~> 1.0)
87
98
  tilt (~> 1.1, != 1.3.0)
99
+ sprockets-rails (2.0.0)
100
+ actionpack (>= 3.0)
101
+ activesupport (>= 3.0)
102
+ sprockets (~> 2.8)
88
103
  sqlite3 (1.3.7)
89
104
  sqlite3-ruby (1.3.3)
90
105
  sqlite3 (>= 1.3.3)
91
106
  test_notifier (1.0.1)
92
107
  notifier
93
- tilt (1.3.3)
94
- tzinfo (0.3.35)
108
+ thor (0.18.1)
109
+ thread_safe (0.1.0)
110
+ atomic
111
+ tilt (1.4.1)
112
+ treetop (1.4.14)
113
+ polyglot
114
+ polyglot (>= 0.3.1)
115
+ tzinfo (0.3.37)
95
116
 
96
117
  PLATFORMS
97
118
  ruby
98
119
 
99
120
  DEPENDENCIES
100
- actionpack
101
- activerecord
102
- activesupport
103
121
  nokogiri
104
122
  paginate!
105
123
  pry-meta
106
- rspec
124
+ rails (~> 4.0.0)
125
+ rspec (~> 2.14.0.rc1)
107
126
  sqlite3-ruby
108
127
  test_notifier
@@ -0,0 +1,146 @@
1
+ # Paginate
2
+
3
+ [![Build Status](https://travis-ci.org/fnando/paginate.png)](https://travis-ci.org/fnando/paginate)
4
+ [![CodeClimate](https://codeclimate.com/github/fnando/paginate.png)](https://codeclimate.com/github/fnando/paginate/)
5
+
6
+ Paginate collections using SIZE+1 to determine if there is a next page. Includes ActiveRecord and ActionView support.
7
+
8
+ Works only with **Rails 3+**.
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ gem install paginate
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ You can use Paginate with or without ActiveRecord. Let's try a simple array pagination. Imagine that you have something like this in your controller.
19
+
20
+ ```ruby
21
+ @things = Array.new(11) {|i| "Item #{i}"}
22
+ ```
23
+
24
+ Then on your view:
25
+
26
+ ```erb
27
+ <%= paginate @things %>
28
+ ```
29
+
30
+ That's it! This is all you have to do! In this case we're using the default page size (which is 10).
31
+ The url used on page links is taken from the current requested uri.
32
+
33
+ You can set default values globally:
34
+
35
+ ```ruby
36
+ Paginate.configure do |config|
37
+ config.size = 20
38
+ config.param_name = :p
39
+ end
40
+ ```
41
+
42
+ More examples:
43
+
44
+ ```ruby
45
+ Post.paginate(1) # page 1 from Post model
46
+ Post.paginate(page: 1) # page 1 from Post model
47
+ Post.paginate(page: 1, size: 5) # page 1 from Post model with custom size
48
+ @user.things.paginate(:page => params[:page]) # paginate association
49
+ ```
50
+
51
+ ```erb
52
+ <%= paginate @things, size: 5 %>
53
+ <%= paginate @things, url: -> page { things_path(:page => page) } %>
54
+ <%= paginate @things, "/some/path" %>
55
+ <%= paginate @things, param_name: :p %>
56
+ ```
57
+
58
+ 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.
59
+
60
+ ```erb
61
+ <%= render @things, paginate: true %>
62
+ <%= render @things, paginate: true, size: 5 %>
63
+ <%= render "thing", collection: @things, paginate: true, size: 5 %>
64
+ ```
65
+
66
+ ## I18n support
67
+
68
+ If you want to translate links, you have implement the following scopes:
69
+
70
+ ```yaml
71
+ en:
72
+ paginate:
73
+ next: "Older"
74
+ previous: "Newer"
75
+ page: "Page {{page}}"
76
+ more: "Load more"
77
+ ```
78
+
79
+ ## Styling
80
+
81
+ If you want something like Twitter Search use this CSS:
82
+
83
+ ```css
84
+ .paginate { overflow: hidden; }
85
+ .paginate li { float: left; }
86
+ .paginate li.previous-page:after { content: "«"; padding: 0 5px; }
87
+ .paginate li.next-page:before { content: "»"; padding: 0 5px; }
88
+ .paginate .disabled { display: none; }
89
+ ```
90
+
91
+ You can create new renderers. Paginate comes with two renderers.
92
+
93
+ * `Paginate::Renderer::List`: is the default renderer. Uses a `<ul>` with previous and next page. Also displays the current page.
94
+ * `Paginate::Renderer::More`: define a "Load more" page. This is useful for renderer pagination through AJAX.
95
+
96
+ To create a new renderer, just inherit from `Paginate::Renderer::Base` and define the `render` method. Here's the `Paginate::Renderer::More` code:
97
+
98
+ ```ruby
99
+ module Paginate
100
+ module Renderer
101
+ class More < Base
102
+ def more_label
103
+ I18n.t("paginate.more")
104
+ end
105
+
106
+ def render
107
+ return unless processor.next_page?
108
+
109
+ <<-HTML.html_safe
110
+ <p class="paginate">
111
+ <a class="more" href="#{next_url}" title="#{more_label}">#{more_label}</a>
112
+ </p>
113
+ HTML
114
+ end
115
+ end
116
+ end
117
+ end
118
+ ```
119
+
120
+ You can specify the default renderer by setting the `Pagination::Config.renderer` option.
121
+
122
+ ```ruby
123
+ Paginate.configure do |config|
124
+ config.renderer = Paginate::Renderer::More
125
+ end
126
+ ```
127
+
128
+ You can also specify while calling the `paginate` helper.
129
+
130
+ ```erb
131
+ <%= paginate @items, renderer: Paginate::Renderer::More %>
132
+ ```
133
+
134
+ ## License
135
+
136
+ (The MIT License)
137
+
138
+ Copyright © 2010:
139
+
140
+ * Nando Vieira • <http://simplesideias.com.br>
141
+
142
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
143
+
144
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
145
+
146
+ THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,13 +1,14 @@
1
1
  require "bundler"
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
- require "rake/testtask"
5
- Rake::TestTask.new do |t|
6
- t.libs += %w[ test lib ]
7
- t.test_files = FileList["test/**/*_test.rb"]
8
- t.verbose = true
9
- t.ruby_opts = %w[ -rubygems ]
10
- end
11
-
12
4
  require "rspec/core/rake_task"
13
5
  RSpec::Core::RakeTask.new
6
+
7
+ desc "Run specs against all gemfiles"
8
+ task "spec:all" do
9
+ %w[Gemfile gemfiles/rails3.gemfile].each do |gemfile|
10
+ ENV["BUNDLE_GEMFILE"] = gemfile
11
+ Rake::Task["spec"].reenable
12
+ Rake::Task["spec"].invoke
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+ gemspec path: ".."
3
+
4
+ gem "rails", "~> 3.2.13"
@@ -0,0 +1,132 @@
1
+ PATH
2
+ remote: /mnt/hgfs/!%Projects/github/paginate
3
+ specs:
4
+ paginate (3.0.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ actionmailer (3.2.13)
10
+ actionpack (= 3.2.13)
11
+ mail (~> 2.5.3)
12
+ actionpack (3.2.13)
13
+ activemodel (= 3.2.13)
14
+ activesupport (= 3.2.13)
15
+ builder (~> 3.0.0)
16
+ erubis (~> 2.7.0)
17
+ journey (~> 1.0.4)
18
+ rack (~> 1.4.5)
19
+ rack-cache (~> 1.2)
20
+ rack-test (~> 0.6.1)
21
+ sprockets (~> 2.2.1)
22
+ activemodel (3.2.13)
23
+ activesupport (= 3.2.13)
24
+ builder (~> 3.0.0)
25
+ activerecord (3.2.13)
26
+ activemodel (= 3.2.13)
27
+ activesupport (= 3.2.13)
28
+ arel (~> 3.0.2)
29
+ tzinfo (~> 0.3.29)
30
+ activeresource (3.2.13)
31
+ activemodel (= 3.2.13)
32
+ activesupport (= 3.2.13)
33
+ activesupport (3.2.13)
34
+ i18n (= 0.6.1)
35
+ multi_json (~> 1.0)
36
+ arel (3.0.2)
37
+ awesome_print (1.1.0)
38
+ builder (3.0.4)
39
+ coderay (1.0.9)
40
+ diff-lcs (1.2.4)
41
+ erubis (2.7.0)
42
+ hike (1.2.3)
43
+ i18n (0.6.1)
44
+ journey (1.0.4)
45
+ json (1.8.0)
46
+ mail (2.5.4)
47
+ mime-types (~> 1.16)
48
+ treetop (~> 1.4.8)
49
+ method_source (0.8.1)
50
+ mime-types (1.23)
51
+ mini_portile (0.5.0)
52
+ multi_json (1.7.7)
53
+ nokogiri (1.6.0)
54
+ mini_portile (~> 0.5.0)
55
+ notifier (0.4.1)
56
+ polyglot (0.3.3)
57
+ pry (0.9.12.2)
58
+ coderay (~> 1.0.5)
59
+ method_source (~> 0.8)
60
+ slop (~> 3.4)
61
+ pry-meta (0.0.5)
62
+ awesome_print
63
+ pry
64
+ pry-nav
65
+ pry-remote
66
+ pry-nav (0.2.3)
67
+ pry (~> 0.9.10)
68
+ pry-remote (0.1.7)
69
+ pry (~> 0.9)
70
+ slop (~> 3.0)
71
+ rack (1.4.5)
72
+ rack-cache (1.2)
73
+ rack (>= 0.4)
74
+ rack-ssl (1.3.3)
75
+ rack
76
+ rack-test (0.6.2)
77
+ rack (>= 1.0)
78
+ rails (3.2.13)
79
+ actionmailer (= 3.2.13)
80
+ actionpack (= 3.2.13)
81
+ activerecord (= 3.2.13)
82
+ activeresource (= 3.2.13)
83
+ activesupport (= 3.2.13)
84
+ bundler (~> 1.0)
85
+ railties (= 3.2.13)
86
+ railties (3.2.13)
87
+ actionpack (= 3.2.13)
88
+ activesupport (= 3.2.13)
89
+ rack-ssl (~> 1.3.2)
90
+ rake (>= 0.8.7)
91
+ rdoc (~> 3.4)
92
+ thor (>= 0.14.6, < 2.0)
93
+ rake (10.1.0)
94
+ rdoc (3.12.2)
95
+ json (~> 1.4)
96
+ rspec (2.14.0.rc1)
97
+ rspec-core (= 2.14.0.rc1)
98
+ rspec-expectations (= 2.14.0.rc1)
99
+ rspec-mocks (= 2.14.0.rc1)
100
+ rspec-core (2.14.0.rc1)
101
+ rspec-expectations (2.14.0.rc1)
102
+ diff-lcs (>= 1.1.3, < 2.0)
103
+ rspec-mocks (2.14.0.rc1)
104
+ slop (3.4.5)
105
+ sprockets (2.2.2)
106
+ hike (~> 1.2)
107
+ multi_json (~> 1.0)
108
+ rack (~> 1.0)
109
+ tilt (~> 1.1, != 1.3.0)
110
+ sqlite3 (1.3.7)
111
+ sqlite3-ruby (1.3.3)
112
+ sqlite3 (>= 1.3.3)
113
+ test_notifier (1.0.1)
114
+ notifier
115
+ thor (0.18.1)
116
+ tilt (1.4.1)
117
+ treetop (1.4.14)
118
+ polyglot
119
+ polyglot (>= 0.3.1)
120
+ tzinfo (0.3.37)
121
+
122
+ PLATFORMS
123
+ ruby
124
+
125
+ DEPENDENCIES
126
+ nokogiri
127
+ paginate!
128
+ pry-meta
129
+ rails (~> 3.2.13)
130
+ rspec (~> 2.14.0.rc1)
131
+ sqlite3-ruby
132
+ test_notifier