mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
rubygems 1.8.x compatibility fixes applied to dev branch
This commit is contained in:
parent
7fe09c806d
commit
bafff3dc7d
2 changed files with 8 additions and 4 deletions
|
@ -19,14 +19,18 @@ class Pry
|
|||
end
|
||||
|
||||
command "gem-cd", "Change working directory to specified gem's directory.", :argument_required => true do |gem|
|
||||
spec = Gem.source_index.find_name(gem).sort { |a,b| Gem::Version.new(b.version) <=> Gem::Version.new(a.version) }.first
|
||||
specs = Gem::Specification.respond_to?(:each) ? Gem::Specification.find_all_by_name(gem) : Gem.source_index.find_name(gem)
|
||||
spec = specs.sort { |a,b| Gem::Version.new(b.version) <=> Gem::Version.new(a.version) }.first
|
||||
spec ? Dir.chdir(spec.full_gem_path) : output.puts("Gem `#{gem}` not found.")
|
||||
end
|
||||
|
||||
|
||||
command "gem-list", "List/search installed gems. (Optional parameter: a regexp to limit the search)" do |pattern|
|
||||
pattern = Regexp.new pattern.to_s, Regexp::IGNORECASE
|
||||
gems = Gem.source_index.find_name(pattern).group_by(&:name)
|
||||
gems = if Gem::Specification.respond_to?(:each)
|
||||
Gem::Specification.select{|spec| spec.name =~ pattern }.group_by(&:name)
|
||||
else
|
||||
Gem.source_index.gems.values.group_by(&:name).select { |gemname, specs| gemname =~ pattern }
|
||||
end
|
||||
|
||||
gems.each do |gem, specs|
|
||||
specs.sort! do |a,b|
|
||||
|
|
|
@ -44,7 +44,7 @@ class Pry
|
|||
# Find all installed Pry plugins and store them in an internal array.
|
||||
def locate_plugins
|
||||
Gem.refresh
|
||||
Gem.source_index.find_name('').each do |gem|
|
||||
(Gem::Specification.respond_to?(:each) ? Gem::Specification : Gem.source_index.find_name('')).each do |gem|
|
||||
next if gem.name !~ PRY_PLUGIN_PREFIX
|
||||
plugin_name = gem.name.split('-', 2).last
|
||||
@plugins << Plugin.new(plugin_name, gem.name, true) if !gem_located?(gem.name)
|
||||
|
|
Loading…
Add table
Reference in a new issue