Browse files

dont alter LOAD_PATH and require files relative to lib/

  • Loading branch information...
1 parent d52182c commit 169090cc02515facf23e51f5104b6904579b63d1 Lee Jarvis committed Apr 24, 2011
Showing with 26 additions and 34 deletions.
  1. +5 −4 Rakefile
  2. +11 −15 lib/pry.rb
  3. +1 −2 lib/pry/command_base.rb
  4. +8 −10 lib/pry/commands.rb
  5. +1 −3 lib/pry/pry_instance.rb
View
9 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
View
26 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 @@
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)
View
3 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
View
18 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 @@ class Commands < CommandBase
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 @@ class Commands < CommandBase
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 @@ class Commands < CommandBase
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
View
4 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

0 comments on commit 169090c

Please sign in to comment.