Skip to content
This repository
Browse code

Sequel is back

  • Loading branch information...
commit fb36491eb5d17f264fb07825913e7a6d7f2952fc 1 parent 4ced819
Mislav Marohnić authored
2  Gemfile
@@ -7,7 +7,7 @@ gem 'rake'
7 7 gem 'activerecord', '~> 3.1.0.rc'
8 8 gem 'activeresource', '~> 3.1.0.rc'
9 9 gem 'actionpack', '~> 3.1.0.rc'
10   -gem 'sequel', '~> 3.8.0', :platforms => :ruby_18 # broken on 1.9
  10 +gem 'sequel', '~> 3.8'
11 11 gem 'rspec', '~> 2.6.0'
12 12 gem 'mocha', '~> 0.9.8'
13 13 gem 'sqlite3', '~> 1.3.3'
4 Gemfile.lock
@@ -92,7 +92,7 @@ GEM
92 92 ruby-debug-base19 (>= 0.11.19)
93 93 ruby_core_source (0.1.5)
94 94 archive-tar-minitar (>= 0.5.2)
95   - sequel (3.8.0)
  95 + sequel (3.25.0)
96 96 sprockets (2.0.0.beta.12)
97 97 hike (~> 1.2)
98 98 rack (~> 1.0)
@@ -119,5 +119,5 @@ DEPENDENCIES
119 119 rspec (~> 2.6.0)
120 120 ruby-debug
121 121 ruby-debug19
122   - sequel (~> 3.8.0)
  122 + sequel (~> 3.8)
123 123 sqlite3 (~> 1.3.3)
23 lib/will_paginate/finders/sequel.rb
... ... @@ -1,23 +0,0 @@
1   -require 'will_paginate/core_ext'
2   -require 'sequel'
3   -require 'sequel/extensions/pagination'
4   -
5   -existing_methods = Sequel::Dataset::Pagination.instance_methods
6   -
7   -Sequel::Dataset::Pagination.module_eval do
8   - # it should quack like a WillPaginate::Collection
9   -
10   - alias :total_pages :page_count unless existing_methods.include_method? :total_pages
11   - alias :per_page :page_size unless existing_methods.include_method? :per_page
12   - alias :previous_page :prev_page unless existing_methods.include_method? :previous_page
13   - alias :total_entries :pagination_record_count unless existing_methods.include_method? :total_entries
14   -
15   - def out_of_bounds?
16   - current_page > total_pages
17   - end
18   -
19   - # Current offset of the paginated collection
20   - def offset
21   - (current_page - 1) * per_page
22   - end
23   -end
29 lib/will_paginate/sequel.rb
... ... @@ -0,0 +1,29 @@
  1 +require 'sequel'
  2 +require 'sequel/extensions/pagination'
  3 +
  4 +module WillPaginate
  5 + module SequelMethods
  6 + def total_pages
  7 + page_count
  8 + end
  9 +
  10 + def per_page
  11 + page_size
  12 + end
  13 +
  14 + def total_entries
  15 + pagination_record_count
  16 + end
  17 +
  18 + def out_of_bounds?
  19 + current_page > total_pages
  20 + end
  21 +
  22 + # Current offset of the paginated collection
  23 + def offset
  24 + (current_page - 1) * per_page
  25 + end
  26 + end
  27 +
  28 + Sequel::Dataset::Pagination.send(:include, SequelMethods)
  29 +end
4 spec/finders/sequel_spec.rb
... ... @@ -1,7 +1,7 @@
1 1 require 'spec_helper'
2 2
3 3 begin
4   - require 'will_paginate/finders/sequel'
  4 + require 'will_paginate/sequel'
5 5 require File.expand_path('../sequel_test_connector', __FILE__)
6 6 rescue LoadError, ArgumentError => error
7 7 warn "Error running Sequel specs: #{error.message}"
@@ -37,8 +37,6 @@ class Car < Sequel::Model
37 37 result.total_pages.should == 2
38 38 result.per_page.should == 2
39 39 result.current_page.should == 1
40   - result.previous_page.should be_nil
41   - result.next_page.should == 2
42 40 end
43 41
44 42 it "should perform" do

0 comments on commit fb36491

Please sign in to comment.
Something went wrong with that request. Please try again.