diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-18 21:19:18 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-18 21:19:18 +0000 |
commit | 7bbf2f308580f468802cd7d32c94fce1b9f1779e (patch) | |
tree | 0a680f59e70a78d60e776d7b763e618fb2fec624 /lib/rexml | |
parent | 34276148c4450faa77bb298cfbe005f7c263f802 (diff) |
* lib: Convert tabs to spaces for ruby files per
http://redmine.ruby-lang.org/projects/ruby/wiki/DeveloperHowto#coding-style
Patch by Steve Klabnik [Ruby 1.9 - Bug #4730]
Patch by Jason Dew [Ruby 1.9 - Feature #4718]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml')
-rw-r--r-- | lib/rexml/cdata.rb | 18 | ||||
-rw-r--r-- | lib/rexml/child.rb | 2 | ||||
-rw-r--r-- | lib/rexml/comment.rb | 12 | ||||
-rw-r--r-- | lib/rexml/document.rb | 20 | ||||
-rw-r--r-- | lib/rexml/element.rb | 52 | ||||
-rw-r--r-- | lib/rexml/light/node.rb | 14 | ||||
-rw-r--r-- | lib/rexml/node.rb | 12 | ||||
-rw-r--r-- | lib/rexml/parsers/lightparser.rb | 8 | ||||
-rw-r--r-- | lib/rexml/parsers/sax2parser.rb | 12 | ||||
-rw-r--r-- | lib/rexml/parsers/ultralightparser.rb | 8 | ||||
-rw-r--r-- | lib/rexml/quickpath.rb | 90 | ||||
-rw-r--r-- | lib/rexml/xpath.rb | 10 |
12 files changed, 129 insertions, 129 deletions
diff --git a/lib/rexml/cdata.rb b/lib/rexml/cdata.rb index e1235d60f8..496c6ec9fe 100644 --- a/lib/rexml/cdata.rb +++ b/lib/rexml/cdata.rb @@ -6,15 +6,15 @@ module REXML STOP = ']]>' ILLEGAL = /(\]\]>)/ - # Constructor. CData is data between <![CDATA[ ... ]]> - # - # _Examples_ - # CData.new( source ) - # CData.new( "Here is some CDATA" ) - # CData.new( "Some unprocessed data", respect_whitespace_TF, parent_element ) - def initialize( first, whitespace=true, parent=nil ) - super( first, whitespace, parent, false, true, ILLEGAL ) - end + # Constructor. CData is data between <![CDATA[ ... ]]> + # + # _Examples_ + # CData.new( source ) + # CData.new( "Here is some CDATA" ) + # CData.new( "Some unprocessed data", respect_whitespace_TF, parent_element ) + def initialize( first, whitespace=true, parent=nil ) + super( first, whitespace, parent, false, true, ILLEGAL ) + end # Make a copy of this object # diff --git a/lib/rexml/child.rb b/lib/rexml/child.rb index de84a312fe..d0b4e352fa 100644 --- a/lib/rexml/child.rb +++ b/lib/rexml/child.rb @@ -7,7 +7,7 @@ module REXML # class directly. class Child include Node - attr_reader :parent # The Parent of this object + attr_reader :parent # The Parent of this object # Constructor. Any inheritors of this class should call super to make # sure this method is called. diff --git a/lib/rexml/comment.rb b/lib/rexml/comment.rb index e401090376..d5bb65c51a 100644 --- a/lib/rexml/comment.rb +++ b/lib/rexml/comment.rb @@ -38,15 +38,15 @@ module REXML # See REXML::Formatters # # output:: - # Where to write the string + # Where to write the string # indent:: - # An integer. If -1, no indenting will be used; otherwise, the - # indentation will be this number of spaces, and children will be - # indented an additional amount. + # An integer. If -1, no indenting will be used; otherwise, the + # indentation will be this number of spaces, and children will be + # indented an additional amount. # transitive:: - # Ignored by this class. The contents of comments are never modified. + # Ignored by this class. The contents of comments are never modified. # ie_hack:: - # Needed for conformity to the child API, but not used by this class. + # Needed for conformity to the child API, but not used by this class. def write( output, indent=-1, transitive=false, ie_hack=false ) Kernel.warn("Comment.write is deprecated. See REXML::Formatters") indent( output, indent ) diff --git a/lib/rexml/document.rb b/lib/rexml/document.rb index 790a1c78db..b4d7aa7e7d 100644 --- a/lib/rexml/document.rb +++ b/lib/rexml/document.rb @@ -165,7 +165,7 @@ module REXML # Document.new("<a><b/></a>").serialize( tr ) # # output:: - # output an object which supports '<< string'; this is where the + # output an object which supports '<< string'; this is where the # document will be written. # indent:: # An integer. If -1, no indenting will be used; otherwise, the @@ -188,15 +188,15 @@ module REXML output = Output.new( output, xml_decl.encoding ) end formatter = if indent > -1 - if transitive - require "rexml/formatters/transitive" - REXML::Formatters::Transitive.new( indent, ie_hack ) - else - REXML::Formatters::Pretty.new( indent, ie_hack ) - end - else - REXML::Formatters::Default.new( ie_hack ) - end + if transitive + require "rexml/formatters/transitive" + REXML::Formatters::Transitive.new( indent, ie_hack ) + else + REXML::Formatters::Pretty.new( indent, ie_hack ) + end + else + REXML::Formatters::Default.new( ie_hack ) + end formatter.write( self, output ) end diff --git a/lib/rexml/element.rb b/lib/rexml/element.rb index 97fbd0645b..0650824d6d 100644 --- a/lib/rexml/element.rb +++ b/lib/rexml/element.rb @@ -20,7 +20,7 @@ module REXML class Element < Parent include Namespace - UNDEFINED = "UNDEFINED"; # The default name + UNDEFINED = "UNDEFINED"; # The default name # Mechanisms for accessing attributes and child elements of this # element. @@ -31,17 +31,17 @@ module REXML # Constructor # arg:: - # if not supplied, will be set to the default value. - # If a String, the name of this object will be set to the argument. - # If an Element, the object will be shallowly cloned; name, - # attributes, and namespaces will be copied. Children will +not+ be - # copied. + # if not supplied, will be set to the default value. + # If a String, the name of this object will be set to the argument. + # If an Element, the object will be shallowly cloned; name, + # attributes, and namespaces will be copied. Children will +not+ be + # copied. # parent:: - # if supplied, must be a Parent, and will be used as - # the parent of this object. + # if supplied, must be a Parent, and will be used as + # the parent of this object. # context:: - # If supplied, must be a hash containing context items. Context items - # include: + # If supplied, must be a hash containing context items. Context items + # include: # * <tt>:respect_whitespace</tt> the value of this is :+all+ or an array of # strings being the names of the elements to respect # whitespace for. Defaults to :+all+. @@ -297,7 +297,7 @@ module REXML el = @elements.add(element) attrs.each do |key, value| el.attributes[key]=value - end if attrs.kind_of? Hash + end if attrs.kind_of? Hash el end @@ -667,7 +667,7 @@ module REXML # # Writes out this element, and recursively, all children. # output:: - # output an object which supports '<< string'; this is where the + # output an object which supports '<< string'; this is where the # document will be written. # indent:: # An integer. If -1, no indenting will be used; otherwise, the @@ -690,15 +690,15 @@ module REXML def write(output=$stdout, indent=-1, transitive=false, ie_hack=false) Kernel.warn("#{self.class.name}.write is deprecated. See REXML::Formatters") formatter = if indent > -1 - if transitive - require "rexml/formatters/transitive" - REXML::Formatters::Transitive.new( indent, ie_hack ) - else - REXML::Formatters::Pretty.new( indent, ie_hack ) - end - else - REXML::Formatters::Default.new( ie_hack ) - end + if transitive + require "rexml/formatters/transitive" + REXML::Formatters::Transitive.new( indent, ie_hack ) + else + REXML::Formatters::Pretty.new( indent, ie_hack ) + end + else + REXML::Formatters::Default.new( ie_hack ) + end formatter.write( self, output ) end @@ -778,7 +778,7 @@ module REXML else return XPath::first( @element, index ) #{ |element| - # return element if element.kind_of? Element + # return element if element.kind_of? Element #} #return nil end @@ -1086,7 +1086,7 @@ module REXML # doc.root.attributes['foo'] = '4' # doc.root.attributes['x:foo'] = nil def []=( name, value ) - if value.nil? # Delete the named attribute + if value.nil? # Delete the named attribute attr = get_attribute(name) delete attr return @@ -1116,8 +1116,8 @@ module REXML value.prefix != "xmlns" and old_attr.prefix != "xmlns" and @element.namespace( old_attr.prefix ) == @element.namespace( value.prefix ) - store value.name, { old_attr.prefix => old_attr, - value.prefix => value } + store value.name, { old_attr.prefix => old_attr, + value.prefix => value } else store value.name, value end @@ -1236,7 +1236,7 @@ module REXML ( !namespace.empty? || !attribute.fully_expanded_name.index(':') ) # foo will match xmlns:foo, but only if foo isn't also an attribute result = attribute if !result or !namespace.empty? or - !attribute.fully_expanded_name.index(':') + !attribute.fully_expanded_name.index(':') end } result diff --git a/lib/rexml/light/node.rb b/lib/rexml/light/node.rb index c8701f3abb..07effd0705 100644 --- a/lib/rexml/light/node.rb +++ b/lib/rexml/light/node.rb @@ -1,13 +1,13 @@ require 'rexml/xmltokens' # [ :element, parent, name, attributes, children* ] - # a = Node.new - # a << "B" # => <a>B</a> - # a.b # => <a>B<b/></a> - # a.b[1] # => <a>B<b/><b/><a> - # a.b[1]["x"] = "y" # => <a>B<b/><b x="y"/></a> - # a.b[0].c # => <a>B<b><c/></b><b x="y"/></a> - # a.b.c << "D" # => <a>B<b><c>D</c></b><b x="y"/></a> +# a = Node.new +# a << "B" # => <a>B</a> +# a.b # => <a>B<b/></a> +# a.b[1] # => <a>B<b/><b/><a> +# a.b[1]["x"] = "y" # => <a>B<b/><b x="y"/></a> +# a.b[0].c # => <a>B<b><c/></b><b x="y"/></a> +# a.b.c << "D" # => <a>B<b><c>D</c></b><b x="y"/></a> module REXML module Light # Represents a tagged XML element. Elements are characterized by diff --git a/lib/rexml/node.rb b/lib/rexml/node.rb index 85457f1ad0..dabf7a931b 100644 --- a/lib/rexml/node.rb +++ b/lib/rexml/node.rb @@ -36,12 +36,12 @@ module REXML end def indent to, ind - if @parent and @parent.context and not @parent.context[:indentstyle].nil? then - indentstyle = @parent.context[:indentstyle] - else - indentstyle = ' ' - end - to << indentstyle*ind unless ind<1 + if @parent and @parent.context and not @parent.context[:indentstyle].nil? then + indentstyle = @parent.context[:indentstyle] + else + indentstyle = ' ' + end + to << indentstyle*ind unless ind<1 end def parent? diff --git a/lib/rexml/parsers/lightparser.rb b/lib/rexml/parsers/lightparser.rb index ca9692c449..43633f7347 100644 --- a/lib/rexml/parsers/lightparser.rb +++ b/lib/rexml/parsers/lightparser.rb @@ -44,10 +44,10 @@ module REXML end # An element is an array. The array contains: - # 0 The parent element - # 1 The tag name - # 2 A hash of attributes - # 3..-1 The child elements + # 0 The parent element + # 1 The tag name + # 2 A hash of attributes + # 3..-1 The child elements # An element is an array of size > 3 # Text is a String # PIs are [ :processing_instruction, target, data ] diff --git a/lib/rexml/parsers/sax2parser.rb b/lib/rexml/parsers/sax2parser.rb index 1e69e14e45..7c0311aa2e 100644 --- a/lib/rexml/parsers/sax2parser.rb +++ b/lib/rexml/parsers/sax2parser.rb @@ -28,15 +28,15 @@ module REXML # Listen arguments: # # Symbol, Array, Block - # Listen to Symbol events on Array elements + # Listen to Symbol events on Array elements # Symbol, Block # Listen to Symbol events # Array, Listener - # Listen to all events on Array elements + # Listen to all events on Array elements # Array, Block - # Listen to :start_element events on Array elements + # Listen to :start_element events on Array elements # Listener - # Listen to All events + # Listen to All events # # Symbol can be one of: :start_element, :end_element, # :start_prefix_mapping, :end_prefix_mapping, :characters, @@ -209,7 +209,7 @@ module REXML ((name.nil? and match.nil?) or match.nil? or ( (name == match) or (match.kind_of? Regexp and name =~ match) - ) + ) ) ) end.collect{|x| x[-1]} @@ -222,7 +222,7 @@ module REXML ((name.nil? and match.nil?) or match.nil? or ( (name == match) or (match.kind_of? Regexp and name =~ match) - ) + ) ) ) end.collect{|x| x[-1]} diff --git a/lib/rexml/parsers/ultralightparser.rb b/lib/rexml/parsers/ultralightparser.rb index 96c55d837e..7460845881 100644 --- a/lib/rexml/parsers/ultralightparser.rb +++ b/lib/rexml/parsers/ultralightparser.rb @@ -42,10 +42,10 @@ module REXML end # An element is an array. The array contains: - # 0 The parent element - # 1 The tag name - # 2 A hash of attributes - # 3..-1 The child elements + # 0 The parent element + # 1 The tag name + # 2 A hash of attributes + # 3..-1 The child elements # An element is an array of size > 3 # Text is a String # PIs are [ :processing_instruction, target, data ] diff --git a/lib/rexml/quickpath.rb b/lib/rexml/quickpath.rb index 8229bacd6f..4925f6a133 100644 --- a/lib/rexml/quickpath.rb +++ b/lib/rexml/quickpath.rb @@ -49,20 +49,20 @@ module REXML def QuickPath::filter elements, path return elements if path.nil? or path == '' or elements.size == 0 case path - when /^\/\//u # Descendant + when /^\/\//u # Descendant return axe( elements, "descendant-or-self", $' ) - when /^\/?\b(\w[-\w]*)\b::/u # Axe + when /^\/?\b(\w[-\w]*)\b::/u # Axe return axe( elements, $1, $' ) - when /^\/(?=\b([:!\w][-\.\w]*:)?[-!\*\.\w]*\b([^:(]|$)|\*)/u # Child - rest = $' - results = [] - elements.each do |element| - results |= filter( element.to_a, rest ) - end - return results - when /^\/?(\w[-\w]*)\(/u # / Function - return function( elements, $1, $' ) - when Namespace::NAMESPLIT # Element name + when /^\/(?=\b([:!\w][-\.\w]*:)?[-!\*\.\w]*\b([^:(]|$)|\*)/u # Child + rest = $' + results = [] + elements.each do |element| + results |= filter( element.to_a, rest ) + end + return results + when /^\/?(\w[-\w]*)\(/u # / Function + return function( elements, $1, $' ) + when Namespace::NAMESPLIT # Element name name = $2 ns = $1 rest = $' @@ -79,22 +79,22 @@ module REXML matches |= predicate( element.to_a, path[1..-1] ) if element.kind_of? Element end return matches - when /^\[/u # Predicate + when /^\[/u # Predicate return predicate( elements, path ) - when /^\/?\.\.\./u # Ancestor + when /^\/?\.\.\./u # Ancestor return axe( elements, "ancestor", $' ) - when /^\/?\.\./u # Parent + when /^\/?\.\./u # Parent return filter( elements.collect{|e|e.parent}, $' ) - when /^\/?\./u # Self + when /^\/?\./u # Self return filter( elements, $' ) - when /^\*/u # Any + when /^\*/u # Any results = [] elements.each do |element| results |= filter( [element], $' ) if element.kind_of? Element #if element.kind_of? Element - # children = element.to_a - # children.delete_if { |child| !child.kind_of?(Element) } - # results |= filter( children, $' ) + # children = element.to_a + # children.delete_if { |child| !child.kind_of?(Element) } + # results |= filter( children, $' ) #end end return results @@ -132,7 +132,7 @@ module REXML matches = filter(elements.collect{|element| element.parent}.uniq, rest) when "following-sibling" matches = filter(elements.collect{|element| element.next_sibling}.uniq, - rest) + rest) when "previous-sibling" matches = filter(elements.collect{|element| element.previous_sibling}.uniq, rest ) @@ -174,32 +174,32 @@ module REXML predicate.gsub!( /#{OPERAND_}\s*([<>=])\s*#{OPERAND_}\s*([<>=])\s*#{OPERAND_}/u, '\1 \2 \3 and \3 \4 \5' ) - # Let's do some Ruby trickery to avoid some work: - predicate.gsub!( /&/u, "&&" ) - predicate.gsub!( /=/u, "==" ) - predicate.gsub!( /@(\w[-\w.]*)/u, 'attribute("\1")' ) - predicate.gsub!( /\bmod\b/u, "%" ) - predicate.gsub!( /\b(\w[-\w.]*\()/u ) { - fname = $1 - fname.gsub( /-/u, "_" ) - } + # Let's do some Ruby trickery to avoid some work: + predicate.gsub!( /&/u, "&&" ) + predicate.gsub!( /=/u, "==" ) + predicate.gsub!( /@(\w[-\w.]*)/u, 'attribute("\1")' ) + predicate.gsub!( /\bmod\b/u, "%" ) + predicate.gsub!( /\b(\w[-\w.]*\()/u ) { + fname = $1 + fname.gsub( /-/u, "_" ) + } - Functions.pair = [ 0, elements.size ] - results = [] - elements.each do |element| - Functions.pair[0] += 1 - Functions.node = element - res = eval( predicate ) - case res - when true - results << element - when Fixnum - results << element if Functions.pair[0] == res - when String - results << element + Functions.pair = [ 0, elements.size ] + results = [] + elements.each do |element| + Functions.pair[0] += 1 + Functions.node = element + res = eval( predicate ) + case res + when true + results << element + when Fixnum + results << element if Functions.pair[0] == res + when String + results << element + end end - end - return filter( results, rest ) + return filter( results, rest ) end def QuickPath::attribute( name ) diff --git a/lib/rexml/xpath.rb b/lib/rexml/xpath.rb index a8952ff473..0f99808def 100644 --- a/lib/rexml/xpath.rb +++ b/lib/rexml/xpath.rb @@ -12,12 +12,12 @@ module REXML # Finds and returns the first node that matches the supplied xpath. # element:: - # The context element + # The context element # path:: - # The xpath to search for. If not supplied or nil, returns the first - # node matching '*'. + # The xpath to search for. If not supplied or nil, returns the first + # node matching '*'. # namespaces:: - # If supplied, a Hash which defines a namespace mapping. + # If supplied, a Hash which defines a namespace mapping. # variables:: # If supplied, a Hash which maps $variables in the query # to values. This can be used to avoid XPath injection attacks @@ -45,7 +45,7 @@ module REXML # path:: # The xpath to search for. If not supplied or nil, defaults to '*' # namespaces:: - # If supplied, a Hash which defines a namespace mapping + # If supplied, a Hash which defines a namespace mapping # variables:: # If supplied, a Hash which maps $variables in the query # to values. This can be used to avoid XPath injection attacks |