diff --git a/Rakefile b/Rakefile index 0bd770e2..e3a31f30 100644 --- a/Rakefile +++ b/Rakefile @@ -36,7 +36,8 @@ end desc "run pry" task :pry do - require "#{direc}/lib/pry" + $LOAD_PATH.unshift "#{direc}/lib" + require 'pry' binding.pry end @@ -51,7 +52,7 @@ namespace :ruby do s.add_dependency("method_source",">=0.4.0") s.platform = Gem::Platform::RUBY end - + Rake::GemPackageTask.new(spec) do |pkg| pkg.need_zip = false pkg.need_tar = false @@ -61,7 +62,7 @@ end [:mingw32, :mswin32].each do |v| namespace v do spec = Gem::Specification.new do |s| - apply_spec_defaults(s) + apply_spec_defaults(s) s.add_dependency("method_source",">=0.4.0") s.add_dependency("win32console", ">=1.3.0") s.platform = "i386-#{v}" @@ -80,7 +81,7 @@ namespace :jruby do s.add_dependency("method_source",">=0.4.0") s.platform = "java" end - + Rake::GemPackageTask.new(spec) do |pkg| pkg.need_zip = false pkg.need_tar = false diff --git a/lib/pry.rb b/lib/pry.rb index 9818adc9..566d3491 100644 --- a/lib/pry.rb +++ b/lib/pry.rb @@ -1,10 +1,6 @@ # (C) John Mair (banisterfiend) 2011 # MIT License -direc = File.dirname(__FILE__) - -$LOAD_PATH << File.expand_path(direc) - require "method_source" require 'shellwords' require "readline" @@ -20,17 +16,17 @@ if RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/ end end -require "#{direc}/pry/version" -require "#{direc}/pry/hooks" -require "#{direc}/pry/print" -require "#{direc}/pry/command_base" -require "#{direc}/pry/commands" -require "#{direc}/pry/prompts" -require "#{direc}/pry/custom_completions" -require "#{direc}/pry/completion" -require "#{direc}/pry/core_extensions" -require "#{direc}/pry/pry_class" -require "#{direc}/pry/pry_instance" +require "pry/version" +require "pry/hooks" +require "pry/print" +require "pry/command_base" +require "pry/commands" +require "pry/prompts" +require "pry/custom_completions" +require "pry/completion" +require "pry/core_extensions" +require "pry/pry_class" +require "pry/pry_instance" # TEMPORARY HACK FOR BUG IN JRUBY 1.9 REGEX (which kills CodeRay) diff --git a/lib/pry/command_base.rb b/lib/pry/command_base.rb index 22d56451..1e3b8e67 100644 --- a/lib/pry/command_base.rb +++ b/lib/pry/command_base.rb @@ -1,6 +1,5 @@ -direc = File.dirname(__FILE__) require 'rubygems/dependency_installer' -require "#{direc}/command_base_helpers" +require "pry/command_base_helpers" class Pry diff --git a/lib/pry/commands.rb b/lib/pry/commands.rb index 5bc31759..287ec730 100644 --- a/lib/pry/commands.rb +++ b/lib/pry/commands.rb @@ -1,12 +1,10 @@ -direc = File.dirname(__FILE__) - require "optparse" require "method_source" require 'slop' require 'rubygems/dependency_installer' -require "#{direc}/command_base" -require "#{direc}/pry_instance" -require "#{direc}/command_helpers" +require "pry/command_base" +require "pry/pry_instance" +require "pry/command_helpers" class Pry @@ -118,7 +116,7 @@ e.g: stat hello_method else meth_name = meth_name_from_binding(target) end - + if (meth = get_method_object(meth_name, target, opts.to_hash(true))).nil? output.puts "Invalid method name: #{meth_name}. Type `stat --help` for help" next @@ -145,7 +143,7 @@ e.g: stat hello_method command "gist-method", "Gist a method to github. Type `gist-method --help` for more info.", :requires_gem => "gist" do |*args| target = target() - + opts = Slop.parse!(args) do |opts| opts.banner = %{Usage: gist-method [OPTIONS] [METH] Gist the method (doc or source) to github. @@ -165,17 +163,17 @@ e.g: gist -d my_method next if opts.help? # This needs to be extracted into its own method as it's shared - # by show-method and show-doc and stat commands + # by show-method and show-doc and stat commands meth_name = args.shift if meth_name - if meth_name =~ /\A([^\.\#]+)[\.\#](.+)\z/ + if meth_name =~ /\A([^\.\#]+)[\.\#](.+)\z/ context, meth_name = $1, $2 target = Pry.binding_for(target.eval(context)) end else meth_name = meth_name_from_binding(target) end - + if (meth = get_method_object(meth_name, target, opts.to_hash(true))).nil? output.puts "Invalid method name: #{meth_name}. Type `gist-method --help` for help" next diff --git a/lib/pry/pry_instance.rb b/lib/pry/pry_instance.rb index 0fa39532..a6e57949 100644 --- a/lib/pry/pry_instance.rb +++ b/lib/pry/pry_instance.rb @@ -1,6 +1,4 @@ -direc = File.dirname(__FILE__) - -require "#{direc}/command_processor.rb" +require "pry/command_processor.rb" class Pry