makevoid-dm-pagination 0.3.3

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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 YOUR NAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,36 @@
1
+ = dm-pagination
2
+
3
+ A plugin for the Merb framework that provides pagination for DataMapper.
4
+
5
+ === usage:
6
+
7
+ In your controller:
8
+
9
+ @posts = Post.paginate(:page => params[:page])
10
+
11
+
12
+ In your view(s), to render the pagination helper:
13
+
14
+ <%= paginate @posts %>
15
+
16
+
17
+ === parameters:
18
+
19
+ :order = same paramaters as the :order in a normal DM call ( http://datamapper.org/doku.php?id=docs:finders&s[]=order#order )
20
+
21
+ :per_page = Number of items per page
22
+
23
+ :page = What page number
24
+
25
+
26
+ === configure it:
27
+
28
+ defaults:
29
+
30
+ Merb::Plugins.config[:dm_pagination] = {
31
+ :prev_label => '&laquo; Prec.',
32
+ :next_label => 'Succ. &raquo;',
33
+ :truncate => '...',
34
+ :paginator => :trio, # :duo is also present
35
+ :page_param => :p # param's name in the url
36
+ }
@@ -0,0 +1,85 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+
4
+ require 'merb-core'
5
+ require 'merb-core/tasks/merb'
6
+
7
+ GEM_NAME = "dm-pagination"
8
+ GEM_VERSION = "0.3.2"
9
+ AUTHOR = "Genki Takiuchi"
10
+ EMAIL = "genki@s21g.com"
11
+ HOMEPAGE = "http://blog.s21g.com/genki"
12
+ SUMMARY = "Merb plugin that provides pagination for DataMapper"
13
+ RUBYFORGE_PROJECT = "asakusarb"
14
+
15
+ spec = Gem::Specification.new do |s|
16
+ s.rubyforge_project = RUBYFORGE_PROJECT
17
+ s.name = GEM_NAME
18
+ s.version = GEM_VERSION
19
+ s.platform = Gem::Platform::RUBY
20
+ s.has_rdoc = true
21
+ s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
22
+ s.summary = SUMMARY
23
+ s.description = s.summary
24
+ s.author = AUTHOR
25
+ s.email = EMAIL
26
+ s.homepage = HOMEPAGE
27
+ s.add_dependency('merb', '>= 1.0.7.1')
28
+ s.require_path = 'lib'
29
+ s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
30
+ end
31
+
32
+ Rake::GemPackageTask.new(spec) do |pkg|
33
+ pkg.need_tar = true
34
+ pkg.gem_spec = spec
35
+ end
36
+
37
+ desc "install the plugin as a gem"
38
+ task :install do
39
+ Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
40
+ end
41
+
42
+ desc "Uninstall the gem"
43
+ task :uninstall do
44
+ Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
45
+ end
46
+
47
+ desc "Create a gemspec file"
48
+ task :gemspec do
49
+ File.open("#{GEM_NAME}.gemspec", "w") do |file|
50
+ file.puts spec.to_ruby
51
+ end
52
+ end
53
+
54
+ desc "Run spec"
55
+ task :spec do
56
+ sh "spec spec --color"
57
+ end
58
+
59
+ desc 'Package and upload the release to rubyforge.'
60
+ task :release => :package do |t|
61
+ require 'rubyforge'
62
+ v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
63
+ abort "Versions don't match #{v} vs #{GEM_VERSION}" unless v == GEM_VERSION
64
+ pkg = "pkg/#{GEM_NAME}-#{GEM_VERSION}"
65
+
66
+ require 'rubyforge'
67
+ rf = RubyForge.new.configure
68
+ puts "Logging in"
69
+ rf.login
70
+
71
+ c = rf.userconfig
72
+ # c["release_notes"] = description if description
73
+ # c["release_changes"] = changes if changes
74
+ c["preformatted"] = true
75
+
76
+ files = [
77
+ "#{pkg}.tgz",
78
+ "#{pkg}.gem"
79
+ ].compact
80
+
81
+ puts "Releasing #{GEM_NAME} v. #{GEM_VERSION}"
82
+ rf.add_release RUBYFORGE_PROJECT, GEM_NAME, GEM_VERSION, *files
83
+ end
84
+
85
+ task :default => :spec
data/TODO ADDED
@@ -0,0 +1,5 @@
1
+ TODO:
2
+ Fix LICENSE with your name
3
+ Fix Rakefile with your name and contact info
4
+ Add your code to lib/dm-pagination.rb
5
+ Add your Merb rake tasks to lib/dm-pagination/merbtasks.rb
@@ -0,0 +1,43 @@
1
+ # make sure we're running inside Merb
2
+ if defined?(Merb::Plugins)
3
+
4
+ # Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
5
+ Merb::Plugins.config[:dm_pagination] = {
6
+ :prev_label => '&laquo; Prev',
7
+ :next_label => 'Next &raquo;',
8
+ :truncate => '...',
9
+ :paginator => :trio,
10
+ :page_param => :page
11
+ }
12
+
13
+ Merb::BootLoader.before_app_loads do
14
+ # require code that must be loaded before the application
15
+ require 'dm-pagination/paginatable'
16
+ module DataMapper
17
+ module Resource
18
+ module ClassMethods
19
+ include DmPagination::Paginatable
20
+ end
21
+ end
22
+
23
+ class Collection
24
+ extend DmPagination::Paginatable
25
+ end
26
+ end
27
+
28
+ require 'dm-pagination/pagination_builder'
29
+ module Merb
30
+ module GlobalHelpers
31
+ def paginate(pagination, *args, &block)
32
+ DmPagination::PaginationBuilder.new(self, pagination, *args, &block)
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ Merb::BootLoader.after_app_loads do
39
+ # code that can be required after the application loads
40
+ end
41
+
42
+ Merb::Plugins.add_rakefiles "dm-pagination/merbtasks"
43
+ end
@@ -0,0 +1,6 @@
1
+ namespace :dm_pagination do
2
+ desc "Do something for dm-pagination"
3
+ task :default do
4
+ puts "dm-pagination doesn't do anything"
5
+ end
6
+ end
@@ -0,0 +1,12 @@
1
+ require 'dm-pagination/paginator'
2
+
3
+ module DmPagination
4
+ module Paginatable
5
+ def paginate(options = {})
6
+ paginator_type = options.delete(:paginator) ||
7
+ Merb::Plugins.config[:dm_pagination][:paginator]
8
+ paginator = Paginator.const_get(paginator_type.to_s.camel_case)
9
+ paginator.new(all, options)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,90 @@
1
+ module DmPagination
2
+ class PaginationBuilder
3
+ def initialize(context, pagination, *args, &block)
4
+ @context = context
5
+ @pagination = pagination
6
+ @block = block
7
+ @options = args.last.kind_of?(Hash) ? args.pop : {}
8
+ @options[:page] ||= Merb::Plugins.config[:dm_pagination][:page_param]
9
+ @args = args.blank? ? [:prev, :pages, :next] : args
10
+ end
11
+
12
+ def to_s(*args)
13
+ args = @args if args.blank?
14
+ items = args.map{|i| respond_to?("link_to_#{i}") ?
15
+ send("link_to_#{i}") : []}.flatten
16
+ @context.tag(:div, items.join("\n"), :class => "pagination")
17
+ end
18
+
19
+ def link_to_pages
20
+ @pagination.pages.map{|page| link_to_page(page)}
21
+ end
22
+
23
+ def link_to_prev
24
+ if @pagination.page > 1
25
+ @context.link_to prev_label,
26
+ url(@options[:page] => @pagination.page - 1),
27
+ :class => :prev, :rel => "prev"
28
+ else
29
+ span.call(prev_label, :prev)
30
+ end
31
+ end
32
+
33
+ def link_to_next
34
+ if @pagination.page < @pagination.num_pages
35
+ @context.link_to next_label,
36
+ url(@options[:page] => @pagination.page + 1),
37
+ :class => :next, :rel => "next"
38
+ else
39
+ span.call(next_label, :next)
40
+ end
41
+ end
42
+
43
+ def link_to_page(page)
44
+ if page.nil?
45
+ span.call truncate, @options[:style]
46
+ elsif page == @pagination.page
47
+ span.call page, [@options[:style], 'current'].compact.join(' ')
48
+ else
49
+ span.call link(page), @options[:style]
50
+ end
51
+ end
52
+
53
+ private
54
+ def span
55
+ proc do |*args|
56
+ @context.tag(:span, args[0].to_s,
57
+ :class => [args[1], "disabled"].compact.join(' '))
58
+ end
59
+ end
60
+
61
+ def link(page, *args)
62
+ if @block
63
+ @block.call(page, *args)
64
+ else
65
+ @context.link_to(page, url(@options[:page] => page))
66
+ end
67
+ end
68
+
69
+ def truncate
70
+ @options[:truncate] || Merb::Plugins.config[:dm_pagination][:truncate]
71
+ end
72
+
73
+ def prev_label
74
+ @options[:prev] || Merb::Plugins.config[:dm_pagination][:prev_label]
75
+ end
76
+
77
+ def next_label
78
+ @options[:next] || Merb::Plugins.config[:dm_pagination][:next_label]
79
+ end
80
+
81
+ def url(params)
82
+ @context.params.delete(:action)
83
+ @context.params.delete(:controller)
84
+ route = @options[:url].nil? ? @context.class.name.downcase : @options[:url]
85
+ @context.url(route.to_sym, @context.params.merge(params))
86
+ end
87
+
88
+
89
+ end
90
+ end
@@ -0,0 +1,38 @@
1
+ module DmPagination
2
+ module Paginator
3
+ class Base
4
+ attr_reader :page, :num_pages
5
+
6
+ def initialize(collection, options)
7
+ @proxy_collection = collection
8
+ order = options[:order]
9
+
10
+ @page = (options[:page] || 1).to_i
11
+ @per_page = (options[:per_page] || 10).to_i
12
+ @num_pages = (@proxy_collection.count + @per_page - 1) / @per_page
13
+ @offset = (@page - 1)*@per_page
14
+
15
+ @collection = collection.all(:offset => @offset, :limit => @per_page)
16
+ @collection = @collection.all(:order => order) if order
17
+ end
18
+
19
+ def count
20
+ [0, [@proxy_collection.count - @offset, @per_page].min].max
21
+ end
22
+
23
+ def respond_to?(*args, &block)
24
+ super || @collection.send(:respond_to?, *args, &block)
25
+ end
26
+
27
+ def method_missing(method, *args, &block)
28
+ @collection.send(method, *args, &block)
29
+ end
30
+
31
+ def to_json
32
+ @collection.to_json
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ Dir[File.join(File.dirname(__FILE__), %w(paginator *))].each{|i| require(i)}
@@ -0,0 +1,23 @@
1
+ module DmPagination
2
+ module Paginator
3
+ class Solo < Base
4
+ def pages(window = 10, left = 5, right = 4)
5
+ num_of_pages = num_pages
6
+ return [] if num_of_pages <= 1
7
+ right_page = page + right
8
+ if right_page > num_of_pages
9
+ right_page = num_of_pages
10
+ elsif right_page < window
11
+ right_page = window
12
+ end
13
+ left_page = if num_of_pages - right_page < right
14
+ page - (window - (right_page - page + 1))
15
+ else
16
+ page - left
17
+ end
18
+ left_page = 1 if left_page <= 0
19
+ (left_page..right_page)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,13 @@
1
+ module DmPagination
2
+ module Paginator
3
+ class Trio < Base
4
+ def pages(window = 5, left = 2, right = 2)
5
+ return [] if num_pages <= 1
6
+ (1..num_pages).inject([]) do |result, i|
7
+ i <= left || (num_pages - i) < right || (i-page).abs < window ?
8
+ result << i : (result.last.nil? ? result : result << nil)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,186 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+ DataMapper.setup(:default, "sqlite3::memory:")
3
+
4
+ Post.auto_migrate!
5
+
6
+ describe "dm-pagination" do
7
+ describe "paginatable" do
8
+ it "should extend DataMapper::Resource" do
9
+ test = Post.new
10
+ test.should_not be_nil
11
+ Post.should be_respond_to(:paginate)
12
+ Post.all.should be_respond_to(:paginate)
13
+ end
14
+
15
+ it "should return Pagination object" do
16
+ Post.paginate.should be_kind_of(DmPagination::Paginator::Base)
17
+ Post.all.paginate.should be_kind_of(DmPagination::Paginator::Base)
18
+ end
19
+
20
+ it "should respond to model's method" do
21
+ Post.paginate.should be_respond_to(:to_atom)
22
+ end
23
+ end
24
+
25
+ describe "pagination" do
26
+ before :all do
27
+ Post.all.destroy!
28
+ 101.times{|i| Post.create(:index => i)}
29
+ end
30
+
31
+ it "should be specified on 101 test posts" do
32
+ Post.count.should == 101
33
+ end
34
+
35
+ it "should have 10 pages" do
36
+ Post.paginate.num_pages.should == 11
37
+ Post.all.paginate.num_pages.should == 11
38
+ end
39
+
40
+ it "should be able to calculate num pages on scope" do
41
+ Post.all(:index.gt => 50).count.should == 50
42
+ Post.all(:index.gt => 50).paginate.num_pages.should == 5
43
+ Post.all(:index.gt => 49).paginate.num_pages.should == 6
44
+ end
45
+
46
+ it "should act as Collection" do
47
+ Post.paginate(:page => 8).count.should == 10
48
+ Post.paginate(:page => 11).count.should == 1
49
+ Post.paginate(:page => 12).count.should == 0
50
+ Post.paginate(:page => 5, :per_page => 6).count.should == 6
51
+ end
52
+
53
+ it "should handle :order parametetr" do
54
+ Post.paginate(:page => 1, :order => [:id.desc]).first.id.should == 101
55
+ end
56
+ end
57
+
58
+ describe "pagination builder" do
59
+ include Merb::Helpers::Tag
60
+
61
+ before :all do
62
+ Post.all.destroy!
63
+ 101.times{|i| Post.create(:index => i)}
64
+ end
65
+
66
+ it "should be tested on 101 posts" do
67
+ Post.count.should == 101
68
+ end
69
+
70
+ it "should have rendered with pagination" do
71
+ response = request "/pagination_builder/simple"
72
+ response.should be_successful
73
+ response.should have_selector("div.pagination")
74
+ response.should have_selector("ul")
75
+ response.should have_selector("li")
76
+ response.should have_selector("a[rel=next]")
77
+ end
78
+
79
+ it "should have rendered with pagination at page 2" do
80
+ response = request "/pagination_builder/simple", :params => {:page => 2}
81
+ response.should be_successful
82
+ response.should have_selector("a.prev[rel=prev]")
83
+ response.should have_selector("a.next[rel=next]")
84
+ response.body.scan(/Prev|Next/).should == %w(Prev Next)
85
+ url = "/pagination_builder/simple?page=3"
86
+ response.should have_xpath("//a[@href='#{url}']")
87
+ end
88
+
89
+ it "should be able to control links" do
90
+ response = request "/pagination_builder/variant"
91
+ response.should be_successful
92
+ response.body.scan(/Prev|Next/).should == %w(Next Prev)
93
+ response.should have_selector("a.next[rel=next]")
94
+ response.should_not have_selector("a.prev[rel=prev]")
95
+ response.should have_selector("span.prev")
96
+ response.should have_selector("span.number")
97
+ response.should_not have_selector("span.prev.number")
98
+ url = "/pagination_builder/variant?foo=2"
99
+ response.should have_xpath("//a[@href='#{url}']")
100
+ end
101
+
102
+ describe "solo paginator" do
103
+ before :all do
104
+ Merb::Plugins.config[:dm_pagination][:paginator] = :solo
105
+ end
106
+
107
+ after :all do
108
+ Merb::Plugins.config[:dm_pagination][:paginator] = :trio
109
+ end
110
+
111
+ it "should have rendered with pagination(1, 3, 4, 5, 6, 7, 8, 9, 10) at page 2" do
112
+ response = request "/pagination_builder/simple", :params => {:page => 2}
113
+ (1..10).reject{|p| p == 2}.each do |page|
114
+ url = "/pagination_builder/simple?page=#{page}"
115
+ response.should have_xpath("//a[@href='#{url}']")
116
+ end
117
+ [2, 11].each do |page|
118
+ url = "/pagination_builder/simple?page=#{page}"
119
+ response.should_not have_xpath("//a[@href='#{url}']")
120
+ end
121
+ end
122
+
123
+ it "should have rendered with pagination(1, 2, 3, 4, 6, 7, 8, 9, 10) at page 5" do
124
+ response = request "/pagination_builder/simple", :params => {:page => 5}
125
+ (1..10).reject{|p| p == 5}.each do |page|
126
+ url = "/pagination_builder/simple?page=#{page}"
127
+ response.should have_xpath("//a[@href='#{url}']")
128
+ end
129
+ [5, 11].each do |page|
130
+ url = "/pagination_builder/simple?page=#{page}"
131
+ response.should_not have_xpath("//a[@href='#{url}']")
132
+ end
133
+ end
134
+
135
+ it "should have rendered with pagination(2, 3, 4, 5, 6, 8, 9, 10, 11) at page 7" do
136
+ response = request "/pagination_builder/simple", :params => {:page => 7}
137
+ (2..11).reject{|p| p == 7}.each do |page|
138
+ url = "/pagination_builder/simple?page=#{page}"
139
+ response.should have_xpath("//a[@href='#{url}']")
140
+ end
141
+ [1, 7].each do |page|
142
+ url = "/pagination_builder/simple?page=#{page}"
143
+ response.should_not have_xpath("//a[@href='#{url}']")
144
+ end
145
+ end
146
+
147
+ it "should have rendered with pagination(2, 3, 4, 5, 6, 7, 8, 9, 11) at page 10" do
148
+ response = request "/pagination_builder/simple", :params => {:page => 10}
149
+ (2..11).reject{|p| p == 10}.each do |page|
150
+ url = "/pagination_builder/simple?page=#{page}"
151
+ response.should have_xpath("//a[@href='#{url}']")
152
+ end
153
+ [1, 10].each do |page|
154
+ url = "/pagination_builder/simple?page=#{page}"
155
+ response.should_not have_xpath("//a[@href='#{url}']")
156
+ end
157
+ end
158
+
159
+ it "should have rendered with pagination(2, 3, 4, 5, 6, 7, 8, 9, 10) at page 11" do
160
+ response = request "/pagination_builder/simple", :params => {:page => 11}
161
+ (2..10).each do |page|
162
+ url = "/pagination_builder/simple?page=#{page}"
163
+ response.should have_xpath("//a[@href='#{url}']")
164
+ end
165
+ [1, 11].each do |page|
166
+ url = "/pagination_builder/simple?page=#{page}"
167
+ response.should_not have_xpath("//a[@href='#{url}']")
168
+ end
169
+ end
170
+ end
171
+
172
+ it "should have rendered with pagination 'pagination_builder?page=2'" do
173
+ response = request "/pagination_builder"
174
+ url = "/pagination_builder?page=2"
175
+ response.should have_xpath("//a[@href='#{url}']")
176
+ end
177
+ end
178
+
179
+ describe "#to_json" do
180
+ it "returns the json of the collection" do
181
+ pagination = Post.paginate(:page => 1)
182
+
183
+ pagination.to_json.should == pagination.instance_variable_get(:@collection).to_json
184
+ end
185
+ end
186
+ end
@@ -0,0 +1,16 @@
1
+ class PaginationBuilder < Merb::Controller
2
+ def simple
3
+ @posts = Post.paginate(params)
4
+ render
5
+ end
6
+
7
+ def variant
8
+ @posts = Post.paginate(params)
9
+ render
10
+ end
11
+
12
+ def index
13
+ @posts = Post.paginate(params)
14
+ render
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ class Post
2
+ include DataMapper::Resource
3
+
4
+ property :id, Serial
5
+ property :index, Integer
6
+
7
+ def self.to_atom
8
+ "atom"
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
3
+ <head>
4
+ <title>Fresh Merb App</title>
5
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6
+ <link rel="stylesheet" href="/stylesheets/master.css" type="text/css" media="screen" charset="utf-8"/>
7
+ </head>
8
+ <body>
9
+ <%= catch_content :for_layout %>
10
+ </body>
11
+ </html>
@@ -0,0 +1,7 @@
1
+ <ul>
2
+ <% @posts.each do |post| %>
3
+ <li><%= post.index %></li>
4
+ <% end %>
5
+ </ul>
6
+
7
+ <%= paginate @posts %>
@@ -0,0 +1,7 @@
1
+ <ul>
2
+ <% @posts.each do |post| %>
3
+ <li><%= post.index %></li>
4
+ <% end %>
5
+ </ul>
6
+
7
+ <%= paginate @posts %>
@@ -0,0 +1 @@
1
+ <%= paginate @posts, :pages, :next, :prev, :style => 'number', :page => :foo %>
@@ -0,0 +1,13 @@
1
+ Merb::Router.prepare do |r|
2
+ # RESTful routes
3
+ # r.resources :posts
4
+
5
+ # This is the default route for /:controller/:action/:id
6
+ # This is fine for most cases. If you're heavily using resource-based
7
+ # routes, you may want to comment/remove this line to prevent
8
+ # clients from calling your create or destroy actions with a GET
9
+ r.default_routes
10
+
11
+ # Change this for your home page to be available at /
12
+ # r.match('/').to(:controller => 'whatever', :action =>'index')
13
+ end
@@ -0,0 +1,42 @@
1
+ $:.push File.join(File.dirname(__FILE__), '..', 'lib')
2
+ require 'rubygems'
3
+ require 'spec'
4
+ require 'merb-core'
5
+ require 'merb-helpers'
6
+ require 'merb-assets'
7
+ require 'dm-core'
8
+ require 'dm-pagination'
9
+ require 'dm-pagination/paginatable'
10
+ require 'dm-pagination/pagination_builder'
11
+ require 'dm-aggregates'
12
+
13
+ default_options = {
14
+ :environment => 'test',
15
+ :adapter => 'runner',
16
+ :merb_root => File.dirname(__FILE__) / 'fixture',
17
+ :log_file => File.dirname(__FILE__) / '..' / 'log' / "merb_test.log"
18
+ }
19
+ options = default_options.merge($START_OPTIONS || {})
20
+ DataMapper::Model.append_extensions DmPagination::Paginatable
21
+ module Merb
22
+ module GlobalHelpers
23
+ def paginate(pagination, *args, &block)
24
+ DmPagination::PaginationBuilder.new(self, pagination, *args, &block)
25
+ end
26
+ end
27
+ end
28
+
29
+ Merb.disable(:initfile)
30
+ Merb.start_environment(options)
31
+
32
+ Spec::Runner.configure do |config|
33
+ config.include Merb::Test::RequestHelper
34
+ config.include Webrat::Matchers
35
+ config.include Webrat::HaveTagMatcher
36
+
37
+ def with_level(level)
38
+ Merb.logger = Merb::Logger.new(StringIO.new, level)
39
+ yield
40
+ Merb.logger
41
+ end
42
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: makevoid-dm-pagination
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.3
5
+ platform: ruby
6
+ authors:
7
+ - Genki Takiuchi
8
+ - makevoid
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-03-31 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: merb
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 1.0.7.1
25
+ version:
26
+ description: Merb plugin that provides pagination for DataMapper
27
+ email: genki@s21g.com
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - README
34
+ - LICENSE
35
+ - TODO
36
+ files:
37
+ - LICENSE
38
+ - README
39
+ - Rakefile
40
+ - TODO
41
+ - lib/dm-pagination
42
+ - lib/dm-pagination/merbtasks.rb
43
+ - lib/dm-pagination/paginatable.rb
44
+ - lib/dm-pagination/pagination_builder.rb
45
+ - lib/dm-pagination/paginator
46
+ - lib/dm-pagination/paginator/solo.rb
47
+ - lib/dm-pagination/paginator/trio.rb
48
+ - lib/dm-pagination/paginator.rb
49
+ - lib/dm-pagination.rb
50
+ - spec/dm-pagination_spec.rb
51
+ - spec/fixture
52
+ - spec/fixture/app
53
+ - spec/fixture/app/controllers
54
+ - spec/fixture/app/controllers/pagination_builder.rb
55
+ - spec/fixture/app/models
56
+ - spec/fixture/app/models/post.rb
57
+ - spec/fixture/app/views
58
+ - spec/fixture/app/views/layout
59
+ - spec/fixture/app/views/layout/application.html.erb
60
+ - spec/fixture/app/views/pagination_builder
61
+ - spec/fixture/app/views/pagination_builder/index.html.erb
62
+ - spec/fixture/app/views/pagination_builder/simple.html.erb
63
+ - spec/fixture/app/views/pagination_builder/variant.html.erb
64
+ - spec/fixture/config
65
+ - spec/fixture/config/router.rb
66
+ - spec/spec_helper.rb
67
+ has_rdoc: true
68
+ homepage: http://blog.s21g.com/genki
69
+ post_install_message:
70
+ rdoc_options: []
71
+
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: "0"
85
+ version:
86
+ requirements: []
87
+
88
+ rubyforge_project: asakusarb
89
+ rubygems_version: 1.2.0
90
+ signing_key:
91
+ specification_version: 2
92
+ summary: Merb plugin that provides pagination for DataMapper
93
+ test_files: []
94
+