From 45f2f105f8a8ef4115f0e0c3fd32fd89e2d36f81 Mon Sep 17 00:00:00 2001 From: John Mair Date: Fri, 21 Jan 2011 19:09:21 +1300 Subject: [PATCH] almost ready for 0.4.0 release, created new example_input2.rb example for advanced input usage --- CHANGELOG | 10 ++++++++++ README.markdown | 6 ++++++ examples/example_image_edit.rb | 2 +- examples/example_input2.rb | 31 +++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 examples/example_input2.rb diff --git a/CHANGELOG b/CHANGELOG index 30fe42af..41bea8d2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,13 @@ +21/1/2010 version 0.4.0 +* added command API +* added many new commands, i.e ls_methods and friends +* modified other commands +* now accepts greater customization, can modify: input, output, hooks, + prompt, print object +* added tab completion (even completes commands) +* added extensive tests +* added examples +* many more changes 9/12/2010 version 0.1.3 * Got rid of rubygems dependency, refactored some code. 8/12/2010 version 0.1.2 diff --git a/README.markdown b/README.markdown index ca4af631..ee0fc8c6 100644 --- a/README.markdown +++ b/README.markdown @@ -242,6 +242,12 @@ If you want to access a method of the same name, prefix the invocation by whites current one with `obj` as the receiver of the new session. Very useful when exploring large or complicated runtime state. +Example Programs +---------------- + +Pry comes bundled with a few example programs to illustrate some +features, see the `examples/` directory. + Customizing Pry --------------- diff --git a/examples/example_image_edit.rb b/examples/example_image_edit.rb index ad29de60..648b4891 100644 --- a/examples/example_image_edit.rb +++ b/examples/example_image_edit.rb @@ -38,7 +38,7 @@ class WinClass < Gosu::Window def initialize super(WIDTH, HEIGHT, false) - @img = TexPlay.create_image(self, 200, 200) + @img = TexPlay.create_image(self, 200, 200).clear :color => :black @img.rect 0, 0, @img.width - 1, @img.height - 1 @binding = @img.__binding__ diff --git a/examples/example_input2.rb b/examples/example_input2.rb new file mode 100644 index 00000000..7e828ea1 --- /dev/null +++ b/examples/example_input2.rb @@ -0,0 +1,31 @@ +direc = File.dirname(__FILE__) + +require 'rubygems' +require "#{direc}/../lib/pry" + +# Create a StringIO that contains the input data for all the Pry objects +cmds = <<-CMDS +cd 1 +status +puts 'hello from 1!!' +cd 2 +nesting +puts 'hello from 2!!' +_pry_.parent.input = Readline +back +exit_all +CMDS +str_input = StringIO.new(cmds) + +# Start a Pry session on the Fixnum 5 using the input data in +# str_input +Pry.input = str_input + +# Start the session reading from str_input. +# Note that because `Pry.input` is set to `str_input` all nested pry +# sessions will read from `str_input` too. All pry sessions are there +# for non-interactive, except for `pry(1)` which starts off +# non-interactive but is set to be interactive by pry(2) (using +# _pry_.parent.input = Readline) + +0.pry