Project

page_up

0.0
No commit activity in last 3 years
No release in over 3 years
Simple paginator
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 13.0
~> 3.9.0
 Project Readme

PageUp

Build Status Code Climate

PageUp is a simple pagination gem, the idea being to use composition and decoration of objects (rather than mixing into ActiveRecord) to divy up a collection for pagination. This allows use with data sources other than ActiveRecord.

Usage

To create a paginated collection use the PageUp[] macro.

page_up_pages = PageUp[ collection, page_number, number_per_page ]

In addition to delegating all the original collection methods back to the underling object, a page up collection allows:

Access to the total number of pages with pages

page_up_pages.pages => 3

Access to the supplied page number with page (defaults to 1)

page_up_pages.page => 2

Access to the supplied per page count with per_page (defaults to 25)

page_up_pages.per_page => 25

And provides a range indicating the current section of pages, this is intended for integration with output views to indicate nearby page bookmarks and as such returns the previous two and next two pages, but is bounded so that at the start or end of a collection always returns 5... e.g:

# page 2
page_up_pages.current_slice => 1..5 

# page 7
page_up_pages.current_slice => 5..9 

# page n-2
page_up_pages.current_slice => n-5..n 

ToDo

Extract helpers for integration with Rails and ORM libraries.

Installation

Add this line to your application's Gemfile:

gem 'page_up'

And then execute:

$ bundle

Or install it yourself as:

$ gem install page_up

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request