mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
resolved conflict, brought in injekt's awesome changes, added changes to README and fixed but in lesspipe broken pipes
This commit is contained in:
parent
59f0880d8b
commit
263e722c2a
4 changed files with 36 additions and 9 deletions
|
@ -1,5 +1,4 @@
|
||||||
![Alt text](http://dl.dropbox.com/u/26521875/pry_logo2.png)
|
![Alt text](http://dl.dropbox.com/u/26521875/pry_logo_shade.png)
|
||||||
|
|
||||||
(C) John Mair (banisterfiend) 2011
|
(C) John Mair (banisterfiend) 2011
|
||||||
|
|
||||||
_Get to the code_
|
_Get to the code_
|
||||||
|
@ -50,7 +49,7 @@ Example: Navigating around state
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
Pry allows us to pop in and out of different scopes (objects) using
|
Pry allows us to pop in and out of different scopes (objects) using
|
||||||
the `cd` command. To view what variables and methods are available
|
the `cd` command. To view which variables and methods are available
|
||||||
within a particular scope we use the versatile `ls` command.
|
within a particular scope we use the versatile `ls` command.
|
||||||
|
|
||||||
Here we will begin Pry at top-level, then pry on a class and then on
|
Here we will begin Pry at top-level, then pry on a class and then on
|
||||||
|
@ -100,7 +99,7 @@ point available. When the session ends the program continues with any
|
||||||
modifications you made to it.
|
modifications you made to it.
|
||||||
|
|
||||||
This functionality can be used for such things as: debugging,
|
This functionality can be used for such things as: debugging,
|
||||||
implementing developer consoles, and applying hot patches.
|
implementing developer consoles and applying hot patches.
|
||||||
|
|
||||||
code:
|
code:
|
||||||
|
|
||||||
|
@ -134,7 +133,32 @@ Pry session:
|
||||||
pry(main)> exit
|
pry(main)> exit
|
||||||
|
|
||||||
program resumes here.
|
program resumes here.
|
||||||
|
|
||||||
|
Command Shell Integration
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
A line of input that begins with a '.' will be forwarded to the
|
||||||
|
command shell. This enables us to navigate the file system, spawn
|
||||||
|
an editor, and run git and rake directly from within Pry.
|
||||||
|
|
||||||
|
Further, we can use the `shell-mode` command to incorporate the
|
||||||
|
present working directory into the Pry prompt and bring in (very
|
||||||
|
limited at this stage, sorry) file name completion.
|
||||||
|
We can also interpolate Ruby code directly into the shell by
|
||||||
|
using the normal `#{}` string interpolation syntax.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
In the code below we're going to switch to `shell-mode` and use the
|
||||||
|
`gem-cd` command to enter the home directory for a gem and examine
|
||||||
|
some of the files there, we will also show off some interpolation.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Features and limitations
|
Features and limitations
|
||||||
------------------------
|
------------------------
|
||||||
|
|
|
@ -4,7 +4,7 @@ class Pry
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def gem_installed?(gem_name)
|
def gem_installed?(gem_name)
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
!!Gem.source_index.find_name(gem_name).first
|
!!Gem.source_index.find_name(gem_name).first
|
||||||
end
|
end
|
||||||
|
@ -94,8 +94,9 @@ class Pry
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
lesspipe { |less| less.puts text }
|
lesspipe { |less| less.puts text }
|
||||||
rescue Exception
|
rescue Errno::ENOENT
|
||||||
simple_pager(text)
|
simple_pager(text)
|
||||||
|
rescue Errno::EPIPE
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -71,7 +71,7 @@ class Pry
|
||||||
|
|
||||||
@@cd_history << Dir.pwd
|
@@cd_history << Dir.pwd
|
||||||
Dir.chdir(dest)
|
Dir.chdir(dest)
|
||||||
output.puts "=> #{dest.inspect}"
|
output.puts "=> #{dest}"
|
||||||
rescue Errno::ENOENT
|
rescue Errno::ENOENT
|
||||||
output.puts "No such directory: #{dest}"
|
output.puts "No such directory: #{dest}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
require "awesome_print"
|
||||||
|
|
||||||
class Pry
|
class Pry
|
||||||
DEFAULT_PRINT = proc do |output, value|
|
DEFAULT_PRINT = proc do |output, value|
|
||||||
if Pry.color
|
if Pry.color
|
||||||
output.puts "=> #{CodeRay.scan(Pry.view(value), :ruby).term}"
|
output.puts "=> #{value.ai}"#"#{CodeRay.scan(Pry.view(value), :ruby).term}"
|
||||||
else
|
else
|
||||||
output.puts "=> #{Pry.view(value)}"
|
output.puts "=> #{Pry.view(value)}"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue