mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
WrappedModule#candidates: return Array on JRuby >=1.9
JRuby 1.9 has a nasty bug with `Enumerator#find_index`, which we utilise in the code of `whereami` command. More information on the bug: https://github.com/jruby/jruby/issues/525 Simply return an Array, formed from the original Enumerator on JRuby 1.9 and higher. This kills the efficiency, but leastwise, it will be working. As a bonus, remove some a junk method.
This commit is contained in:
parent
9a2999982c
commit
684ac1fccf
1 changed files with 12 additions and 10 deletions
|
@ -235,13 +235,19 @@ class Pry
|
|||
method_candidates.count
|
||||
end
|
||||
|
||||
# @return [Enumerator]
|
||||
# @note On JRuby 1.9 and higher, in certain conditions, this method chucks
|
||||
# away its ability to be quick (when there are lots of monkey patches,
|
||||
# like in Rails). However, it should be efficient enough on other rubies.
|
||||
# @see https://github.com/jruby/jruby/issues/525
|
||||
# @return [Enumerator, Array] on JRuby 1.9 and higher returns Array, on
|
||||
# other rubies returns Enumerator
|
||||
def candidates
|
||||
generator.new do |y|
|
||||
(0...number_of_candidates).each do |num|
|
||||
y.yield candidate(num)
|
||||
end
|
||||
end
|
||||
enum = generator.new do |y|
|
||||
(0...number_of_candidates).each do |num|
|
||||
y.yield candidate(num)
|
||||
end
|
||||
end
|
||||
Pry::Helpers::BaseHelpers.jruby_19? ? enum.to_a : enum
|
||||
end
|
||||
|
||||
# @return [Boolean] Whether YARD docs are available for this module.
|
||||
|
@ -267,10 +273,6 @@ class Pry
|
|||
Pry::WrappedModule(sup) if sup
|
||||
end
|
||||
|
||||
def first_module_candidate_with_source
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Ruby 1.8 doesn't support `Enumerator` (it's called Generator instead)
|
||||
|
|
Loading…
Add table
Reference in a new issue