Porting REXML to Ruby 1.9
Unicode changes:
- baseparser.rb and source.rb were changed to force encoding to utf-8.
- XPath function
translate
converted to support characters - Comparing indexed strings against numbers was changed to compare slices against strings.
- Encoding specific tests were changed as necessary to specify the encoding expected.
Other language changes:
{"a","b"}
no longer supported, converted to{"a"=>"b"}
Array.to_s
now contains square brackets, quotes, and commas.Array.join
used instead when join semantics is required.- Colon is no longer accepted as an alternative to
then
inwhen
statements. - Renamed variables when necessary to prevent warning message when a block variable shadowed a local variable. The idiom
var = array.find {|var| ...}
now requires the block variable to be named differently than the local variable. REXML also has a few places where block variables were set tonil
immediately outside of the block “for performance reasons”. In a few cases,for node in nodeset
was replaced withnodeset.each do |node|
Hash.index
changed toHash.key
Enumeration.zip
no longer insertsnil
s to pad out arrays.- An instance variable which previously wasn’t initialized now explicitly initialized to false
- Added a
sleep
in a threaded sax/socket test to prevent a race condition.
REXML changes:
- Substitution of entities was done in a single pass, this meant that entity values whose value referenced other entities would only get fully expanded if the order of the hash matched the order of evaluation.
get_attribute_ns('','a')
previously matched both an attribute nameda
, andxmlns:a
. Which one returned depended on the order of a hash. Changed the method to only selecta
.- One regular expression which had explicitly specified
/u
for unicode changed to not be unicode: this was the regular expression matching the xml prolog declaration itself which must be matched against bytes. - Added a unit test for 110 and tests and fixes for 123, 127.
Outputs of running bin/suite.rb:
["3.1.7.2", "1.9.0", "2007-12-31"] REXML version = 3.1.7.2 Loaded suite REXML Started ............................................................................................................................................................................................................................................................................................................................................................ Finished in 12.893064488 seconds. 348 tests, 1252 assertions, 0 failures, 0 errors
["3.1.7.2", "1.8.6", "2007-06-07"] REXML version = 3.1.7.2 Loaded suite REXML Started ............................................................................................................................................................................................................................................................................................................................................................ Finished in 34.733291 seconds. 348 tests, 1252 assertions, 0 failures, 0 errors