objectreload-pagination 0.1.9 → 0.1.11

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.9
1
+ 0.1.11
@@ -2,9 +2,6 @@
2
2
  require 'active_record/base_extensions'
3
3
  require 'active_record/scope_extensions'
4
4
 
5
- # Loads
6
- require 'action_controller/rescue_with_helper'
7
-
8
5
  # Loads internal pagination classes
9
6
  require 'pagination/collection'
10
7
  require 'pagination/named_scope'
@@ -13,15 +10,3 @@ require 'pagination/view_helpers'
13
10
 
14
11
  # Loads the :paginate view helper
15
12
  ActionView::Base.send :include, Pagination::ViewHelpers
16
-
17
- # Load :rescue_with_handler - solution: https://rails.lighthouseapp.com/projects/8994/tickets/2034-exceptions-in-views-hard-to-catch
18
- ActionController::Base.send :include, RescueWithHelper
19
-
20
- ActionController::Base.send(:rescue_from, Pagination::InvalidPage, :with => :not_found)
21
-
22
- def not_found
23
- # Avoid calling '304 Not Modified'
24
- if stale?(:etag => "invalid_page", :last_modified => DateTime.now.utc)
25
- render_optional_error_file 404
26
- end
27
- end
@@ -1,11 +1,4 @@
1
1
  module Pagination
2
- class InvalidPage < ArgumentError
3
- def initialize(page, max = 1)
4
- super "#{page} must be greater than 0" if page < 1
5
- super "#{page} must be less than #{max}" if page >= 1
6
- end
7
- end
8
-
9
2
  class Collection < Array
10
3
  attr_reader :current_page, :per_page, :total_entries, :total_pages
11
4
 
@@ -22,12 +15,9 @@ module Pagination
22
15
  self.total_entries ||= @collection.empty? ? 0 : @collection.count(:id , :distinct => true)
23
16
  end
24
17
 
25
- raise InvalidPage.new(@current_page) if @current_page < 1
26
18
  raise ArgumentError, "`per_page` setting cannot be less than 1 (#{@per_page} given)" if @per_page < 1
27
19
 
28
20
  replace(already_paginated ? @collection : @collection.paginate(:limit => limit, :offset => offset))
29
-
30
- raise InvalidPage.new(current_page, total_pages) if current_page > total_pages
31
21
  end
32
22
 
33
23
  def previous_page
@@ -49,11 +49,6 @@ class CollectionTest < Test::Unit::TestCase
49
49
  assert_equal 4, pag_array.count
50
50
  end
51
51
 
52
- should "rise an error InvalidPage" do
53
- assert_raise(Pagination::InvalidPage) { paginate_collection(@collection, -2, 2) }
54
- assert_raise(Pagination::InvalidPage) { paginate_collection(@collection, 1000, 2) }
55
- end
56
-
57
52
  should "rise an error ArgumentError" do
58
53
  assert_raise(ArgumentError) { paginate_collection(@collection, 2, -2) }
59
54
  end
@@ -1,4 +1,4 @@
1
- gem 'actionpack', '2.3.5'
1
+ gem 'actionpack', '2.3.8'
2
2
  require 'action_controller'
3
3
  require 'action_controller/test_process'
4
4
 
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
- gem 'test-unit', '1.2.3'
2
+ gem 'test-unit', '>= 2.0'
3
3
  require 'test/unit'
4
- gem 'activerecord', '2.3.5'
4
+ gem 'activerecord', '2.3.8'
5
5
  require 'active_record'
6
6
  require 'shoulda'
7
7
  require 'logger'
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: objectreload-pagination
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 13
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 1
8
- - 9
9
- version: 0.1.9
9
+ - 11
10
+ version: 0.1.11
10
11
  platform: ruby
11
12
  authors:
12
13
  - Mateusz Drozdzynski
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-07-08 00:00:00 +03:00
18
+ date: 2010-07-12 00:00:00 +03:00
18
19
  default_executable:
19
20
  dependencies: []
20
21
 
@@ -35,7 +36,6 @@ files:
35
36
  - Rakefile
36
37
  - VERSION
37
38
  - init.rb
38
- - lib/action_controller/rescue_with_helper.rb
39
39
  - lib/active_record/base_extensions.rb
40
40
  - lib/active_record/scope_extensions.rb
41
41
  - lib/pagination.rb
@@ -59,23 +59,27 @@ rdoc_options:
59
59
  require_paths:
60
60
  - lib
61
61
  required_ruby_version: !ruby/object:Gem::Requirement
62
+ none: false
62
63
  requirements:
63
64
  - - ">="
64
65
  - !ruby/object:Gem::Version
66
+ hash: 3
65
67
  segments:
66
68
  - 0
67
69
  version: "0"
68
70
  required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
69
72
  requirements:
70
73
  - - ">="
71
74
  - !ruby/object:Gem::Version
75
+ hash: 3
72
76
  segments:
73
77
  - 0
74
78
  version: "0"
75
79
  requirements: []
76
80
 
77
81
  rubyforge_project:
78
- rubygems_version: 1.3.6
82
+ rubygems_version: 1.3.7
79
83
  signing_key:
80
84
  specification_version: 3
81
85
  summary: Simple pagination - without changes in controllers
@@ -1,16 +0,0 @@
1
- # When an exception happens inside a view, it is wrapped with an
2
- # ActionView::TemplateError. The lookup for the rescue_with_handler
3
- # then fails to find the handle for the original exception. This solution
4
- # special cases the template error to look also at the wrapped exception
5
- # and if there is a handler for that exception, then call it and ignore
6
- # the wrapping.
7
- module RescueWithHelper
8
- def rescue_with_handler(exception)
9
- if ((exception.class == ActionView::TemplateError) &&
10
- (orig_exception = exception.original_exception) &&
11
- (orig_handler = handler_for_rescue(orig_exception)))
12
- exception = orig_exception
13
- end
14
- super(exception)
15
- end
16
- end