pry 0.6.7pre4-i386-mingw32 → 0.6.8-i386-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,39 +1,39 @@
1
- direc = File.dirname(__FILE__)
2
-
3
- require 'rubygems'
4
- require "#{direc}/../lib/pry"
5
-
6
- class MathCommands < Pry::CommandBase
7
- command "greet", "Greet a person, e.g: greet john" do |name|
8
- output.puts "Good afternoon #{name.capitalize}! Do you like Math?"
9
- end
10
-
11
- command "add", "Add a list of numbers together, e.g: add 1 2 3 4" do |*args|
12
- output.puts "Total: #{args.map(&:to_f).inject(&:+)}"
13
- end
14
-
15
- command "multiply", "Multiply a list of numbers together, e.g: multiply 1 2 3 4" do |*args|
16
- output.puts "Total: #{args.map(&:to_f).inject(&:*)}"
17
- end
18
-
19
- # Explicitly giving a description of "" to prevent command being
20
- # displayed in 'help'
21
- command "exit", "" do
22
- throw :breakout, 0
23
- end
24
-
25
- # Bring in the "!" method from Pry::Commands
26
- import_from Pry::Commands, "!"
27
- end
28
-
29
- # Since we provide math commands, let's have mathematical
30
- # before_session and after_session hooks, and a mathematical prompt
31
- math_prompt = [proc { "math> " }, proc { "math* " }]
32
- math_hooks = {
33
- :before_session => proc { |output, *| output.puts "Welcome! Let's do some math! Type 'help' for a list of commands." },
34
- :after_session => proc { |output, *| output.puts "Goodbye!" }
35
- }
36
-
37
- # Start a Pry session using the commands defined in MyCommands
38
- # Type 'help' in Pry to get a list of the commands and their descriptions
39
- Pry.start(TOPLEVEL_BINDING, :commands => MathCommands, :prompt => math_prompt, :hooks => math_hooks)
1
+ direc = File.dirname(__FILE__)
2
+
3
+ require 'rubygems'
4
+ require "#{direc}/../lib/pry"
5
+
6
+ class MathCommands < Pry::CommandBase
7
+ command "greet", "Greet a person, e.g: greet john" do |name|
8
+ output.puts "Good afternoon #{name.capitalize}! Do you like Math?"
9
+ end
10
+
11
+ command "add", "Add a list of numbers together, e.g: add 1 2 3 4" do |*args|
12
+ output.puts "Total: #{args.map(&:to_f).inject(&:+)}"
13
+ end
14
+
15
+ command "multiply", "Multiply a list of numbers together, e.g: multiply 1 2 3 4" do |*args|
16
+ output.puts "Total: #{args.map(&:to_f).inject(&:*)}"
17
+ end
18
+
19
+ # Explicitly giving a description of "" to prevent command being
20
+ # displayed in 'help'
21
+ command "exit", "" do
22
+ throw :breakout, 0
23
+ end
24
+
25
+ # Bring in the "!" method from Pry::Commands
26
+ import_from Pry::Commands, "!"
27
+ end
28
+
29
+ # Since we provide math commands, let's have mathematical
30
+ # before_session and after_session hooks, and a mathematical prompt
31
+ math_prompt = [proc { "math> " }, proc { "math* " }]
32
+ math_hooks = {
33
+ :before_session => proc { |output, *| output.puts "Welcome! Let's do some math! Type 'help' for a list of commands." },
34
+ :after_session => proc { |output, *| output.puts "Goodbye!" }
35
+ }
36
+
37
+ # Start a Pry session using the commands defined in MyCommands
38
+ # Type 'help' in Pry to get a list of the commands and their descriptions
39
+ Pry.start(TOPLEVEL_BINDING, :commands => MathCommands, :prompt => math_prompt, :hooks => math_hooks)
@@ -1,12 +1,12 @@
1
- direc = File.dirname(__FILE__)
2
-
3
- require 'rubygems'
4
- require "#{direc}/../lib/pry"
5
-
6
- my_hooks = {
7
- :before_session => proc { |out, obj| out.puts "Opening #{obj}." },
8
- :after_session => proc { |out, obj| out.puts "Closing #{obj}." }
9
- }
10
-
11
- # Start a Pry session using the hooks hash defined in my_hooks
12
- Pry.start(TOPLEVEL_BINDING, :hooks => my_hooks)
1
+ direc = File.dirname(__FILE__)
2
+
3
+ require 'rubygems'
4
+ require "#{direc}/../lib/pry"
5
+
6
+ my_hooks = {
7
+ :before_session => proc { |out, target| out.puts "Opening #{target.eval('self')}." },
8
+ :after_session => proc { |out, target| out.puts "Closing #{target.eval('self')}." }
9
+ }
10
+
11
+ # Start a Pry session using the hooks hash defined in my_hooks
12
+ Pry.start(TOPLEVEL_BINDING, :hooks => my_hooks)
@@ -1,71 +1,71 @@
1
- # Note: this requires you to have Gosu and TexPlay installed.
2
- # `gem install gosu`
3
- # `gem install texplay`
4
- #
5
- # Extra instructions for installing Gosu on Linux can be found here:
6
- # http://code.google.com/p/gosu/wiki/GettingStartedOnLinux
7
- #
8
- # Instructions for using TexPlay can be found here:
9
- # http://banisterfiend.wordpress.com/2008/08/23/texplay-an-image-manipulation-tool-for-ruby-and-gosu/
10
- #
11
- # Have fun! :)
12
-
13
- direc = File.dirname(__FILE__)
14
-
15
- require 'rubygems'
16
- require "texplay"
17
- require "#{direc}/../lib/pry"
18
-
19
- WIDTH = 640
20
- HEIGHT = 480
21
-
22
- IMAGE_PROMPT = [ proc { "(image edit)> " }, proc { "(image edit)* " } ]
23
-
24
- class ImageCommands < Pry::CommandBase
25
- command "drawing_methods", "Show a list of TexPlay methods" do
26
- output.puts "#{Pry.view(TexPlay.public_instance_methods)}"
27
- end
28
-
29
- command "exit", "Exit the program." do
30
- output.puts "Thanks for dropping by!"
31
- exit
32
- end
33
-
34
- import_from Pry::Commands, "ls", "!"
35
- end
36
-
37
- class WinClass < Gosu::Window
38
-
39
- def initialize
40
- super(WIDTH, HEIGHT, false)
41
- @img = TexPlay.create_image(self, 200, 200).clear :color => :black
42
- @img.rect 0, 0, @img.width - 1, @img.height - 1
43
-
44
- @binding = Pry.binding_for(@img)
45
-
46
- @pry_instance = Pry.new(:commands => ImageCommands, :prompt => IMAGE_PROMPT)
47
- end
48
-
49
- def draw
50
- @img.draw_rot(WIDTH / 2, HEIGHT / 2, 1, 0, 0.5, 0.5)
51
- end
52
-
53
- def update
54
- exit if button_down?(Gosu::KbEscape)
55
-
56
- # We do not want a REPL session as the loop prevents the image
57
- # being updated; instead we do a REP session, and let the image
58
- # update each time the user presses enter. We maintain the same
59
- # binding object to keep locals between calls to `Pry#rep()`
60
- @pry_instance.rep(@binding)
61
- end
62
- end
63
-
64
- puts "Welcome to ImageEdit; type `help` for a list of commands and `drawing_methods` for a list of drawing methods available."
65
- puts "--"
66
- puts "Example: Try typing 'circle width/2, height/2, 95, :color => :blue, :fill => true'"
67
- puts "If you want to save your image, type: save(\"img.png\")"
68
-
69
- w = WinClass.new
70
- w.show
71
-
1
+ # Note: this requires you to have Gosu and TexPlay installed.
2
+ # `gem install gosu`
3
+ # `gem install texplay`
4
+ #
5
+ # Extra instructions for installing Gosu on Linux can be found here:
6
+ # http://code.google.com/p/gosu/wiki/GettingStartedOnLinux
7
+ #
8
+ # Instructions for using TexPlay can be found here:
9
+ # http://banisterfiend.wordpress.com/2008/08/23/texplay-an-image-manipulation-tool-for-ruby-and-gosu/
10
+ #
11
+ # Have fun! :)
12
+
13
+ direc = File.dirname(__FILE__)
14
+
15
+ require 'rubygems'
16
+ require "texplay"
17
+ require "#{direc}/../lib/pry"
18
+
19
+ WIDTH = 640
20
+ HEIGHT = 480
21
+
22
+ IMAGE_PROMPT = [ proc { "(image edit)> " }, proc { "(image edit)* " } ]
23
+
24
+ class ImageCommands < Pry::CommandBase
25
+ command "drawing_methods", "Show a list of TexPlay methods" do
26
+ output.puts "#{Pry.view(TexPlay.public_instance_methods)}"
27
+ end
28
+
29
+ command "exit", "Exit the program." do
30
+ output.puts "Thanks for dropping by!"
31
+ exit
32
+ end
33
+
34
+ import_from Pry::Commands, "ls", "!"
35
+ end
36
+
37
+ class WinClass < Gosu::Window
38
+
39
+ def initialize
40
+ super(WIDTH, HEIGHT, false)
41
+ @img = TexPlay.create_image(self, 200, 200).clear :color => :black
42
+ @img.rect 0, 0, @img.width - 1, @img.height - 1
43
+
44
+ @binding = Pry.binding_for(@img)
45
+
46
+ @pry_instance = Pry.new(:commands => ImageCommands, :prompt => IMAGE_PROMPT)
47
+ end
48
+
49
+ def draw
50
+ @img.draw_rot(WIDTH / 2, HEIGHT / 2, 1, 0, 0.5, 0.5)
51
+ end
52
+
53
+ def update
54
+ exit if button_down?(Gosu::KbEscape)
55
+
56
+ # We do not want a REPL session as the loop prevents the image
57
+ # being updated; instead we do a REP session, and let the image
58
+ # update each time the user presses enter. We maintain the same
59
+ # binding object to keep locals between calls to `Pry#rep()`
60
+ @pry_instance.rep(@binding)
61
+ end
62
+ end
63
+
64
+ puts "Welcome to ImageEdit; type `help` for a list of commands and `drawing_methods` for a list of drawing methods available."
65
+ puts "--"
66
+ puts "Example: Try typing 'circle width/2, height/2, 95, :color => :blue, :fill => true'"
67
+ puts "If you want to save your image, type: save(\"img.png\")"
68
+
69
+ w = WinClass.new
70
+ w.show
71
+
@@ -1,10 +1,10 @@
1
- direc = File.dirname(__FILE__)
2
-
3
- require 'rubygems'
4
- require "#{direc}/../lib/pry"
5
-
6
- # Create a StringIO that contains the input data
7
- str_input = StringIO.new("puts 'hello world!'\nputs \"I am in \#{self}\"\nexit")
8
-
9
- # Start a Pry session on the Fixnum 5 using the input data in str_input
10
- Pry.start(5, :input => str_input)
1
+ direc = File.dirname(__FILE__)
2
+
3
+ require 'rubygems'
4
+ require "#{direc}/../lib/pry"
5
+
6
+ # Create a StringIO that contains the input data
7
+ str_input = StringIO.new("puts 'hello world!'\nputs \"I am in \#{self}\"\nexit")
8
+
9
+ # Start a Pry session on the Fixnum 5 using the input data in str_input
10
+ Pry.start(5, :input => str_input)
@@ -1,32 +1,32 @@
1
- direc = File.dirname(__FILE__)
2
-
3
- require 'rubygems'
4
- require "#{direc}/../lib/pry"
5
-
6
- # Create a StringIO that contains the input data for all the Pry objects
7
- cmds = <<-CMDS
8
- cd 1
9
- status
10
- puts 'hello from 1!!'
11
- cd 2
12
- nesting
13
- puts 'hello from 2!!'
14
- _pry_.parent.input = Readline
15
- back
16
- exit-all
17
- CMDS
18
-
19
- # create our StringIO object
20
- str_input = StringIO.new(cmds)
21
-
22
- # set global input to str_input, this means that all pry sessions
23
- # adopt this object as their input object.
24
- Pry.input = str_input
25
-
26
- # Start the session reading from str_input.
27
- # Note that because `Pry.input` is set to `str_input` all nested pry
28
- # sessions will read from `str_input` too. All pry sessions are there
29
- # for non-interactive, except for `pry(1)` which starts off
30
- # non-interactive but is set to be interactive by pry(2) (using
31
- # _pry_.parent.input = Readline)
32
- 0.pry
1
+ direc = File.dirname(__FILE__)
2
+
3
+ require 'rubygems'
4
+ require "#{direc}/../lib/pry"
5
+
6
+ # Create a StringIO that contains the input data for all the Pry objects
7
+ cmds = <<-CMDS
8
+ cd 1
9
+ status
10
+ puts 'hello from 1!!'
11
+ cd 2
12
+ nesting
13
+ puts 'hello from 2!!'
14
+ _pry_.parent.input = Readline
15
+ back
16
+ exit-all
17
+ CMDS
18
+
19
+ # create our StringIO object
20
+ str_input = StringIO.new(cmds)
21
+
22
+ # set global input to str_input, this means that all pry sessions
23
+ # adopt this object as their input object.
24
+ Pry.input = str_input
25
+
26
+ # Start the session reading from str_input.
27
+ # Note that because `Pry.input` is set to `str_input` all nested pry
28
+ # sessions will read from `str_input` too. All pry sessions are there
29
+ # for non-interactive, except for `pry(1)` which starts off
30
+ # non-interactive but is set to be interactive by pry(2) (using
31
+ # _pry_.parent.input = Readline)
32
+ 0.pry
@@ -1,14 +1,14 @@
1
- direc = File.dirname(__FILE__)
2
-
3
- require 'rubygems'
4
- require "#{direc}/../lib/pry"
5
-
6
- # Create a StringIO to contain the output data
7
- str_output = StringIO.new
8
-
9
- # Start a Pry session on the Fixnum 5 using str_output to store the
10
- # output (not writing to $stdout)
11
- Pry.start(5, :output => str_output)
12
-
13
- # Display all the output accumulated during the session
14
- puts str_output.string
1
+ direc = File.dirname(__FILE__)
2
+
3
+ require 'rubygems'
4
+ require "#{direc}/../lib/pry"
5
+
6
+ # Create a StringIO to contain the output data
7
+ str_output = StringIO.new
8
+
9
+ # Start a Pry session on the Fixnum 5 using str_output to store the
10
+ # output (not writing to $stdout)
11
+ Pry.start(5, :output => str_output)
12
+
13
+ # Display all the output accumulated during the session
14
+ puts str_output.string
@@ -1,9 +1,9 @@
1
- direc = File.dirname(__FILE__)
2
-
3
- require 'rubygems'
4
- require "#{direc}/../lib/pry"
5
-
6
- my_print = proc { |out, value| out.puts "Output is: #{value.inspect}" }
7
-
8
- # Start a Pry session using the print object defined in my_print
9
- Pry.start(TOPLEVEL_BINDING, :print => my_print)
1
+ direc = File.dirname(__FILE__)
2
+
3
+ require 'rubygems'
4
+ require "#{direc}/../lib/pry"
5
+
6
+ my_print = proc { |out, value| out.puts "Output is: #{value.inspect}" }
7
+
8
+ # Start a Pry session using the print object defined in my_print
9
+ Pry.start(TOPLEVEL_BINDING, :print => my_print)
@@ -1,12 +1,12 @@
1
- direc = File.dirname(__FILE__)
2
-
3
- require 'rubygems'
4
- require "#{direc}/../lib/pry"
5
-
6
- # Remember, first prompt in array is the main prompt, second is the wait
7
- # prompt (used for multiline input when more input is required)
8
- my_prompt = [ proc { |obj, *| "inside #{obj}> " },
9
- proc { |obj, *| "inside #{obj}* "} ]
10
-
11
- # Start a Pry session using the prompt defined in my_prompt
12
- Pry.start(TOPLEVEL_BINDING, :prompt => my_prompt)
1
+ direc = File.dirname(__FILE__)
2
+
3
+ require 'rubygems'
4
+ require "#{direc}/../lib/pry"
5
+
6
+ # Remember, first prompt in array is the main prompt, second is the wait
7
+ # prompt (used for multiline input when more input is required)
8
+ my_prompt = [ proc { |obj, *| "inside #{obj}> " },
9
+ proc { |obj, *| "inside #{obj}* "} ]
10
+
11
+ # Start a Pry session using the prompt defined in my_prompt
12
+ Pry.start(TOPLEVEL_BINDING, :prompt => my_prompt)
data/lib/pry.rb CHANGED
@@ -1,32 +1,32 @@
1
- # (C) John Mair (banisterfiend) 2011
2
- # MIT License
3
-
4
- direc = File.dirname(__FILE__)
5
-
6
- $LOAD_PATH << File.expand_path(direc)
7
-
8
- require "method_source"
9
- require 'shellwords'
10
- require "readline"
11
- require "stringio"
12
- require "coderay"
13
-
14
- if RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/
15
- begin
16
- require 'win32console'
17
- rescue LoadError
18
- $stderr.puts "Need to `gem install win32console`"
19
- exit 1
20
- end
21
- end
22
-
23
- require "pry/version"
24
- require "pry/hooks"
25
- require "pry/print"
26
- require "pry/command_base"
27
- require "pry/commands"
28
- require "pry/prompts"
29
- require "pry/completion"
30
- require "pry/core_extensions"
31
- require "pry/pry_class"
32
- require "pry/pry_instance"
1
+ # (C) John Mair (banisterfiend) 2011
2
+ # MIT License
3
+
4
+ direc = File.dirname(__FILE__)
5
+
6
+ $LOAD_PATH << File.expand_path(direc)
7
+
8
+ require "method_source"
9
+ require 'shellwords'
10
+ require "readline"
11
+ require "stringio"
12
+ require "coderay"
13
+
14
+ if RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/
15
+ begin
16
+ require 'win32console'
17
+ rescue LoadError
18
+ $stderr.puts "Need to `gem install win32console`"
19
+ exit 1
20
+ end
21
+ end
22
+
23
+ require "pry/version"
24
+ require "pry/hooks"
25
+ require "pry/print"
26
+ require "pry/command_base"
27
+ require "pry/commands"
28
+ require "pry/prompts"
29
+ require "pry/completion"
30
+ require "pry/core_extensions"
31
+ require "pry/pry_class"
32
+ require "pry/pry_instance"