pry 0.8.4pre1-i386-mingw32 → 0.9.0-i386-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGELOG +25 -6
  3. data/README.markdown +11 -4
  4. data/Rakefile +15 -19
  5. data/TODO +28 -2
  6. data/bin/pry +28 -11
  7. data/examples/example_basic.rb +2 -4
  8. data/examples/example_command_override.rb +2 -5
  9. data/examples/example_commands.rb +1 -4
  10. data/examples/example_hooks.rb +2 -5
  11. data/examples/example_image_edit.rb +4 -8
  12. data/examples/example_input.rb +1 -4
  13. data/examples/example_input2.rb +1 -4
  14. data/examples/example_output.rb +1 -4
  15. data/examples/example_print.rb +2 -5
  16. data/examples/example_prompt.rb +2 -5
  17. data/examples/helper.rb +6 -0
  18. data/lib/pry.rb +59 -3
  19. data/lib/pry/command_context.rb +10 -9
  20. data/lib/pry/command_processor.rb +51 -73
  21. data/lib/pry/command_set.rb +79 -28
  22. data/lib/pry/commands.rb +9 -123
  23. data/lib/pry/completion.rb +30 -29
  24. data/lib/pry/config.rb +100 -0
  25. data/lib/pry/default_commands/basic.rb +37 -0
  26. data/lib/pry/default_commands/context.rb +16 -15
  27. data/lib/pry/default_commands/documentation.rb +73 -54
  28. data/lib/pry/default_commands/easter_eggs.rb +1 -20
  29. data/lib/pry/default_commands/gems.rb +31 -40
  30. data/lib/pry/default_commands/input.rb +223 -15
  31. data/lib/pry/default_commands/introspection.rb +108 -73
  32. data/lib/pry/default_commands/ls.rb +25 -11
  33. data/lib/pry/default_commands/shell.rb +29 -39
  34. data/lib/pry/extended_commands/experimental.rb +17 -0
  35. data/lib/pry/extended_commands/user_command_api.rb +22 -0
  36. data/lib/pry/helpers.rb +1 -0
  37. data/lib/pry/helpers/base_helpers.rb +15 -104
  38. data/lib/pry/helpers/command_helpers.rb +96 -59
  39. data/lib/pry/helpers/text.rb +83 -0
  40. data/lib/pry/history_array.rb +105 -0
  41. data/lib/pry/plugins.rb +79 -0
  42. data/lib/pry/pry_class.rb +102 -114
  43. data/lib/pry/pry_instance.rb +123 -55
  44. data/lib/pry/version.rb +1 -1
  45. data/pry.gemspec +45 -0
  46. data/test/helper.rb +57 -7
  47. data/test/test_command_processor.rb +205 -0
  48. data/test/{test_commandset.rb → test_command_set.rb} +18 -12
  49. data/test/test_default_commands.rb +59 -0
  50. data/test/test_default_commands/test_context.rb +64 -0
  51. data/test/test_default_commands/test_documentation.rb +31 -0
  52. data/test/test_default_commands/test_gems.rb +14 -0
  53. data/test/test_default_commands/test_input.rb +327 -0
  54. data/test/test_default_commands/test_introspection.rb +155 -0
  55. data/test/test_history_array.rb +65 -0
  56. data/test/test_pry.rb +548 -313
  57. metadata +48 -15
  58. data/lib/pry/hooks.rb +0 -17
  59. data/lib/pry/print.rb +0 -16
  60. data/lib/pry/prompts.rb +0 -31
data/.gitignore CHANGED
@@ -2,6 +2,7 @@ Makefile
2
2
  *.so
3
3
  *.o
4
4
  *.def
5
+ *.rbc
5
6
  doc/
6
7
  pkg/
7
8
  coverage/
data/CHANGELOG CHANGED
@@ -1,3 +1,22 @@
1
+ 17/6/2011 version 0.9.0
2
+ * plugin system
3
+ * regex commands
4
+ * show-method works on methods defined in REPL
5
+ * new command system/API
6
+ * rubinius core support
7
+ * inp/out special locals
8
+ * _ex_ backtrace navigation object (_ex_.line, _ex_.file)
9
+ * readline history saving/loading
10
+ * prompt stack
11
+ * more hooks
12
+ * amend-line
13
+ * play
14
+ * show-input
15
+ * edit
16
+ * much more comprehensive test suite
17
+ * support for new and old rubygems API
18
+ * changed -s behaviour of ls (now excludes Object methods)
19
+
1
20
  26/3/2011 version 0.7.6.1
2
21
  * added slightly better support for YARD
3
22
  * now @param and @return tags are colored green and markdown `code` is syntax highlighted using coderay
@@ -24,11 +43,11 @@
24
43
  * --color mode for pry commandline
25
44
  * clean up requires (put them all in one place)
26
45
  * simple-prompt command and toggle-color commandd.
27
-
46
+
28
47
  28/2/2011 version 0.6.3
29
48
  * Using MethodSource 0.3.4 so 1.8 show-method support provided
30
49
  * `Set` class added to list of classes that are inspected
31
-
50
+
32
51
  26/2/2011 version 0.6.1
33
52
  * !@ command alias for exit_all
34
53
  * `cd /` for breaking out to pry top level (jump-to 0)
@@ -40,11 +59,11 @@
40
59
  22/2/2011 version 0.5.8
41
60
  * Added -c (context) option to show-doc, show-methods and eval-file
42
61
  * Fixed up ordering issue of -c and -r parameters to command line pry
43
-
62
+
44
63
  21/2/2011 version 0.5.7
45
64
  * Added pry executable, auto-loads .pryrc in user's home directory, if it
46
65
  exists.
47
-
66
+
48
67
  19/2/2011 version 0.5.5
49
68
  * Added Pry.run_command
50
69
  * More useful error messages
@@ -65,7 +84,7 @@
65
84
  * Get rid of ls_method and ls_imethods (subsumed by more powerful ls)
66
85
  * Get rid of show_idoc and show_imethod
67
86
  * Add special eval-file command that evals target file in current context
68
-
87
+
69
88
  27/1/2011 version 0.4.5
70
89
  * fixed show_method (though fragile as it references __binding_impl__
71
90
  directly, making a name change to that method difficult
@@ -99,4 +118,4 @@
99
118
  * now rescuing SyntaxError as well as Racc::Parser error in valid_expression?
100
119
  8/12/2010 version 0.1.0
101
120
  * release!
102
-
121
+
@@ -1,9 +1,18 @@
1
- ![Alt text](http://dl.dropbox.com/u/26521875/pry_logo_shade.png)
1
+ ![Alt text](http://dl.dropbox.com/u/15761219/pry_horizontal_red.png)
2
2
 
3
3
  (C) John Mair (banisterfiend) 2011
4
4
 
5
5
  _Get to the code_
6
6
 
7
+ ## These docs are now out of date for the 0.9.0 release.
8
+
9
+ ** New documentation will be available shortly, please see the CHANGELOG and Pry's own livehelp system for information in the meantime.
10
+
11
+ Also note that JRuby is not yet supported in this release, but will be soon.
12
+
13
+ Thanks **
14
+
15
+
7
16
  Pry is a powerful alternative to the standard IRB shell for Ruby. It is
8
17
  written from scratch to provide a number of advanced features, some of
9
18
  these include:
@@ -549,8 +558,6 @@ Problems or questions contact me at [github](http://github.com/banister)
549
558
  The Pry team consists of:
550
559
 
551
560
  * [banisterfiend](http://github.com/banister)
552
- * [epitron](http://github.com/epitron)
553
561
  * [injekt](http://github.com/injekt)
554
562
  * [Mon_Ouie](http://github.com/mon-ouie)
555
-
556
-
563
+ * [Rob Gleeson](https://github.com/robgleeson)
data/Rakefile CHANGED
@@ -5,7 +5,8 @@ $:.unshift 'lib'
5
5
  require 'pry/version'
6
6
 
7
7
  CLOBBER.include("**/*~", "**/*#*", "**/*.log")
8
- CLEAN.include("**/*#*", "**/*#*.*", "**/*_flymake*.*", "**/*_flymake", "**/*.rbc")
8
+ CLEAN.include("**/*#*", "**/*#*.*", "**/*_flymake*.*", "**/*_flymake",
9
+ "**/*.rbc", "**/.#*.*")
9
10
 
10
11
  def apply_spec_defaults(s)
11
12
  s.name = "pry"
@@ -16,25 +17,25 @@ def apply_spec_defaults(s)
16
17
  s.email = 'jrmair@gmail.com'
17
18
  s.description = s.summary
18
19
  s.homepage = "http://banisterfiend.wordpress.com"
19
- s.has_rdoc = 'yard'
20
20
  s.executables = ["pry"]
21
21
  s.files = `git ls-files`.split("\n")
22
22
  s.test_files = `git ls-files -- test/*`.split("\n")
23
23
  s.add_dependency("ruby_parser",">=2.0.5")
24
24
  s.add_dependency("coderay",">=0.9.8")
25
- s.add_dependency("slop",">=1.5.3")
26
- s.add_dependency("method_source",">=0.4.0")
25
+ s.add_dependency("slop","~>1.9.0")
26
+ s.add_dependency("method_source",">=0.6.0")
27
27
  s.add_development_dependency("bacon",">=1.1.0")
28
+ s.add_development_dependency("open4", "~>1.0.1")
28
29
  end
29
30
 
31
+ desc "Run tests"
30
32
  task :test do
31
33
  sh "bacon -Itest -rubygems -a"
32
34
  end
33
35
 
34
36
  desc "run pry"
35
37
  task :pry do
36
- require 'pry'
37
- binding.pry
38
+ load 'bin/pry'
38
39
  end
39
40
 
40
41
  desc "show pry version"
@@ -52,6 +53,13 @@ namespace :ruby do
52
53
  pkg.need_zip = false
53
54
  pkg.need_tar = false
54
55
  end
56
+
57
+ desc "Generate gemspec file"
58
+ task :gemspec do
59
+ File.open("#{spec.name}.gemspec", "w") do |f|
60
+ f << spec.to_ruby
61
+ end
62
+ end
55
63
  end
56
64
 
57
65
  [:mingw32, :mswin32].each do |v|
@@ -69,20 +77,8 @@ end
69
77
  end
70
78
  end
71
79
 
72
- namespace :jruby do
73
- spec = Gem::Specification.new do |s|
74
- apply_spec_defaults(s)
75
- s.platform = "java"
76
- end
77
-
78
- Rake::GemPackageTask.new(spec) do |pkg|
79
- pkg.need_zip = false
80
- pkg.need_tar = false
81
- end
82
- end
83
-
84
80
  desc "build all platform gems at once"
85
- task :gems => [:clean, :rmgems, "ruby:gem", "jruby:gem", "mswin32:gem", "mingw32:gem"]
81
+ task :gems => [:clean, :rmgems, "ruby:gem", "mswin32:gem", "mingw32:gem"]
86
82
 
87
83
  desc "remove all platform gems"
88
84
  task :rmgems => ["ruby:clobber_package"]
data/TODO CHANGED
@@ -1,13 +1,39 @@
1
1
 
2
+ ROADMAP
3
+
2
4
  FUTURE
3
- * allows pipes (|) for commands
5
+ --------
6
+ * Pry server and Pry client for SLIME style remote repl connectinos.
7
+ * i18n support
8
+
9
+ 0.9.0
10
+ Major features
11
+ --------------
12
+ * Restructure command system and helpers (almost complete)
13
+ * Delete unnecessary commands, add a couple of new ones (e.g amend-line)
14
+ * Readline history
15
+ * Plugin support
16
+ * Support Rubinius core methods
17
+ * in[] and out[] arrays
18
+ * Improve test coverage (test some commands, etc)
19
+
20
+ Minor changes
21
+ -------------
22
+ * improve edit-method support for various editors
23
+ * ensure all commands have appropriate error handing and informative error messages
24
+ * show-doc should include signature of method
25
+
26
+ Optional
27
+ --------
28
+ * multi-line readline support
29
+
4
30
 
5
31
  0.8.0
6
32
  * allow #{} interpolation of all commands
7
33
  * update documentation! new commands and features and change in behaviour of `run`
8
34
  * add ; at end of line to suppress return value output
9
35
  * Remove message spam (before/after hooks)
10
- * stop commands returning a value
36
+ * stop commands returning a value
11
37
  * use `redo` in the r() method when encounter a command
12
38
  * shell functionality should just use system(), but redirect in and
13
39
  out to Pry.input and Pry.output by reassining $stdin and $stdout
data/bin/pry CHANGED
@@ -20,8 +20,26 @@ See: `https://github.com/banister` for more information.
20
20
  }
21
21
 
22
22
  on :e, :exec, "A line of code to execute in context before the session starts", true
23
- on :f, "Suppress loading of ~/.pryrc"
24
- on "no-color", "Disable syntax highlighting for session"
23
+
24
+ on "no-pager", "Disable pager for long output" do
25
+ Pry.pager = false
26
+ end
27
+
28
+ on "no-color", "Disable syntax highlighting for session" do
29
+ Pry.color = false
30
+ end
31
+
32
+ on :f, "Suppress loading of ~/.pryrc" do
33
+ # load ~/.pryrc, if not suppressed with -f option
34
+ Pry.config.should_load_rc = false
35
+ end
36
+
37
+ on "no-plugins", "Suppress loading of plugins." do
38
+ # suppress plugins if given --no-plugins optino
39
+ Pry.config.plugins.enabled = false
40
+ end
41
+
42
+ on "installed-plugins", "List installed plugins."
25
43
 
26
44
  on "simple-prompt", "Enable simple prompt mode" do
27
45
  Pry.prompt = Pry::SIMPLE_PROMPT
@@ -47,18 +65,17 @@ See: `https://github.com/banister` for more information.
47
65
  )
48
66
  end
49
67
 
50
- # invoked via cli
51
- Pry.cli = true
52
-
53
- Pry::Commands.instance_eval do
54
- command "reset", "Reset the REPL to a clean state." do
55
- output.puts "Pry reset."
56
- exec("pry")
68
+ if opts["installed-plugins"]
69
+ puts "Installed Plugins:"
70
+ puts "--"
71
+ Pry.locate_plugins.each do |plugin|
72
+ puts "#{plugin.name}".ljust(18) + plugin.spec.summary
57
73
  end
74
+ exit
58
75
  end
59
76
 
60
- # load ~/.pryrc, if not suppressed with -f option
61
- Pry.should_load_rc = !opts.f?
77
+ # invoked via cli
78
+ Pry.cli = true
62
79
 
63
80
  # create the actual context
64
81
  context = Pry.binding_for(eval(opts[:context]))
@@ -1,7 +1,4 @@
1
- direc = File.dirname(__FILE__)
2
-
3
- require 'rubygems'
4
- require "#{direc}/../lib/pry"
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
5
2
 
6
3
  # define a local.
7
4
  a = "a local variable"
@@ -14,4 +11,5 @@ end
14
11
  # Start pry session at top-level.
15
12
  # The local variable `a` and the `hello` method will
16
13
  # be accessible.
14
+ puts __LINE__
17
15
  binding.pry
@@ -1,7 +1,4 @@
1
- direc = File.dirname(__FILE__)
2
-
3
- require 'rubygems'
4
- require "#{direc}/../lib/pry"
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
5
2
 
6
3
  # Inherit standard command set, but tweak them by importing some and
7
4
  # overriding others.
@@ -18,7 +15,7 @@ class MyCommands < Pry::CommandBase
18
15
 
19
16
  # analogy to Ruby's native alias_method idiom for decorating a method
20
17
  alias_command "old_status", "status", ""
21
-
18
+
22
19
  # Invoke one command from within another using `run`
23
20
  command "status", "Modified status." do |x|
24
21
  output.puts "About to show status, are you ready?"
@@ -1,7 +1,4 @@
1
- direc = File.dirname(__FILE__)
2
-
3
- require 'rubygems'
4
- require "#{direc}/../lib/pry"
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
5
2
 
6
3
  class MathCommands < Pry::CommandBase
7
4
  command "greet", "Greet a person, e.g: greet john" do |name|
@@ -1,12 +1,9 @@
1
- direc = File.dirname(__FILE__)
2
-
3
- require 'rubygems'
4
- require "#{direc}/../lib/pry"
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
5
2
 
6
3
  my_hooks = {
7
4
  :before_session => proc { |out, target| out.puts "Opening #{target.eval('self')}." },
8
5
  :after_session => proc { |out, target| out.puts "Closing #{target.eval('self')}." }
9
6
  }
10
-
7
+
11
8
  # Start a Pry session using the hooks hash defined in my_hooks
12
9
  Pry.start(TOPLEVEL_BINDING, :hooks => my_hooks)
@@ -1,7 +1,7 @@
1
1
  # Note: this requires you to have Gosu and TexPlay installed.
2
2
  # `gem install gosu`
3
3
  # `gem install texplay`
4
- #
4
+ #
5
5
  # Extra instructions for installing Gosu on Linux can be found here:
6
6
  # http://code.google.com/p/gosu/wiki/GettingStartedOnLinux
7
7
  #
@@ -10,11 +10,7 @@
10
10
  #
11
11
  # Have fun! :)
12
12
 
13
- direc = File.dirname(__FILE__)
14
-
15
- require 'rubygems'
16
- require "texplay"
17
- require "#{direc}/../lib/pry"
13
+ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
18
14
 
19
15
  WIDTH = 640
20
16
  HEIGHT = 480
@@ -42,12 +38,12 @@ class WinClass < Gosu::Window
42
38
  @img.rect 0, 0, @img.width - 1, @img.height - 1
43
39
 
44
40
  @binding = Pry.binding_for(@img)
45
-
41
+
46
42
  @pry_instance = Pry.new(:commands => ImageCommands, :prompt => IMAGE_PROMPT)
47
43
  end
48
44
 
49
45
  def draw
50
- @img.draw_rot(WIDTH / 2, HEIGHT / 2, 1, 0, 0.5, 0.5)
46
+ @img.draw_rot(WIDTH / 2, HEIGHT / 2, 1, 0, 0.5, 0.5)
51
47
  end
52
48
 
53
49
  def update
@@ -1,7 +1,4 @@
1
- direc = File.dirname(__FILE__)
2
-
3
- require 'rubygems'
4
- require "#{direc}/../lib/pry"
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
5
2
 
6
3
  # Create a StringIO that contains the input data
7
4
  str_input = StringIO.new("puts 'hello world!'\nputs \"I am in \#{self}\"\nexit")
@@ -1,7 +1,4 @@
1
- direc = File.dirname(__FILE__)
2
-
3
- require 'rubygems'
4
- require "#{direc}/../lib/pry"
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
5
2
 
6
3
  # Create a StringIO that contains the input data for all the Pry objects
7
4
  cmds = <<-CMDS
@@ -1,7 +1,4 @@
1
- direc = File.dirname(__FILE__)
2
-
3
- require 'rubygems'
4
- require "#{direc}/../lib/pry"
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
5
2
 
6
3
  # Create a StringIO to contain the output data
7
4
  str_output = StringIO.new
@@ -1,9 +1,6 @@
1
- direc = File.dirname(__FILE__)
2
-
3
- require 'rubygems'
4
- require "#{direc}/../lib/pry"
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
5
2
 
6
3
  my_print = proc { |out, value| out.puts "Output is: #{value.inspect}" }
7
-
4
+
8
5
  # Start a Pry session using the print object defined in my_print
9
6
  Pry.start(TOPLEVEL_BINDING, :print => my_print)
@@ -1,12 +1,9 @@
1
- direc = File.dirname(__FILE__)
2
-
3
- require 'rubygems'
4
- require "#{direc}/../lib/pry"
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
5
2
 
6
3
  # Remember, first prompt in array is the main prompt, second is the wait
7
4
  # prompt (used for multiline input when more input is required)
8
5
  my_prompt = [ proc { |obj, *| "inside #{obj}> " },
9
6
  proc { |obj, *| "inside #{obj}* "} ]
10
-
7
+
11
8
  # Start a Pry session using the prompt defined in my_prompt
12
9
  Pry.start(TOPLEVEL_BINDING, :prompt => my_prompt)
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+ unless Object.const_defined? 'Pry'
3
+ $:.unshift File.expand_path '../../lib', __FILE__
4
+ require 'pry'
5
+ end
6
+
data/lib/pry.rb CHANGED
@@ -1,6 +1,63 @@
1
1
  # (C) John Mair (banisterfiend) 2011
2
2
  # MIT License
3
3
 
4
+ require 'pp'
5
+ require 'pry/helpers/base_helpers'
6
+ class Pry
7
+ # The default hooks - display messages when beginning and ending Pry sessions.
8
+ DEFAULT_HOOKS = {
9
+ :before_session => proc do |out, target|
10
+ # ensure we're actually in a method
11
+ meth_name = target.eval('__method__')
12
+ file = target.eval('__FILE__')
13
+
14
+ # /unknown/ for rbx
15
+ if file !~ /(\(.*\))|<.*>/ && file !~ /__unknown__/ && file != "" && file != "-e"
16
+ Pry.run_command "whereami 5", :output => out, :show_output => true, :context => target, :commands => Pry::Commands
17
+ end
18
+ end
19
+ }
20
+
21
+ # The default prints
22
+ DEFAULT_PRINT = proc do |output, value|
23
+ Helpers::BaseHelpers.stagger_output("=> #{Helpers::BaseHelpers.colorize_code(value.pretty_inspect)}", output)
24
+ end
25
+
26
+ # Will only show the first line of the backtrace
27
+ DEFAULT_EXCEPTION_HANDLER = proc do |output, exception|
28
+ output.puts "#{exception.class}: #{exception.message}"
29
+ output.puts "from #{exception.backtrace.first}"
30
+ end
31
+
32
+ # The default prompt; includes the target and nesting level
33
+ DEFAULT_PROMPT = [
34
+ proc { |target_self, nest_level|
35
+ if nest_level == 0
36
+ "pry(#{Pry.view_clip(target_self)})> "
37
+ else
38
+ "pry(#{Pry.view_clip(target_self)}):#{Pry.view_clip(nest_level)}> "
39
+ end
40
+ },
41
+
42
+ proc { |target_self, nest_level|
43
+ if nest_level == 0
44
+ "pry(#{Pry.view_clip(target_self)})* "
45
+ else
46
+ "pry(#{Pry.view_clip(target_self)}):#{Pry.view_clip(nest_level)}* "
47
+ end
48
+ }
49
+ ]
50
+
51
+ # A simple prompt - doesn't display target or nesting level
52
+ SIMPLE_PROMPT = [proc { ">> " }, proc { " | " }]
53
+
54
+ SHELL_PROMPT = [
55
+ proc { |target_self, _| "pry #{Pry.view_clip(target_self)}:#{Dir.pwd} $ " },
56
+ proc { |target_self, _| "pry #{Pry.view_clip(target_self)}:#{Dir.pwd} * " }
57
+ ]
58
+
59
+ end
60
+
4
61
  require "method_source"
5
62
  require 'shellwords'
6
63
  require "readline"
@@ -20,15 +77,14 @@ if RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/
20
77
  end
21
78
 
22
79
  require "pry/version"
23
- require "pry/hooks"
24
- require "pry/print"
80
+ require "pry/history_array"
25
81
  require "pry/helpers"
26
82
  require "pry/command_set"
27
83
  require "pry/commands"
28
84
  require "pry/command_context"
29
- require "pry/prompts"
30
85
  require "pry/custom_completions"
31
86
  require "pry/completion"
87
+ require "pry/plugins"
32
88
  require "pry/core_extensions"
33
89
  require "pry/pry_class"
34
90
  require "pry/pry_instance"