Skip to content
Browse files

version 0.5.7, added Pry executable, pry --help at command line for m…

…ore info
  • Loading branch information...
1 parent 99c0cb3 commit 22d31c0b92db2772acb53f817c0b2aa32793f351 @banister banister committed Feb 21, 2011
Showing with 92 additions and 5 deletions.
  1. +4 −0 CHANGELOG
  2. +4 −4 README.markdown
  3. +1 −0 Rakefile
  4. +63 −0 bin/pry
  5. +19 −0 lib/pry/commands.rb
  6. +1 −1 lib/pry/version.rb
View
4 CHANGELOG
@@ -1,3 +1,7 @@
+21/2/2010 version 0.5.7
+* Added pry executable, auto-loads .pryrc in user's home directory, if it
+ exists.
+
19/2/2010 version 0.5.5
* Added Pry.run_command
* More useful error messages
View
8 README.markdown
@@ -21,6 +21,10 @@ is trivial to set it to read from any object that has a `readline` method and wr
`puts` method - many other aspects of Pry are also configurable making
it a good choice for implementing custom shells.
+Pry now comes with an executable so it can be invoked at the command line.
+Just enter `pry` to start. A `.pryrc` file in the user's home directory will
+be loaded if it exists. Type `pry --help` at the command line for more information.
+
* Install the [gem](https://rubygems.org/gems/pry): `gem install pry`
* Read the [documentation](http://rdoc.info/github/banister/pry/master/file/README.markdown)
* See the [source code](http://github.com/banister/pry)
@@ -180,10 +184,6 @@ invoke any of these methods directly depending on exactly what aspect of the fun
###Limitations:
-* Pry does not pretend to be a replacement for `irb`,
- and so does not have an executable. It is designed to be used by
- other programs, not on its own. For a full-featured `irb` replacement
- see [ripl](https://github.com/cldwalker/ripl)
* Pry's `show-method` and `show-doc` commands do not work
in Ruby 1.8.
View
1 Rakefile
@@ -24,6 +24,7 @@ def apply_spec_defaults(s)
s.add_development_dependency("bacon",">=1.1.0")
s.homepage = "http://banisterfiend.wordpress.com"
s.has_rdoc = 'yard'
+ s.executables = ["pry"]
s.files = Dir["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c", "lib/**/*.rb", "examples/**/*.rb",
"test/*.rb", "CHANGELOG", "LICENSE", "README.markdown", "Rakefile", ".gemtest"]
end
View
63 bin/pry
@@ -0,0 +1,63 @@
+#!/usr/bin/env ruby
+
+# (C) John Mair (banisterfiend)
+# MIT license
+
+begin
+ require 'pry'
+rescue LoadError
+ require 'rubygems'
+ require 'pry'
+end
+require "optparse"
+
+# defaults
+options = {
+ :context => TOPLEVEL_BINDING,
+ :loadrc => true
+}
+
+OptionParser.new do |opts|
+ opts.banner = %{Usage: pry [OPTIONS]
+Start a Pry session.
+See: `https://github.com/banister` for more information.
+--
+}
+ opts.on("-r", "--require FILE", "`require` a Ruby script at startup.") do |file|
+ require file
+ end
+
+ opts.on("-e", "--exec CODE", "A line of Ruby code to execute in context before the session starts.") do |code|
+ options[:code] = code
+ end
+
+ opts.on("-f", "Suppress loading of ~/.pryrc") do
+ options[:loadrc] = false
+ end
+
+ opts.on("-v", "--version", "Display the Pry version.") do
+ puts "Pry version #{Pry::VERSION} on Ruby #{RUBY_VERSION}"
+ exit
+ end
+
+ opts.on("-c", "--context CONTEXT",
+ "Start the session in the specified context. Equivalent to `context.pry` in a session.") do |context|
+ options[:context] = Pry.binding_for(eval(context))
+ end
+
+ opts.on_tail("-h", "--help", "This message.") do
+ puts opts
+ exit
+ end
+end.parse!
+
+rcpath = File.expand_path("~/.pryrc")
+
+# load ~/.pryrc, if not suppressed with -f option
+load rcpath if File.exists?(rcpath) && options[:loadrc]
+
+# execute line of code, if provided with -e option
+options[:context].eval(options[:code]) if options[:code]
+
+# start the session
+options[:context].pry
View
19 lib/pry/commands.rb
@@ -465,6 +465,25 @@ class Commands < CommandBase
end
end
+ command "east-coker", "" do
+ text = %{
+--
+Now the light falls
+Across the open field, leaving the deep lane
+Shuttered with branches, dark in the afternoon,
+Where you lean against a bank while a van passes,
+And the deep lane insists on the direction
+Into the village, in the electric heat
+Hypnotised. In a warm haze the sultry light
+Is absorbed, not refracted, by grey stone.
+The dahlias sleep in the empty silence.
+Wait for the early owl.
+-- T.S Eliot
+}
+ output.puts text
+ text
+ end
+
command "cohen-poem", "" do
text = %{
--
View
2 lib/pry/version.rb
@@ -1,3 +1,3 @@
class Pry
- VERSION = "0.5.6"
+ VERSION = "0.5.7"
end

0 comments on commit 22d31c0

Please sign in to comment.
Something went wrong with that request. Please try again.