diff --git a/Rakefile b/Rakefile index 4d226bfa..e658f4f6 100644 --- a/Rakefile +++ b/Rakefile @@ -51,6 +51,13 @@ namespace :ruby do pkg.need_zip = false pkg.need_tar = false end + + desc "Generate gemspec file" + task :gemspec do + File.open("#{spec.name}-#{spec.version}.gemspec", "w") do |f| + f << spec.to_ruby + end + end end [:mingw32, :mswin32].each do |v| diff --git a/lib/pry/default_commands/gems.rb b/lib/pry/default_commands/gems.rb index 62f016a7..3f2d4421 100644 --- a/lib/pry/default_commands/gems.rb +++ b/lib/pry/default_commands/gems.rb @@ -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| diff --git a/lib/pry/helpers/base_helpers.rb b/lib/pry/helpers/base_helpers.rb index 67e87da8..fb412b1b 100644 --- a/lib/pry/helpers/base_helpers.rb +++ b/lib/pry/helpers/base_helpers.rb @@ -23,7 +23,7 @@ class Pry def gem_installed?(gem_name) require 'rubygems' - !!Gem.source_index.find_name(gem_name).first + Gem::Specification.respond_to?(:find_all_by_name) ? !Gem::Specification.find_all_by_name(gem_name).empty? : Gem.source_index.find_name(gem_name).first end def command_dependencies_met?(options) diff --git a/lib/pry/plugins.rb b/lib/pry/plugins.rb index 70b0fa94..b8c4f4b6 100644 --- a/lib/pry/plugins.rb +++ b/lib/pry/plugins.rb @@ -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) diff --git a/pry-0.8.3.gemspec b/pry-0.8.3.gemspec new file mode 100644 index 00000000..090ab750 --- /dev/null +++ b/pry-0.8.3.gemspec @@ -0,0 +1,44 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{pry} + s.version = "0.8.3" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["John Mair (banisterfiend)"] + s.date = %q{2011-05-31} + s.default_executable = %q{pry} + s.description = %q{attach an irb-like session to any object at runtime} + s.email = %q{jrmair@gmail.com} + s.executables = ["pry"] + s.files = [".document", ".gemtest", ".gitignore", ".yardopts", "CHANGELOG", "LICENSE", "README.markdown", "Rakefile", "TODO", "bin/pry", "examples/example_basic.rb", "examples/example_command_override.rb", "examples/example_commands.rb", "examples/example_hooks.rb", "examples/example_image_edit.rb", "examples/example_input.rb", "examples/example_input2.rb", "examples/example_output.rb", "examples/example_print.rb", "examples/example_prompt.rb", "lib/pry.rb", "lib/pry/command_context.rb", "lib/pry/command_processor.rb", "lib/pry/command_set.rb", "lib/pry/commands.rb", "lib/pry/completion.rb", "lib/pry/core_extensions.rb", "lib/pry/custom_completions.rb", "lib/pry/helpers.rb", "lib/pry/helpers/base_helpers.rb", "lib/pry/helpers/command_helpers.rb", "lib/pry/hooks.rb", "lib/pry/print.rb", "lib/pry/prompts.rb", "lib/pry/pry_class.rb", "lib/pry/pry_instance.rb", "lib/pry/version.rb", "test/test.rb", "test/test_helper.rb", "test/testrc", "wiki/Customizing-pry.md", "wiki/Home.md"] + s.homepage = %q{http://banisterfiend.wordpress.com} + s.require_paths = ["lib"] + s.rubygems_version = %q{1.6.2} + s.summary = %q{attach an irb-like session to any object at runtime} + s.test_files = ["test/test.rb", "test/test_helper.rb", "test/testrc"] + + if s.respond_to? :specification_version then + s.specification_version = 3 + + if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q, [">= 2.0.5"]) + s.add_runtime_dependency(%q, [">= 0.9.8"]) + s.add_runtime_dependency(%q, [">= 1.5.5"]) + s.add_runtime_dependency(%q, [">= 0.4.0"]) + s.add_development_dependency(%q, [">= 1.1.0"]) + else + s.add_dependency(%q, [">= 2.0.5"]) + s.add_dependency(%q, [">= 0.9.8"]) + s.add_dependency(%q, [">= 1.5.5"]) + s.add_dependency(%q, [">= 0.4.0"]) + s.add_dependency(%q, [">= 1.1.0"]) + end + else + s.add_dependency(%q, [">= 2.0.5"]) + s.add_dependency(%q, [">= 0.9.8"]) + s.add_dependency(%q, [">= 1.5.5"]) + s.add_dependency(%q, [">= 0.4.0"]) + s.add_dependency(%q, [">= 1.1.0"]) + end +end