pry 0.9.3pre1-i386-mswin32 → 0.9.4-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/CHANGELOG +53 -0
  2. data/CONTRIBUTORS +13 -0
  3. data/README.markdown +4 -2
  4. data/Rakefile +17 -3
  5. data/TODO +22 -0
  6. data/lib/pry.rb +102 -24
  7. data/lib/pry/command_context.rb +12 -0
  8. data/lib/pry/command_processor.rb +50 -19
  9. data/lib/pry/command_set.rb +17 -7
  10. data/lib/pry/completion.rb +6 -6
  11. data/lib/pry/config.rb +6 -2
  12. data/lib/pry/default_commands/basic.rb +8 -4
  13. data/lib/pry/default_commands/context.rb +84 -36
  14. data/lib/pry/default_commands/documentation.rb +50 -30
  15. data/lib/pry/default_commands/easter_eggs.rb +5 -0
  16. data/lib/pry/default_commands/input.rb +20 -16
  17. data/lib/pry/default_commands/introspection.rb +61 -77
  18. data/lib/pry/default_commands/ls.rb +22 -14
  19. data/lib/pry/default_commands/shell.rb +32 -17
  20. data/lib/pry/extended_commands/user_command_api.rb +32 -1
  21. data/lib/pry/helpers/base_helpers.rb +21 -9
  22. data/lib/pry/helpers/command_helpers.rb +99 -17
  23. data/lib/pry/helpers/text.rb +12 -11
  24. data/lib/pry/history.rb +61 -0
  25. data/lib/pry/plugins.rb +19 -8
  26. data/lib/pry/pry_class.rb +49 -60
  27. data/lib/pry/pry_instance.rb +122 -119
  28. data/lib/pry/version.rb +1 -1
  29. data/pry.gemspec +15 -14
  30. data/test/helper.rb +31 -0
  31. data/test/test_command_processor.rb +8 -87
  32. data/test/test_command_set.rb +40 -2
  33. data/test/test_completion.rb +26 -0
  34. data/test/test_default_commands/test_context.rb +185 -1
  35. data/test/test_default_commands/test_documentation.rb +10 -0
  36. data/test/test_default_commands/test_input.rb +39 -13
  37. data/test/test_default_commands/test_introspection.rb +11 -1
  38. data/test/test_default_commands/test_shell.rb +18 -0
  39. data/test/test_pry.rb +217 -47
  40. data/test/test_pry_history.rb +84 -0
  41. data/test/test_pry_output.rb +44 -0
  42. data/test/test_special_locals.rb +35 -0
  43. metadata +83 -77
@@ -15,7 +15,11 @@ class Pry
15
15
  context.instance_eval(&stub_block)
16
16
  else
17
17
  ret = context.instance_exec(*correct_arg_arity(block.arity, args), &block)
18
- ret if options[:keep_retval]
18
+ if options[:keep_retval]
19
+ ret
20
+ else
21
+ Pry::CommandContext::VOID_VALUE
22
+ end
19
23
  end
20
24
  end
21
25
 
@@ -24,9 +28,15 @@ class Pry
24
28
  case arity <=> 0
25
29
  when -1
26
30
  args
27
- when 1, 0
28
- # Keep 1.8 happy
29
- args.values_at 0..(arity - 1)
31
+ when 0
32
+ []
33
+ when 1
34
+ # another jruby hack
35
+ if Pry::Helpers::BaseHelpers.jruby?
36
+ args[0..(arity - 1)]
37
+ else
38
+ args.values_at 0..(arity - 1)
39
+ end
30
40
  end
31
41
  end
32
42
  end
@@ -227,11 +237,11 @@ class Pry
227
237
  output.puts
228
238
  help_text = heading("Command List: ") + "\n"
229
239
 
230
- commands.each do |key, command|
240
+ help_text << commands.map do |key, command|
231
241
  if command.description && !command.description.empty?
232
- help_text << "#{command.options[:listing]}".ljust(18) + command.description + "\n"
242
+ "#{command.options[:listing]}".ljust(18) + command.description
233
243
  end
234
- end
244
+ end.compact.sort.join("\n")
235
245
 
236
246
  stagger_output(help_text)
237
247
  else
@@ -94,7 +94,7 @@ class Pry
94
94
  begin
95
95
  candidates = eval("#{receiver}.constants.collect{|m| m.to_s}", bind)
96
96
  candidates |= eval("#{receiver}.methods.collect{|m| m.to_s}", bind)
97
- rescue Exception
97
+ rescue RescuableException
98
98
  candidates = []
99
99
  end
100
100
  candidates.grep(/^#{message}/).collect{|e| receiver + "::" + e}
@@ -114,7 +114,7 @@ class Pry
114
114
 
115
115
  begin
116
116
  candidates = eval(receiver, bind).methods.collect{|m| m.to_s}
117
- rescue Exception
117
+ rescue RescuableException
118
118
  candidates = []
119
119
  end
120
120
  select_message(receiver, message, candidates)
@@ -126,7 +126,7 @@ class Pry
126
126
 
127
127
  begin
128
128
  candidates = eval(receiver, bind).methods.collect{|m| m.to_s}
129
- rescue Exception
129
+ rescue RescuableException
130
130
  candidates = []
131
131
  end
132
132
  select_message(receiver, message, candidates)
@@ -149,7 +149,7 @@ class Pry
149
149
  # Foo::Bar.func
150
150
  begin
151
151
  candidates = eval("#{receiver}.methods", bind).collect{|m| m.to_s}
152
- rescue Exception
152
+ rescue RescuableException
153
153
  candidates = []
154
154
  end
155
155
  else
@@ -157,8 +157,8 @@ class Pry
157
157
  candidates = []
158
158
  ObjectSpace.each_object(Module){|m|
159
159
  begin
160
- name = m.name
161
- rescue Exception
160
+ name = m.name.to_s
161
+ rescue RescuableException
162
162
  name = ""
163
163
  end
164
164
  next if name != "IRB::Context" and
@@ -51,9 +51,9 @@ class Pry
51
51
  # return value of that callable invocation is used as the exact
52
52
  # shell command to invoke the editor.
53
53
  # @example String
54
- # Pry.editor = "emacsclient"
54
+ # Pry.config.editor = "emacsclient"
55
55
  # @example Callable
56
- # Pry.editor = proc { |file, line| "emacsclient #{file} +#{line}" }
56
+ # Pry.config.editor = proc { |file, line| "emacsclient #{file} +#{line}" }
57
57
  # @return [String, #call]
58
58
  attr_accessor :editor
59
59
 
@@ -107,6 +107,10 @@ class Pry
107
107
 
108
108
  # @return [Integer] Amount of results that will be stored into out
109
109
  attr_accessor :memory_size
110
+
111
+ # @return [Proc] The proc that manages ^D presses in the REPL.
112
+ # The proc is passed the current eval_string and the current pry instance.
113
+ attr_accessor :control_d_handler
110
114
  end
111
115
  end
112
116
 
@@ -8,11 +8,11 @@ class Pry
8
8
  end
9
9
 
10
10
  command "simple-prompt", "Toggle the simple prompt." do
11
- case Pry.active_instance.prompt
11
+ case _pry_.prompt
12
12
  when Pry::SIMPLE_PROMPT
13
- Pry.active_instance.pop_prompt
13
+ _pry_.pop_prompt
14
14
  else
15
- Pry.active_instance.push_prompt Pry::SIMPLE_PROMPT
15
+ _pry_.push_prompt Pry::SIMPLE_PROMPT
16
16
  end
17
17
  end
18
18
 
@@ -24,7 +24,7 @@ class Pry
24
24
  next output.puts "Provide a command set name" if command_set.nil?
25
25
 
26
26
  set = target.eval(arg_string)
27
- Pry.active_instance.commands.import set
27
+ _pry_.commands.import set
28
28
  end
29
29
 
30
30
  command "reload-method", "Reload the source file that contains the specified method" do |meth_name|
@@ -44,6 +44,10 @@ class Pry
44
44
  end
45
45
  end
46
46
 
47
+ command "req", "Require file(s) and expand their paths." do |*args|
48
+ args.each { |file_name| load File.expand_path(file_name) }
49
+ end
50
+
47
51
  command "reset", "Reset the REPL to a clean state." do
48
52
  output.puts "Pry reset."
49
53
  exec "pry"
@@ -6,75 +6,122 @@ class Pry
6
6
  Context = Pry::CommandSet.new do
7
7
  import Ls
8
8
 
9
- command "cd", "Start a Pry session on VAR (use `cd ..` to go back and `cd /` to return to Pry top-level)", :keep_retval => true do |obj|
10
- case obj
11
- when nil
12
- output.puts "Must provide an object."
13
- next
14
- when ".."
15
- throw(:breakout, opts[:nesting].level)
16
- when "/"
17
- throw(:breakout, 1) if opts[:nesting].level > 0
18
- next
19
- when "::"
20
- TOPLEVEL_BINDING.pry
21
- next
9
+ command "cd", "Move into a new context (use `cd ..` to go back and `cd /` to return to Pry top-level). Complex syntax (e.g cd ../@x/y) also supported." do |obj|
10
+ path = arg_string.split(/\//)
11
+ stack = _pry_.binding_stack.dup
12
+
13
+ # special case when we only get a single "/", return to root
14
+ stack = [stack.first] if path.empty?
15
+
16
+ resolve_failure = false
17
+ path.each do |context|
18
+ begin
19
+ case context.chomp
20
+ when ""
21
+ stack = [stack.first]
22
+ when "::"
23
+ stack.push(TOPLEVEL_BINDING)
24
+ when "."
25
+ next
26
+ when ".."
27
+ if stack.one?
28
+ _pry_.binding_stack.clear
29
+ throw(:breakout)
30
+ else
31
+ stack.pop
32
+ end
33
+ else
34
+ stack.push(Pry.binding_for(stack.last.eval(context)))
35
+ end
36
+
37
+ rescue RescuableException
38
+ output.puts "Bad object path: #{arg_string}. Failed trying to resolve: #{context}"
39
+ resolve_failure = true
40
+ end
41
+ end
42
+
43
+ next if resolve_failure
44
+
45
+ _pry_.binding_stack = stack
46
+ end
47
+
48
+ command "switch-to", "Start a new sub-session on a binding in the current stack (numbered by nesting)." do |selection|
49
+ selection = selection.to_i
50
+
51
+ if selection < 0 || selection > _pry_.binding_stack.size - 1
52
+ output.puts "Invalid binding index #{selection} - use `nesting` command to view valid indices."
22
53
  else
23
- Pry.start target.eval(arg_string)
54
+ Pry.start(_pry_.binding_stack[selection])
24
55
  end
25
56
  end
26
57
 
27
58
  command "nesting", "Show nesting information." do
28
- nesting = opts[:nesting]
29
-
30
59
  output.puts "Nesting status:"
31
60
  output.puts "--"
32
- nesting.each do |level, obj|
61
+ _pry_.binding_stack.each_with_index do |obj, level|
33
62
  if level == 0
34
- output.puts "#{level}. #{Pry.view_clip(obj)} (Pry top level)"
63
+ output.puts "#{level}. #{Pry.view_clip(obj.eval('self'))} (Pry top level)"
35
64
  else
36
- output.puts "#{level}. #{Pry.view_clip(obj)}"
65
+ output.puts "#{level}. #{Pry.view_clip(obj.eval('self'))}"
37
66
  end
38
67
  end
39
68
  end
40
69
 
41
- command "jump-to", "Jump to a Pry session further up the stack, exiting all sessions below." do |break_level|
70
+ command "jump-to", "Jump to a binding further up the stack, popping all bindings below." do |break_level|
42
71
  break_level = break_level.to_i
43
- nesting = opts[:nesting]
72
+ nesting_level = _pry_.binding_stack.size - 1
44
73
 
45
74
  case break_level
46
- when nesting.level
47
- output.puts "Already at nesting level #{nesting.level}"
48
- when (0...nesting.level)
49
- throw(:breakout, break_level + 1)
75
+ when nesting_level
76
+ output.puts "Already at nesting level #{nesting_level}"
77
+ when (0...nesting_level)
78
+ _pry_.binding_stack.slice!(break_level + 1, _pry_.binding_stack.size)
79
+
50
80
  else
51
- max_nest_level = nesting.level - 1
81
+ max_nest_level = nesting_level - 1
52
82
  output.puts "Invalid nest level. Must be between 0 and #{max_nest_level}. Got #{break_level}."
53
83
  end
54
84
  end
55
85
 
56
- command "exit", "End the current Pry session. Accepts optional return value. Aliases: quit, back" do
57
- throw(:breakout, [opts[:nesting].level, target.eval(arg_string)])
86
+ command "exit-all", "End the current Pry session (popping all bindings) and returning to caller. Accepts optional return value. Aliases: !!@" do
87
+ # clear the binding stack
88
+ _pry_.binding_stack.clear
89
+
90
+ # break out of the repl loop
91
+ throw(:breakout, target.eval(arg_string))
58
92
  end
59
93
 
60
- alias_command "quit", "exit", ""
61
- alias_command "back", "exit", ""
94
+ alias_command "!!@", "exit-all", ""
95
+
96
+ command "exit", "Pop the current binding and return to the one immediately prior. Note this does NOT exit the program. Aliases: quit", :keep_retval => true do
97
+ if _pry_.binding_stack.one?
98
+ # when breaking out of top-level then behave like `exit-all`
99
+ _pry_.binding_stack.clear
100
+ throw(:breakout, target.eval(arg_string))
101
+ else
102
+ # otherwise just pop a binding
103
+ popped_object = _pry_.binding_stack.pop.eval('self')
62
104
 
63
- command "exit-all", "End all nested Pry sessions. Accepts optional return value. Aliases: !!@" do
64
- throw(:breakout, [0, target.eval(arg_string)])
105
+ # return a user-specified value if given
106
+ if !arg_string.empty?
107
+ target.eval(arg_string)
108
+ else
109
+ popped_object
110
+ end
111
+ end
65
112
  end
66
113
 
67
- alias_command "!!@", "exit-all", ""
114
+ alias_command "quit", "exit", ""
68
115
 
69
116
  command "exit-program", "End the current program. Aliases: quit-program, !!!" do
70
- Pry.active_instance.save_history if Pry.config.history.should_save
71
- exit
117
+ Pry.save_history if Pry.config.history.should_save
118
+ Kernel.exit target.eval(arg_string).to_i
72
119
  end
73
120
 
74
121
  alias_command "quit-program", "exit-program", ""
75
122
  alias_command "!!!", "exit-program", ""
76
123
 
77
- command "!pry", "Start a Pry session on current self; this even works mid-expression." do
124
+ command "!pry", "Start a Pry session on current self; this even works mid multi-line expression." do
78
125
  target.pry
79
126
  end
80
127
 
@@ -100,6 +147,7 @@ class Pry
100
147
  set_file_and_dir_locals(file)
101
148
  output.puts "\n#{text.bold('From:')} #{file} @ line #{line_num} in #{klass}##{meth_name}:\n\n"
102
149
 
150
+
103
151
  # This method inspired by http://rubygems.org/gems/ir_b
104
152
  File.open(file).each_with_index do |line, index|
105
153
  line_n = index + 1
@@ -11,7 +11,7 @@ class Pry
11
11
  target = target()
12
12
 
13
13
  opts = Slop.parse!(args) do |opt|
14
- opt.banner = "Usage: show-doc [OPTIONS] [METH]\n" \
14
+ opt.banner = "Usage: show-doc [OPTIONS] [METH 1] [METH 2] [METH N]\n" \
15
15
  "Show the comments above method METH. Tries instance methods first and then methods by default.\n" \
16
16
  "e.g show-doc hello_method"
17
17
 
@@ -28,24 +28,26 @@ class Pry
28
28
 
29
29
  next if opts.help?
30
30
 
31
- meth_name = args.shift
32
- if (meth = get_method_object(meth_name, target, opts.to_hash(true))).nil?
33
- output.puts "Invalid method name: #{meth_name}. Type `show-doc --help` for help"
34
- next
35
- end
31
+ args = [nil] if args.empty?
32
+ args.each do |method_name|
33
+ meth_name = method_name
34
+ if (meth = get_method_object(meth_name, target, opts.to_hash(true))).nil?
35
+ output.puts "Invalid method name: #{meth_name}. Type `show-doc --help` for help"
36
+ next
37
+ end
36
38
 
37
- doc, code_type = doc_and_code_type_for(meth)
38
- next if !doc
39
+ doc, code_type = doc_and_code_type_for(meth)
40
+ next if !doc
39
41
 
40
- next output.puts("No documentation found.") if doc.empty?
41
- doc = process_comment_markup(doc, code_type)
42
- output.puts make_header(meth, code_type, doc)
43
- if meth.respond_to?(:parameters)
44
- output.puts "#{text.bold("signature")}: #{signature_for(meth)}"
42
+ next output.puts("No documentation found.") if doc.empty?
43
+ doc = process_comment_markup(doc, code_type)
44
+ output.puts make_header(meth, code_type, doc)
45
+ output.puts "#{text.bold("visibility: ")} #{method_visibility(meth).to_s}"
46
+ output.puts "#{text.bold("signature: ")} #{signature_for(meth)}"
45
47
  output.puts
48
+ render_output(opts.flood?, false, doc)
49
+ doc
46
50
  end
47
- render_output(opts.flood?, false, doc)
48
- doc
49
51
  end
50
52
 
51
53
  alias_command "?", "show-doc", ""
@@ -84,13 +86,12 @@ class Pry
84
86
  output.puts "--"
85
87
  output.puts "Name: " + meth_name
86
88
  output.puts "Owner: " + (meth.owner.to_s ? meth.owner.to_s : "Unknown")
89
+ output.puts "Visibility: " + method_visibility(meth).to_s
87
90
  output.puts "Type: " + (meth.is_a?(Method) ? "Bound" : "Unbound")
88
91
  output.puts "Arity: " + meth.arity.to_s
92
+ output.puts "Method Signature: " + signature_for(meth)
89
93
 
90
- if meth.respond_to?(:parameters)
91
- output.puts "Method Signature: " + signature_for(meth)
92
- end
93
-
94
+ output.puts "Source location: " + (meth.source_location ? meth.source_location.join(":") : "Not found.")
94
95
  end
95
96
 
96
97
  command "gist-method", "Gist a method to github. Type `gist-method --help` for more info.", :requires_gem => "gist" do |*args|
@@ -142,19 +143,38 @@ class Pry
142
143
  end
143
144
 
144
145
  helpers do
145
- def signature_for(meth)
146
- param_strings = []
147
- meth.parameters.each do |kind, name|
148
- case kind
149
- when :req
150
- param_strings << name
151
- when :opt
152
- param_strings << "#{name}=?"
153
- when :rest
154
- param_strings << "*#{name}"
146
+
147
+ # paraphrased from awesome_print gem
148
+ def signature_for(method)
149
+ if method.respond_to?(:parameters)
150
+
151
+ args = method.parameters.inject([]) do |arr, (type, name)|
152
+ name ||= (type == :block ? 'block' : "arg#{arr.size + 1}")
153
+ arr << case type
154
+ when :req then name.to_s
155
+ when :opt, :rest then "*#{name}"
156
+ when :block then "&#{name}"
157
+ else '?'
158
+ end
155
159
  end
160
+ else
161
+ args = (1..method.arity.abs).map { |i| "arg#{i}" }
162
+ args[-1] = "*#{args[-1]}" if method.arity < 0
163
+ end
164
+
165
+ "#{method.name}(#{args.join(', ')})"
166
+ end
167
+
168
+ def method_visibility(meth)
169
+ if meth.owner.public_instance_methods.include? meth.name
170
+ :public
171
+ elsif meth.owner.protected_instance_methods.include? meth.name
172
+ :protected
173
+ elsif meth.owner.private_instance_methods.include? meth.name
174
+ :private
175
+ else
176
+ :none
156
177
  end
157
- "#{meth.name}(#{param_strings.join(", ")})"
158
178
  end
159
179
  end
160
180
 
@@ -3,6 +3,11 @@ class Pry
3
3
 
4
4
  EasterEggs = Pry::CommandSet.new do
5
5
 
6
+ command(/!s\/(.*?)\/(.*?)/, "") do |source, dest|
7
+ eval_string.gsub!(/#{source}/) { dest }
8
+ run "show-input"
9
+ end
10
+
6
11
  command "east-coker", "" do
7
12
  text = %{
8
13
  --
@@ -12,7 +12,7 @@ class Pry
12
12
  render_output(false, 1, Pry.color ? CodeRay.scan(eval_string, :ruby).term : eval_string)
13
13
  end
14
14
 
15
- command(/amend-line.?(-?\d+)?(?:\.\.(-?\d+))?/, "Amend a line of input in multi-line mode. Type `amend-line --help` for more information. Aliases %",
15
+ command(/amend-line(?: (-?\d+)(?:\.\.(-?\d+))?)?/, "Amend a line of input in multi-line mode. Type `amend-line --help` for more information. Aliases %",
16
16
  :interpolate => false, :listing => "amend-line") do |*args|
17
17
  start_line_number, end_line_number, replacement_line = *args
18
18
 
@@ -52,11 +52,11 @@ e.g amend-line puts 'hello again' # no line number modifies immediately preced
52
52
  run "show-input"
53
53
  end
54
54
 
55
- alias_command(/%.?(-?\d+)?(?:\.\.(-?\d+))?/, /amend-line.?(-?\d+)?(?:\.\.(-?\d+))?/, "")
55
+ alias_command(/%.?(-?\d+)?(?:\.\.(-?\d+))?/, /amend-line(?: (-?\d+)(?:\.\.(-?\d+))?)?/, "")
56
56
 
57
- command "play", "Play back a string or a method or a file as input. Type `play --help` for more information." do |*args|
57
+ command "play", "Play back a string variable or a method or a file as input. Type `play --help` for more information." do |*args|
58
58
  opts = Slop.parse!(args) do |opt|
59
- opt.banner "Usage: play [OPTIONS] [--help]\nDefault action (no options) is to play the provided string\ne.g `play puts 'hello world'` #=> \"hello world\"\ne.g `play -m Pry#repl --lines 1..-1`\ne.g `play -f Rakefile --lines 5`"
59
+ opt.banner "Usage: play [OPTIONS] [--help]\nDefault action (no options) is to play the provided string variable\ne.g `play _in_[20] --lines 1..3`\ne.g `play -m Pry#repl --lines 1..-1`\ne.g `play -f Rakefile --lines 5`"
60
60
 
61
61
  opt.on :l, :lines, 'The line (or range of lines) to replay.', true, :as => Range
62
62
  opt.on :m, :method, 'Play a method.', true
@@ -65,8 +65,6 @@ e.g amend-line puts 'hello again' # no line number modifies immediately preced
65
65
  opt.on :h, :help, "This message." do
66
66
  output.puts opt
67
67
  end
68
-
69
- opt.on_noopts { Pry.active_instance.input = StringIO.new(arg_string) }
70
68
  end
71
69
 
72
70
  if opts.m?
@@ -75,29 +73,35 @@ e.g amend-line puts 'hello again' # no line number modifies immediately preced
75
73
  output.puts "Invalid method name: #{meth_name}."
76
74
  next
77
75
  end
78
- code, code_type = code_and_code_type_for(meth)
76
+ code, _ = code_and_code_type_for(meth)
79
77
  next if !code
80
78
 
81
79
  range = opts.l? ? one_index_range_or_number(opts[:l]) : (0..-1)
82
80
  range = (0..-2) if opts.o?
83
81
 
84
- Pry.active_instance.input = StringIO.new(Array(code.each_line.to_a[range]).join)
85
- end
86
-
87
- if opts.f?
82
+ _pry_.input = StringIO.new(Array(code.each_line.to_a[range]).join)
83
+ elsif opts.f?
88
84
  file_name = File.expand_path(opts[:f])
89
85
  next output.puts "No such file: #{opts[:f]}" if !File.exists?(file_name)
90
86
  text_array = File.readlines(file_name)
91
87
  range = opts.l? ? one_index_range_or_number(opts[:l]) : (0..-1)
92
88
  range = (0..-2) if opts.o?
93
89
 
94
- Pry.active_instance.input = StringIO.new(Array(text_array[range]).join)
90
+ _pry_.input = StringIO.new(Array(text_array[range]).join)
91
+ else
92
+ next output.puts "Error: no input to play command" if !args.first
93
+ code = target.eval(args.first)
94
+
95
+ range = opts.l? ? one_index_range_or_number(opts[:l]) : (0..-1)
96
+ range = (0..-2) if opts.o?
97
+
98
+ eval_string << Array(code.each_line.to_a[range]).join
95
99
  end
96
100
  end
97
101
 
98
102
  command "hist", "Show and replay Readline history. Type `hist --help` for more info. Aliases: history" do |*args|
99
103
  # exclude the current command from history.
100
- history = Readline::HISTORY.to_a[0..-2]
104
+ history = Pry.history.to_a[0..-2]
101
105
 
102
106
  opts = Slop.parse!(args) do |opt|
103
107
  opt.banner "Usage: hist [--replay START..END] [--clear] [--grep PATTERN] [--head N] [--tail N] [--help] [--save [START..END] file.txt]\n"
@@ -132,7 +136,7 @@ e.g amend-line puts 'hello again' # no line number modifies immediately preced
132
136
  :unless => :grep do |limit|
133
137
 
134
138
  limit ||= 10
135
- offset = history.size-limit
139
+ offset = history.size - limit
136
140
  offset = offset < 0 ? 0 : offset
137
141
 
138
142
  list = history.last limit
@@ -164,13 +168,13 @@ e.g amend-line puts 'hello again' # no line number modifies immediately preced
164
168
  :as => Range,
165
169
  :unless => :grep do |range|
166
170
  actions = Array(history[range]).join("\n") + "\n"
167
- Pry.active_instance.input = StringIO.new(actions)
171
+ _pry_.input = StringIO.new(actions)
168
172
  end
169
173
 
170
174
  opt.on "save", "Save history to a file. --save [start..end] output.txt. Pry commands are excluded from saved history.", true, :as => Range
171
175
 
172
176
  opt.on :c, :clear, 'Clear the history', :unless => :grep do
173
- Readline::HISTORY.shift until Readline::HISTORY.empty?
177
+ Pry.history.clear
174
178
  output.puts 'History cleared.'
175
179
  end
176
180