Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove REXML support altogether. Now we *really* need a new name?

  • Loading branch information...
commit bcf018eb2d097fddbe27c3a7421f000e0f25a5f2 1 parent 7450645
@Empact Empact authored
View
2  History.txt
@@ -2,7 +2,9 @@
* major enhancements
+ * Add Nokogiri
* Remove previously deprecated functionality
+ * Remove REXML support
* Error on any unrecognized options
* Normalize hash declaration syntax:
* for :key => '@string', string is taken to be the :from argument
View
4 README.rdoc
@@ -150,11 +150,11 @@ which may be used via _new_ construction as well as _from_xml_ construction.
== Selecting a parser
-By default, ROXML will use Nokogiri if it is available, followed by LibXML or REXML. If you'd like to
+By default, ROXML will use Nokogiri if it is available, followed by LibXML. If you'd like to
explicitly require one or the other, you may do the following:
module ROXML
- XML_PARSER = 'nokogiri' # or 'libxml' or 'rexml'
+ XML_PARSER = 'nokogiri' # or 'libxml'
end
require 'roxml'
View
2  Rakefile
@@ -33,7 +33,7 @@ end
Dir['tasks/**/*.rake'].each { |t| load t }
task :default => [:test, :spec]
-task :rexml => ['test:rexml', 'spec:rexml']
+task :all => [:libxml, :nokogiri]
task :libxml => ['test:libxml', 'spec:libxml']
task :nokogiri => ['test:nokogiri', 'spec:nokogiri']
View
2  lib/roxml.rb
@@ -17,7 +17,7 @@ def self.included(base) # :nodoc:
end
module InstanceMethods # :nodoc:
- # Returns a LibXML::XML::Node or a REXML::Element representing this object
+ # Returns an XML object representing this object
def to_xml(name = self.class.tag_name)
XML::Node.create(name.to_s).tap do |root|
self.class.roxml_attrs.each do |attr|
View
4 lib/roxml/xml.rb
@@ -10,9 +10,7 @@ module ROXML
parsers.shift
retry
else
- parsers_sentence = PREFERRED_PARSERS.to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ')
- warn %{ROXML is unable to locate #{parsers_sentence} on your system, and so is falling back to the much slower REXML. It's best to check this out and get #{parsers_sentence} working if possible.}
- XML_PARSER = 'rexml' # :nodoc:
+ raise "Could not load either nokogiri or libxml"
end
end
end
View
78 lib/roxml/xml/parsers/rexml.rb
@@ -1,78 +0,0 @@
-require 'rexml/document'
-
-module ROXML
- module XML # :nodoc:all
- Document = REXML::Document
- Node = REXML::Element
-
- module Error; end
- [REXML::ParseException, REXML::UndefinedNamespaceException, REXML::Validation::ValidationException].each do |exception|
- exception.send(:include, Error)
- end
-
- class Node
- class << self
- def new_cdata(content)
- REXML::CData.new(content)
- end
-
- alias :create :new
- end
-
- alias_attribute :content, :text
-
- def search(xpath)
- REXML::XPath.match(self, xpath)
- end
-
- def add_child(element)
- if element.is_a?(REXML::CData)
- REXML::CData.new(element, true, self)
- else
- add_element(element)
- end
- end
-
- def ==(other)
- to_s == other.to_s
- end
- end
-
- class Parser
- class << self
- def parse(source)
- REXML::Document.new(source, :ignore_whitespace_nodes => :all)
- end
-
- def parse_file(path) #:nodoc:
- path = path.sub('file:', '') if path.starts_with?('file:')
- parse(open(path))
- end
-
- def parse_io(path) #:nodoc:
- parse(path)
- end
-
- def register_error_handler(&block)
- end
- end
- ParseError = REXML::ParseException
- end
-
- class Document
- delegate :search, :to => :root
-
- def root=(node)
- raise ArgumentError, "Root is already defined" if root
- add(node)
- end
-
- def save(destination, opts = {:formatter => REXML::Formatters::Default.new})
- self << REXML::XMLDecl.new unless xml_decl != REXML::XMLDecl.default # always output xml declaration
- File.open(destination, "w") do |f|
- opts[:formatter].write(self, f)
- end
- end
- end
- end
-end
View
12 roxml.gemspec
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Ben Woosley", "Zak Mandhro", "Anders Engstrom", "Russ Olsen"]
- s.date = %q{2009-10-12}
+ s.date = %q{2009-10-14}
s.description = %q{ROXML is a Ruby library designed to make it easier for Ruby developers to work with XML.
Using simple annotations, it enables Ruby classes to be mapped to XML. ROXML takes care
of the marshalling and unmarshalling of mapped attributes so that developers can focus on
@@ -49,7 +49,7 @@ RESTful applications, Web Services, and XML-RPC.
"lib/roxml/hash_definition.rb",
"lib/roxml/xml.rb",
"lib/roxml/xml/parsers/libxml.rb",
- "lib/roxml/xml/parsers/rexml.rb",
+ "lib/roxml/xml/parsers/nokogiri.rb",
"lib/roxml/xml/references.rb",
"roxml.gemspec",
"spec/definition_spec.rb",
@@ -64,11 +64,13 @@ RESTful applications, Web Services, and XML-RPC.
"spec/shared_specs.rb",
"spec/spec.opts",
"spec/spec_helper.rb",
+ "spec/support/libxml.rb",
+ "spec/support/nokogiri.rb",
+ "spec/xml/namespace_spec.rb",
"spec/xml/parser_spec.rb",
"tasks/rdoc.rake",
"tasks/rspec.rake",
"tasks/test.rake",
- "test/bugs/rexml_bugs.rb",
"test/fixtures/book_malformed.xml",
"test/fixtures/book_pair.xml",
"test/fixtures/book_text_with_attribute.xml",
@@ -137,8 +139,10 @@ RESTful applications, Web Services, and XML-RPC.
"spec/roxml_spec.rb",
"spec/shared_specs.rb",
"spec/spec_helper.rb",
+ "spec/support/libxml.rb",
+ "spec/support/nokogiri.rb",
+ "spec/xml/namespace_spec.rb",
"spec/xml/parser_spec.rb",
- "test/bugs/rexml_bugs.rb",
"test/mocks/dictionaries.rb",
"test/mocks/mocks.rb",
"test/support/fixtures.rb",
View
3  spec/support/rexml.rb
@@ -1,3 +0,0 @@
-module ROXML
- XML_PARSER = 'rexml'
-end
View
33 spec/xml/parser_spec.rb
@@ -15,41 +15,12 @@
it "should escape invalid characters on output to text node" do
node = ROXML::XML::Node.create("entities")
node.content = " < > ' \" & "
- case ROXML::XML_PARSER
- when 'libxml', 'nokogiri'
- node.to_s.should == "<entities> &lt; &gt; ' \" &amp; </entities>"
- when 'rexml'
- node.to_s.should == "<entities> &lt; &gt; &apos; &quot; &amp; </entities>"
- else
- raise "Unrecognized Parser"
- end
+ node.to_s.should == "<entities> &lt; &gt; ' \" &amp; </entities>"
end
it "should esape invalid characters for attribute name" do
node = ROXML::XML::Node.create("attr_holder")
node.attributes["entities"] = "\"'<>&"
- case ROXML::XML_PARSER
- when 'libxml', 'nokogiri'
- node.to_s.should == %{<attr_holder entities="&quot;'&lt;&gt;&amp;"/>}
- when 'rexml'
- node.to_s.should == %{<attr_holder entities='&quot;&apos;&lt;&gt;&amp;'/>}
- else
- raise "Unrecognized Parser"
- end
+ node.to_s.should == %{<attr_holder entities="&quot;'&lt;&gt;&amp;"/>}
end
end
-
-describe ROXML::XML::Document do
- describe "#save" do
- context "with rexml parser" do
- it "should defer to existing XMLDecl" do
- if ROXML::XML_PARSER == 'rexml'
- @doc = ROXML::XML::Document.new
- @doc << REXML::XMLDecl.new('1.1')
- @doc.save('spec/xml/decl_test.xml')
- ROXML::XML::Parser.parse(File.read('spec/xml/decl_test.xml')).to_s.should == ROXML::XML::Parser.parse(%{<?xml version="1.1"?>}).to_s
- end
- end
- end
- end
-end
View
2  tasks/rspec.rake
@@ -7,7 +7,7 @@ Spec::Rake::SpecTask.new(:spec) do |spec|
end
namespace :spec do
- [:rexml, :libxml, :nokogiri].each do |parser|
+ [:libxml, :nokogiri].each do |parser|
desc "Spec ROXML under the #{parser} parser"
Spec::Rake::SpecTask.new(parser) do |spec|
spec.libs << 'lib' << 'spec' << 'examples'
View
8 tasks/test.rake
@@ -28,14 +28,6 @@ namespace :test do
Rake::Task["test"].invoke
end
- desc "Test ROXML under the REXML parser"
- task :rexml do
- module ROXML
- XML_PARSER = 'rexml'
- end
- Rake::Task["test"].invoke
- end
-
desc "Runs tests under RCOV"
task :rcov do
system "rcov -T --no-html -x '^/' #{FileList['test/unit/*_test.rb']}"
View
15 test/bugs/rexml_bugs.rb
@@ -1,15 +0,0 @@
-require 'test/test_helper'
-
-class RexmlBugs < ActiveSupport::TestCase
- def test_that_some_illegal_chars_are_parsed_without_complaint
- p "REXML ignores illegal ']]>' brackets in xml content"
- assert_nothing_raised do
- # The right angle bracket (>) may be represented using the string "&gt;", and MUST, for compatibility,
- # be escaped using either "&gt;" or a character reference when it appears in the string "]]>" in content,
- # when that string is not marking the end of a CDATA section.
- # - http://www.w3.org/TR/xml11/#syntax
- xml = "<title>The Big Book of ]]> everything more</title>"
- assert_equal xml, REXML::Document.new(xml).to_s
- end
- end
-end
View
8 test/unit/xml_namespace_test.rb
@@ -17,14 +17,6 @@ def test_default_namespace_is_applied_to_in_element
end
end
- def test_that_rexml_follows_nameless_default_namespace
- require 'rexml/document'
- xml = REXML::Document.new(
- '<container xmlns="http://fakenamespace.org"><node>Yeah, content</node></container>')
-
- assert_equal "Yeah, content", xml.root.get_elements('node').first.text
- end
-
def test_default_namespace_on_root_node_should_be_found
require 'libxml'
xml = LibXML::XML::Parser.string(
View
2  website/index.html
@@ -49,7 +49,7 @@
<span class="small">by <a href="http://github.com/Empact">Empact</a></small></h1>
<div class="description">
- ROXML is a module for binding Ruby classes to XML. It supports custom mapping and bidirectional marshaling between Ruby and XML using annotation-style class methods. ROXML supports the LibXML and REXML XML processors.
+ ROXML is a module for binding Ruby classes to XML. It supports custom mapping and bidirectional marshaling between Ruby and XML using annotation-style class methods. ROXML supports the Nokogiri and LibXML XML processors.
</div>
<p>We may not want to work with XML, but we don't always get to pick just how our data comes. If you do need to do serious work with XML, ROXML is here to make it nice.
Please sign in to comment.
Something went wrong with that request. Please try again.