pry 0.9.8pre6 → 0.9.8pre7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pry/default_commands/documentation.rb +4 -0
- data/lib/pry/default_commands/input.rb +40 -41
- data/lib/pry/pry_class.rb +9 -10
- data/lib/pry/version.rb +1 -1
- data/pry.gemspec +13 -13
- data/test/test_command_integration.rb +1 -1
- data/test/test_hooks.rb +24 -31
- metadata +14 -14
@@ -192,6 +192,10 @@ USAGE
|
|
192
192
|
def perform_gist
|
193
193
|
type_map = { :ruby => "rb", :c => "c", :plain => "plain" }
|
194
194
|
|
195
|
+
if self.content =~ /\A\s*\z/
|
196
|
+
raise CommandError, "Found no code to gist."
|
197
|
+
end
|
198
|
+
|
195
199
|
# prevent Gist from exiting the session on error
|
196
200
|
begin
|
197
201
|
extname = opts.present?(:file) ? ".#{gist_file_extension(opts[:f])}" : ".#{type_map[self.code_type]}"
|
@@ -3,59 +3,58 @@ class Pry
|
|
3
3
|
|
4
4
|
Input = Pry::CommandSet.new do
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
create_command "!", "Clear the input buffer. Useful if the parsing process goes wrong and you get stuck in the read loop.", :use_prefix => false do
|
7
|
+
def process
|
8
|
+
output.puts "Input buffer cleared!"
|
9
|
+
eval_string.replace("")
|
10
|
+
end
|
9
11
|
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
+
create_command "show-input", "Show the contents of the input buffer for the current multi-line expression." do
|
14
|
+
def process
|
15
|
+
output.puts Code.new(eval_string).with_line_numbers
|
16
|
+
end
|
13
17
|
end
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
start_line_number, end_line_number, replacement_line = *args
|
19
|
+
create_command(/amend-line(?: (-?\d+)(?:\.\.(-?\d+))?)?/) do
|
20
|
+
description "Amend a line of input in multi-line mode. Type `amend-line --help` for more information. Aliases %"
|
21
|
+
command_options :interpolate => false, :listing => "amend-line"
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
Amend a line of input in multi-line mode. `amend-line N`, where the N in `amend-line N` represents line to replace.
|
23
|
+
banner <<-'BANNER'
|
24
|
+
Amend a line of input in multi-line mode. `amend-line N`, where the N in `amend-line N` represents line to replace.
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
opt.on :h, :help, "This message." do
|
32
|
-
output.puts opt.help
|
33
|
-
end
|
34
|
-
end
|
26
|
+
Can also specify a range of lines using `amend-line N..M` syntax. Passing '!' as replacement content deletes the line(s) instead. Aliases: %N
|
27
|
+
e.g amend-line 1 puts 'hello world! # replace line 1'
|
28
|
+
e.g amend-line 1..4 ! # delete lines 1..4
|
29
|
+
e.g amend-line 3 >puts 'goodbye' # insert before line 3
|
30
|
+
e.g amend-line puts 'hello again' # no line number modifies immediately preceding line
|
31
|
+
BANNER
|
35
32
|
|
36
|
-
|
33
|
+
def process
|
34
|
+
start_line_number, end_line_number, replacement_line = *args
|
37
35
|
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
if eval_string.empty?
|
37
|
+
raise CommandError, "No input to amend."
|
38
|
+
end
|
41
39
|
|
42
|
-
|
43
|
-
|
40
|
+
replacement_line = "" if !replacement_line
|
41
|
+
input_array = eval_string.each_line.to_a
|
44
42
|
|
45
|
-
|
46
|
-
|
43
|
+
end_line_number = start_line_number.to_i if !end_line_number
|
44
|
+
line_range = start_line_number ? (one_index_number(start_line_number.to_i)..one_index_number(end_line_number.to_i)) : input_array.size - 1
|
47
45
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
46
|
+
# delete selected lines if replacement line is '!'
|
47
|
+
if arg_string == "!"
|
48
|
+
input_array.slice!(line_range)
|
49
|
+
elsif arg_string.start_with?(">")
|
50
|
+
insert_slot = Array(line_range).first
|
51
|
+
input_array.insert(insert_slot, arg_string[1..-1] + "\n")
|
52
|
+
else
|
53
|
+
input_array[line_range] = arg_string + "\n"
|
54
|
+
end
|
55
|
+
eval_string.replace input_array.join
|
56
|
+
run "show-input"
|
56
57
|
end
|
57
|
-
eval_string.replace input_array.join
|
58
|
-
run "show-input"
|
59
58
|
end
|
60
59
|
|
61
60
|
alias_command(/%.?(-?\d+)?(?:\.\.(-?\d+))?/, "amend-line")
|
data/lib/pry/pry_class.rb
CHANGED
@@ -117,17 +117,16 @@ class Pry
|
|
117
117
|
|
118
118
|
# yield the binding_stack to the hook for modification
|
119
119
|
pry_instance.exec_hook(
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
if pry_instance.binding_stack.empty?
|
127
|
-
head, *tail = binding_stack
|
128
|
-
pry_instance.binding_stack.push(*tail)
|
129
|
-
else
|
120
|
+
:when_started,
|
121
|
+
target,
|
122
|
+
options,
|
123
|
+
pry_instance
|
124
|
+
)
|
125
|
+
|
126
|
+
if !pry_instance.binding_stack.empty?
|
130
127
|
head = pry_instance.binding_stack.pop
|
128
|
+
else
|
129
|
+
head = target
|
131
130
|
end
|
132
131
|
|
133
132
|
# Enter the matrix
|
data/lib/pry/version.rb
CHANGED
data/pry.gemspec
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
|
-
s.name =
|
5
|
-
s.version = "0.9.
|
4
|
+
s.name = %q{pry}
|
5
|
+
s.version = "0.9.8pre7"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = [
|
9
|
-
s.date =
|
10
|
-
s.description =
|
11
|
-
s.email =
|
12
|
-
s.executables = [
|
13
|
-
s.files = [
|
14
|
-
s.homepage =
|
15
|
-
s.require_paths = [
|
16
|
-
s.rubygems_version =
|
17
|
-
s.summary =
|
18
|
-
s.test_files = [
|
8
|
+
s.authors = [%q{John Mair (banisterfiend)}]
|
9
|
+
s.date = %q{2012-01-20}
|
10
|
+
s.description = %q{An IRB alternative and runtime developer console}
|
11
|
+
s.email = %q{jrmair@gmail.com}
|
12
|
+
s.executables = [%q{pry}]
|
13
|
+
s.files = [%q{.document}, %q{.gemtest}, %q{.gitignore}, %q{.travis.yml}, %q{.yardopts}, %q{CHANGELOG}, %q{CONTRIBUTORS}, %q{Gemfile}, %q{LICENSE}, %q{README.markdown}, %q{Rakefile}, %q{TODO}, %q{bin/pry}, %q{examples/example_basic.rb}, %q{examples/example_command_override.rb}, %q{examples/example_commands.rb}, %q{examples/example_hooks.rb}, %q{examples/example_image_edit.rb}, %q{examples/example_input.rb}, %q{examples/example_input2.rb}, %q{examples/example_output.rb}, %q{examples/example_print.rb}, %q{examples/example_prompt.rb}, %q{examples/helper.rb}, %q{lib/pry.rb}, %q{lib/pry/cli.rb}, %q{lib/pry/code.rb}, %q{lib/pry/command.rb}, %q{lib/pry/command_set.rb}, %q{lib/pry/commands.rb}, %q{lib/pry/completion.rb}, %q{lib/pry/config.rb}, %q{lib/pry/core_extensions.rb}, %q{lib/pry/custom_completions.rb}, %q{lib/pry/default_commands/basic.rb}, %q{lib/pry/default_commands/context.rb}, %q{lib/pry/default_commands/documentation.rb}, %q{lib/pry/default_commands/easter_eggs.rb}, %q{lib/pry/default_commands/gems.rb}, %q{lib/pry/default_commands/input.rb}, %q{lib/pry/default_commands/introspection.rb}, %q{lib/pry/default_commands/ls.rb}, %q{lib/pry/default_commands/shell.rb}, %q{lib/pry/extended_commands/experimental.rb}, %q{lib/pry/helpers.rb}, %q{lib/pry/helpers/base_helpers.rb}, %q{lib/pry/helpers/command_helpers.rb}, %q{lib/pry/helpers/options_helpers.rb}, %q{lib/pry/helpers/text.rb}, %q{lib/pry/history.rb}, %q{lib/pry/history_array.rb}, %q{lib/pry/hooks.rb}, %q{lib/pry/indent.rb}, %q{lib/pry/method.rb}, %q{lib/pry/plugins.rb}, %q{lib/pry/pry_class.rb}, %q{lib/pry/pry_instance.rb}, %q{lib/pry/rbx_method.rb}, %q{lib/pry/rbx_path.rb}, %q{lib/pry/version.rb}, %q{lib/pry/wrapped_module.rb}, %q{man/pry.1}, %q{man/pry.1.html}, %q{man/pry.1.ronn}, %q{pry.gemspec}, %q{test/helper.rb}, %q{test/test_cli.rb}, %q{test/test_code.rb}, %q{test/test_command.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_integration.rb}, %q{test/test_command_set.rb}, %q{test/test_completion.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_default_commands/test_ls.rb}, %q{test/test_default_commands/test_shell.rb}, %q{test/test_exception_whitelist.rb}, %q{test/test_history_array.rb}, %q{test/test_hooks.rb}, %q{test/test_indent.rb}, %q{test/test_input_stack.rb}, %q{test/test_method.rb}, %q{test/test_pry.rb}, %q{test/test_pry_defaults.rb}, %q{test/test_pry_history.rb}, %q{test/test_pry_output.rb}, %q{test/test_special_locals.rb}, %q{test/test_syntax_checking.rb}, %q{test/test_wrapped_module.rb}, %q{test/testrc}, %q{test/testrcbad}, %q{wiki/Customizing-pry.md}, %q{wiki/Home.md}]
|
14
|
+
s.homepage = %q{http://pry.github.com}
|
15
|
+
s.require_paths = [%q{lib}]
|
16
|
+
s.rubygems_version = %q{1.8.6}
|
17
|
+
s.summary = %q{An IRB alternative and runtime developer console}
|
18
|
+
s.test_files = [%q{test/helper.rb}, %q{test/test_cli.rb}, %q{test/test_code.rb}, %q{test/test_command.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_integration.rb}, %q{test/test_command_set.rb}, %q{test/test_completion.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_default_commands/test_ls.rb}, %q{test/test_default_commands/test_shell.rb}, %q{test/test_exception_whitelist.rb}, %q{test/test_history_array.rb}, %q{test/test_hooks.rb}, %q{test/test_indent.rb}, %q{test/test_input_stack.rb}, %q{test/test_method.rb}, %q{test/test_pry.rb}, %q{test/test_pry_defaults.rb}, %q{test/test_pry_history.rb}, %q{test/test_pry_output.rb}, %q{test/test_special_locals.rb}, %q{test/test_syntax_checking.rb}, %q{test/test_wrapped_module.rb}, %q{test/testrc}, %q{test/testrcbad}]
|
19
19
|
|
20
20
|
if s.respond_to? :specification_version then
|
21
21
|
s.specification_version = 3
|
@@ -451,7 +451,7 @@ describe "commands" do
|
|
451
451
|
|
452
452
|
str_output = StringIO.new
|
453
453
|
Pry.new(:input => InputTester.new("help"), :output => str_output, :commands => klass).rep
|
454
|
-
str_output.string.
|
454
|
+
str_output.string.should == "help to the music\n"
|
455
455
|
|
456
456
|
|
457
457
|
Pry.reset_defaults
|
data/test/test_hooks.rb
CHANGED
@@ -311,7 +311,7 @@ describe Pry::Hooks do
|
|
311
311
|
describe "when_started hook" do
|
312
312
|
it 'should yield options to the hook' do
|
313
313
|
options = nil
|
314
|
-
Pry.config.hooks.add_hook(:when_started, :test_hook) { |
|
314
|
+
Pry.config.hooks.add_hook(:when_started, :test_hook) { |target, opt, _| options = opt }
|
315
315
|
|
316
316
|
redirect_pry_io(StringIO.new("exit"), out=StringIO.new) do
|
317
317
|
Pry.start binding, :hello => :baby
|
@@ -321,45 +321,39 @@ describe Pry::Hooks do
|
|
321
321
|
Pry.config.hooks.delete_hook(:when_started, :test_hook)
|
322
322
|
end
|
323
323
|
|
324
|
-
|
325
|
-
options = nil
|
326
|
-
o = Object.new
|
327
|
-
class << o; attr_accessor :value; end
|
328
|
-
|
329
|
-
Pry.config.hooks.add_hook(:when_started, :test_hook) { |binding_stack, opt, _pry_| binding_stack.replace [Pry.binding_for(o)] }
|
324
|
+
describe "target" do
|
330
325
|
|
331
|
-
|
332
|
-
|
326
|
+
it 'should yield the target, as a binding ' do
|
327
|
+
b = nil
|
328
|
+
Pry.config.hooks.add_hook(:when_started, :test_hook) { |target, opt, _| b = target }
|
329
|
+
|
330
|
+
redirect_pry_io(StringIO.new("exit"), out=StringIO.new) do
|
331
|
+
Pry.start 5, :hello => :baby
|
332
|
+
end
|
333
|
+
|
334
|
+
b.is_a?(Binding).should == true
|
335
|
+
Pry.config.hooks.delete_hook(:when_started, :test_hook)
|
333
336
|
end
|
334
337
|
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
+
it 'should yield the target to the hook' do
|
339
|
+
b = nil
|
340
|
+
Pry.config.hooks.add_hook(:when_started, :test_hook) { |target, opt, _| b = target }
|
338
341
|
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
class << o; attr_accessor :value; end
|
343
|
-
|
344
|
-
Pry.config.hooks.add_hook(:when_started, :test_hook) { |binding_stack, opt, _pry_| _pry_.binding_stack = [Pry.binding_for(o)] }
|
342
|
+
redirect_pry_io(StringIO.new("exit"), out=StringIO.new) do
|
343
|
+
Pry.start 5, :hello => :baby
|
344
|
+
end
|
345
345
|
|
346
|
-
|
347
|
-
Pry.
|
346
|
+
b.eval('self').should == 5
|
347
|
+
Pry.config.hooks.delete_hook(:when_started, :test_hook)
|
348
348
|
end
|
349
|
-
|
350
|
-
o.value.should == true
|
351
|
-
Pry.config.hooks.delete_hook(:when_started, :test_hook)
|
352
349
|
end
|
353
350
|
|
354
|
-
it 'should
|
351
|
+
it 'should allow overriding of target (and binding_stack)' do
|
355
352
|
options = nil
|
356
353
|
o = Object.new
|
357
354
|
class << o; attr_accessor :value; end
|
358
|
-
|
359
|
-
Pry.config.hooks.add_hook(:when_started, :test_hook)
|
360
|
-
_pry_.binding_stack = [Pry.binding_for(o)]
|
361
|
-
binding_stack.replace [Pry.binding_for(5)]
|
362
|
-
end
|
355
|
+
|
356
|
+
Pry.config.hooks.add_hook(:when_started, :test_hook) { |target, opt, _pry_| _pry_.binding_stack = [Pry.binding_for(o)] }
|
363
357
|
|
364
358
|
redirect_pry_io(InputTester.new("@value = true","exit-all")) do
|
365
359
|
Pry.start binding, :hello => :baby
|
@@ -368,8 +362,7 @@ describe Pry::Hooks do
|
|
368
362
|
o.value.should == true
|
369
363
|
Pry.config.hooks.delete_hook(:when_started, :test_hook)
|
370
364
|
end
|
371
|
-
|
372
|
-
|
365
|
+
|
373
366
|
end
|
374
367
|
|
375
368
|
describe "after_session hook" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.8pre7
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-20 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: coderay
|
16
|
-
requirement: &
|
16
|
+
requirement: &70177446226220 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70177446226220
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: slop
|
27
|
-
requirement: &
|
27
|
+
requirement: &70177446227200 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -35,10 +35,10 @@ dependencies:
|
|
35
35
|
version: '3'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
|
-
version_requirements: *
|
38
|
+
version_requirements: *70177446227200
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: method_source
|
41
|
-
requirement: &
|
41
|
+
requirement: &70177446782420 !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|
44
44
|
- - ~>
|
@@ -46,10 +46,10 @@ dependencies:
|
|
46
46
|
version: '0.7'
|
47
47
|
type: :runtime
|
48
48
|
prerelease: false
|
49
|
-
version_requirements: *
|
49
|
+
version_requirements: *70177446782420
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
51
|
name: bacon
|
52
|
-
requirement: &
|
52
|
+
requirement: &70177446839420 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
54
54
|
requirements:
|
55
55
|
- - ~>
|
@@ -57,10 +57,10 @@ dependencies:
|
|
57
57
|
version: '1.1'
|
58
58
|
type: :development
|
59
59
|
prerelease: false
|
60
|
-
version_requirements: *
|
60
|
+
version_requirements: *70177446839420
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: open4
|
63
|
-
requirement: &
|
63
|
+
requirement: &70177446844900 !ruby/object:Gem::Requirement
|
64
64
|
none: false
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
@@ -68,10 +68,10 @@ dependencies:
|
|
68
68
|
version: '1.3'
|
69
69
|
type: :development
|
70
70
|
prerelease: false
|
71
|
-
version_requirements: *
|
71
|
+
version_requirements: *70177446844900
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: rake
|
74
|
-
requirement: &
|
74
|
+
requirement: &70177446853320 !ruby/object:Gem::Requirement
|
75
75
|
none: false
|
76
76
|
requirements:
|
77
77
|
- - ~>
|
@@ -79,7 +79,7 @@ dependencies:
|
|
79
79
|
version: '0.9'
|
80
80
|
type: :development
|
81
81
|
prerelease: false
|
82
|
-
version_requirements: *
|
82
|
+
version_requirements: *70177446853320
|
83
83
|
description: An IRB alternative and runtime developer console
|
84
84
|
email: jrmair@gmail.com
|
85
85
|
executables:
|