1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

refactored example initialization code (still need to update examples for new API)

This commit is contained in:
John Mair 2011-06-03 03:22:59 +12:00
parent 61bb4d9a17
commit 1a9738ff11
11 changed files with 24 additions and 48 deletions

View file

@ -1,7 +1,4 @@
direc = File.dirname(__FILE__)
require 'rubygems'
require "#{direc}/../lib/pry"
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
# define a local.
a = "a local variable"
@ -14,4 +11,5 @@ end
# Start pry session at top-level.
# The local variable `a` and the `hello` method will
# be accessible.
puts __LINE__
binding.pry

View file

@ -1,7 +1,4 @@
direc = File.dirname(__FILE__)
require 'rubygems'
require "#{direc}/../lib/pry"
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
# Inherit standard command set, but tweak them by importing some and
# overriding others.

View file

@ -1,7 +1,4 @@
direc = File.dirname(__FILE__)
require 'rubygems'
require "#{direc}/../lib/pry"
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
class MathCommands < Pry::CommandBase
command "greet", "Greet a person, e.g: greet john" do |name|

View file

@ -1,7 +1,4 @@
direc = File.dirname(__FILE__)
require 'rubygems'
require "#{direc}/../lib/pry"
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
my_hooks = {
:before_session => proc { |out, target| out.puts "Opening #{target.eval('self')}." },

View file

@ -10,11 +10,7 @@
#
# Have fun! :)
direc = File.dirname(__FILE__)
require 'rubygems'
require "texplay"
require "#{direc}/../lib/pry"
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
WIDTH = 640
HEIGHT = 480

View file

@ -1,7 +1,4 @@
direc = File.dirname(__FILE__)
require 'rubygems'
require "#{direc}/../lib/pry"
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
# Create a StringIO that contains the input data
str_input = StringIO.new("puts 'hello world!'\nputs \"I am in \#{self}\"\nexit")

View file

@ -1,7 +1,4 @@
direc = File.dirname(__FILE__)
require 'rubygems'
require "#{direc}/../lib/pry"
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
# Create a StringIO that contains the input data for all the Pry objects
cmds = <<-CMDS

View file

@ -1,7 +1,4 @@
direc = File.dirname(__FILE__)
require 'rubygems'
require "#{direc}/../lib/pry"
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
# Create a StringIO to contain the output data
str_output = StringIO.new

View file

@ -1,7 +1,4 @@
direc = File.dirname(__FILE__)
require 'rubygems'
require "#{direc}/../lib/pry"
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
my_print = proc { |out, value| out.puts "Output is: #{value.inspect}" }

View file

@ -1,7 +1,4 @@
direc = File.dirname(__FILE__)
require 'rubygems'
require "#{direc}/../lib/pry"
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
# Remember, first prompt in array is the main prompt, second is the wait
# prompt (used for multiline input when more input is required)

6
examples/helper.rb Normal file
View file

@ -0,0 +1,6 @@
require 'rubygems'
unless Object.const_defined? 'Pry'
$:.unshift File.expand_path '../../lib', __FILE__
require 'pry'
end