janlelis / irbtools

Improvements for Ruby's IRB console 💎︎
MIT License
920 stars 27 forks source link

irbtool libraries interfere with Nokogiri::XML::Builder #40

Closed mgraham closed 6 years ago

mgraham commented 6 years ago

Hello - we are very excited to start using irbtools on our team, but we're encountering a problem.

We are using irbtools 2.1.0 and Nokogiri 1.8.1, ruby 2.2.5 and Rails 4.2.7.1.

We are getting an error when building XML documents with Nokogiri::XML::Builder, when irbtools is installed.

This is our code:

builder = Nokogiri::XML::Builder.new do |xml|
  xml.send(:version, 12345)
end

It raises this error:

ArgumentError: wrong number of arguments (1 for 0)
from /Volumes/OSXHOME/Users/michael/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/irbtools-2.1.0/lib/irbtools/libraries.rb:100:in `version'

It appears that what is actually happening is that Nokogiri is somehow calling the version method defined inlib/irbtools/libraries.rb, around line 100:

Irbtools.add_library 'ruby_version', :autoload => :RubyVersion do
  def version() RubyVersion end unless defined? version
end

The same is true for the following:

xml.send(:info)
xml.send(:os)
xml.send(:engine)
xml.send(:version)

All of these call the methods defined in irbtools/libraries.rb

janlelis commented 6 years ago

Thanks! I've removed these methods which should fix the problem.

mgraham commented 6 years ago

That fixed it! Thank you so much!