Like with REXML, I ported XML Builder to run on Ruby version 1.9. As there is likely to be an extended transition period between 1.8 and 2.0, the design goal was to build a single library that supports both.
As Ruby 1.9’s support for regular expressions is fully unicode aware, tr and Regexp are used in place of pack and unpack. Should be a major performance win, especially with big strings.
no more need for String.to_xs and Fixnum.xchr
move from BlankSlate to BasicObject. As it doesn’t include ::Kernel, BasicObject is much more brutal than BlankSlate. Constants like ::String must be explicitly qualified, as do methods like ::Kernel.raise and ::Kernel.block_given?
Since the use of $KCODE produces warnings on Ruby 1.9, this support has been removed from Builder when running on Ruby 1.9. New default (absent $KCODE) switches from “doesn’t understand utf-8” to “supports utf-8”. This means that there will be fewer cases where non-ASCII characters are replaced with XML numeric character references.
trend is towards replacing assert_raises with assert_raise
instance_methods are no longer an array of strings, instead it is an array of symbols. Replace instance_methods.include? with method_defined?
Builder::CSS relies on instance_eval. BasicObject support for this method is under active discussion.
what is the equivalent to rake/contrib/sshpublisher in Ruby 1.9?. Updated: solved.
how this affects alternative implementations like JRuby and IronRuby
use U+FFFD instead of * to indicate invalid Unicode characters
need to stop the blankslate (and for now, css) tests from running on 1.9
Sam, thanks for taking this stuff on. The Ruby XML libraries have been driving me nuts for ages, and it’s good to finally see someone at the wheel who’s detail-oriented and has a serious background with XML.
Sam: In general, you should be able to use the gem just fine on JRuby...and if not, it’s a bug and we’ll fix it. WRT 1.9 features, we plan to start adding them after our 1.1 final release this month, but we already have the regular expression engine done (thanks to Marcin Mielzinsky).
Please feel free to contact me directly with any questions. I want to make sure everything works on JRuby.
"Next performance fix: Builder::XChar" by Sam Ruby
Chuckle. :-) You might take a look at how I completely eliminated to_xs in my patch for Ruby 1.9. Perhaps similar techniques could be used for JRuby, as the root cause is that 1.8 MRI doesn’t grok Unicode?...
Thanks for the patch Sam! Unfortunately, it looks like things have broken again with Ruby 1.9.1. I’ve nailed down the problem to incompatibilities with minitest (the new Test::Unit implementation). You can find my fixes on github at [link]
m Rakefile m lib/builder/blankslate.rb m lib/builder/css.rb m lib/builder/xchar.rb m lib/builder/xmlbase.rb m lib/builder/xmlmarkup.rb m test/test_blankslate.rb m test/test_markupbuilder.rb m test/test_xchar.rb Apply Sam Ruby’s ruby1.9 patch from...