ruby-changes:52505
From: hsbt <ko1@a...>
Date: Thu, 13 Sep 2018 15:59:28 +0900 (JST)
Subject: [ruby-changes:52505] hsbt:r64716: Move SER branch to tags.
hsbt 2018-09-13 15:59:22 +0900 (Thu, 13 Sep 2018) New Revision: 64716 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64716 Log: Move SER branch to tags. Added directories: tags/SER/ Removed directories: branches/SER/ Index: SER/lib/rexml/node.rb =================================================================== --- SER/lib/rexml/node.rb (revision 64715) +++ SER/lib/rexml/node.rb (nonexistent) @@ -1,35 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/SER/lib/rexml/node.rb#L0 -require "rexml/parseexception" - -module REXML - # Represents a node in the tree. Nodes are never encountered except as - # superclasses of other objects. Nodes have siblings. - module Node - # @return the next sibling (nil if unset) - def next_sibling_node - return nil if @parent.nil? - @parent[ @parent.index(self) + 1 ] - end - - # @return the previous sibling (nil if unset) - def previous_sibling_node - return nil if @parent.nil? - ind = @parent.index(self) - return nil if ind == 0 - @parent[ ind - 1 ] - end - - def to_s indent=-1 - rv = "" - write rv,indent - rv - end - - def indent to, ind - to << " "*ind unless ind<1 - end - - def parent? - false; - end - end -end Property changes on: SER/lib/rexml/node.rb ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: SER/lib/rexml/encoding.rb =================================================================== --- SER/lib/rexml/encoding.rb (revision 64715) +++ SER/lib/rexml/encoding.rb (nonexistent) @@ -1,62 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/SER/lib/rexml/encoding.rb#L0 -module REXML - module Encoding - @@uconv_available = false - - ENCODING_CLAIMS = { } - - def Encoding.claim( encoding_str, match=nil ) - if match - ENCODING_CLAIMS[ match ] = encoding_str - else - ENCODING_CLAIMS[ /^\s*<?xml\s*version=(['"]).*?\1\s*encoding=(["'])#{encoding_str}\2/ ] = encoding_str - end - end - - # Native, default format is UTF-8, so it is declared here rather than in - # an encodings/ definition. - UTF_8 = 'UTF-8' - claim( UTF_8 ) - - # ID ---> Encoding name - attr_reader :encoding - def encoding=( enc ) - enc = UTF_8 unless enc - @encoding = enc.upcase - require "rexml/encodings/#@encoding" unless @encoding == UTF_8 - end - - def check_encoding str - rv = ENCODING_CLAIMS.find{|k,v| str =~ k } - # Raise an exception if there is a declared encoding and we don't - # recognize it - unless rv - if str =~ /^\s*<?xml\s*version=(['"]).*?\1\s*encoding=(["'])(.*?)\2/ - raise "A matching encoding handler was not found for encoding '#{$3}', or the encoding handler failed to load due to a missing support library (such as uconv)." - else - return UTF_8 - end - end - return rv[1] - end - - def to_utf_8(str) - return str - end - - def from_utf_8 content - return content - end - end - - module Encodingses - encodings = [] - $:.each do |incl_dir| - if Dir[ File.join(incl_dir, 'rexml', 'encodings') ].size > 0 - encodings |= Dir[ File.join(incl_dir, 'rexml', 'encodings', '*_decl.rb') ] - end - encodings.collect!{ |f| File.basename(f) } - encodings.uniq! - end - encodings.each { |enc| require "rexml/encodings/#{enc}" } - end -end Property changes on: SER/lib/rexml/encoding.rb ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: SER/lib/rexml/rexml.rb =================================================================== --- SER/lib/rexml/rexml.rb (revision 64715) +++ SER/lib/rexml/rexml.rb (nonexistent) @@ -1,26 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/SER/lib/rexml/rexml.rb#L0 -# REXML is an XML parser for Ruby, in Ruby. -# -# URL: http://www.germane-software.com/software/rexml -# Author: Sean Russell <ser@g...> -# Version: 2.5.6 -# Date: +2003/054 - - - -# -# Short Description: -# Why did I write REXML? At the time of this writing, there were already -# two XML parsers for Ruby. The first is a Ruby binding to a native XML -# parser. This is a fast parser, using proven technology. However, -# it isn't very portable. The second is a native Ruby implementation, but -# I didn't like its API very much. I wrote REXML for myself, so that I'd -# have an XML parser that had an intuitive API. -# -# API documentation can be downloaded from the REXML home page, or can -# be accessed online at http://www.germane-software.com/software/rexml_doc -# A tutorial is available in docs/tutorial.html -module REXML - Copyright = 'Copyright #{Time.now.year} Sean Russell <ser@g...>' - Date = "@ANT_DATE@" - Version = "@ANT_VERSION@" -end Property changes on: SER/lib/rexml/rexml.rb ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: SER/lib/rexml/xmldecl.rb =================================================================== --- SER/lib/rexml/xmldecl.rb (revision 64715) +++ SER/lib/rexml/xmldecl.rb (nonexistent) @@ -1,72 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/SER/lib/rexml/xmldecl.rb#L0 -require 'rexml/encoding' -require 'rexml/source' - -module REXML - # NEEDS DOCUMENTATION - class XMLDecl < Child - include Encoding - - DEFAULT_VERSION = "1.0"; - DEFAULT_ENCODING = "UTF-8"; - DEFAULT_STANDALONE = "no"; - START = '<\?xml'; - STOP = '\?>'; - - attr_accessor :version, :standalone - - def initialize(version=DEFAULT_VERSION, encoding=nil, standalone=nil) - @encoding_set = !encoding.nil? - if version.kind_of? XMLDecl - super() - @version = version.version - self.encoding = version.encoding - @standalone = version.standalone - else - super() - @version = version - self.encoding = encoding - @standalone = standalone - end - @version = DEFAULT_VERSION if @version.nil? - end - - def clone - XMLDecl.new(self) - end - - def write writer, indent=-1, transitive=false, ie_hack=false - indent( writer, indent ) - writer << START.sub(/\\/u, '') - writer << " #{content}" - writer << STOP.sub(/\\/u, '') - end - - def ==( other ) - other.kind_of?(XMLDecl) and - other.version == @version and - other.encoding == self.encoding and - other.standalone == @standalone - end - - def xmldecl version, encoding, standalone - @version = version - @encoding_set = !encoding.nil? - self.encoding = encoding - @standalone = standalone - end - - def node_type - :xmldecl - end - - alias :stand_alone? :standalone - - private - def content - rv = "version='#@version'" - rv << " encoding='#{encoding}'" if @encoding_set - rv << " standalone='#@standalone'" if @standalone - rv - end - end -end Property changes on: SER/lib/rexml/xmldecl.rb ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: SER/lib/rexml/quickpath.rb =================================================================== --- SER/lib/rexml/quickpath.rb (revision 64715) +++ SER/lib/rexml/quickpath.rb (nonexistent) @@ -1,266 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/SER/lib/rexml/quickpath.rb#L0 -require 'rexml/functions' -require 'rexml/xmltokens' - -module REXML - class QuickPath - include Functions - include XMLTokens - - EMPTY_HASH = {} - - def QuickPath::first element, path, namespaces=EMPTY_HASH - match(element, path, namespaces)[0] - end - - def QuickPath::each element, path, namespaces=EMPTY_HASH, &block - path = "*" unless path - match(element, path, namespaces).each( &block ) - end - - def QuickPath::match element, path, namespaces=EMPTY_HASH - raise "nil is not a valid xpath" unless path - results = nil - Functions::namespace_context = namespaces - case path - when /^\/([^\/]|$)/u - # match on root - path = path[1..-1] - return [element.root.parent] if path == '' - results = filter([element.root], path) - when /^[-\w]*::/u - results = filter([element], path) - when /^\*/u - results = filter(element.to_a, path) - when /^[[!\w:]/u - # match on child - matches = [] - children = element.to_a - results = filter(children, path) - else - results = filter([element], path) - end - return results - end - - # Given an array of nodes it filters the array based on the path. The - # result is that when this method returns, the array will contain elements - # which match the path - def QuickPath::filter elements, path - return elements if path.nil? or path == '' or elements.size == 0 - case path - when /^\/\//u # Descendant - return axe( elements, "descendant-or-self", $' ) - when /^\/?\b(\w[-\w]*)\b::/u # Axe - axe_name = $1 - rest = $' - 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 - name = $2 - ns = $1 - rest = $' - elements.delete_if do |element| - !(element.kind_of? Element and - (element.expanded_name == name or - (element.name == name and - element.namespace == Functions.namespace_context[ns]))) - end - return filter( elements, rest ) - when /^\/\[/u - matches = [] - elements.each do |element| - matches |= predicate( element.to_a, path[1..-1] ) if element.kind_of? Element - end - return matches - when /^\[/u # Predicate - return predicate( elements, path ) - when /^\/?\.\.\./u # Ancestor - return axe( elements, "ancestor", $' ) - when /^\/?\.\./u # Parent - return filter( elements.collect{|e|e.parent}, $' ) - when /^\/?\./u # Self - return filter( elements, $' ) - 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, $' ) - #end - end - return results - end - return [] - end - - def QuickPath::axe( elements, axe_name, rest ) - matches = [] - matches = filter( elements.dup, rest ) if axe_name =~ /-or-self$/u - case axe_name - when /^descendant/u - elements.each do |element| - matches |= filter( element.to_a, "descendant-or-self::#{rest}" ) if element.kind_of? Element - end - when /^ancestor/u - elements.each do |element| - while element.parent - matches << element.parent - element = element.parent - end - end - matches = filter( matches, rest ) - when "self" - matches = filter( elements, rest ) - when "child" - elements.each do |element| - matches |= filter( element.to_a, rest ) if element.kind_of? Element - end - when "attribute" - elements.each do |element| - matches << element.attributes[ rest ] if element.kind_of? Element - end - when "parent" - matches = filter(elements.collect{|element| element.parent}.uniq, rest) - when "following-sibling" - matches = filter(elements.collect{|element| element.next_sibling}.uniq, - rest) - when "previous-sibling" - matches = filter(elements.collect{|element| - element.previous_sibling}.uniq, rest ) - end - return matches.uniq - end - - # A predicate filters a node-set with respect to an axis to produce a - # new node-set. For each node in the node-set to be filtered, the - # PredicateExpr is evaluated with that node as the context node, with - # the number of nodes in the node-set as the context size, and with the - # proximity position of the node in the node-set with respect to the - # axis as the context position; if PredicateExpr evaluates to true for - # that node, the node is included in the new node-set; otherwise, it is - # not included. - # - # A PredicateExpr is evaluated by evaluating the Expr and converting - # the result to a boolean. If the result is a number, the result will - # be converted to true if the number is equal to the context position - # and will be converted to false otherwise; if the result is not a - # number, then the result will be converted as if by a call to the - # boolean function. Thus a location path para[3] is equivalent to - # para[position()=3]. - def QuickPath::predicate( elements, path ) - ind = 1 - bcount = 1 - while bcount > 0 - bcount += 1 if path[ind] == ?[ - bcount -= 1 if path[ind] == ?] - ind += 1 - end - ind -= 1 - predicate = path[1..ind-1] - rest = path[ind+1..-1] - - # have to change 'a [=<>] b [=<>] c' into 'a [=<>] b and b [=<>] c' - predicate.gsub!( /([^\s(and)(or)<>=]+)\s*([<>=])\s*([^\s(and)(or)<>=]+)\s*([<>=])\s*([^\s(and)(or)<>=]+)/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, "_" ) - } - - 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 - return filter( results, rest ) - end - - def QuickPath::attribute( name ) - return Functions.node.attributes[name] if Functions.node.kind_of? Element - end - - def QuickPath::name() - return Functions.node.name if Functions.node.kind_of? Element - end - - def QuickPath::method_missing( id, *args ) - begin - Functions.send( id.id2name, *args ) - rescue Exception - raise "METHOD: #{id.id2name}(#{args.join ', '})\n#{$!.message}" - end - end - - def QuickPath::function( elements, fname, rest ) - args = parse_args( elements, rest ) - Functions.pair = [0, elements.size] - results = [] - elements.each do |element| - Functions.pair[0] += 1 - Functions.node = element - res = Functions.send( fname, *args ) - case res - when true - results << element - when Fixnum - results << element if Functions.pair[0] == res - end - end - return results - end - - def QuickPath::parse_args( element, string ) - # /.*?(?:\)|,)/ - arguments = [] - buffer = "" - while string and string != "" - c = string[0] - string.sub!(/^./u, "") - case c - when ?, - # if depth = 1, then we start a new argument - arguments << evaluate( buffer ) - #arguments << evaluate( string[0..count] ) - when ?( - # start a new method call - function( element, buffer, string ) - buffer = "" - when ?) - # close the method call and return arguments - return arguments - else - buffer << c - end - end - "" - end - end -end Property changes on: SER/lib/rexml/quickpath.rb ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: SER/lib/rexml/parseexception.rb =================================================================== --- SER/lib/rexml/parseexception.rb (revision 64715) +++ SER/lib/rexml/parseexception.rb (nonexistent) @@ -1,44 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/SER/lib/rexml/parseexception.rb#L0 -module REXML - class ParseException < Exception - attr_accessor :source, :parser, :continued_exception - - def initialize( message, source=nil, parser=nil, exception=nil ) - super(message) - @source = source - @parser = parser - @continued_exception = exception - end - - def to_s - # Quote the original exception, if there was one - if @continued_exception - err = @continued_exception.message - err << "\n" - err << @continued_exception.backtrace[0..3].join("\n") - err << "\n...\n" - else - err = "" - end - - # Get the stack trace and error message - err << super - - # Add contextual information - err << "\n#{@source.current_line}\nLast 80 unconsumed characters:\n#{@source.buffer[0..80].gsub(/\n/, ' ')}\n" if @source - err << "\nContext:\n#{@parser.context}" if @parser - err - end - - def position - @source.current_line[0] if @source - end - - def line - @source.current_line[2] if @source - end - - def context - @source.current_line - end - end -end Property changes on: SER/lib/rexml/parseexception.rb ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: SER/lib/rexml/parent.rb =================================================================== --- SER/lib/rexml/parent.rb (revision 64715) +++ SER/lib/rexml/parent.rb (nonexistent) @@ -1,165 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/SER/lib/rexml/parent.rb#L0 -require "rexml/child" - -module REXML - # A parent has children, and has methods for accessing them. The Parent - # class is never encountered except as the superclass for some other - # object. - class Parent < Child - include Enumerable - - # Constructor - # @param parent if supplied, will be set as the parent of this object - def initialize parent=nil - super(parent) - @children = [] - end - - def add( object ) - #puts "PARENT GOTS #{size} CHILDREN" - object.parent = self - @children << object - #puts "PARENT NOW GOTS #{size} CHILDREN" - object - end - - alias :push :add - alias :<< :push - - def unshift( object ) - object.parent = self - @children.unshift object - end - - def delete( object ) - return unless @children.include? object - @children.delete object - object.parent = nil - end - - def each(&block) - @children.each(&block) - end - - def delete_if( &block ) - @children.delete_if(&block) - end - - def delete_at( index ) - @children.delete_at index - end - - def each_index( &block ) - @children.each_index(&block) - end - - # Fetches a child at a given index - # @param index the Integer index of the child to fetch - def []( index ) - @children[index] - end - - alias :each_child :each - - - - # Set an index entry. See Array.[]= - # @param index the index of the element to set - # @param opt either the object to set, or an Integer length - # @param child if opt is an Integer, this is the child to set - # @return the parent (self) - def []=( *args ) - args[-1].parent = self - @children[*args[0..-2]] = args[-1] - end - - # Inserts an child before another child - # @param child1 this is either an xpath or an Element. If an Element, - # child2 will be inserted before child1 in the child list of the parent. - # If an xpath, child2 will be inserted before the first child to match - # the xpath. - # @param child2 the child to insert - # @return the parent (self) - def insert_before( child1, child2 ) - if child1.kind_of? String - child1 = XPath.first( self, child1 ) - child1.parent.insert_before child1, child2 - else - ind = index(child1) - child2.parent.delete(child2) if child2.parent - @children[ind,0] = child2 - child2.parent = self - end - self - end - - (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/