The tale of converting RubyFrontier to be compatible Ruby 1.9.3 continues.
My own code is full of surprises! I found a place where I was using the hash literal convenience notation where key and value are separated by a comma instead of the full-fledged =>
operator; that’s a no-no in Ruby 1.9.
Also, remember when I said this?
Do I ever expect a block variable to be the same object as a variable outside the block? It doesn’t seem probable. The fact that this could happen was never anything but surprising and troublesome. The interior of a block is a local scope, and one naturally expects a block variable to be local to that scope. If I want to affect a variable outside a block, I can assign to that variable from inside the block; I am unlikely to use the implicit iterative changing of the block variable as a way to do this.
Well, I was wrong! There was a place where I did indeed use that trick, as a way of carrying the block variable out into a rescue
block in case there was an exception (so that I could report the value of the block variable at that moment):
begin
v = nil
adrPageTable["tools"].each_value { |v| theBindingMaker.instance_eval(File.read(v)) }
rescue SyntaxError
raise "Trouble parsing #{v}"
end
That doesn’t work in Ruby 1.9.3; v
in the rescue
block is still nil. It’s easy to fix this so that it works in both versions of Ruby:
begin
vv = nil
adrPageTable["tools"].each_value { |v| theBindingMaker.instance_eval(File.read(vv = v)) }
rescue SyntaxError
raise "Trouble parsing #{vv}"
end
Another slight difficulty, not with RubyFrontier itself but with the switch to Ruby 1.9.3, is that String#hash
gives a different output from Ruby 1.8.7 (for the same string), as discussed here. It isn’t crucial, but for the sake of guaranteed consistency I have switched to using Digest::MD5.hexdigest
.
Apart from the difference in hash values, and aside from a slight difference in the ordering of <meta>
tags (probably caused by the fact that Ruby 1.9 hashes enumerate their keys in a different order), the upshot is that the entire Script Debugger 5 help documentation comes out letter-for-letter identical when produced by RubyFrontier 1.1 under Ruby 1.9.3 or by RubyFrontier 1.0.2 under Ruby 1.8.7. That’s a very good sign!
This page prepared
February 14, 2014
by Matt Neuburg, phd = matt at tidbits dot com,
using RubyFrontier.
RubyFrontier is a port, written in the Ruby language,
of the Web-site-creation features of UserLand Frontier.
Works just like Frontier, but written in Ruby!
Download RubyFrontier from
GitHub.