This project is archived and is in readonly mode.
plugin.rb incompatibility with Ruby 1.9
Reported by Jeff Schwab | March 4th, 2009 @ 08:11 PM | in 2.x
railties/lib/commands/plugin.rb uses the method "reject" on a String, but String no longer has this method in Ruby 1.9 (since String is no longer Enumerable).
The attached patch adds a call to String#lines, per the suggestion at: http://eigenclass.org/hiki/Chang...
The error message is of the form: plugin.rb:137:in
externals': undefined method
reject' for "":String
(NoMethodError)
I've been trying to submit a patch through git for the past two days, but can't even get rails test to work out of the box. Relevant threads are at: http://groups.google.com/group/r...
Comments and changes to this ticket
-
Matt Jones March 4th, 2009 @ 08:52 PM
- Tag changed from patch to patch, ruby1.9
This patch still needs some work - note that String#lines is not defined for RUBY_VERSION < 1.9. Given the current speed of the migration effort, Ruby 1.8 support is needed. I'd recommend that you revise the patch in the spirit of line 904 of plugin.rb:
@urls_to_fetch = RUBY_VERSION >= '1.9' ? urls_to_fetch.lines : urls_to_fetch.to_a
..which will work correctly on both 1.9 and 1.8.
Either that, or you could use an approach like this:
lines = str.send(str.respond_to?(:lines) ? :lines : :to_s).to_a
(from this blog post )
-
Jeff Schwab March 4th, 2009 @ 09:48 PM
Thanks for the gentle treatment of my rookie mistake. An updated patch is attached.
In other codebases, I would include a comment, explaining what I did and why, and referring to this bug report. I see that there are no other such comments in the file, so I guess they only go in the version control logs. Here is a "starter" log entry:
Ruby 1.8 strings are Enumerable, but do not support :lines. In Ruby 1.9, the situation is reversed.
-
Jeff Schwab March 6th, 2009 @ 02:34 AM
- no changes were found...
-
Pratik March 9th, 2009 @ 12:58 PM
- Assigned user set to Jeremy Kemper
-
Repository March 10th, 2009 @ 06:58 PM
- State changed from new to committed
(from [e609d83f1a7f49bf8a9549c480a67ee045950336]) Fixed an incompatibility with Ruby 1.9.
Ruby 1.8 strings are Enumerable, but there is no String#lines method. In Ruby 1.9, the situation is reversed. To work around this disparity, the RailsEnvironment#externals method now explicitly checks whether a String responds_to? :lines.
[#2130 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net http://github.com/rails/rails/co...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 2130 plugin.rb incompatibility with Ruby 1.9 [#2130 state:committed]