pagers 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0045ecc04a429c56771d9dce706949fc3836c9b5
4
- data.tar.gz: 6fdd2abf723af68ecb4f4fecb88eb8eb6c5b7945
3
+ metadata.gz: 60cb3aa5e6534fa01d610ee97b51a57a608fa1ea
4
+ data.tar.gz: 387fbe739a703c9bbace61aa93e8954b6f5f618a
5
5
  SHA512:
6
- metadata.gz: 92da1eeafdfabaf9a2389e7e49941f13cbd6c53c9a83d1c2be30243a667fdd33ee865685b1f24c4717e2c990abe77a8c5b4fc002321e95d13c121e3099644680
7
- data.tar.gz: 64fd9a84bbc9f6659276bb697ac70f749aafecbf768b0a1eeee73100ce1994c9e1ea34f22c7efe835e36440c655a9d533b2d282f0d64f6f293c000329f292059
6
+ metadata.gz: bd1833f8e500783bdf98ea79b575204cbfda882de16f8eead6aba6c7b2f15d0164a761fc59cf720af0ac4a3f3742afbf59d9be4053911146f3d0b6f237bf76dd
7
+ data.tar.gz: a77c456c35e087e34acfab715cded647c3feedb824dab64496cab3a66687d727edffacee513a551fd47132794fb5c09f78b71403d96fd820b81aa49dff8cf3e9
data/README.rdoc CHANGED
@@ -15,7 +15,7 @@ Then bundle:
15
15
  = Usage
16
16
 
17
17
  Call the page scope:
18
- @collection = Model.page(1, length: 10)
18
+ @collection = Model.page(1, length: 10, padding: 4)
19
19
 
20
20
  And in your views just:
21
21
  <%= paginate @collection %>
@@ -9,12 +9,15 @@ module Pagers
9
9
  subclass.class_eval do
10
10
  if superclass == ::ActiveRecord::Base
11
11
  scope :page, ->(number, options={}) {
12
- length = options[:length] || Rails.application.config.pagers.length
13
- padding = options[:padding] || Rails.application.config.pagers.padding
12
+ length = options[:length] || Rails.application.config.pagers[:length]
13
+ padding = options[:padding] || Rails.application.config.pagers[:padding]
14
14
  current_page = [number.to_i, 1].max
15
- offset_value = (length * (current_page - 1)) + (current_page == 1 ? padding : 0)
16
- limit_value = length - (current_page == 1 ? padding : 0)
15
+ offset_value = (length * (current_page - 1)) + padding
16
+ limit_value = length
17
17
  values = Module.new do
18
+ define_method :padding do
19
+ padding
20
+ end
18
21
  define_method :page_length do
19
22
  length
20
23
  end
@@ -32,7 +32,7 @@ module Pagers
32
32
  r = except(:limit, :offset, :order, :reorder)
33
33
  r = r.except(:includes) unless references_eager_loaded_tables?
34
34
  r = r.count
35
- r.respond_to?(:count) ? r.count : r
35
+ (r.respond_to?(:count) ? r.count : r) - padding
36
36
  end
37
37
  end
38
38
 
@@ -1,5 +1,5 @@
1
1
  module Pagers
2
2
 
3
- VERSION = '3.0.0'
3
+ VERSION = '3.0.1'
4
4
 
5
5
  end
Binary file
@@ -1234,3 +1234,40 @@ Processing by PagesController#index as HTML
1234
1234
  Rendered /Users/Matt/Documents/Museways/Herramientas/Rails/pagers/app/views/pagers/_main.html.erb (0.6ms)
1235
1235
  Rendered pages/index.html.erb within layouts/application (2.1ms)
1236
1236
  Completed 200 OK in 5ms (Views: 4.8ms | ActiveRecord: 0.1ms)
1237
+ Model Load (1.3ms) SELECT "models".* FROM "models" LIMIT 4 OFFSET 0
1238
+ Model Load (0.3ms) SELECT "models".* FROM "models" LIMIT 4 OFFSET 0
1239
+ Model Load (0.4ms) SELECT "models".* FROM "models" LIMIT 4 OFFSET 0
1240
+ Model Load (1.1ms) SELECT "models".* FROM "models" LIMIT 4 OFFSET 0
1241
+ Model Load (1.2ms) SELECT "models".* FROM "models" LIMIT 4 OFFSET 0
1242
+
1243
+ ***** Debugger requested, but was not available (ensure the debugger gem is listed in Gemfile/installed as gem): Start server with --debugger to enable *****
1244
+
1245
+ Model Load (1.3ms) SELECT "models".* FROM "models" LIMIT 4 OFFSET 0
1246
+ Model Load (1.1ms) SELECT "models".* FROM "models" LIMIT 4 OFFSET 0
1247
+ Model Load (1.3ms) SELECT "models".* FROM "models" LIMIT 4 OFFSET 0
1248
+ Model Load (1.1ms) SELECT "models".* FROM "models" LIMIT 4 OFFSET 0
1249
+ Model Load (1.9ms) SELECT "models".* FROM "models" LIMIT 20 OFFSET 0
1250
+
1251
+
1252
+ Started GET "/" for 127.0.0.1 at 2014-05-27 11:28:45 -0300
1253
+ ActiveRecord::SchemaMigration Load (2.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
1254
+ Processing by PagesController#index as HTML
1255
+  (0.1ms) SELECT COUNT(*) FROM "models"
1256
+ Rendered /Users/Matt/Documents/Museways/Herramientas/Rails/pagers/app/views/pagers/_main.html.erb (6.3ms)
1257
+ Rendered pages/index.html.erb within layouts/application (11.5ms)
1258
+ Completed 200 OK in 37ms (Views: 35.3ms | ActiveRecord: 0.4ms)
1259
+
1260
+
1261
+ Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2014-05-27 11:28:45 -0300
1262
+
1263
+
1264
+ Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2014-05-27 11:28:45 -0300
1265
+
1266
+
1267
+ Started GET "/?p=2" for 127.0.0.1 at 2014-05-27 11:28:47 -0300
1268
+ Processing by PagesController#index as HTML
1269
+ Parameters: {"p"=>"2"}
1270
+  (0.1ms) SELECT COUNT(*) FROM "models"
1271
+ Rendered /Users/Matt/Documents/Museways/Herramientas/Rails/pagers/app/views/pagers/_main.html.erb (1.3ms)
1272
+ Rendered pages/index.html.erb within layouts/application (3.1ms)
1273
+ Completed 200 OK in 6ms (Views: 5.8ms | ActiveRecord: 0.1ms)