pry 0.6.7pre4-i386-mingw32 → 0.6.8-i386-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +88 -75
- data/LICENSE +25 -25
- data/README.markdown +321 -309
- data/Rakefile +103 -103
- data/bin/pry +83 -82
- data/examples/example_basic.rb +17 -17
- data/examples/example_command_override.rb +35 -35
- data/examples/example_commands.rb +39 -39
- data/examples/example_hooks.rb +12 -12
- data/examples/example_image_edit.rb +71 -71
- data/examples/example_input.rb +10 -10
- data/examples/example_input2.rb +32 -32
- data/examples/example_output.rb +14 -14
- data/examples/example_print.rb +9 -9
- data/examples/example_prompt.rb +12 -12
- data/lib/pry.rb +32 -32
- data/lib/pry/command_base.rb +150 -150
- data/lib/pry/commands.rb +616 -577
- data/lib/pry/completion.rb +202 -202
- data/lib/pry/core_extensions.rb +55 -55
- data/lib/pry/hooks.rb +19 -8
- data/lib/pry/print.rb +19 -19
- data/lib/pry/prompts.rb +26 -26
- data/lib/pry/pry_class.rb +219 -186
- data/lib/pry/pry_instance.rb +316 -316
- data/lib/pry/version.rb +3 -3
- data/test/test.rb +725 -681
- data/test/test_helper.rb +46 -38
- data/test/testrc +2 -0
- metadata +102 -66
data/Rakefile
CHANGED
@@ -1,103 +1,103 @@
|
|
1
|
-
dlext = Config::CONFIG['DLEXT']
|
2
|
-
direc = File.dirname(__FILE__)
|
3
|
-
|
4
|
-
require 'rake/clean'
|
5
|
-
require 'rake/gempackagetask'
|
6
|
-
require "#{direc}/lib/pry/version"
|
7
|
-
|
8
|
-
CLOBBER.include("**/*.#{dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o")
|
9
|
-
CLEAN.include("ext/**/*.#{dlext}", "ext/**/*.log", "ext/**/*.o",
|
10
|
-
"ext/**/*~", "ext/**/*#*", "ext/**/*.obj", "**/*#*", "**/*#*.*",
|
11
|
-
"ext/**/*.def", "ext/**/*.pdb", "**/*_flymake*.*", "**/*_flymake")
|
12
|
-
|
13
|
-
def apply_spec_defaults(s)
|
14
|
-
s.name = "pry"
|
15
|
-
s.summary = "attach an irb-like session to any object at runtime"
|
16
|
-
s.version = Pry::VERSION
|
17
|
-
s.date = Time.now.strftime '%Y-%m-%d'
|
18
|
-
s.author = "John Mair (banisterfiend)"
|
19
|
-
s.email = 'jrmair@gmail.com'
|
20
|
-
s.description = s.summary
|
21
|
-
s.require_path = 'lib'
|
22
|
-
s.add_dependency("ruby_parser",">=2.0.5")
|
23
|
-
s.add_dependency("coderay",">=0.9.7")
|
24
|
-
s.add_development_dependency("bacon",">=1.1.0")
|
25
|
-
s.homepage = "http://banisterfiend.wordpress.com"
|
26
|
-
s.has_rdoc = 'yard'
|
27
|
-
s.executables = ["pry"]
|
28
|
-
s.files = Dir["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c", "lib/**/*.rb", "examples/**/*.rb",
|
29
|
-
"test/*.rb", "CHANGELOG", "LICENSE", "README.markdown", "Rakefile", ".gemtest"]
|
30
|
-
end
|
31
|
-
|
32
|
-
task :test do
|
33
|
-
sh "bacon -k #{direc}/test/test.rb"
|
34
|
-
end
|
35
|
-
|
36
|
-
desc "run pry"
|
37
|
-
task :pry do
|
38
|
-
require "#{direc}/lib/pry.rb"
|
39
|
-
Pry.start
|
40
|
-
end
|
41
|
-
|
42
|
-
desc "show pry version"
|
43
|
-
task :version do
|
44
|
-
puts "Pry version: #{Pry::VERSION}"
|
45
|
-
end
|
46
|
-
|
47
|
-
namespace :ruby do
|
48
|
-
spec = Gem::Specification.new do |s|
|
49
|
-
apply_spec_defaults(s)
|
50
|
-
s.add_dependency("method_source",">=0.3.4")
|
51
|
-
s.platform = Gem::Platform::RUBY
|
52
|
-
end
|
53
|
-
|
54
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
55
|
-
pkg.need_zip = false
|
56
|
-
pkg.need_tar = false
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
[:mingw32, :mswin32].each do |v|
|
61
|
-
namespace v do
|
62
|
-
spec = Gem::Specification.new do |s|
|
63
|
-
apply_spec_defaults(s)
|
64
|
-
s.add_dependency("method_source",">=0.3.4")
|
65
|
-
s.add_dependency("win32console", ">=1.3.0")
|
66
|
-
s.platform = "i386-#{v}"
|
67
|
-
end
|
68
|
-
|
69
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
70
|
-
pkg.need_zip = false
|
71
|
-
pkg.need_tar = false
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
namespace :jruby do
|
77
|
-
spec = Gem::Specification.new do |s|
|
78
|
-
apply_spec_defaults(s)
|
79
|
-
s.add_dependency("method_source","=0.2.0")
|
80
|
-
s.platform = "java"
|
81
|
-
end
|
82
|
-
|
83
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
84
|
-
pkg.need_zip = false
|
85
|
-
pkg.need_tar = false
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
|
-
desc "build all platform gems at once"
|
91
|
-
task :gems => [:rmgems, "ruby:gem", "jruby:gem", "mswin32:gem", "mingw32:gem"]
|
92
|
-
|
93
|
-
desc "remove all platform gems"
|
94
|
-
task :rmgems => ["ruby:clobber_package"]
|
95
|
-
|
96
|
-
desc "build and push latest gems"
|
97
|
-
task :pushgems => :gems do
|
98
|
-
chdir("#{direc}/pkg") do
|
99
|
-
Dir["*.gem"].each do |gemfile|
|
100
|
-
sh "gem push #{gemfile}"
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
1
|
+
dlext = Config::CONFIG['DLEXT']
|
2
|
+
direc = File.dirname(__FILE__)
|
3
|
+
|
4
|
+
require 'rake/clean'
|
5
|
+
require 'rake/gempackagetask'
|
6
|
+
require "#{direc}/lib/pry/version"
|
7
|
+
|
8
|
+
CLOBBER.include("**/*.#{dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o")
|
9
|
+
CLEAN.include("ext/**/*.#{dlext}", "ext/**/*.log", "ext/**/*.o",
|
10
|
+
"ext/**/*~", "ext/**/*#*", "ext/**/*.obj", "**/*#*", "**/*#*.*",
|
11
|
+
"ext/**/*.def", "ext/**/*.pdb", "**/*_flymake*.*", "**/*_flymake")
|
12
|
+
|
13
|
+
def apply_spec_defaults(s)
|
14
|
+
s.name = "pry"
|
15
|
+
s.summary = "attach an irb-like session to any object at runtime"
|
16
|
+
s.version = Pry::VERSION
|
17
|
+
s.date = Time.now.strftime '%Y-%m-%d'
|
18
|
+
s.author = "John Mair (banisterfiend)"
|
19
|
+
s.email = 'jrmair@gmail.com'
|
20
|
+
s.description = s.summary
|
21
|
+
s.require_path = 'lib'
|
22
|
+
s.add_dependency("ruby_parser",">=2.0.5")
|
23
|
+
s.add_dependency("coderay",">=0.9.7")
|
24
|
+
s.add_development_dependency("bacon",">=1.1.0")
|
25
|
+
s.homepage = "http://banisterfiend.wordpress.com"
|
26
|
+
s.has_rdoc = 'yard'
|
27
|
+
s.executables = ["pry"]
|
28
|
+
s.files = Dir["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c", "lib/**/*.rb", "examples/**/*.rb",
|
29
|
+
"test/*.rb", "test/testrc", "CHANGELOG", "LICENSE", "README.markdown", "Rakefile", ".gemtest"]
|
30
|
+
end
|
31
|
+
|
32
|
+
task :test do
|
33
|
+
sh "bacon -k #{direc}/test/test.rb"
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "run pry"
|
37
|
+
task :pry do
|
38
|
+
require "#{direc}/lib/pry.rb"
|
39
|
+
Pry.start
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "show pry version"
|
43
|
+
task :version do
|
44
|
+
puts "Pry version: #{Pry::VERSION}"
|
45
|
+
end
|
46
|
+
|
47
|
+
namespace :ruby do
|
48
|
+
spec = Gem::Specification.new do |s|
|
49
|
+
apply_spec_defaults(s)
|
50
|
+
s.add_dependency("method_source",">=0.3.4")
|
51
|
+
s.platform = Gem::Platform::RUBY
|
52
|
+
end
|
53
|
+
|
54
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
55
|
+
pkg.need_zip = false
|
56
|
+
pkg.need_tar = false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
[:mingw32, :mswin32].each do |v|
|
61
|
+
namespace v do
|
62
|
+
spec = Gem::Specification.new do |s|
|
63
|
+
apply_spec_defaults(s)
|
64
|
+
s.add_dependency("method_source",">=0.3.4")
|
65
|
+
s.add_dependency("win32console", ">=1.3.0")
|
66
|
+
s.platform = "i386-#{v}"
|
67
|
+
end
|
68
|
+
|
69
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
70
|
+
pkg.need_zip = false
|
71
|
+
pkg.need_tar = false
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
namespace :jruby do
|
77
|
+
spec = Gem::Specification.new do |s|
|
78
|
+
apply_spec_defaults(s)
|
79
|
+
s.add_dependency("method_source","=0.2.0")
|
80
|
+
s.platform = "java"
|
81
|
+
end
|
82
|
+
|
83
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
84
|
+
pkg.need_zip = false
|
85
|
+
pkg.need_tar = false
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
desc "build all platform gems at once"
|
91
|
+
task :gems => [:rmgems, "ruby:gem", "jruby:gem", "mswin32:gem", "mingw32:gem"]
|
92
|
+
|
93
|
+
desc "remove all platform gems"
|
94
|
+
task :rmgems => ["ruby:clobber_package"]
|
95
|
+
|
96
|
+
desc "build and push latest gems"
|
97
|
+
task :pushgems => :gems do
|
98
|
+
chdir("#{direc}/pkg") do
|
99
|
+
Dir["*.gem"].each do |gemfile|
|
100
|
+
sh "gem push #{gemfile}"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
data/bin/pry
CHANGED
@@ -1,82 +1,83 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# (C) John Mair (banisterfiend)
|
4
|
-
# MIT license
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'pry'
|
8
|
-
rescue LoadError
|
9
|
-
require 'rubygems'
|
10
|
-
require 'pry'
|
11
|
-
end
|
12
|
-
require 'optparse'
|
13
|
-
|
14
|
-
# defaults
|
15
|
-
options = {
|
16
|
-
:context_string => "TOPLEVEL_BINDING",
|
17
|
-
:loadrc => true
|
18
|
-
}
|
19
|
-
|
20
|
-
OptionParser.new do |opts|
|
21
|
-
opts.banner = %{Usage: pry [OPTIONS]
|
22
|
-
Start a Pry session.
|
23
|
-
See: `https://github.com/banister` for more information.
|
24
|
-
--
|
25
|
-
}
|
26
|
-
opts.on("-r", "--require FILE", "`require` a Ruby script at startup.") do |file|
|
27
|
-
require file
|
28
|
-
end
|
29
|
-
|
30
|
-
opts.on("-e", "--exec CODE", "A line of Ruby code to execute in context before the session starts.") do |code|
|
31
|
-
options[:code] = code
|
32
|
-
end
|
33
|
-
|
34
|
-
opts.on("-f", "Suppress loading of ~/.pryrc") do
|
35
|
-
options[:loadrc] = false
|
36
|
-
end
|
37
|
-
|
38
|
-
opts.on("--color", "Start session
|
39
|
-
Pry.color =
|
40
|
-
end
|
41
|
-
|
42
|
-
opts.on("--simple-prompt", "Simple prompt mode.") do
|
43
|
-
Pry.prompt = Pry::SIMPLE_PROMPT
|
44
|
-
end
|
45
|
-
|
46
|
-
opts.on("-I LOADPATH", "Specify $LOAD_PATH directory.") do |load_path|
|
47
|
-
$LOAD_PATH << load_path
|
48
|
-
end
|
49
|
-
|
50
|
-
opts.on("-v", "--version", "Display the Pry version.") do
|
51
|
-
puts "Pry version #{Pry::VERSION} on Ruby #{RUBY_VERSION}"
|
52
|
-
exit
|
53
|
-
end
|
54
|
-
|
55
|
-
opts.on("-c", "--context CONTEXT",
|
56
|
-
"Start the session in the specified context. Equivalent to `context.pry` in a session.") do |context|
|
57
|
-
|
58
|
-
# save the context name
|
59
|
-
options[:context_string] = context
|
60
|
-
end
|
61
|
-
|
62
|
-
opts.on_tail("-h", "--help", "This message.") do
|
63
|
-
puts opts
|
64
|
-
exit
|
65
|
-
end
|
66
|
-
end.parse!
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
load
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
if
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# (C) John Mair (banisterfiend)
|
4
|
+
# MIT license
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'pry'
|
8
|
+
rescue LoadError
|
9
|
+
require 'rubygems'
|
10
|
+
require 'pry'
|
11
|
+
end
|
12
|
+
require 'optparse'
|
13
|
+
|
14
|
+
# defaults
|
15
|
+
options = {
|
16
|
+
:context_string => "TOPLEVEL_BINDING",
|
17
|
+
:loadrc => true
|
18
|
+
}
|
19
|
+
|
20
|
+
OptionParser.new do |opts|
|
21
|
+
opts.banner = %{Usage: pry [OPTIONS]
|
22
|
+
Start a Pry session.
|
23
|
+
See: `https://github.com/banister` for more information.
|
24
|
+
--
|
25
|
+
}
|
26
|
+
opts.on("-r", "--require FILE", "`require` a Ruby script at startup.") do |file|
|
27
|
+
require file
|
28
|
+
end
|
29
|
+
|
30
|
+
opts.on("-e", "--exec CODE", "A line of Ruby code to execute in context before the session starts.") do |code|
|
31
|
+
options[:code] = code
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on("-f", "Suppress loading of ~/.pryrc") do
|
35
|
+
options[:loadrc] = false
|
36
|
+
end
|
37
|
+
|
38
|
+
opts.on("--no-color", "Start session without syntax highlighting.") do
|
39
|
+
Pry.color = false
|
40
|
+
end
|
41
|
+
|
42
|
+
opts.on("--simple-prompt", "Simple prompt mode.") do
|
43
|
+
Pry.prompt = Pry::SIMPLE_PROMPT
|
44
|
+
end
|
45
|
+
|
46
|
+
opts.on("-I LOADPATH", "Specify $LOAD_PATH directory.") do |load_path|
|
47
|
+
$LOAD_PATH << load_path
|
48
|
+
end
|
49
|
+
|
50
|
+
opts.on("-v", "--version", "Display the Pry version.") do
|
51
|
+
puts "Pry version #{Pry::VERSION} on Ruby #{RUBY_VERSION}"
|
52
|
+
exit
|
53
|
+
end
|
54
|
+
|
55
|
+
opts.on("-c", "--context CONTEXT",
|
56
|
+
"Start the session in the specified context. Equivalent to `context.pry` in a session.") do |context|
|
57
|
+
|
58
|
+
# save the context name
|
59
|
+
options[:context_string] = context
|
60
|
+
end
|
61
|
+
|
62
|
+
opts.on_tail("-h", "--help", "This message.") do
|
63
|
+
puts opts
|
64
|
+
exit
|
65
|
+
end
|
66
|
+
end.parse!
|
67
|
+
|
68
|
+
# invoked via cli
|
69
|
+
Pry.cli = true
|
70
|
+
|
71
|
+
# load ~/.pryrc, if not suppressed with -f option
|
72
|
+
Pry.should_load_rc = false if !options[:loadrc]
|
73
|
+
|
74
|
+
# create the actual context
|
75
|
+
context = Pry.binding_for(eval(options[:context_string]))
|
76
|
+
|
77
|
+
# run code passed with `-e`, if there is any.
|
78
|
+
if options[:code]
|
79
|
+
Pry.new(:input => StringIO.new(options[:code]), :print => proc {}).rep(context)
|
80
|
+
end
|
81
|
+
|
82
|
+
# start the session
|
83
|
+
context.pry
|
data/examples/example_basic.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
direc = File.dirname(__FILE__)
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require "#{direc}/../lib/pry"
|
5
|
-
|
6
|
-
# define a local.
|
7
|
-
a = "a local variable"
|
8
|
-
|
9
|
-
# defing a top-level method.
|
10
|
-
def hello
|
11
|
-
puts "hello world!"
|
12
|
-
end
|
13
|
-
|
14
|
-
# Start pry session at top-level.
|
15
|
-
# The local variable `a` and the `hello` method will
|
16
|
-
# be accessible.
|
17
|
-
pry
|
1
|
+
direc = File.dirname(__FILE__)
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require "#{direc}/../lib/pry"
|
5
|
+
|
6
|
+
# define a local.
|
7
|
+
a = "a local variable"
|
8
|
+
|
9
|
+
# defing a top-level method.
|
10
|
+
def hello
|
11
|
+
puts "hello world!"
|
12
|
+
end
|
13
|
+
|
14
|
+
# Start pry session at top-level.
|
15
|
+
# The local variable `a` and the `hello` method will
|
16
|
+
# be accessible.
|
17
|
+
pry
|
@@ -1,35 +1,35 @@
|
|
1
|
-
direc = File.dirname(__FILE__)
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require "#{direc}/../lib/pry"
|
5
|
-
|
6
|
-
# Inherit standard command set, but tweak them by importing some and
|
7
|
-
# overriding others.
|
8
|
-
# Illustrates use of `command`, `run`, and `import_from` commands.
|
9
|
-
class MyCommands < Pry::CommandBase
|
10
|
-
|
11
|
-
# Override ls command
|
12
|
-
command "ls", "An unhelpful ls" do
|
13
|
-
output.puts "No, i refuse to display any useful information."
|
14
|
-
end
|
15
|
-
|
16
|
-
# bring in just the status command from Pry::Commands
|
17
|
-
import_from Pry::Commands, "status"
|
18
|
-
|
19
|
-
# analogy to Ruby's native alias_method idiom for decorating a method
|
20
|
-
alias_command "old_status", "status", ""
|
21
|
-
|
22
|
-
# Invoke one command from within another using `run`
|
23
|
-
command "status", "Modified status." do |x|
|
24
|
-
output.puts "About to show status, are you ready?"
|
25
|
-
run "old_status", x
|
26
|
-
output.puts "Finished showing status."
|
27
|
-
end
|
28
|
-
|
29
|
-
# bring in a few other commands
|
30
|
-
import_from Pry::Commands, "quit", "show-method"
|
31
|
-
end
|
32
|
-
|
33
|
-
# Start a Pry session using the commands defined in MyCommands
|
34
|
-
# Type 'help' in Pry to get a list of the commands and their descriptions
|
35
|
-
Pry.start(TOPLEVEL_BINDING, :commands => MyCommands)
|
1
|
+
direc = File.dirname(__FILE__)
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require "#{direc}/../lib/pry"
|
5
|
+
|
6
|
+
# Inherit standard command set, but tweak them by importing some and
|
7
|
+
# overriding others.
|
8
|
+
# Illustrates use of `command`, `run`, and `import_from` commands.
|
9
|
+
class MyCommands < Pry::CommandBase
|
10
|
+
|
11
|
+
# Override ls command
|
12
|
+
command "ls", "An unhelpful ls" do
|
13
|
+
output.puts "No, i refuse to display any useful information."
|
14
|
+
end
|
15
|
+
|
16
|
+
# bring in just the status command from Pry::Commands
|
17
|
+
import_from Pry::Commands, "status"
|
18
|
+
|
19
|
+
# analogy to Ruby's native alias_method idiom for decorating a method
|
20
|
+
alias_command "old_status", "status", ""
|
21
|
+
|
22
|
+
# Invoke one command from within another using `run`
|
23
|
+
command "status", "Modified status." do |x|
|
24
|
+
output.puts "About to show status, are you ready?"
|
25
|
+
run "old_status", x
|
26
|
+
output.puts "Finished showing status."
|
27
|
+
end
|
28
|
+
|
29
|
+
# bring in a few other commands
|
30
|
+
import_from Pry::Commands, "quit", "show-method"
|
31
|
+
end
|
32
|
+
|
33
|
+
# Start a Pry session using the commands defined in MyCommands
|
34
|
+
# Type 'help' in Pry to get a list of the commands and their descriptions
|
35
|
+
Pry.start(TOPLEVEL_BINDING, :commands => MyCommands)
|