From 68ada997a819c6bff3ddd2f0c9be306250d6182f Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Thu, 26 Mar 2015 00:35:28 +0100 Subject: [PATCH] Moved default namespace into Oga::XML The default namespace is now located at Oga::XML::DEFAULT_NAMESPACE instead of Oga::XML::Attribute::DEFAULT_NAMESPACE. --- lib/oga.rb | 1 + lib/oga/xml/attribute.rb | 11 ----------- lib/oga/xml/default_namespace.rb | 13 +++++++++++++ spec/oga/xml/attribute_spec.rb | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 lib/oga/xml/default_namespace.rb diff --git a/lib/oga.rb b/lib/oga.rb index 797fab7..b53f8da 100644 --- a/lib/oga.rb +++ b/lib/oga.rb @@ -34,6 +34,7 @@ require_relative 'oga/xml/xml_declaration' require_relative 'oga/xml/processing_instruction' require_relative 'oga/xml/doctype' require_relative 'oga/xml/namespace' +require_relative 'oga/xml/default_namespace' require_relative 'oga/xml/attribute' require_relative 'oga/xml/element' require_relative 'oga/xml/node_set' diff --git a/lib/oga/xml/attribute.rb b/lib/oga/xml/attribute.rb index d291c4f..9a227de 100644 --- a/lib/oga/xml/attribute.rb +++ b/lib/oga/xml/attribute.rb @@ -21,17 +21,6 @@ module Oga class Attribute attr_accessor :name, :namespace_name, :element, :value - ## - # The default namespace available to all attributes. This namespace can - # not be modified. - # - # @return [Oga::XML::Namespace] - # - DEFAULT_NAMESPACE = Namespace.new( - :name => 'xml', - :uri => 'http://www.w3.org/XML/1998/namespace' - ).freeze - ## # @param [Hash] options # diff --git a/lib/oga/xml/default_namespace.rb b/lib/oga/xml/default_namespace.rb new file mode 100644 index 0000000..fab44b4 --- /dev/null +++ b/lib/oga/xml/default_namespace.rb @@ -0,0 +1,13 @@ +module Oga + module XML + ## + # The default XML namespace. + # + # @return [Oga::XML::Namespace] + # + DEFAULT_NAMESPACE = Namespace.new( + :name => 'xml', + :uri => 'http://www.w3.org/XML/1998/namespace' + ).freeze + end # XML +end # Oga diff --git a/spec/oga/xml/attribute_spec.rb b/spec/oga/xml/attribute_spec.rb index 686e1bf..0afc4b5 100644 --- a/spec/oga/xml/attribute_spec.rb +++ b/spec/oga/xml/attribute_spec.rb @@ -33,7 +33,7 @@ describe Oga::XML::Attribute do end it 'returns the default XML namespace when the "xml" prefix is used' do - @default.namespace.should == Oga::XML::Attribute::DEFAULT_NAMESPACE + @default.namespace.should == Oga::XML::DEFAULT_NAMESPACE end end