pox_paginate 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/README.rdoc +57 -2
- data/Rakefile +13 -7
- data/VERSION +1 -1
- data/lib/pox_paginate/active_resource/xml_format.rb +0 -0
- data/lib/pox_paginate/active_resource.rb +0 -0
- data/lib/pox_paginate/active_support/core_hash_ext.rb +0 -0
- data/lib/pox_paginate/active_support.rb +0 -0
- data/lib/pox_paginate/remote_collection.rb +0 -0
- data/lib/pox_paginate/will_paginate/collection_extensions.rb +0 -0
- data/lib/pox_paginate/will_paginate.rb +0 -0
- data/lib/pox_paginate/xml_mini/jdom.rb +0 -0
- data/lib/pox_paginate/xml_mini/libxml.rb +0 -0
- data/lib/pox_paginate/xml_mini/nokogiri.rb +0 -0
- data/lib/pox_paginate/xml_mini/rexml.rb +0 -0
- data/lib/pox_paginate/xml_mini.rb +0 -0
- data/lib/pox_paginate.rb +12 -1
- data/spec/config/database.yml +0 -0
- data/spec/db/migrate/001_create_oogas.rb +0 -0
- data/spec/pox_paginate/active_resource/xml_format_spec.rb +0 -0
- data/spec/pox_paginate/active_support/core_hash_ext_spec.rb +0 -0
- data/spec/pox_paginate/will_paginate/collection_extensions_spec.rb +0 -0
- data/spec/pox_paginate/xml_mini_spec.rb +0 -0
- data/spec/spec_helper.rb +5 -1
- metadata +71 -23
data/CHANGELOG
ADDED
data/README.rdoc
CHANGED
@@ -1,5 +1,60 @@
|
|
1
|
-
= PoxPaginate
|
1
|
+
= PoxPaginate 0.1.1
|
2
2
|
|
3
3
|
PoxPaginate is an extension to WillPaginate and ActiveResource that makes it possible to transparently paginate over a collection of XML serialised resources.
|
4
4
|
|
5
|
-
|
5
|
+
This gem is based on our experience building largish distributed systems consisting of multiple Rails apps integrated over POX (Plain Old XML). Yes, it is in production. No, unfortunately we aren't allowed to talk about it.
|
6
|
+
|
7
|
+
== Installation
|
8
|
+
|
9
|
+
PoxPaginate is available as a gem.
|
10
|
+
gem install pox_paginate
|
11
|
+
|
12
|
+
and in your Rails environment.rb
|
13
|
+
config.gem "pox_paginate", :version => '>= 0.1.0', :lib => "pox_paginate"
|
14
|
+
|
15
|
+
We also strongly recommend you use Ruby LibXML or Nokogiri rather than the standard REXML for deserialisation. While PoxPaginate supports all three, REXML is simply too slow for use in production. To switch to using either gem:
|
16
|
+
(sudo) gem install libxml-ruby
|
17
|
+
or
|
18
|
+
(sudo) gem install nokogiri
|
19
|
+
|
20
|
+
After this, you need to instruct Rails to use them. In environment.rb, do
|
21
|
+
ActiveSupport::XmlMini.backend = 'LibXML'
|
22
|
+
or
|
23
|
+
ActiveSupport::XmlMini.backend = 'Nokogiri'
|
24
|
+
|
25
|
+
Before you ask, yes we're working on adding support for jdom so PoxPaginate can be used on JRuby :)
|
26
|
+
|
27
|
+
== Usage
|
28
|
+
|
29
|
+
When constructing the xml serialised form of a resource in a controller, add pagination - like so:
|
30
|
+
class ProductsController < ApplicationController
|
31
|
+
|
32
|
+
# GET /products
|
33
|
+
# GET /products.xml
|
34
|
+
def index
|
35
|
+
@products = Product.paginate :page => params[:page], :per_page => params[:per_page]
|
36
|
+
respond_to do |format|
|
37
|
+
format.html # index.html.erb
|
38
|
+
format.xml { render :xml => @products }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
...
|
42
|
+
...
|
43
|
+
...
|
44
|
+
end
|
45
|
+
|
46
|
+
PoxPaginate extends WillPaginate::Collection to add 'current_page,' 'per_page' and 'total_entries' as attributes on the root node of the collection xml.
|
47
|
+
|
48
|
+
On the client, you do the usual:
|
49
|
+
class Product < ActiveResource::Base
|
50
|
+
self.site = 'http://oogabooga.in'
|
51
|
+
end
|
52
|
+
|
53
|
+
Now whenever you do
|
54
|
+
Product.find(:all, :params => {:page => 2, :per_page => 5})
|
55
|
+
|
56
|
+
PoxPaginate will kick in if pagination related attributes are present on the root node, and will result in the creation of a PoxPaginate::RemoteCollection, which is a subclass of WillPaginate::Collection and so behaves in exactly the same manner.
|
57
|
+
|
58
|
+
=== Note
|
59
|
+
* PoxPaginate currently overrides the Hash.from_xml method to fix a bug in Rails that is documented in this {Lighthouse ticket}[https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3217-parsing-an-xml-file-with-multiple-records-and-extra-attributes-besides-type-fails]
|
60
|
+
* PoxPaginate must needs be installed on both the client and the server Rails instance
|
data/Rakefile
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'activesupport', '~> 2.3.5'
|
3
|
+
gem 'rspec', '~> 1.3.0'
|
4
|
+
|
1
5
|
require 'spec'
|
2
6
|
require 'spec/rake/spectask'
|
3
7
|
|
@@ -8,7 +12,6 @@ namespace :spec do
|
|
8
12
|
desc "Run all unit specs"
|
9
13
|
Spec::Rake::SpecTask.new(:unit) do |task|
|
10
14
|
task.spec_files = FileList['spec/pox_paginate/**/*_spec.rb']
|
11
|
-
# task.spec_opts = ['--options', 'spec/spec.opts']
|
12
15
|
end
|
13
16
|
end
|
14
17
|
|
@@ -16,18 +19,21 @@ begin
|
|
16
19
|
require 'jeweler'
|
17
20
|
Jeweler::Tasks.new do |gemspec|
|
18
21
|
gemspec.name = "pox_paginate"
|
19
|
-
gemspec.summary = "Transparent support for pagination using WillPaginate
|
20
|
-
gemspec.description = "
|
22
|
+
gemspec.summary = "Transparent support for pagination using WillPaginate with POX (Plain Old Xml) and ActiveResource"
|
23
|
+
gemspec.description = "Transparent support for pagination using WillPaginate with POX (Plain Old Xml) and ActiveResource. This gem is based on C42 Engineering's experience building largish distributed systems consisting of multiple Rails apps integrated over POX (Plain Old XML)."
|
21
24
|
gemspec.authors = ["Sidu Ponnappa", "Niranjan Paranjape"]
|
22
25
|
gemspec.email = "opensource@c42.in"
|
23
|
-
gemspec.homepage = "http://
|
26
|
+
gemspec.homepage = "http://c42.in/open_source"
|
24
27
|
gemspec.has_rdoc = false
|
25
28
|
gemspec.require_path = "lib"
|
26
29
|
gemspec.files.exclude *['.gitignore']
|
30
|
+
|
27
31
|
gemspec.test_files.exclude *['.gitignore']
|
28
|
-
gemspec.add_dependency('activesupport', '
|
29
|
-
gemspec.add_dependency('activeresource', '
|
30
|
-
gemspec.add_dependency('will_paginate', '
|
32
|
+
gemspec.add_dependency('activesupport', '~> 2.3.5')
|
33
|
+
gemspec.add_dependency('activeresource', '~> 2.3.5')
|
34
|
+
gemspec.add_dependency('will_paginate', '~> 2.3.12')
|
35
|
+
gemspec.add_development_dependency('rspec', '~> 1.3.0')
|
36
|
+
gemspec.add_development_dependency('activerecord', '~> 2.3.5')
|
31
37
|
end
|
32
38
|
|
33
39
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/pox_paginate.rb
CHANGED
@@ -1,7 +1,18 @@
|
|
1
|
+
# Copyright 2009 C42 Engineering
|
2
|
+
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
# Unless required by applicable law or agreed to in writing, software distributed under the License
|
7
|
+
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
8
|
+
# See the License for the specific language governing permissions and limitations under the License.
|
9
|
+
|
1
10
|
require 'rubygems'
|
11
|
+
gem 'activeresource', '~> 2.3.5'
|
12
|
+
gem 'activesupport', '~> 2.3.5'
|
2
13
|
require 'active_resource'
|
3
|
-
require 'will_paginate'
|
4
14
|
require 'active_support'
|
15
|
+
require 'will_paginate'
|
5
16
|
|
6
17
|
module PoxPaginate
|
7
18
|
Root = File.dirname(__FILE__)
|
data/spec/config/database.yml
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pox_paginate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Sidu Ponnappa
|
@@ -10,40 +15,80 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2010-
|
18
|
+
date: 2010-07-29 00:00:00 +05:30
|
14
19
|
default_executable:
|
15
20
|
dependencies:
|
16
21
|
- !ruby/object:Gem::Dependency
|
17
22
|
name: activesupport
|
18
|
-
|
19
|
-
|
20
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
21
25
|
requirements:
|
22
|
-
- -
|
26
|
+
- - ~>
|
23
27
|
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 2
|
30
|
+
- 3
|
31
|
+
- 5
|
24
32
|
version: 2.3.5
|
25
|
-
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
26
35
|
- !ruby/object:Gem::Dependency
|
27
36
|
name: activeresource
|
28
|
-
|
29
|
-
|
30
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
39
|
requirements:
|
32
|
-
- -
|
40
|
+
- - ~>
|
33
41
|
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 2
|
44
|
+
- 3
|
45
|
+
- 5
|
34
46
|
version: 2.3.5
|
35
|
-
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
36
49
|
- !ruby/object:Gem::Dependency
|
37
50
|
name: will_paginate
|
38
|
-
|
39
|
-
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
53
|
requirements:
|
42
|
-
- -
|
54
|
+
- - ~>
|
43
55
|
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 2
|
58
|
+
- 3
|
59
|
+
- 12
|
44
60
|
version: 2.3.12
|
45
|
-
|
46
|
-
|
61
|
+
type: :runtime
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rspec
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ~>
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 1
|
72
|
+
- 3
|
73
|
+
- 0
|
74
|
+
version: 1.3.0
|
75
|
+
type: :development
|
76
|
+
version_requirements: *id004
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: activerecord
|
79
|
+
prerelease: false
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ~>
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
segments:
|
85
|
+
- 2
|
86
|
+
- 3
|
87
|
+
- 5
|
88
|
+
version: 2.3.5
|
89
|
+
type: :development
|
90
|
+
version_requirements: *id005
|
91
|
+
description: Transparent support for pagination using WillPaginate with POX (Plain Old Xml) and ActiveResource. This gem is based on C42 Engineering's experience building largish distributed systems consisting of multiple Rails apps integrated over POX (Plain Old XML).
|
47
92
|
email: opensource@c42.in
|
48
93
|
executables: []
|
49
94
|
|
@@ -52,6 +97,7 @@ extensions: []
|
|
52
97
|
extra_rdoc_files:
|
53
98
|
- README.rdoc
|
54
99
|
files:
|
100
|
+
- CHANGELOG
|
55
101
|
- README.rdoc
|
56
102
|
- Rakefile
|
57
103
|
- VERSION
|
@@ -76,7 +122,7 @@ files:
|
|
76
122
|
- spec/pox_paginate/xml_mini_spec.rb
|
77
123
|
- spec/spec_helper.rb
|
78
124
|
has_rdoc: true
|
79
|
-
homepage: http://
|
125
|
+
homepage: http://c42.in/open_source
|
80
126
|
licenses: []
|
81
127
|
|
82
128
|
post_install_message:
|
@@ -88,21 +134,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
134
|
requirements:
|
89
135
|
- - ">="
|
90
136
|
- !ruby/object:Gem::Version
|
137
|
+
segments:
|
138
|
+
- 0
|
91
139
|
version: "0"
|
92
|
-
version:
|
93
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
141
|
requirements:
|
95
142
|
- - ">="
|
96
143
|
- !ruby/object:Gem::Version
|
144
|
+
segments:
|
145
|
+
- 0
|
97
146
|
version: "0"
|
98
|
-
version:
|
99
147
|
requirements: []
|
100
148
|
|
101
149
|
rubyforge_project:
|
102
|
-
rubygems_version: 1.3.
|
150
|
+
rubygems_version: 1.3.6
|
103
151
|
signing_key:
|
104
152
|
specification_version: 3
|
105
|
-
summary: Transparent support for pagination using WillPaginate
|
153
|
+
summary: Transparent support for pagination using WillPaginate with POX (Plain Old Xml) and ActiveResource
|
106
154
|
test_files:
|
107
155
|
- spec/db/migrate/001_create_oogas.rb
|
108
156
|
- spec/pox_paginate/active_resource/xml_format_spec.rb
|