active_resource_pagination 0.0.1 → 0.0.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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.3
@@ -0,0 +1,55 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{active_resource_pagination}
8
+ s.version = "0.0.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Dorren Chen"]
12
+ s.date = %q{2010-06-02}
13
+ s.description = %q{Adds pagination to Active Resource}
14
+ s.email = %q{dorrenchen@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "active_resource_pagination.gemspec",
27
+ "lib/active_resource_pagination.rb",
28
+ "spec/active_resource_pagination_spec.rb",
29
+ "spec/spec.opts",
30
+ "spec/spec_helper.rb"
31
+ ]
32
+ s.homepage = %q{http://github.com/dorren/active_resource_pagination}
33
+ s.rdoc_options = ["--charset=UTF-8"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = %q{1.3.6}
36
+ s.summary = %q{Adds pagination to Active Resource}
37
+ s.test_files = [
38
+ "spec/active_resource_pagination_spec.rb",
39
+ "spec/spec_helper.rb"
40
+ ]
41
+
42
+ if s.respond_to? :specification_version then
43
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
47
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
48
+ else
49
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
50
+ end
51
+ else
52
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
53
+ end
54
+ end
55
+
@@ -9,17 +9,22 @@ module ActiveResource
9
9
  # Article.paginate(:all, :page => 2, :per_page => 20, :total_entries => 123)
10
10
  # Article.paginate(:all, :from => :most_popular,
11
11
  # :params => {:year => 2010, :page => 1, :per_page => 20})
12
+ #
13
+ # To set default per_page value for all resources. you can do
14
+ # ActiveResource.per_page = 20 # do this in config/environment or initializers
15
+ #
16
+ # or to implement per_page() in your resource class.
12
17
  module Pagination
13
18
  def self.included(base)
19
+ base.class_eval do
20
+ class << self
21
+ attr_accessor :per_page
22
+ end
23
+ end
14
24
  base.extend ClassMethods
15
25
  end
16
26
 
17
- module ClassMethods
18
- # can be overrided in subclass
19
- def per_page
20
- 10
21
- end
22
-
27
+ module ClassMethods
23
28
  # use same method signatures as find(), optional additional parameters:
24
29
  # page - current page
25
30
  # per_pape - entries per page
@@ -14,7 +14,7 @@ describe ActiveResource::Pagination do
14
14
  instantiate_collection(format.decode(xml))
15
15
  end
16
16
  end
17
-
17
+
18
18
  # generate 5 articles, per_page is 2
19
19
  xml = (1..5).collect{|x| {:name => "article #{x}", :content => "blah blah #{x}"}}.to_xml(:root => "articles")
20
20
  @articles = Article.from_xml(xml)
@@ -24,10 +24,17 @@ describe ActiveResource::Pagination do
24
24
  ActiveResource::Base.should respond_to(:paginate)
25
25
  end
26
26
 
27
- it "should override per_page" do
27
+ it "should override per_page in method" do
28
28
  Article.per_page.should == 2
29
29
  end
30
30
 
31
+ it "should override per_page ad hoc" do
32
+ class Comment < ActiveResource::Base
33
+ end
34
+ Comment.per_page = 5
35
+ Comment.per_page.should == 5
36
+ end
37
+
31
38
  describe "when backend does not paginate" do
32
39
  before(:each) do
33
40
  Article.should_receive(:find).and_return(@articles)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Dorren Chen
@@ -47,6 +47,7 @@ files:
47
47
  - README.rdoc
48
48
  - Rakefile
49
49
  - VERSION
50
+ - active_resource_pagination.gemspec
50
51
  - lib/active_resource_pagination.rb
51
52
  - spec/active_resource_pagination_spec.rb
52
53
  - spec/spec.opts