pox_paginate 0.2.0.beta1 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format documentation
data/CHANGELOG CHANGED
@@ -1,4 +1,5 @@
1
- == Coming soon
1
+ == 0.2.0
2
+ * Rails 3.0.0 compatibility
2
3
  * jRuby support with jdom
3
4
 
4
5
  == 0.2.0.beta1
data/Gemfile CHANGED
@@ -1,12 +1,19 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem 'activeresource', '~> 3.0.0.rc2'
4
- gem 'activesupport', '~> 3.0.0.rc2'
3
+ gem 'activeresource', '~> 3.0.0'
4
+ gem 'activesupport', '~> 3.0.0'
5
5
  gem 'will_paginate', '~> 3.0.pre2'
6
+
6
7
  group :test do
7
- gem 'activerecord', '~> 3.0.0.rc2'
8
+ gem 'activerecord', '~> 3.0.0'
8
9
  gem 'rspec', '~> 2.0.0.beta.20'
9
- gem 'sqlite3-ruby', '~> 1.3.1'
10
- gem 'nokogiri', '~> 1.4.3.1'
11
- gem 'libxml-ruby', '~> 1.1.4'
10
+ platforms :jruby do
11
+ gem 'jdbc-sqlite3', '~> 3.6.3.054'
12
+ gem 'activerecord-jdbcsqlite3-adapter', '~> 0.9.7'
13
+ end
14
+ platforms :ruby do
15
+ gem 'sqlite3-ruby', '~> 1.3.1'
16
+ gem 'nokogiri', '~> 1.4.3.1'
17
+ gem 'libxml-ruby', '~> 1.1.4'
18
+ end
12
19
  end
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = PoxPaginate 0.1.1
1
+ = PoxPaginate 0.2.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
 
@@ -6,23 +6,23 @@ This gem is based on our experience building largish distributed systems consist
6
6
 
7
7
  == Installation
8
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
-
9
+ PoxPaginate is available as a gem. In your Gemfile add
10
+ gem 'pox_paginate', '~> 0.2.1'
11
+
15
12
  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
13
+ gem 'nokogiri', '~> 1.4.3.1'
17
14
  or
18
- (sudo) gem install nokogiri
15
+ gem 'libxml-ruby', '~> 1.1.4'
16
+
17
+ * These gems are not added in the Gemfile
19
18
 
20
- After this, you need to instruct Rails to use them. In environment.rb, do
19
+ After this, you need to instruct Rails to use them. In application.rb, do
21
20
  ActiveSupport::XmlMini.backend = 'LibXML'
22
21
  or
23
22
  ActiveSupport::XmlMini.backend = 'Nokogiri'
24
23
 
25
- Before you ask, yes we're working on adding support for jdom so PoxPaginate can be used on JRuby :)
24
+ JDOM is supported as a backend on JRuby
25
+ ActiveSupport::XmlMini.backend = 'JDOM'
26
26
 
27
27
  == Usage
28
28
 
@@ -76,4 +76,5 @@ If your patch is accepted, we will add you to the 'Contributors' section of the
76
76
  == Contributors
77
77
 
78
78
  * {Sidu Ponnappa}[http://github.com/kaiwren]
79
- * {Niranjan Paranjape}[http://github.com/niranjan]
79
+ * {Niranjan Paranjape}[http://github.com/niranjan]
80
+ * {Jean-Denis Vauguet}[http://github.com/chikamichi]
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  puts "Building on Ruby #{RUBY_VERSION}, #{RUBY_RELEASE_DATE}, #{RUBY_PLATFORM}"
2
2
 
3
3
  require 'rubygems'
4
- gem 'activesupport', '~> 3.0.0.rc2'
4
+ gem 'activesupport', '~> 3.0.0'
5
5
  gem 'rspec', '~> 2.0.0.beta.20'
6
6
 
7
7
  require 'rake'
@@ -34,11 +34,11 @@ begin
34
34
  gemspec.files.exclude *['.gitignore']
35
35
 
36
36
  gemspec.test_files.exclude *['.gitignore']
37
- gemspec.add_dependency('activesupport', '~> 3.0.0.rc2')
38
- gemspec.add_dependency('activeresource', '~> 3.0.0.rc2')
37
+ gemspec.add_dependency('activesupport', '~> 3.0.0')
38
+ gemspec.add_dependency('activeresource', '~> 3.0.0')
39
39
  gemspec.add_dependency('will_paginate', '~> 3.0.pre2')
40
40
  gemspec.add_development_dependency('rspec', '~> 2.0.0.beta.20')
41
- gemspec.add_development_dependency('activerecord', '~> 3.0.0.rc2')
41
+ gemspec.add_development_dependency('activerecord', '~> 3.0.0')
42
42
  gemspec.add_development_dependency('sqlite3-ruby', '~> 1.3.1')
43
43
  gemspec.add_development_dependency('nokogiri', '~> 1.4.3.1')
44
44
  gemspec.add_development_dependency('libxml-ruby', '~> 1.1.4')
@@ -47,6 +47,6 @@ begin
47
47
 
48
48
  Jeweler::GemcutterTasks.new
49
49
  rescue LoadError
50
- puts "Jeweler not available. Install it with: gem install technicalpickles-jeweler -s http://gems.github.com"
50
+ puts "Jeweler not available. Install it with: gem install jeweler"
51
51
  puts "If you're using JRuby and are having trouble installing jeweler, try installing the git (gem install git) and rubyforge (gem install rubyforge) gems by hand. Also remember to update gems itself (jruby -S gem update --system)."
52
52
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0.beta1
1
+ 0.2.1
data/lib/pox_paginate.rb CHANGED
@@ -21,6 +21,7 @@ module PoxPaginate
21
21
  Root = File.dirname(__FILE__)
22
22
  end
23
23
 
24
+ require "#{PoxPaginate::Root}/pox_paginate/version"
24
25
  require "#{PoxPaginate::Root}/pox_paginate/active_support"
25
26
  require "#{PoxPaginate::Root}/pox_paginate/remote_collection"
26
27
  require "#{PoxPaginate::Root}/pox_paginate/active_resource"
@@ -0,0 +1,5 @@
1
+ module PoxPaginate # :nodoc:
2
+ module Version # :nodoc:
3
+ STRING = File.readlines(File.expand_path('../../../VERSION', __FILE__)).first
4
+ end
5
+ end
@@ -1,8 +1,28 @@
1
+ include Java
2
+
3
+ import javax.xml.parsers.DocumentBuilder unless defined? DocumentBuilder
4
+ import javax.xml.parsers.DocumentBuilderFactory unless defined? DocumentBuilderFactory
5
+ import java.io.StringReader unless defined? StringReader
6
+ import org.xml.sax.InputSource unless defined? InputSource
7
+ import org.xml.sax.Attributes unless defined? Attributes
8
+ import org.w3c.dom.Node unless defined? Node
9
+
1
10
  module PoxPaginate
2
11
  module XmlMini
3
12
  module JDOM
4
13
  def root_node_attributes(xml)
14
+ dbf = DocumentBuilderFactory.new_instance
15
+ xml_string_reader = StringReader.new(xml)
16
+ xml_input_source = InputSource.new(xml_string_reader)
17
+ doc = dbf.new_document_builder.parse(xml_input_source)
18
+ attribute_hash = {}
19
+ attributes = doc.document_element.attributes
20
+ for i in 0...attributes.length
21
+ attribute_hash[attributes.item(i).name] = attributes.item(i).value
22
+ end
23
+ attribute_hash
5
24
  end
25
+
6
26
  end
7
27
  end
8
28
  end
data/pox_paginate.gemspec CHANGED
@@ -5,18 +5,19 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pox_paginate}
8
- s.version = "0.2.0.beta1"
8
+ s.version = "0.2.1"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sidu Ponnappa", "Niranjan Paranjape"]
12
- s.date = %q{2010-08-28}
12
+ s.date = %q{2010-09-14}
13
13
  s.description = %q{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).}
14
14
  s.email = %q{opensource@c42.in}
15
15
  s.extra_rdoc_files = [
16
16
  "README.rdoc"
17
17
  ]
18
18
  s.files = [
19
- "CHANGELOG",
19
+ ".rspec",
20
+ "CHANGELOG",
20
21
  "Gemfile",
21
22
  "README.rdoc",
22
23
  "Rakefile",
@@ -28,6 +29,7 @@ Gem::Specification.new do |s|
28
29
  "lib/pox_paginate/active_support.rb",
29
30
  "lib/pox_paginate/active_support/core_hash_ext.rb",
30
31
  "lib/pox_paginate/remote_collection.rb",
32
+ "lib/pox_paginate/version.rb",
31
33
  "lib/pox_paginate/will_paginate.rb",
32
34
  "lib/pox_paginate/will_paginate/collection_extensions.rb",
33
35
  "lib/pox_paginate/xml_mini.rb",
@@ -63,30 +65,30 @@ Gem::Specification.new do |s|
63
65
  s.specification_version = 3
64
66
 
65
67
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
66
- s.add_runtime_dependency(%q<activesupport>, ["~> 3.0.0.rc2"])
67
- s.add_runtime_dependency(%q<activeresource>, ["~> 3.0.0.rc2"])
68
+ s.add_runtime_dependency(%q<activesupport>, ["~> 3.0.0"])
69
+ s.add_runtime_dependency(%q<activeresource>, ["~> 3.0.0"])
68
70
  s.add_runtime_dependency(%q<will_paginate>, ["~> 3.0.pre2"])
69
71
  s.add_development_dependency(%q<rspec>, ["~> 2.0.0.beta.20"])
70
- s.add_development_dependency(%q<activerecord>, ["~> 3.0.0.rc2"])
72
+ s.add_development_dependency(%q<activerecord>, ["~> 3.0.0"])
71
73
  s.add_development_dependency(%q<sqlite3-ruby>, ["~> 1.3.1"])
72
74
  s.add_development_dependency(%q<nokogiri>, ["~> 1.4.3.1"])
73
75
  s.add_development_dependency(%q<libxml-ruby>, ["~> 1.1.4"])
74
76
  else
75
- s.add_dependency(%q<activesupport>, ["~> 3.0.0.rc2"])
76
- s.add_dependency(%q<activeresource>, ["~> 3.0.0.rc2"])
77
+ s.add_dependency(%q<activesupport>, ["~> 3.0.0"])
78
+ s.add_dependency(%q<activeresource>, ["~> 3.0.0"])
77
79
  s.add_dependency(%q<will_paginate>, ["~> 3.0.pre2"])
78
80
  s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.20"])
79
- s.add_dependency(%q<activerecord>, ["~> 3.0.0.rc2"])
81
+ s.add_dependency(%q<activerecord>, ["~> 3.0.0"])
80
82
  s.add_dependency(%q<sqlite3-ruby>, ["~> 1.3.1"])
81
83
  s.add_dependency(%q<nokogiri>, ["~> 1.4.3.1"])
82
84
  s.add_dependency(%q<libxml-ruby>, ["~> 1.1.4"])
83
85
  end
84
86
  else
85
- s.add_dependency(%q<activesupport>, ["~> 3.0.0.rc2"])
86
- s.add_dependency(%q<activeresource>, ["~> 3.0.0.rc2"])
87
+ s.add_dependency(%q<activesupport>, ["~> 3.0.0"])
88
+ s.add_dependency(%q<activeresource>, ["~> 3.0.0"])
87
89
  s.add_dependency(%q<will_paginate>, ["~> 3.0.pre2"])
88
90
  s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.20"])
89
- s.add_dependency(%q<activerecord>, ["~> 3.0.0.rc2"])
91
+ s.add_dependency(%q<activerecord>, ["~> 3.0.0"])
90
92
  s.add_dependency(%q<sqlite3-ruby>, ["~> 1.3.1"])
91
93
  s.add_dependency(%q<nokogiri>, ["~> 1.4.3.1"])
92
94
  s.add_dependency(%q<libxml-ruby>, ["~> 1.1.4"])
@@ -1,9 +1,13 @@
1
1
  require File.dirname(__FILE__) + '/../../spec_helper'
2
2
 
3
3
  describe PoxPaginate::ActiveResource::XmlFormat do
4
- it "should foo" do
5
- ::ActiveSupport::XmlMini.backend = 'LibXML'
6
- collection = ActiveResource::Formats::XmlFormat.decode(paginated_xml(DateTime.parse('2010-02-06T21:09:48+05:30')))
7
- collection.should be_a(PoxPaginate::RemoteCollection)
4
+ xml_backends.each do |deserialiser|
5
+ context "using #{deserialiser}" do
6
+ it "should create a RemoteCollection after parsing paginated array" do
7
+ ::ActiveSupport::XmlMini.backend = deserialiser
8
+ collection = ActiveResource::Formats::XmlFormat.decode(paginated_xml(DateTime.parse('2010-02-06T21:09:48+05:30')))
9
+ collection.should be_a(PoxPaginate::RemoteCollection)
10
+ end
11
+ end
8
12
  end
9
13
  end
@@ -9,10 +9,6 @@ describe 'XmlSerializer Extensions' do
9
9
  Ooga.create!(:name => 'Woot')
10
10
  end
11
11
 
12
- it "should ooga" do
13
- Ooga.count.should == 5
14
- end
15
-
16
12
  it "should serialize to xml with root node attributes containing pagination metadata" do
17
13
  page = Ooga.paginate :page => 2, :per_page => 2
18
14
  xml = page.to_xml
@@ -5,8 +5,8 @@ describe PoxPaginate::XmlMini do
5
5
  @date = DateTime.parse('2010-02-06T21:09:48+05:30')
6
6
  end
7
7
 
8
- %w(REXML LibXML Nokogiri).each do |deserialiser|
9
- describe "using #{deserialiser}" do
8
+ xml_backends.each do |deserialiser|
9
+ context "using #{deserialiser}" do
10
10
  before :all do
11
11
  ActiveSupport::XmlMini.backend = deserialiser
12
12
  end
@@ -38,10 +38,10 @@ describe PoxPaginate::XmlMini do
38
38
 
39
39
  it "should not add root node attributes if there are none" do
40
40
  ActiveSupport::XmlMini.root_node_attributes(unpaginated_xml(@date)).should == {
41
- 'type' => "array",
41
+ 'type' => "array"
42
42
  }
43
+ ActiveSupport::XmlMini.root_node_attributes({:test => "Ooga"}.to_xml).should == {}
43
44
  end
44
-
45
45
  end
46
46
  end
47
47
  end
data/spec/spec_helper.rb CHANGED
@@ -55,3 +55,7 @@ def unpaginated_xml(date)
55
55
  </oogas>
56
56
  EOXML
57
57
  end
58
+
59
+ def xml_backends
60
+ RUBY_PLATFORM =~ /java/ ? %w(REXML JDOM) : %w(REXML LibXML Nokogiri)
61
+ end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pox_paginate
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1848230051
5
- prerelease: true
4
+ hash: 21
5
+ prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- - beta1
11
- version: 0.2.0.beta1
9
+ - 1
10
+ version: 0.2.1
12
11
  platform: ruby
13
12
  authors:
14
13
  - Sidu Ponnappa
@@ -17,7 +16,7 @@ autorequire:
17
16
  bindir: bin
18
17
  cert_chain: []
19
18
 
20
- date: 2010-08-28 00:00:00 +05:30
19
+ date: 2010-09-14 00:00:00 +05:30
21
20
  default_executable:
22
21
  dependencies:
23
22
  - !ruby/object:Gem::Dependency
@@ -28,13 +27,12 @@ dependencies:
28
27
  requirements:
29
28
  - - ~>
30
29
  - !ruby/object:Gem::Version
31
- hash: 977940607
30
+ hash: 7
32
31
  segments:
33
32
  - 3
34
33
  - 0
35
34
  - 0
36
- - rc2
37
- version: 3.0.0.rc2
35
+ version: 3.0.0
38
36
  type: :runtime
39
37
  version_requirements: *id001
40
38
  - !ruby/object:Gem::Dependency
@@ -45,13 +43,12 @@ dependencies:
45
43
  requirements:
46
44
  - - ~>
47
45
  - !ruby/object:Gem::Version
48
- hash: 977940607
46
+ hash: 7
49
47
  segments:
50
48
  - 3
51
49
  - 0
52
50
  - 0
53
- - rc2
54
- version: 3.0.0.rc2
51
+ version: 3.0.0
55
52
  type: :runtime
56
53
  version_requirements: *id002
57
54
  - !ruby/object:Gem::Dependency
@@ -96,13 +93,12 @@ dependencies:
96
93
  requirements:
97
94
  - - ~>
98
95
  - !ruby/object:Gem::Version
99
- hash: 977940607
96
+ hash: 7
100
97
  segments:
101
98
  - 3
102
99
  - 0
103
100
  - 0
104
- - rc2
105
- version: 3.0.0.rc2
101
+ version: 3.0.0
106
102
  type: :development
107
103
  version_requirements: *id005
108
104
  - !ruby/object:Gem::Dependency
@@ -163,6 +159,7 @@ extensions: []
163
159
  extra_rdoc_files:
164
160
  - README.rdoc
165
161
  files:
162
+ - .rspec
166
163
  - CHANGELOG
167
164
  - Gemfile
168
165
  - README.rdoc
@@ -175,6 +172,7 @@ files:
175
172
  - lib/pox_paginate/active_support.rb
176
173
  - lib/pox_paginate/active_support/core_hash_ext.rb
177
174
  - lib/pox_paginate/remote_collection.rb
175
+ - lib/pox_paginate/version.rb
178
176
  - lib/pox_paginate/will_paginate.rb
179
177
  - lib/pox_paginate/will_paginate/collection_extensions.rb
180
178
  - lib/pox_paginate/xml_mini.rb
@@ -211,14 +209,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
211
209
  required_rubygems_version: !ruby/object:Gem::Requirement
212
210
  none: false
213
211
  requirements:
214
- - - ">"
212
+ - - ">="
215
213
  - !ruby/object:Gem::Version
216
- hash: 25
214
+ hash: 3
217
215
  segments:
218
- - 1
219
- - 3
220
- - 1
221
- version: 1.3.1
216
+ - 0
217
+ version: "0"
222
218
  requirements: []
223
219
 
224
220
  rubyforge_project: