Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mislav/will_paginate
base: master
...
head fork: merbjedi/merb_paginate
compare: master
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 19 files changed
  • 0 commit comments
  • 1 contributor
View
1  .gitignore
@@ -2,3 +2,4 @@
/rails
*.gem
/coverage
+.DS_Store
View
6 CHANGELOG.rdoc
@@ -1,3 +1,9 @@
+== merb_paginate
+* Repackaged as a merb-only plugin
+* Removed the Rails "cruft"
+* Packaged as its own gem
+* Now uses Merb::Plugins.config properly to set default Paging
+
== "agnostic" branch
* added Sequel support
View
103 Rakefile
@@ -1,70 +1,59 @@
require 'rubygems'
-begin
- hanna_dir = '/Users/mislav/Projects/Hanna/lib'
- $:.unshift hanna_dir if File.exists? hanna_dir
- require 'hanna/rdoctask'
-rescue LoadError
- require 'rake'
- require 'rake/rdoctask'
-end
+require 'rake/gempackagetask'
+
+require 'merb-core'
+require 'merb-core/tasks/merb'
+
load 'spec/tasks.rake'
desc 'Default: run specs.'
task :default => :spec
-desc 'Generate RDoc documentation for the will_paginate plugin.'
-Rake::RDocTask.new(:rdoc) do |rdoc|
- rdoc.rdoc_files.include('README.rdoc', 'LICENSE', 'CHANGELOG.rdoc').
- include('lib/**/*.rb').
- exclude('lib/will_paginate/finders/active_record/named_scope*').
- exclude('lib/will_paginate/finders/sequel.rb').
- exclude('lib/will_paginate/view_helpers/merb.rb').
- exclude('lib/will_paginate/deprecation.rb').
- exclude('lib/will_paginate/core_ext.rb').
- exclude('lib/will_paginate/version.rb')
-
- rdoc.main = "README.rdoc" # page to start on
- rdoc.title = "will_paginate documentation"
+GEM_NAME = "merb_paginate"
+GEM_VERSION = "0.9.0"
+AUTHORS = ['Jacques Crocker', 'Mislav Marohnić', 'PJ Hyett']
+EMAIL = 'merbjedi@gmail.com'
+HOMEPAGE = 'http://github.com/merbjedi/merb_paginate'
+SUMMARY = "merb_paginate is a fork of will_paginate agnostic branch, refocused to work specifically with Merb"
+
+spec = Gem::Specification.new do |s|
+ s.rubyforge_project = 'merb'
+ s.name = GEM_NAME
+ s.version = GEM_VERSION
+ s.platform = Gem::Platform::RUBY
+ s.has_rdoc = true
+ s.extra_rdoc_files = ["README.rdoc", "LICENSE"]
+ s.summary = SUMMARY
+ s.description = s.summary
+ s.authors = AUTHORS
+ s.email = EMAIL
+ s.homepage = HOMEPAGE
- rdoc.rdoc_dir = 'doc' # rdoc output folder
- rdoc.options << '--inline-source' << '--charset=UTF-8'
- rdoc.options << '--webcvs=http://github.com/mislav/will_paginate/tree/master/'
+ s.add_dependency('merb-core', '>= 1.0')
+
+ s.require_path = 'lib'
+ s.files = %w(LICENSE README.rdoc CHANGELOG.rdoc Rakefile) + Dir.glob("{lib,spec}/**/*")
end
-desc %{Update ".manifest" with the latest list of project filenames. Respect\
-.gitignore by excluding everything that git ignores. Update `files` and\
-`test_files` arrays in "*.gemspec" file if it's present.}
-task :manifest do
- list = Dir['**/*'].sort
- spec_file = Dir['*.gemspec'].first
- list -= [spec_file] if spec_file
-
- ignores = File.read('.gitignore').to_a
- ignores << 'website'
-
- ignores.each do |glob|
- glob = glob.chomp.sub(/^\//, '')
- list -= Dir[glob]
- list -= Dir["#{glob}/**/*"] if File.directory?(glob) and !File.symlink?(glob)
- puts "excluding #{glob}"
- end
+Rake::GemPackageTask.new(spec) do |pkg|
+ pkg.gem_spec = spec
+end
- if spec_file
- spec = File.read spec_file
- spec.gsub! /^(\s* s.(test_)?files \s* = \s* )( \[ [^\]]* \] | %w\( [^)]* \) )/mx do
- assignment = $1
- bunch = $2 ? list.grep(/^(test|spec)\//) : list
- '%s%%w(%s)' % [assignment, bunch.join(' ')]
- end
-
- File.open(spec_file, 'w') {|f| f << spec }
- end
- File.open('.manifest', 'w') {|f| f << list.join("\n") }
+desc "install the plugin as a gem"
+task :install do
+ Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
end
-task :website do
- Dir.chdir('website') do
- %x(haml index.haml index.html)
- %x(sass pagination.sass pagination.css)
+desc "Uninstall the gem"
+task :uninstall do
+ Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
+end
+
+desc "Create a gemspec file"
+task :gemspec do
+ File.open("#{GEM_NAME}.gemspec", "w") do |file|
+ file.puts spec.to_ruby
end
-end
+end
+
+require 'lib/merbtasks'
View
1  lib/merb_paginate.rb
@@ -0,0 +1 @@
+require 'will_paginate'
View
17 lib/merbtasks.rb
@@ -0,0 +1,17 @@
+namespace :app_config do
+ desc "Create a blank config/app_config.yml file"
+ task :init do
+ puts "Setting up AppConfig files..."
+ `mkdir -p config/app_config`
+
+ ["config/app_config.yml",
+ "config/app_config/development.yml",
+ "config/app_config/production.yml"
+ ].each do |path|
+ `touch #{path}`
+ puts "Created: #{path}"
+ end
+ puts "Complete!"
+ puts "Add key/value pairs to your yaml file,\nthen access them in your Merb project via AppConfig.[key]"
+ end
+end
View
16 lib/will_paginate.rb
@@ -31,15 +31,9 @@ def self.enable_named_scope(patch = true)
end
end
-if defined?(Rails)
- require 'will_paginate/view_helpers/action_view' if defined?(ActionController)
- require 'will_paginate/finders/active_record' if defined?(ActiveRecord)
-end
-
-if defined?(Merb::Plugins)
- require 'will_paginate/view_helpers/merb'
- # auto-load the right ORM adapter
- if adapter = { :datamapper => 'data_mapper', :activerecord => 'active_record', :sequel => 'sequel' }[Merb.orm]
- require "will_paginate/finders/#{adapter}"
- end
+require 'merb-core'
+require 'will_paginate/view_helpers/merb'
+# auto-load the right ORM adapter
+if adapter = { :datamapper => 'data_mapper', :activerecord => 'active_record', :sequel => 'sequel' }[Merb.orm]
+ require "will_paginate/finders/#{adapter}"
end
View
2  lib/will_paginate/array.rb
@@ -30,4 +30,6 @@ def paginate(options = {})
pager.replace self[pager.offset, pager.per_page].to_a
end
end
+
+ alias :total_entries :size
end
View
26 lib/will_paginate/core_ext.rb
@@ -31,28 +31,4 @@ def slice!(*keys)
replace(slice(*keys))
end
end
-end
-
-unless String.instance_methods.include? 'constantize'
- String.class_eval do
- def constantize
- unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ self
- raise NameError, "#{self.inspect} is not a valid constant name!"
- end
-
- Object.module_eval("::#{$1}", __FILE__, __LINE__)
- end
- end
-end
-
-unless String.instance_methods.include? 'underscore'
- String.class_eval do
- def underscore
- self.to_s.gsub(/::/, '/').
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
- tr("-", "_").
- downcase
- end
- end
-end
+end
View
16 lib/will_paginate/view_helpers.rb
@@ -25,18 +25,8 @@ def self.pagination_options() @pagination_options; end
# Overrides the default +pagination_options+
def self.pagination_options=(value) @pagination_options = value; end
- self.pagination_options = {
- :class => 'pagination',
- :previous_label => '&laquo; Previous',
- :next_label => 'Next &raquo;',
- :inner_window => 4, # links around the current page
- :outer_window => 1, # links around beginning and end
- :separator => ' ', # single space is friendly to spiders and non-graphic browsers
- :param_name => :page,
- :params => nil,
- :renderer => 'WillPaginate::ViewHelpers::LinkRenderer',
- :page_links => true,
- :container => true
- }
+ def self.pagination_options
+ Merb::Plugins.config[:paging] || {}
+ end
end
end
View
142 lib/will_paginate/view_helpers/action_view.rb
@@ -1,142 +0,0 @@
-require 'will_paginate/view_helpers/base'
-require 'action_view'
-require 'action_pack/version'
-require 'will_paginate/view_helpers/link_renderer'
-
-module WillPaginate
- module ViewHelpers
- # = ActionView helpers
- #
- # This module serves for availability in ActionView templates. It also adds a new
- # view helper: +paginated_section+.
- #
- # == Using the helper without arguments
- # If the helper is called without passing in the collection object, it will
- # try to read from the instance variable inferred by the controller name.
- # For example, calling +will_paginate+ while the current controller is
- # PostsController will result in trying to read from the <tt>@posts</tt>
- # variable. Example:
- #
- # <%= will_paginate :id => true %>
- #
- # ... will result in <tt>@post</tt> collection getting paginated:
- #
- # <div class="pagination" id="posts_pagination"> ... </div>
- #
- module ActionView
- include WillPaginate::ViewHelpers::Base
-
- def will_paginate(collection = nil, options = {}) #:nodoc:
- options, collection = collection, nil if collection.is_a? Hash
- collection ||= infer_collection_from_controller
-
- super(collection, options.symbolize_keys)
- end
-
- def page_entries_info(collection = nil, options = {}) #:nodoc:
- options, collection = collection, nil if collection.is_a? Hash
- collection ||= infer_collection_from_controller
-
- super(collection, options.symbolize_keys)
- end
-
- # Wrapper for rendering pagination links at both top and bottom of a block
- # of content.
- #
- # <% paginated_section @posts do %>
- # <ol id="posts">
- # <% for post in @posts %>
- # <li> ... </li>
- # <% end %>
- # </ol>
- # <% end %>
- #
- # will result in:
- #
- # <div class="pagination"> ... </div>
- # <ol id="posts">
- # ...
- # </ol>
- # <div class="pagination"> ... </div>
- #
- # Arguments are passed to a <tt>will_paginate</tt> call, so the same options
- # apply. Don't use the <tt>:id</tt> option; otherwise you'll finish with two
- # blocks of pagination links sharing the same ID (which is invalid HTML).
- def paginated_section(*args, &block)
- pagination = will_paginate(*args).to_s
-
- unless ::ActionView::Base.respond_to? :erb_variable
- concat pagination
- yield
- concat pagination
- else
- content = pagination + capture(&block) + pagination
- concat(content, block.binding)
- end
- end
-
- protected
-
- def infer_collection_from_controller
- collection_name = "@#{controller.controller_name}"
- collection = instance_variable_get(collection_name)
- raise ArgumentError, "The #{collection_name} variable appears to be empty. Did you " +
- "forget to pass the collection object for will_paginate?" if collection.nil?
- collection
- end
- end
- end
-end
-
-ActionView::Base.send :include, WillPaginate::ViewHelpers::ActionView
-# :stopdoc:
-if defined?(ActionController::Base) and ActionController::Base.respond_to? :rescue_responses
- ActionController::Base.rescue_responses['WillPaginate::InvalidPage'] = :not_found
-end
-
-WillPaginate::ViewHelpers::LinkRenderer.class_eval do
- protected
-
- def default_url_params
- { :escape => false }
- end
-
- def url(page)
- @base_url_params ||= begin
- url_params = base_url_params
- merge_optional_params(url_params)
- url_params
- end
-
- url_params = @base_url_params.dup
- add_current_page_param(url_params, page)
-
- @template.url_for(url_params)
- end
-
- def base_url_params
- url_params = default_url_params
- # page links should preserve GET parameters
- symbolized_update(url_params, @template.params) if get_request?
- url_params
- end
-
- def merge_optional_params(url_params)
- symbolized_update(url_params, @options[:params]) if @options[:params]
- end
-
- def add_current_page_param(url_params, page)
- unless param_name.index(/[^\w-]/)
- url_params[param_name.to_sym] = page
- else
- page_param = (defined?(CGIMethods) ? CGIMethods : ActionController::AbstractRequest).
- parse_query_parameters(param_name + '=' + page.to_s)
-
- symbolized_update(url_params, page_param)
- end
- end
-
- def get_request?
- @template.request.get?
- end
-end
View
5 lib/will_paginate/view_helpers/base.rb
@@ -41,7 +41,6 @@ module Base
def will_paginate(collection, options = {})
# early exit if there is nothing to render
return nil unless collection.total_pages > 1
-
options = WillPaginate::ViewHelpers.pagination_options.merge(options)
if options[:prev_label]
@@ -52,7 +51,7 @@ def will_paginate(collection, options = {})
# get the renderer instance
renderer = case options[:renderer]
when String
- options[:renderer].constantize.new
+ Object.full_const_get(options[:renderer]).new
when Class
options[:renderer].new
else
@@ -86,7 +85,7 @@ def will_paginate(collection, options = {})
# text output by passing <tt>:html => false</tt> in options.
def page_entries_info(collection, options = {})
entry_name = options[:entry_name] || (collection.empty?? 'entry' :
- collection.first.class.name.underscore.gsub('_', ' '))
+ collection.first.class.name.snake_case.gsub('_', ' '))
plural_name = if options[:plural_name]
options[:plural_name]
View
2  lib/will_paginate/view_helpers/link_renderer.rb
@@ -38,7 +38,7 @@ def container_attributes
attributes = @options.except *(WillPaginate::ViewHelpers.pagination_options.keys - [:class])
# pagination of Post models will have the ID of "posts_pagination"
if @options[:container] and @options[:id] === true
- attributes[:id] = @collection.first.class.name.underscore.pluralize + '_pagination'
+ attributes[:id] = @collection.first.class.name.snake_case.pluralize + '_pagination'
end
attributes
end
View
18 lib/will_paginate/view_helpers/merb.rb
@@ -1,6 +1,22 @@
require 'will_paginate/view_helpers/base'
require 'will_paginate/view_helpers/link_renderer'
+# Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
+Merb::Plugins.config[:paging] = {
+ :class => 'pagination',
+ :previous_label => '&laquo; Previous',
+ :next_label => 'Next &raquo;',
+ :inner_window => 4, # links around the current page
+ :outer_window => 1, # links around beginning and end
+ :separator => ' ', # single space is friendly to spiders and non-graphic browsers
+ :param_name => :page,
+ :params => nil,
+ :renderer => 'WillPaginate::ViewHelpers::LinkRenderer',
+ :page_links => true,
+ :container => true
+}
+
+
WillPaginate::ViewHelpers::LinkRenderer.class_eval do
protected
@@ -10,4 +26,4 @@ def url(page)
end
end
-Merb::AbstractController.send(:include, WillPaginate::ViewHelpers::Base)
+Merb::AbstractController.send(:include, WillPaginate::ViewHelpers::Base)
View
2  spec/collection_spec.rb
@@ -10,7 +10,7 @@
it "should be a subset of original collection" do
@simple.paginate(:page => 1, :per_page => 3).should == %w( a b c )
end
-
+
it "can be shorter than per_page if on last page" do
@simple.paginate(:page => 2, :per_page => 3).should == %w( d e )
end
View
1  spec/spec_helper.rb
@@ -1,5 +1,4 @@
require 'rubygems'
-gem 'dchelimsky-rspec', '~> 1.1.11'
require 'spec'
module MyExtras
View
54 spec/tasks.rake
@@ -6,55 +6,5 @@ desc 'Run framework-agnostic specs'
Spec::Rake::SpecTask.new(:spec) do |t|
t.libs << 'lib' << 'spec'
t.spec_opts = ['--options', spec_opts]
- t.spec_files = FileList.new('spec/**/*_spec.rb') do |files|
- files.exclude(/\b(active_record|active_resource|action_view|data_mapper|sequel)_/)
- end
-end
-
-namespace :spec do
- desc 'Run specs for core, ActiveRecord and ActionView'
- Spec::Rake::SpecTask.new(:rails) do |t|
- t.libs << 'lib' << 'spec'
- t.spec_opts = ['--options', spec_opts]
- t.spec_files = FileList.new('spec/**/*_spec.rb') do |files|
- files.exclude(/\b(data_mapper|sequel)_/)
- end
- end
-
- desc 'Run specs for DataMapper'
- Spec::Rake::SpecTask.new(:datamapper) do |t|
- t.libs << 'lib' << 'spec'
- t.spec_opts = ['--options', spec_opts]
- t.spec_files = FileList.new('spec/finders_spec.rb', 'spec/finders/data_mapper_spec.rb')
- end
-
- desc 'Run specs for Sequel'
- Spec::Rake::SpecTask.new(:sequel) do |t|
- t.libs << 'lib' << 'spec'
- t.spec_opts = ['--options', spec_opts]
- t.spec_files = FileList.new('spec/finders_spec.rb', 'spec/finders/sequel_spec.rb')
- end
-
- desc 'Analyze spec coverage with RCov'
- Spec::Rake::SpecTask.new(:rcov) do |t|
- t.libs << 'lib' << 'spec'
- t.spec_opts = ['--options', spec_opts]
- t.rcov = true
- t.rcov_opts = lambda do
- IO.readlines('spec/rcov.opts').map { |l| l.chomp.split(" ") }.flatten
- end
- end
-
- desc 'Print Specdoc for all specs'
- Spec::Rake::SpecTask.new(:doc) do |t|
- t.libs << 'lib' << 'spec'
- t.spec_opts = ['--format', 'specdoc', '--dry-run']
- end
-
- desc 'Generate HTML report'
- Spec::Rake::SpecTask.new(:html) do |t|
- t.libs << 'lib' << 'spec'
- t.spec_opts = ['--format', 'html:doc/spec_results.html', '--diff']
- t.fail_on_error = false
- end
-end
+ t.spec_files = FileList.new('spec/**/*_spec.rb')
+end
View
344 spec/view_helpers/action_view_spec.rb
@@ -1,344 +0,0 @@
-require 'spec_helper'
-require 'active_support/rescuable' # needed for Ruby 1.9.1
-require 'action_controller'
-require 'view_helpers/view_example_group'
-require 'will_paginate/view_helpers/action_view'
-require 'will_paginate/collection'
-
-ActionController::Routing::Routes.draw do |map|
- map.connect 'dummy/page/:page', :controller => 'dummy'
- map.connect 'dummy/dots/page.:page', :controller => 'dummy', :action => 'dots'
- map.connect 'ibocorp/:page', :controller => 'ibocorp',
- :requirements => { :page => /\d+/ },
- :defaults => { :page => 1 }
-
- map.connect ':controller/:action/:id'
-end
-
-describe WillPaginate::ViewHelpers::ActionView do
- before(:each) do
- @view = ActionView::Base.new
- @view.controller = DummyController.new
- @view.request = @view.controller.request
- @template = '<%= will_paginate collection, options %>'
- end
-
- def request
- @view.request
- end
-
- def render(locals)
- @view.render(:inline => @template, :locals => locals)
- end
-
- ## basic pagination ##
-
- it "should render" do
- paginate do |pagination|
- assert_select 'a[href]', 3 do |elements|
- validate_page_numbers [2,3,2], elements
- assert_select elements.last, ':last-child', "Next &raquo;"
- end
- assert_select 'span', 1
- assert_select 'span.disabled:first-child', '&laquo; Previous'
- assert_select 'em', '1'
- pagination.first.inner_text.should == '&laquo; Previous 1 2 3 Next &raquo;'
- end
- end
-
- it "should render nothing when there is only 1 page" do
- paginate(:per_page => 30).should be_empty
- end
-
- it "should paginate with options" do
- paginate({ :page => 2 }, :class => 'will_paginate', :previous_label => 'Prev', :next_label => 'Next') do
- assert_select 'a[href]', 4 do |elements|
- validate_page_numbers [1,1,3,3], elements
- # test rel attribute values:
- assert_select elements[1], 'a', '1' do |link|
- link.first['rel'].should == 'prev start'
- end
- assert_select elements.first, 'a', "Prev" do |link|
- link.first['rel'].should == 'prev start'
- end
- assert_select elements.last, 'a', "Next" do |link|
- link.first['rel'].should == 'next'
- end
- end
- assert_select 'em', '2'
- end
- end
-
- it "should paginate using a custom renderer class" do
- paginate({}, :renderer => AdditionalLinkAttributesRenderer) do
- assert_select 'a[default=true]', 3
- end
- end
-
- it "should paginate using a custom renderer instance" do
- renderer = WillPaginate::ViewHelpers::LinkRenderer.new
- def renderer.gap() '<span class="my-gap">~~</span>' end
-
- paginate({ :per_page => 2 }, :inner_window => 0, :outer_window => 0, :renderer => renderer) do
- assert_select 'span.my-gap', '~~'
- end
-
- renderer = AdditionalLinkAttributesRenderer.new(:title => 'rendered')
- paginate({}, :renderer => renderer) do
- assert_select 'a[title=rendered]', 3
- end
- end
-
- it "should have classnames on previous/next links" do
- paginate do |pagination|
- assert_select 'span.disabled.previous_page:first-child'
- assert_select 'a.next_page[href]:last-child'
- end
- end
-
- it "should warn about :prev_label being deprecated" do
- lambda {
- paginate({ :page => 2 }, :prev_label => 'Deprecated') do
- assert_select 'a[href]:first-child', 'Deprecated'
- end
- }.should have_deprecation
- end
-
- it "should match expected markup" do
- paginate
- expected = <<-HTML
- <div class="pagination"><span class="previous_page disabled">&laquo; Previous</span>
- <em>1</em>
- <a href="/foo/bar?page=2" rel="next">2</a>
- <a href="/foo/bar?page=3">3</a>
- <a href="/foo/bar?page=2" class="next_page" rel="next">Next &raquo;</a></div>
- HTML
- expected.strip!.gsub!(/\s{2,}/, ' ')
- expected_dom = HTML::Document.new(expected).root
-
- html_document.root.should == expected_dom
- end
-
- it "should output escaped URLs" do
- paginate({:page => 1, :per_page => 1, :total_entries => 2},
- :page_links => false, :params => { :tag => '<br>' })
-
- assert_select 'a[href]', 1 do |links|
- query = links.first['href'].split('?', 2)[1]
- query.split('&amp;').sort.should == %w(page=2 tag=%3Cbr%3E)
- end
- end
-
- ## advanced options for pagination ##
-
- it "should be able to render without container" do
- paginate({}, :container => false)
- assert_select 'div.pagination', 0, 'main DIV present when it shouldn\'t'
- assert_select 'a[href]', 3
- end
-
- it "should be able to render without page links" do
- paginate({ :page => 2 }, :page_links => false) do
- assert_select 'a[href]', 2 do |elements|
- validate_page_numbers [1,3], elements
- end
- end
- end
-
- it "should have magic HTML ID for the container" do
- paginate do |div|
- div.first['id'].should be_nil
- end
-
- # magic ID
- paginate({}, :id => true) do |div|
- div.first['id'].should == 'fixnums_pagination'
- end
-
- # explicit ID
- paginate({}, :id => 'custom_id') do |div|
- div.first['id'].should == 'custom_id'
- end
- end
-
- ## other helpers ##
-
- it "should render a paginated section" do
- @template = <<-ERB
- <% paginated_section collection, options do %>
- <%= content_tag :div, '', :id => "developers" %>
- <% end %>
- ERB
-
- paginate
- assert_select 'div.pagination', 2
- assert_select 'div.pagination + div#developers', 1
- end
-
- ## parameter handling in page links ##
-
- it "should preserve parameters on GET" do
- request.params :foo => { :bar => 'baz' }
- paginate
- assert_links_match /foo%5Bbar%5D=baz/
- end
-
- it "should not preserve parameters on POST" do
- request.post
- request.params :foo => 'bar'
- paginate
- assert_no_links_match /foo=bar/
- end
-
- it "should add additional parameters to links" do
- paginate({}, :params => { :foo => 'bar' })
- assert_links_match /foo=bar/
- end
-
- it "should add anchor parameter" do
- paginate({}, :params => { :anchor => 'anchor' })
- assert_links_match /#anchor$/
- end
-
- it "should remove arbitrary parameters" do
- request.params :foo => 'bar'
- paginate({}, :params => { :foo => nil })
- assert_no_links_match /foo=bar/
- end
-
- it "should override default route parameters" do
- paginate({}, :params => { :controller => 'baz', :action => 'list' })
- assert_links_match %r{\Wbaz/list\W}
- end
-
- it "should paginate with custom page parameter" do
- paginate({ :page => 2 }, :param_name => :developers_page) do
- assert_select 'a[href]', 4 do |elements|
- validate_page_numbers [1,1,3,3], elements, :developers_page
- end
- end
- end
-
- it "should paginate with complex custom page parameter" do
- request.params :developers => { :page => 2 }
-
- paginate({ :page => 2 }, :param_name => 'developers[page]') do
- assert_select 'a[href]', 4 do |links|
- assert_links_match /\?developers%5Bpage%5D=\d+$/, links
- validate_page_numbers [1,1,3,3], links, 'developers[page]'
- end
- end
- end
-
- it "should paginate with custom route page parameter" do
- request.symbolized_path_parameters.update :controller => 'dummy', :action => nil
- paginate :per_page => 2 do
- assert_select 'a[href]', 6 do |links|
- assert_links_match %r{/page/(\d+)$}, links, [2, 3, 4, 5, 6, 2]
- end
- end
- end
-
- it "should paginate with custom route with dot separator page parameter" do
- request.symbolized_path_parameters.update :controller => 'dummy', :action => 'dots'
- paginate :per_page => 2 do
- assert_select 'a[href]', 6 do |links|
- assert_links_match %r{/page\.(\d+)$}, links, [2, 3, 4, 5, 6, 2]
- end
- end
- end
-
- it "should paginate with custom route and first page number implicit" do
- request.symbolized_path_parameters.update :controller => 'ibocorp', :action => nil
- paginate :page => 2, :per_page => 2 do
- assert_select 'a[href]', 7 do |links|
- assert_links_match %r{/ibocorp(?:/(\d+))?$}, links, [nil, nil, 3, 4, 5, 6, 3]
- end
- end
- end
-
- ## internal hardcore stuff ##
-
- it "should be able to guess the collection name" do
- collection = mock
- collection.expects(:total_pages).returns(1)
-
- @template = '<%= will_paginate options %>'
- @view.controller.controller_name = 'developers'
- @view.assigns['developers'] = collection
-
- paginate(nil)
- end
-
- it "should fail if the inferred collection is nil" do
- @template = '<%= will_paginate options %>'
- @view.controller.controller_name = 'developers'
-
- lambda {
- paginate(nil)
- }.should raise_error(ArgumentError, /@developers/)
- end
-
- if ActionController::Base.respond_to? :rescue_responses
- # only on Rails 2
- it "should set rescue response hook" do
- ActionController::Base.rescue_responses['WillPaginate::InvalidPage'].should == :not_found
- end
- end
-end
-
-class AdditionalLinkAttributesRenderer < WillPaginate::ViewHelpers::LinkRenderer
- def initialize(link_attributes = nil)
- super()
- @additional_link_attributes = link_attributes || { :default => 'true' }
- end
-
- def link(text, target, attributes = {})
- super(text, target, attributes.merge(@additional_link_attributes))
- end
-end
-
-class DummyController
- attr_reader :request
- attr_accessor :controller_name
-
- def initialize
- @request = DummyRequest.new
- @url = ActionController::UrlRewriter.new(@request, @request.params)
- end
-
- def params
- @request.params
- end
-
- def url_for(params)
- @url.rewrite(params)
- end
-end
-
-class DummyRequest
- attr_accessor :symbolized_path_parameters
-
- def initialize
- @get = true
- @params = {}
- @symbolized_path_parameters = { :controller => 'foo', :action => 'bar' }
- end
-
- def get?
- @get
- end
-
- def post
- @get = false
- end
-
- def relative_url_root
- ''
- end
-
- def params(more = nil)
- @params.update(more) if more
- @params
- end
-end
1  website
@@ -1 +0,0 @@
-Subproject commit f6fd2779ace1b1e9f1cf390e254ef08423954bb1
View
20 will_paginate.gemspec
@@ -1,20 +0,0 @@
-Gem::Specification.new do |s|
- s.name = 'will_paginate'
- s.version = '3.0.0'
- s.date = '2008-11-23'
-
- s.summary = "Most awesome pagination solution for every web app"
- s.description = "The will_paginate library provides a simple, yet powerful and extensible API for pagination and rendering of page links in templates."
-
- s.authors = ['Mislav Marohnić', 'PJ Hyett']
- s.email = 'mislav.marohnic@gmail.com'
- s.homepage = 'http://github.com/mislav/will_paginate/wikis'
-
- s.has_rdoc = true
- s.rdoc_options = ['--main', 'README.rdoc']
- s.rdoc_options << '--inline-source' << '--charset=UTF-8'
- s.extra_rdoc_files = ['README.rdoc', 'LICENSE', 'CHANGELOG.rdoc']
-
- s.files = %w(CHANGELOG.rdoc LICENSE README.rdoc Rakefile init.rb lib lib/will_paginate lib/will_paginate.rb lib/will_paginate/array.rb lib/will_paginate/collection.rb lib/will_paginate/core_ext.rb lib/will_paginate/deprecation.rb lib/will_paginate/finders lib/will_paginate/finders.rb lib/will_paginate/finders/active_record lib/will_paginate/finders/active_record.rb lib/will_paginate/finders/active_record/named_scope.rb lib/will_paginate/finders/active_record/named_scope_patch.rb lib/will_paginate/finders/active_resource.rb lib/will_paginate/finders/base.rb lib/will_paginate/finders/data_mapper.rb lib/will_paginate/finders/sequel.rb lib/will_paginate/version.rb lib/will_paginate/view_helpers lib/will_paginate/view_helpers.rb lib/will_paginate/view_helpers/action_view.rb lib/will_paginate/view_helpers/base.rb lib/will_paginate/view_helpers/link_renderer.rb lib/will_paginate/view_helpers/link_renderer_base.rb lib/will_paginate/view_helpers/merb.rb spec spec/collection_spec.rb spec/console spec/console_fixtures.rb spec/database.yml spec/finders spec/finders/active_record_spec.rb spec/finders/active_resource_spec.rb spec/finders/activerecord_test_connector.rb spec/finders/data_mapper_spec.rb spec/finders/data_mapper_test_connector.rb spec/finders/sequel_spec.rb spec/finders/sequel_test_connector.rb spec/finders_spec.rb spec/fixtures spec/fixtures/admin.rb spec/fixtures/developer.rb spec/fixtures/developers_projects.yml spec/fixtures/project.rb spec/fixtures/projects.yml spec/fixtures/replies.yml spec/fixtures/reply.rb spec/fixtures/schema.rb spec/fixtures/topic.rb spec/fixtures/topics.yml spec/fixtures/user.rb spec/fixtures/users.yml spec/rcov.opts spec/spec.opts spec/spec_helper.rb spec/tasks.rake spec/view_helpers spec/view_helpers/action_view_spec.rb spec/view_helpers/base_spec.rb spec/view_helpers/link_renderer_base_spec.rb spec/view_helpers/view_example_group.rb)
- s.test_files = %w(spec/collection_spec.rb spec/console spec/console_fixtures.rb spec/database.yml spec/finders spec/finders/active_record_spec.rb spec/finders/active_resource_spec.rb spec/finders/activerecord_test_connector.rb spec/finders/data_mapper_spec.rb spec/finders/data_mapper_test_connector.rb spec/finders/sequel_spec.rb spec/finders/sequel_test_connector.rb spec/finders_spec.rb spec/fixtures spec/fixtures/admin.rb spec/fixtures/developer.rb spec/fixtures/developers_projects.yml spec/fixtures/project.rb spec/fixtures/projects.yml spec/fixtures/replies.yml spec/fixtures/reply.rb spec/fixtures/schema.rb spec/fixtures/topic.rb spec/fixtures/topics.yml spec/fixtures/user.rb spec/fixtures/users.yml spec/rcov.opts spec/spec.opts spec/spec_helper.rb spec/tasks.rake spec/view_helpers spec/view_helpers/action_view_spec.rb spec/view_helpers/base_spec.rb spec/view_helpers/link_renderer_base_spec.rb spec/view_helpers/view_example_group.rb)
-end

No commit comments for this range

Something went wrong with that request. Please try again.