Changeset 547:fd80af68bedc

Show
Ignore:
Timestamp:
04/06/08 00:29:46 (8 months ago)
Author:
Sean Russell <ser@…>
Branch:
default
Message:

Fixes more 1.9 - related syntax
Changes ftools to FileUtils?

Files:
9 modified

Legend:

Unmodified
Added
Removed
  • bin/info.rb

    r378 r547  
    1818 
    1919k = case ARGV[0] 
    20     when /^t/: 'tag' 
    21     when /^u/: 'url' 
    22     when /^r/: 'revision' 
    23     when /^a/: 'author' 
    24     when /^d/: 'date' 
     20    when /^t/ then 'tag' 
     21    when /^u/ then 'url' 
     22    when /^r/ then 'revision' 
     23    when /^a/ then 'author' 
     24    when /^d/ then 'date' 
    2525    else 
    2626      puts %Q{Unrecognized command "#{ARGV[0]}"} 
  • bin/install.rb

    r282 r547  
    3030require 'getoptlong' 
    3131require 'rbconfig' 
    32 require 'ftools' 
     32require 'FileUtils' 
    3333require 'find' 
    3434 
    3535opts = GetoptLong.new( [ '--uninstall', '-u',           GetoptLong::NO_ARGUMENT], 
    36                                                                                         [ '--destdir', '-d', GetoptLong::REQUIRED_ARGUMENT ], 
    37                                                                                         [ '--target', '-t', GetoptLong::REQUIRED_ARGUMENT ], 
    38                                                                                         [ '--concurrent', '-c', GetoptLong::NO_ARGUMENT], 
    39                                                                                         [ '--help', '-h', GetoptLong::NO_ARGUMENT], 
    40                                                                                         [ '--noop', '-n', GetoptLong::NO_ARGUMENT]) 
     36                                                [ '--destdir', '-d', GetoptLong::REQUIRED_ARGUMENT ], 
     37                                                [ '--target', '-t', GetoptLong::REQUIRED_ARGUMENT ], 
     38                                                [ '--concurrent', '-c', GetoptLong::NO_ARGUMENT], 
     39                                                [ '--help', '-h', GetoptLong::NO_ARGUMENT], 
     40                                                [ '--noop', '-n', GetoptLong::NO_ARGUMENT]) 
    4141 
    4242 
  • bin/repackage.rb

    r43 r547  
    33Dir.chdir ".." if Dir.pwd =~ /bin.?$/ 
    44 
    5 require "ftools" 
     5require "FileUtils" 
    66 
    77def copy_recursively( dir_name, dest ) 
  • src/rexml/document.rb

    r546 r547  
    1818  # Note that if you want to have an XML declaration written for a document 
    1919  # you create, you must add one; REXML documents do not write a default 
    20         # declaration for you.  See |DECLARATION| and |write|. 
    21         class Document < Element 
    22                 # A convenient default XML declaration.  If you want an XML declaration, 
    23                 # the easiest way to add one is mydoc << Document::DECLARATION 
    24     # +DEPRECATED+ 
    25     # Use: mydoc << XMLDecl.default 
    26                 DECLARATION = XMLDecl.default 
    27  
    28                 # Constructor 
    29                 # @param source if supplied, must be a Document, String, or IO.  
    30                 # Documents have their context and Element attributes cloned. 
    31           # Strings are expected to be valid XML documents.  IOs are expected 
    32           # to be sources of valid XML documents. 
    33           # @param context if supplied, contains the context of the document; 
    34           # this should be a Hash. 
    35                 def initialize( source = nil, context = {} ) 
    36                         super() 
    37                         @context = context 
    38                         return if source.nil? 
    39                         if source.kind_of? Document 
    40                                 @context = source.context 
    41                                 super source 
    42                         else 
    43                                 build(  source ) 
    44                         end 
    45                 end 
     20  # declaration for you.  See |DECLARATION| and |write|. 
     21  class Document < Element 
     22        # A convenient default XML declaration.  If you want an XML declaration, 
     23        # the easiest way to add one is mydoc << Document::DECLARATION 
     24        # +DEPRECATED+ 
     25        # Use: mydoc << XMLDecl.default 
     26        DECLARATION = XMLDecl.default 
     27 
     28        # Constructor 
     29        # @param source if supplied, must be a Document, String, or IO.  
     30        # Documents have their context and Element attributes cloned. 
     31        # Strings are expected to be valid XML documents.  IOs are expected 
     32        # to be sources of valid XML documents. 
     33        # @param context if supplied, contains the context of the document; 
     34        # this should be a Hash. 
     35        def initialize( source = nil, context = {} ) 
     36          super() 
     37          @context = context 
     38          return if source.nil? 
     39          if source.kind_of? Document 
     40                @context = source.context 
     41                super source 
     42          else 
     43                build(  source ) 
     44          end 
     45        end 
    4646 
    4747    def node_type 
     
    4949    end 
    5050 
    51                 # Should be obvious 
    52                 def clone 
    53                         Document.new self 
    54                 end 
    55  
    56                 # According to the XML spec, a root node has no expanded name 
    57                 def expanded_name 
    58                         '' 
    59                         #d = doc_type 
    60                         #d ? d.name : "UNDEFINED" 
    61                 end 
    62  
    63                 alias :name :expanded_name 
    64  
    65                 # We override this, because XMLDecls and DocTypes must go at the start 
    66                 # of the document 
    67                 def add( child ) 
    68                         if child.kind_of? XMLDecl 
    69                                 @children.unshift child 
     51        # Should be obvious 
     52        def clone 
     53          Document.new self 
     54        end 
     55 
     56        # According to the XML spec, a root node has no expanded name 
     57        def expanded_name 
     58          '' 
     59          #d = doc_type 
     60          #d ? d.name : "UNDEFINED" 
     61        end 
     62 
     63        alias :name :expanded_name 
     64 
     65        # We override this, because XMLDecls and DocTypes must go at the start 
     66        # of the document 
     67        def add( child ) 
     68          if child.kind_of? XMLDecl 
     69                @children.unshift child 
    7070        child.parent = self 
    71                         elsif child.kind_of? DocType 
     71          elsif child.kind_of? DocType 
    7272        # Find first Element or DocType node and insert the decl right  
    7373        # before it.  If there is no such node, just insert the child at the 
     
    8787          @children[insert_before_index] = child 
    8888        end 
    89                                 child.parent = self 
    90                         else 
    91                                 rv = super 
    92                                 raise "attempted adding second root element to document" if @elements.size > 1 
    93                                 rv 
    94                         end 
    95                 end 
    96                 alias :<< :add 
    97  
    98                 def add_element(arg=nil, arg2=nil) 
    99                         rv = super 
    100                         raise "attempted adding second root element to document" if @elements.size > 1 
    101                         rv 
    102                 end 
    103  
    104                 # @return the root Element of the document, or nil if this document 
    105                 # has no children. 
    106                 def root 
     89                child.parent = self 
     90          else 
     91                rv = super 
     92                raise "attempted adding second root element to document" if @elements.size > 1 
     93                rv 
     94          end 
     95        end 
     96        alias :<< :add 
     97 
     98        def add_element(arg=nil, arg2=nil) 
     99          rv = super 
     100          raise "attempted adding second root element to document" if @elements.size > 1 
     101          rv 
     102        end 
     103 
     104        # @return the root Element of the document, or nil if this document 
     105        # has no children. 
     106        def root 
    107107      elements[1] 
    108108      #self 
    109109      #@children.find { |item| item.kind_of? Element } 
    110                 end 
    111  
    112                 # @return the DocType child of the document, if one exists, 
    113                 # and nil otherwise. 
    114                 def doctype 
    115                         @children.find { |item| item.kind_of? DocType } 
    116                 end 
    117  
    118                 # @return the XMLDecl of this document; if no XMLDecl has been 
    119                 # set, the default declaration is returned. 
    120                 def xml_decl 
    121                         rv = @children[0] 
     110        end 
     111 
     112        # @return the DocType child of the document, if one exists, 
     113        # and nil otherwise. 
     114        def doctype 
     115          @children.find { |item| item.kind_of? DocType } 
     116        end 
     117 
     118        # @return the XMLDecl of this document; if no XMLDecl has been 
     119        # set, the default declaration is returned. 
     120        def xml_decl 
     121          rv = @children[0] 
    122122      return rv if rv.kind_of? XMLDecl 
    123123      rv = @children.unshift(XMLDecl.default)[0] 
    124                 end 
    125  
    126                 # @return the XMLDecl version of this document as a String. 
    127                 # If no XMLDecl has been set, returns the default version. 
    128                 def version 
    129                         xml_decl().version 
    130                 end 
    131  
    132                 # @return the XMLDecl encoding of this document as a String. 
    133                 # If no XMLDecl has been set, returns the default encoding. 
    134                 def encoding 
    135                         xml_decl().encoding 
    136                 end 
    137  
    138                 # @return the XMLDecl standalone value of this document as a String. 
    139                 # If no XMLDecl has been set, returns the default setting. 
    140                 def stand_alone? 
    141                         xml_decl().stand_alone? 
    142                 end 
     124        end 
     125 
     126        # @return the XMLDecl version of this document as a String. 
     127        # If no XMLDecl has been set, returns the default version. 
     128        def version 
     129          xml_decl().version 
     130        end 
     131 
     132        # @return the XMLDecl encoding of this document as a String. 
     133        # If no XMLDecl has been set, returns the default encoding. 
     134        def encoding 
     135          xml_decl().encoding 
     136        end 
     137 
     138        # @return the XMLDecl standalone value of this document as a String. 
     139        # If no XMLDecl has been set, returns the default setting. 
     140        def stand_alone? 
     141          xml_decl().stand_alone? 
     142        end 
    143143 
    144144    # Write the XML tree out, optionally with indent.  This writes out the 
     
    195195          end 
    196196      formatter.write( self, output ) 
    197                 end 
     197        end 
    198198 
    199199                 
    200                 def Document::parse_stream( source, listener ) 
    201                         Parsers::StreamParser.new( source, listener ).parse 
    202                 end 
    203  
    204                 private 
    205                 def build( source ) 
     200        def Document::parse_stream( source, listener ) 
     201          Parsers::StreamParser.new( source, listener ).parse 
     202        end 
     203 
     204        private 
     205        def build( source ) 
    206206      Parsers::TreeParser.new( source, self ).parse 
    207                 end 
    208         end 
     207        end 
     208  end 
    209209end 
  • test/attributes.rb

    r492 r547  
    9292        # Submitted by Kou 
    9393        def test_namespace_conflict 
    94                 assert_raises( ParseException,  
     94                assert_raise( ParseException,  
    9595                        "Declaring two attributes with the same namespace should be an error" ) do 
    9696                        REXML::Document.new <<-XML 
  • test/core_test.rb

    r546 r547  
    5656      '<a a' + [0x0371].pack('U') + '="" />', 
    5757    ].each do |src| 
    58       assert_raises( ParseException, %Q{Parse #{src.inspect} should have failed!} ) do 
     58      assert_raise( ParseException, %Q{Parse #{src.inspect} should have failed!} ) do 
    5959        Document.new(src) 
    6060      end 
     
    135135    assert_equal(comment, comment2) 
    136136 
    137     assert_raises(ParseException) { 
     137    assert_raise(ParseException) { 
    138138      REXML::Document.new("<d><!- foo --></d>") 
    139139    } 
    140     assert_raises(ParseException) { 
     140    assert_raise(ParseException) { 
    141141      REXML::Document.new("<d><!-- foo -></d>") 
    142142    } 
     
    287287    assert_equal(instruction.to_s, instruction2.to_s) 
    288288 
    289     assert_raises(ParseException) { 
     289    assert_raise(ParseException) { 
    290290      REXML::Document.new("<d><?foo bar></d>") 
    291291    } 
     
    856856 
    857857  def test_more_namespaces 
    858     assert_raises( REXML::UndefinedNamespaceException,  
     858    assert_raise( REXML::UndefinedNamespaceException,  
    859859                   %Q{Should have gotten an Undefined Namespace error} )  { 
    860860      doc1 = Document.new("<r><p><n:c/></p></r>") 
     
    10451045  def test_null_element_name 
    10461046    a = REXML::Document.new  
    1047     assert_raises( RuntimeError ) { 
     1047    assert_raise( RuntimeError ) { 
    10481048      a.add_element( nil )  
    10491049    } 
     
    11941194  def test_ticket_76 
    11951195    src = "<div>at&t" 
    1196     assert_raises( ParseException, %Q{"#{src}" is invalid XML} )  { 
     1196    assert_raise( ParseException, %Q{"#{src}" is invalid XML} )  { 
    11971197      REXML::Document.new(src) 
    11981198    } 
     
    12011201  def test_ticket_21 
    12021202    src = "<foo bar=value/>" 
    1203     assert_raises( ParseException, "invalid XML should be caught" ) { 
     1203    assert_raise( ParseException, "invalid XML should be caught" ) { 
    12041204      d = REXML::Document.new(src) 
    12051205    } 
     
    13251325  def test_ticket_14 
    13261326    # Per .2.5 Node Tests of XPath spec  
    1327     assert_raises( REXML::UndefinedNamespaceException,  
     1327    assert_raise( REXML::UndefinedNamespaceException,  
    13281328                   %Q{Should have gotten an Undefined Namespace error} )  { 
    13291329      d = Document.new("<a><n:b/></a>")  
  • test/pullparser.rb

    r390 r547  
    3333    source = "<a><b></a>" 
    3434    parser = REXML::Parsers::PullParser.new(source) 
    35     assert_raises(ParseException, "Parsing should have failed") {  
     35    assert_raise(ParseException, "Parsing should have failed") {  
    3636      results = parser.pull while parser.has_next?  
    3737    } 
  • test/validation_rng.rb

    r441 r547  
    779779    parser = REXML::Parsers::TreeParser.new( source ) 
    780780    parser.add_listener( validator.reset ) 
    781     assert_raises( REXML::Validation::ValidationException,  
     781    assert_raise( REXML::Validation::ValidationException,  
    782782                  "Expected a validation error" ) { parser.parse } 
    783783  end 
  • test/xpath_test.rb

    r491 r547  
    588588 
    589589        def test_name 
    590     assert_raises( UndefinedNamespaceException, "x should be undefined" ) { 
     590    assert_raise( UndefinedNamespaceException, "x should be undefined" ) { 
    591591      d = REXML::Document.new("<a x='foo'><b/><x:b/></a>") 
    592592    }