Hi everybody, I would like to use ruby2ruby in a caming project, but there seems to be an incompatibility with camping, ruby2ruby and markaby. Unfortunately I receive strange Markaby::InvalidXhtmlErrors. To demonstrate, that only combination of all three components causes the problem I added the following code. I relies on Markaby and ruby2ruby only and works fine (a.k.a. as expected). require "rubygems" require "ruby2ruby" require "markaby" def example(&block) $mab.pre( block.to_ruby.gsub(/^proc \{\n(.*)\n\}$/m, ''\1'')) end Markaby::Builder.set(:indent, 2) $mab = Markaby::Builder.new $mab.xhtml_strict do div.literate_markaby! do example do 1 + 1 == 2 end end end puts $mab.to_s When I wrap that up in a camping project, which looks the following, I get an error, when using tag! with arguments. The Code: require "rubygems" require "ruby2ruby" Camping.goes :Test module Test module Controllers class Index < R ''/'' def get div.literate_programming! do example { 1 + 1 == 2 } end end end end module Helpers def example(&block) pre( block.to_ruby.gsub(/^proc \{\n(.*)\n\}$/m, ''\1'')) end end end It raises "Markaby::InvalidXhtmlError no attribute `href'' on div elements:" in the line "div.literate_programming! do" . If I change it to "div do" it works okay. Also every other way of providing arguments raises the error (div.class_name, div(:rel => "options"), ...). I don''t know where the :href attribute comes from and I don''t know, why it only appears within camping and not in markaby itself. Any help would be appreciated. Thanks in advance. Cheers, Gregor Note: I''m using the latest release of camping (1.5.180), markaby (0.5) and ruby2ruby (1.1.7)
Hi Gregor, I wasn''t able to track the error on Camping side, but it comes from r2r that defines nil.error_missing. 2007/9/27, Gregor Schmidt <ruby at schmidtwisser.de>:> require "rubygems" > require "ruby2ruby"# It works in this case but probably breaks r2r on a larger scale. class NilClass undef method_missing end> Camping.goes :Test > > module Test > module Controllers > class Index < R ''/'' > def get > div.literate_programming! do > example { 1 + 1 == 2 } > end > end > end > end > > module Helpers > def example(&block) > pre( block.to_ruby.gsub(/^proc \{\n(.*)\n\}$/m, ''\1'')) > end > end > end> I don''t know where the :href attribute comes from and I don''t know, > why it only appears within camping and not in markaby itself.Camping overrides [:href,:action,:src] to translate relative links to absolute ones. See Mab at the end of camping-unabridged. -- Cheers, zimbatm
On 9/27/07, Jonas Pfenniger <zimbatm at oree.ch> wrote:> Hi Gregor, > > I wasn''t able to track the error on Camping side, but it comes from > r2r that defines nil.error_missing. > > 2007/9/27, Gregor Schmidt <ruby at schmidtwisser.de>: > > require "rubygems" > > require "ruby2ruby" > > # It works in this case but probably breaks r2r on a larger scale. > class NilClass > undef method_missing > end > > > Camping.goes :Test > > > > module Test > > module Controllers > > class Index < R ''/'' > > def get > > div.literate_programming! do > > example { 1 + 1 == 2 } > > end > > end > > end > > end > > > > module Helpers > > def example(&block) > > pre( block.to_ruby.gsub(/^proc \{\n(.*)\n\}$/m, ''\1'')) > > end > > end > > end > > > I don''t know where the :href attribute comes from and I don''t know, > > why it only appears within camping and not in markaby itself. > > Camping overrides [:href,:action,:src] to translate relative links to > absolute ones. See Mab at the end of camping-unabridged. >Thanks for the hint. Finally I manged to work around the incompatibility. Defining NilClass#method_missing for nothing is not too clever, for a large scale libary IMO. By adding module Test # This is my Camping app - not the test/unit test thing (just a reminder) class Mab def tag!(*g,&b) super end end end the problem is solved. Since I''m not changing any behaviour the code should not have unwanted side effects. Perhaps this gives you an idea, where the real cause of the problem is. At least I''ve got a solution now. Thanks for the help Cheers, Gregor
2007/9/27, Gregor Schmidt <ruby at schmidtwisser.de>:> Defining NilClass#method_missing for nothing is not too clever, for a > large scale libary IMO.I''m not sure you understood, it is ruby2ruby who defined nil.method_missing. We can''t start to support each and every hack a library will add to the Ruby core. -- Cheers, zimbatm
On 9/27/07, Jonas Pfenniger <zimbatm at oree.ch> wrote:> > 2007/9/27, Gregor Schmidt <ruby at schmidtwisser.de>: > > Defining NilClass#method_missing for nothing is not too clever, for a > > large scale libary IMO. > > I''m not sure you understood, it is ruby2ruby who defined > nil.method_missing. We can''t start to support each and every hack a > library will add to the Ruby core.^for this reason, you can''t really use ruby2ruby in anything serious. nil.method_missing prevents a lot of exceptions from being thrown, and there''s a lot of code out their that legitimately needs those exceptions to be thrown for correct behavior. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/camping-list/attachments/20070927/84e75ce5/attachment-0001.html
On Sep 27, 2007, at 7:35 PM, John Beppu wrote:> ^for this reason, you can''t really use ruby2ruby in anything > serious. nil.method_missing prevents a lot of exceptions from > being thrown, and there''s a lot of code out their that legitimately > needs those exceptions to be thrown for correct behavior.require ''ruby2ruby'' class NilClass undef method_missing end Solved?
On 9/27/07, Manfred Stienstra <manfred at gmail.com> wrote:> > On Sep 27, 2007, at 7:35 PM, John Beppu wrote: > > ^for this reason, you can''t really use ruby2ruby in anything > > serious. nil.method_missing prevents a lot of exceptions from > > being thrown, and there''s a lot of code out their that legitimately > > needs those exceptions to be thrown for correct behavior. > > require ''ruby2ruby'' > class NilClass > undef method_missing > end > > Solved?I don''t know. What if ruby2ruby relied on the other behaviour? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/camping-list/attachments/20070927/5dc72d95/attachment.html
Sorry, if I was misunderstood with saying> Defining NilClass#method_missing for nothing is not too clever, for a > large scale libary IMO.I was "insulting" ruby2ruby and not camping. So everthing is okay on this side. I solved my particular problem with the combination of caming and ruby2ruby and will not use it for something serious - just academics. I was looking for help, concerning this issue, found it, thankfully, on this list and will post a blog entry tomorrow, so other probably will find it as well.>From my side, everything is okay at this point. Thanks again for thehint. There is nothing I could see, that should be changed inside of caming to allow such a "strange" of standard behaviour. Cheers, Gregor
2007/9/28, Gregor Schmidt <ruby at schmidtwisser.de>:> I was "insulting" ruby2ruby and not camping. So everthing is okay on this side.No problem. You can insult Camping if you want, if at least I get understood. Joking aside, it''s true that ruby2ruby still lacks some maturity but it is an interesting project nonetheless. I have big hopes that one day is will be usable to "platterize" camping.rb -- Cheers, zimbatm
On 9/28/07, Jonas Pfenniger <zimbatm at oree.ch> wrote:> 2007/9/28, Gregor Schmidt <ruby at schmidtwisser.de>: > > I was "insulting" ruby2ruby and not camping. So everthing is okay on this side. > > No problem. You can insult Camping if you want, if at least I get > understood. Joking aside, it''s true that ruby2ruby still lacks some > maturity but it is an interesting project nonetheless. I have big > hopes that one day is will be usable to "platterize" camping.rbFor a none native speaker. Could you give a synonym for "platterize". Cheers, Gregor
On Sep 28, 2007, at 1:33 AM, Gregor Schmidt wrote:> For a none native speaker. Could you give a synonym for "platterize".Trayerize, like ''handing someone something on a platter''.
2007/9/28, Gregor Schmidt <ruby at schmidtwisser.de>:> For a none native speaker. Could you give a synonym for "platterize".Sorry, from a non native speaker too. The term was probably badly chosen. I was referring to the action that consist of taking camping-unabridged.rb and create a "platter?" out of it. It is a reference to the visual output that camping.rb gives. -- Cheers, zimbatm
> I was referring to the action that consist of taking > camping-unabridged.rb and create a "platter?" out of it. It is a > reference to the visual output that camping.rb gives.Ok, now I got it. That would be cool indeed. Cheers, Gregor
On Fri, 28 Sep 2007 10:43:56 +0200, "Jonas Pfenniger" <zimbatm at oree.ch> wrote:> I was referring to the action that consist of taking > camping-unabridged.rb and create a "platter?" out of it. It is a > reference to the visual output that camping.rb gives.Perhaps "condensing" ? -mental