jm81-paginate 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -90,6 +90,20 @@ There are currently three modules.
90
90
  - Paginate::DM - extended by a class that includes DataMapper::Resource
91
91
  - Paginate::AR - extended by a class that inherits ActiveRecord::Base
92
92
 
93
+ For associated collections with DataMapper, you can use Paginator::ORM directly,
94
+ or (for example):
95
+
96
+ jobs = Person.first.jobs
97
+ jobs.extend(Paginate::DM)
98
+ jobs.paginate(:page => 1)
99
+ # or
100
+ DataMapper::Collection.__send__(:include, Paginate::DM) # perhaps in init.rb
101
+ jobs = Person.first.jobs.paginate(:page => 1)
102
+
103
+ Using the *DataMapper::Collection.\_\_send\_\_(:include, Paginate::DM)* option
104
+ makes the *#paginate* methods to all association collections. The first method
105
+ could be used for ActiveRecord.
106
+
93
107
  ##Paginator Classes
94
108
 
95
109
  Paginator classes do the actual work of paginating and are called by the
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ require 'merb-core'
18
18
  require 'merb-core/tasks/merb'
19
19
 
20
20
  GEM_NAME = "paginate"
21
- GEM_VERSION = "0.1.3"
21
+ GEM_VERSION = "0.1.4"
22
22
  AUTHOR = "Jared Morgan"
23
23
  EMAIL = "jmorgan@morgancreative.net"
24
24
  HOMEPAGE = "http://github.com/jm81/paginate/"
data/TODO CHANGED
@@ -1,2 +1,23 @@
1
1
  TODO:
2
- Add your code to lib/paginate.rb
2
+
3
+ - Rails helpers:
4
+ Probably similar to Helpers::Merb. I just don't use Rails enough right now to
5
+ work through it.
6
+
7
+ - Check for dependencies:
8
+ When, for example, Paginate::DM is extended into a class, verify that dm-core
9
+ and dm-aggregates are loaded. This would give me more timely errors than
10
+ finding out when #paginate is first called.
11
+
12
+ - Generic ORM module:
13
+ If dependencies are checked for, this would allow a way to use Paginators::ORM
14
+ through a module without the dependency check.
15
+
16
+ - Includes for ORM collections:
17
+ For example:
18
+
19
+ DataMapper::Collection.__send__(:include, Paginate::DM)
20
+
21
+ What's the best way to do this?
22
+ Something similar for AR?
23
+ Maybe Paginate::auto_includes which would include such as the above
data/lib/helpers/merb.rb CHANGED
@@ -75,7 +75,7 @@ module Paginate
75
75
  # in the query string to be used in the page link.
76
76
  def page_url(page, path = request.path, q = request.query_string)
77
77
  # Remove any current reference to page in the query string
78
- q.to_s.gsub!(/page=(\d+)(&?)/, '')
78
+ q.to_s.gsub!(/page=(-?[\d]+)(&?)/, '')
79
79
  # Assemble new link
80
80
  link = "#{path}?page=#{page}&#{q}"
81
81
  link = link[0..-2] if link[-1..-1] == '&' # Strip trailing ampersand
@@ -53,5 +53,13 @@ describe Paginate::Helpers::Merb do
53
53
  @object.page_url(5, 'path', 'limit=10&something=text&page=10').should ==
54
54
  'path?page=5&limit=10&something=text'
55
55
  end
56
+
57
+ it 'should remove existing negative page option' do
58
+ @object.page_url(5, 'path', 'limit=10&page=-10&something=text').should ==
59
+ 'path?page=5&limit=10&something=text'
60
+
61
+ @object.page_url(5, 'path', 'page=-5&limit=10&something=text').should ==
62
+ 'path?page=5&limit=10&something=text'
63
+ end
56
64
  end
57
65
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jm81-paginate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared Morgan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-22 00:00:00 -07:00
12
+ date: 2009-06-23 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15