pry 0.9.12.6-java → 0.10.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +702 -0
  3. data/LICENSE +2 -2
  4. data/{README.markdown → README.md} +37 -31
  5. data/lib/pry.rb +38 -151
  6. data/lib/pry/cli.rb +35 -17
  7. data/lib/pry/code.rb +19 -63
  8. data/lib/pry/code/code_file.rb +103 -0
  9. data/lib/pry/code/code_range.rb +2 -1
  10. data/lib/pry/code/loc.rb +2 -2
  11. data/lib/pry/code_object.rb +40 -21
  12. data/lib/pry/color_printer.rb +55 -0
  13. data/lib/pry/command.rb +12 -9
  14. data/lib/pry/command_set.rb +81 -38
  15. data/lib/pry/commands.rb +1 -1
  16. data/lib/pry/commands/amend_line.rb +2 -2
  17. data/lib/pry/commands/bang.rb +1 -1
  18. data/lib/pry/commands/cat.rb +11 -2
  19. data/lib/pry/commands/cat/exception_formatter.rb +6 -7
  20. data/lib/pry/commands/cat/file_formatter.rb +15 -32
  21. data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
  22. data/lib/pry/commands/cd.rb +14 -3
  23. data/lib/pry/commands/change_inspector.rb +27 -0
  24. data/lib/pry/commands/change_prompt.rb +26 -0
  25. data/lib/pry/commands/code_collector.rb +4 -4
  26. data/lib/pry/commands/easter_eggs.rb +3 -3
  27. data/lib/pry/commands/edit.rb +10 -22
  28. data/lib/pry/commands/edit/exception_patcher.rb +2 -2
  29. data/lib/pry/commands/edit/file_and_line_locator.rb +0 -2
  30. data/lib/pry/commands/exit_program.rb +0 -1
  31. data/lib/pry/commands/find_method.rb +16 -22
  32. data/lib/pry/commands/gem_install.rb +5 -2
  33. data/lib/pry/commands/gem_open.rb +1 -1
  34. data/lib/pry/commands/gist.rb +10 -11
  35. data/lib/pry/commands/help.rb +14 -14
  36. data/lib/pry/commands/hist.rb +27 -8
  37. data/lib/pry/commands/install_command.rb +14 -12
  38. data/lib/pry/commands/list_inspectors.rb +35 -0
  39. data/lib/pry/commands/list_prompts.rb +35 -0
  40. data/lib/pry/commands/ls.rb +72 -296
  41. data/lib/pry/commands/ls/constants.rb +47 -0
  42. data/lib/pry/commands/ls/formatter.rb +49 -0
  43. data/lib/pry/commands/ls/globals.rb +48 -0
  44. data/lib/pry/commands/ls/grep.rb +21 -0
  45. data/lib/pry/commands/ls/instance_vars.rb +39 -0
  46. data/lib/pry/commands/ls/interrogatable.rb +18 -0
  47. data/lib/pry/commands/ls/jruby_hacks.rb +49 -0
  48. data/lib/pry/commands/ls/local_names.rb +35 -0
  49. data/lib/pry/commands/ls/local_vars.rb +39 -0
  50. data/lib/pry/commands/ls/ls_entity.rb +70 -0
  51. data/lib/pry/commands/ls/methods.rb +57 -0
  52. data/lib/pry/commands/ls/methods_helper.rb +46 -0
  53. data/lib/pry/commands/ls/self_methods.rb +32 -0
  54. data/lib/pry/commands/play.rb +44 -10
  55. data/lib/pry/commands/pry_backtrace.rb +1 -2
  56. data/lib/pry/commands/raise_up.rb +2 -2
  57. data/lib/pry/commands/reload_code.rb +16 -19
  58. data/lib/pry/commands/ri.rb +7 -3
  59. data/lib/pry/commands/shell_command.rb +18 -13
  60. data/lib/pry/commands/shell_mode.rb +2 -4
  61. data/lib/pry/commands/show_doc.rb +5 -0
  62. data/lib/pry/commands/show_info.rb +8 -13
  63. data/lib/pry/commands/show_source.rb +15 -3
  64. data/lib/pry/commands/simple_prompt.rb +1 -1
  65. data/lib/pry/commands/toggle_color.rb +8 -4
  66. data/lib/pry/commands/watch_expression.rb +105 -0
  67. data/lib/pry/commands/watch_expression/expression.rb +38 -0
  68. data/lib/pry/commands/whereami.rb +18 -10
  69. data/lib/pry/commands/wtf.rb +3 -3
  70. data/lib/pry/config.rb +20 -254
  71. data/lib/pry/config/behavior.rb +139 -0
  72. data/lib/pry/config/convenience.rb +26 -0
  73. data/lib/pry/config/default.rb +165 -0
  74. data/lib/pry/core_extensions.rb +31 -21
  75. data/lib/pry/editor.rb +107 -103
  76. data/lib/pry/exceptions.rb +77 -0
  77. data/lib/pry/helpers/base_helpers.rb +22 -109
  78. data/lib/pry/helpers/command_helpers.rb +10 -8
  79. data/lib/pry/helpers/documentation_helpers.rb +1 -2
  80. data/lib/pry/helpers/text.rb +4 -5
  81. data/lib/pry/history.rb +46 -45
  82. data/lib/pry/history_array.rb +6 -1
  83. data/lib/pry/hooks.rb +9 -29
  84. data/lib/pry/indent.rb +6 -6
  85. data/lib/pry/input_completer.rb +242 -0
  86. data/lib/pry/input_lock.rb +132 -0
  87. data/lib/pry/inspector.rb +27 -0
  88. data/lib/pry/last_exception.rb +61 -0
  89. data/lib/pry/method.rb +82 -87
  90. data/lib/pry/{commands/edit/method_patcher.rb → method/patcher.rb} +41 -38
  91. data/lib/pry/module_candidate.rb +4 -14
  92. data/lib/pry/object_path.rb +82 -0
  93. data/lib/pry/output.rb +50 -0
  94. data/lib/pry/pager.rb +193 -48
  95. data/lib/pry/plugins.rb +1 -1
  96. data/lib/pry/prompt.rb +26 -0
  97. data/lib/pry/pry_class.rb +149 -230
  98. data/lib/pry/pry_instance.rb +302 -413
  99. data/lib/pry/rbx_path.rb +1 -1
  100. data/lib/pry/repl.rb +202 -0
  101. data/lib/pry/repl_file_loader.rb +20 -26
  102. data/lib/pry/rubygem.rb +13 -5
  103. data/lib/pry/terminal.rb +2 -1
  104. data/lib/pry/test/helper.rb +26 -41
  105. data/lib/pry/version.rb +1 -1
  106. data/lib/pry/wrapped_module.rb +45 -59
  107. metadata +62 -225
  108. data/.document +0 -2
  109. data/.gitignore +0 -16
  110. data/.travis.yml +0 -25
  111. data/.yardopts +0 -1
  112. data/CHANGELOG +0 -534
  113. data/CONTRIBUTORS +0 -55
  114. data/Gemfile +0 -12
  115. data/Rakefile +0 -140
  116. data/TODO +0 -117
  117. data/lib/pry/completion.rb +0 -321
  118. data/lib/pry/custom_completions.rb +0 -6
  119. data/lib/pry/rbx_method.rb +0 -13
  120. data/man/pry.1 +0 -195
  121. data/man/pry.1.html +0 -204
  122. data/man/pry.1.ronn +0 -141
  123. data/pry.gemspec +0 -29
  124. data/spec/Procfile +0 -3
  125. data/spec/cli_spec.rb +0 -78
  126. data/spec/code_object_spec.rb +0 -277
  127. data/spec/code_spec.rb +0 -219
  128. data/spec/command_helpers_spec.rb +0 -29
  129. data/spec/command_integration_spec.rb +0 -644
  130. data/spec/command_set_spec.rb +0 -627
  131. data/spec/command_spec.rb +0 -821
  132. data/spec/commands/amend_line_spec.rb +0 -247
  133. data/spec/commands/bang_spec.rb +0 -19
  134. data/spec/commands/cat_spec.rb +0 -164
  135. data/spec/commands/cd_spec.rb +0 -250
  136. data/spec/commands/disable_pry_spec.rb +0 -25
  137. data/spec/commands/edit_spec.rb +0 -727
  138. data/spec/commands/exit_all_spec.rb +0 -34
  139. data/spec/commands/exit_program_spec.rb +0 -19
  140. data/spec/commands/exit_spec.rb +0 -34
  141. data/spec/commands/find_method_spec.rb +0 -70
  142. data/spec/commands/gem_list_spec.rb +0 -26
  143. data/spec/commands/gist_spec.rb +0 -79
  144. data/spec/commands/help_spec.rb +0 -56
  145. data/spec/commands/hist_spec.rb +0 -181
  146. data/spec/commands/jump_to_spec.rb +0 -15
  147. data/spec/commands/ls_spec.rb +0 -181
  148. data/spec/commands/play_spec.rb +0 -140
  149. data/spec/commands/raise_up_spec.rb +0 -56
  150. data/spec/commands/save_file_spec.rb +0 -177
  151. data/spec/commands/show_doc_spec.rb +0 -510
  152. data/spec/commands/show_input_spec.rb +0 -17
  153. data/spec/commands/show_source_spec.rb +0 -782
  154. data/spec/commands/whereami_spec.rb +0 -203
  155. data/spec/completion_spec.rb +0 -241
  156. data/spec/control_d_handler_spec.rb +0 -58
  157. data/spec/documentation_helper_spec.rb +0 -73
  158. data/spec/editor_spec.rb +0 -79
  159. data/spec/exception_whitelist_spec.rb +0 -21
  160. data/spec/fixtures/candidate_helper1.rb +0 -11
  161. data/spec/fixtures/candidate_helper2.rb +0 -8
  162. data/spec/fixtures/example.erb +0 -5
  163. data/spec/fixtures/example_nesting.rb +0 -33
  164. data/spec/fixtures/show_source_doc_examples.rb +0 -15
  165. data/spec/fixtures/testrc +0 -2
  166. data/spec/fixtures/testrcbad +0 -2
  167. data/spec/fixtures/whereami_helper.rb +0 -6
  168. data/spec/helper.rb +0 -34
  169. data/spec/helpers/bacon.rb +0 -86
  170. data/spec/helpers/mock_pry.rb +0 -43
  171. data/spec/helpers/table_spec.rb +0 -105
  172. data/spec/history_array_spec.rb +0 -67
  173. data/spec/hooks_spec.rb +0 -522
  174. data/spec/indent_spec.rb +0 -301
  175. data/spec/input_stack_spec.rb +0 -90
  176. data/spec/method_spec.rb +0 -482
  177. data/spec/prompt_spec.rb +0 -60
  178. data/spec/pry_defaults_spec.rb +0 -419
  179. data/spec/pry_history_spec.rb +0 -99
  180. data/spec/pry_output_spec.rb +0 -95
  181. data/spec/pry_spec.rb +0 -515
  182. data/spec/run_command_spec.rb +0 -25
  183. data/spec/sticky_locals_spec.rb +0 -157
  184. data/spec/syntax_checking_spec.rb +0 -81
  185. data/spec/wrapped_module_spec.rb +0 -261
  186. data/wiki/Customizing-pry.md +0 -397
  187. data/wiki/Home.md +0 -4
@@ -1,7 +1,7 @@
1
1
  class Pry
2
2
  class Command::SimplePrompt < Pry::ClassCommand
3
3
  match 'simple-prompt'
4
- group 'Misc'
4
+ group 'prompts'
5
5
  description 'Toggle the simple prompt.'
6
6
 
7
7
  banner <<-'BANNER'
@@ -11,10 +11,14 @@ class Pry
11
11
  BANNER
12
12
 
13
13
  def process
14
- Pry.color = !Pry.color
15
- output.puts "Syntax highlighting #{Pry.color ? "on" : "off"}"
14
+ _pry_.color = color_toggle
15
+ output.puts "Syntax highlighting #{_pry_.color ? "on" : "off"}"
16
+ end
17
+
18
+ def color_toggle
19
+ !_pry_.color
16
20
  end
17
- end
18
21
 
19
- Pry::Commands.add_command(Pry::Command::ToggleColor)
22
+ Pry::Commands.add_command(self)
23
+ end
20
24
  end
@@ -0,0 +1,105 @@
1
+ class Pry
2
+ class Command::WatchExpression < Pry::ClassCommand
3
+ require 'pry/commands/watch_expression/expression.rb'
4
+
5
+ match 'watch'
6
+ group 'Context'
7
+ description 'Watch the value of an expression and print a notification whenever it changes.'
8
+ command_options :use_prefix => false
9
+
10
+ banner <<-'BANNER'
11
+ Usage: watch [EXPRESSION]
12
+ watch
13
+ watch --delete [INDEX]
14
+
15
+ watch [EXPRESSION] adds an expression to the list of those being watched.
16
+ It will be re-evaluated every time you hit enter in pry. If its value has
17
+ changed, the new value will be printed to the console.
18
+
19
+ This is useful if you are step-through debugging and want to see how
20
+ something changes over time. It's also useful if you're trying to write
21
+ a method inside pry and want to check that it gives the right answers
22
+ every time you redefine it.
23
+
24
+ watch on its own displays all the currently watched expressions and their
25
+ values, and watch --delete [INDEX] allows you to delete expressions from
26
+ the list being watched.
27
+ BANNER
28
+
29
+ def options(opt)
30
+ opt.on :d, :delete,
31
+ "Delete the watch expression with the given index. If no index is given; clear all watch expressions.",
32
+ :optional_argument => true, :as => Integer
33
+ opt.on :l, :list,
34
+ "Show all current watch expressions and their values. Calling watch with no expressions or options will also show the watch expressions."
35
+ end
36
+
37
+ def process
38
+ case
39
+ when opts.present?(:delete)
40
+ delete opts[:delete]
41
+ when opts.present?(:list) || args.empty?
42
+ list
43
+ else
44
+ add_hook
45
+ add_expression(args)
46
+ end
47
+ end
48
+
49
+ private
50
+
51
+ def expressions
52
+ _pry_.config.watch_expressions ||= []
53
+ end
54
+
55
+ def delete(index)
56
+ if index
57
+ output.puts "Deleting watch expression ##{index}: #{expressions[index-1]}"
58
+ expressions.delete_at(index-1)
59
+ else
60
+ output.puts "Deleting all watched expressions"
61
+ expressions.clear
62
+ end
63
+ end
64
+
65
+ def list
66
+ if expressions.empty?
67
+ output.puts "No watched expressions"
68
+ else
69
+ _pry_.pager.open do |pager|
70
+ pager.puts "Listing all watched expressions:"
71
+ pager.puts ""
72
+ expressions.each_with_index do |expr, index|
73
+ pager.print text.with_line_numbers(expr.to_s, index+1)
74
+ end
75
+ pager.puts ""
76
+ end
77
+ end
78
+ end
79
+
80
+ def eval_and_print_changed(output)
81
+ expressions.each do |expr|
82
+ expr.eval!
83
+ if expr.changed?
84
+ output.puts "#{text.blue "watch"}: #{expr.to_s}"
85
+ end
86
+ end
87
+ end
88
+
89
+ def add_expression(arguments)
90
+ expressions << Expression.new(_pry_, target, arg_string)
91
+ output.puts "Watching #{Code.new(arg_string)}"
92
+ end
93
+
94
+ def add_hook
95
+ hook = [:after_eval, :watch_expression]
96
+ unless _pry_.hooks.hook_exists?(*hook)
97
+ _pry_.hooks.add_hook(*hook) do |_, _pry_|
98
+ eval_and_print_changed _pry_.output
99
+ end
100
+ end
101
+ end
102
+ end
103
+
104
+ Pry::Commands.add_command(Pry::Command::WatchExpression)
105
+ end
@@ -0,0 +1,38 @@
1
+ class Pry
2
+ class Command::WatchExpression
3
+ class Expression
4
+ attr_reader :target, :source, :value, :previous_value, :_pry_
5
+
6
+ def initialize(_pry_, target, source)
7
+ @_pry_ = _pry_
8
+ @target = target
9
+ @source = source.strip
10
+ end
11
+
12
+ def eval!
13
+ @previous_value = @value
14
+ @value = Pry::ColorPrinter.pp(target_eval(target, source), "")
15
+ end
16
+
17
+ def to_s
18
+ "#{Code.new(source).strip} => #{value}"
19
+ end
20
+
21
+ # Has the value of the expression changed?
22
+ #
23
+ # We use the pretty-printed string represenation to detect differences
24
+ # as this avoids problems with dup (causes too many differences) and == (causes too few)
25
+ def changed?
26
+ (value != previous_value)
27
+ end
28
+
29
+ private
30
+
31
+ def target_eval(target, source)
32
+ target.eval(source)
33
+ rescue => e
34
+ e
35
+ end
36
+ end
37
+ end
38
+ end
@@ -88,10 +88,10 @@ class Pry
88
88
 
89
89
  set_file_and_dir_locals(@file)
90
90
 
91
- out = "\n#{text.bold('From:')} #{location}:\n\n" +
92
- code.with_line_numbers(use_line_numbers?).with_marker(marker).to_s + "\n"
91
+ out = "\n#{text.bold('From:')} #{location}:\n\n" <<
92
+ code.with_line_numbers(use_line_numbers?).with_marker(marker) << "\n"
93
93
 
94
- stagger_output(out)
94
+ _pry_.pager.page out
95
95
  end
96
96
 
97
97
  private
@@ -109,7 +109,7 @@ class Pry
109
109
  end
110
110
 
111
111
  def top_level?
112
- target_self == TOPLEVEL_BINDING.eval("self")
112
+ target_self == Pry.main
113
113
  end
114
114
 
115
115
  def handle_internal_binding
@@ -144,14 +144,21 @@ class Pry
144
144
  end
145
145
  end
146
146
 
147
+ # This either returns the `target_self`
148
+ # or it returns the class of `target_self` if `target_self` is not a class.
149
+ # @return [Pry::WrappedModule]
150
+ def target_class
151
+ target_self.is_a?(Module) ? Pry::WrappedModule(target_self) :
152
+ Pry::WrappedModule(target_self.class)
153
+ end
154
+
147
155
  def class_code
148
156
  return @class_code if @class_code
149
157
 
150
- if valid_method?
151
- mod = Pry::WrappedModule(@method.owner)
152
- idx = mod.candidates.find_index { |v| expand_path(v.source_file) == @file }
153
- @class_code = idx && Pry::Code.from_module(mod, idx)
154
- end
158
+ mod = @method ? Pry::WrappedModule(@method.owner) : target_class
159
+
160
+ idx = mod.candidates.find_index { |v| expand_path(v.source_file) == @file }
161
+ @class_code = idx && Pry::Code.from_module(mod, idx)
155
162
  end
156
163
 
157
164
  def valid_method?
@@ -171,7 +178,7 @@ class Pry
171
178
 
172
179
  def window_size
173
180
  if args.empty?
174
- Pry.config.default_window_size
181
+ _pry_.config.default_window_size
175
182
  else
176
183
  args.first.to_i
177
184
  end
@@ -179,4 +186,5 @@ class Pry
179
186
  end
180
187
 
181
188
  Pry::Commands.add_command(Pry::Command::Whereami)
189
+ Pry::Commands.alias_command '@', 'whereami'
182
190
  end
@@ -1,6 +1,6 @@
1
1
  class Pry
2
2
  class Command::Wtf < Pry::ClassCommand
3
- match /wtf([?!]*)/
3
+ match(/wtf([?!]*)/)
4
4
  group 'Context'
5
5
  description 'Show the backtrace of the most recent exception.'
6
6
  options :listing => 'wtf?'
@@ -50,8 +50,8 @@ class Pry
50
50
 
51
51
  def size_of_backtrace
52
52
  [captures[0].size, 0.5].max * 10
53
+ end
53
54
  end
54
- end
55
55
 
56
- Pry::Commands.add_command(Pry::Command::Wtf)
56
+ Pry::Commands.add_command(Pry::Command::Wtf)
57
57
  end
@@ -1,258 +1,24 @@
1
- require 'ostruct'
2
-
3
- class Pry
4
- class Config < OpenStruct
5
-
6
- # Get/Set the object to use for input by default by all Pry instances.
7
- # Pry.config.input is an option determining the input object - the object from
8
- # which Pry retrieves its lines of input. Pry accepts any object that
9
- # implements the readline method. This includes IO objects, StringIO,
10
- # Readline, File and custom objects. It can also be a Proc which returns an
11
- # object implementing the readline method.
12
- # @return [#readline] The object to use for input by default by all
13
- # Pry instances.
14
- # @example
15
- # Pry.config.input = StringIO.new("@x = 10\nexit")
16
- def input
17
- @reified_input ||=
18
- if @input.respond_to?(:call)
19
- @input.call
20
- else
21
- @input
22
- end
23
- end
24
-
25
- def input=(input)
26
- @reified_input = nil
27
- @input = input
28
- end
29
-
30
- # Get/Set the object to use for output by default by all Pry instances.
31
- # Pry.config.output is an option determining the output object - the object to which
32
- # Pry writes its output. Pry accepts any object that implements the puts method. This
33
- # includes IO objects, StringIO, File and custom objects.
34
- # @return [#puts] The object to use for output by default by all
35
- # Pry instances.
36
- # @example
37
- # Pry.config.output = StringIO.new
38
- attr_accessor :output
39
-
40
- # Get/Set the object to use for commands by default by all Pry instances.
41
- # @return [Pry::CommandBase] The object to use for commands by default by all
42
- # Pry instances.
43
- # @example
44
- # Pry.config.commands = Pry::CommandSet.new do
45
- # import_from Pry::Commands, "ls"
46
- #
47
- # command "greet" do |name|
48
- # output.puts "hello #{name}"
49
- # end
50
- # end
51
- attr_accessor :commands
52
-
53
- # Get/Set the Proc to use for printing by default by all Pry
54
- # instances.
55
- # Two parameters are passed to the print Proc: these are (1) the
56
- # output object for the current session and (2) the expression value to print. It is important
57
- # that you write to the output object instead of just stdout so that all Pry output can be redirected if necessary.
58
- # This is the 'print' component of the REPL.
59
- # @return [Proc] The Proc to use for printing by default by all
60
- # Pry instances.
61
- # @example
62
- # Pry.config.print = proc { |output, value| output.puts "=> #{value.inspect}" }
63
- attr_accessor :print
64
-
65
- # Pry.config.exception_handler is an option determining the exception handler object - the
66
- # Proc responsible for dealing with exceptions raised by user input to the REPL.
67
- # Three parameters are passed to the exception handler Proc: these
68
- # are (1) the output object for the current session, (2) the
69
- # exception object that was raised inside the Pry session, and (3)
70
- # a reference to the associated Pry instance.
71
- # @return [Proc] The Proc to use for printing exceptions by default by all
72
- # Pry instances.
73
- # @example
74
- # Pry.config.exception_handler = proc do |output, exception, _|
75
- # output.puts "#{exception.class}: #{exception.message}"
76
- # output.puts "from #{exception.backtrace.first}"
77
- # end
78
- attr_accessor :exception_handler
79
-
80
- # @return [Array] The classes of exception that will not be caught by Pry.
81
- # @example
82
- # Pry.config.exception_whitelist = [SystemExit, SignalException]
83
- attr_accessor :exception_whitelist
84
-
85
- # @return [Fixnum] The number of lines of context to show before and after
86
- # exceptions, etc.
87
- # @example
88
- # Pry.config.default_window_size = 10
89
- attr_accessor :default_window_size
90
-
91
- # Get/Set the `Pry::Hooks` instance that defines Pry hooks used by default by all Pry
92
- # instances.
93
- # @return [Pry::Hooks] The hooks used by default by all Pry instances.
94
- # @example
95
- # Pry.config.hooks = Pry::Hooks.new.add_hook(:before_session,
96
- # :default) { |output, target, _pry_| output.puts "Good morning!" }
97
- attr_reader :hooks
1
+ class Pry::Config
2
+ require_relative 'config/behavior'
3
+ require_relative 'config/default'
4
+ require_relative 'config/convenience'
5
+ include Pry::Config::Behavior
6
+
7
+ def self.shortcuts
8
+ Convenience::SHORTCUTS
9
+ end
98
10
 
99
- # FIXME:
100
- # This is a hack to alert people of the new API.
101
- # @param [Pry::Hooks] v Only accept `Pry::Hooks` now!
102
- def hooks=(v)
103
- if v.is_a?(Hash)
104
- warn "Hash-based hooks are now deprecated! Use a `Pry::Hooks` object instead! http://rubydoc.info/github/pry/pry/master/Pry/Hooks"
105
- @hooks = Pry::Hooks.from_hash(v)
106
- else
107
- @hooks = v
108
- end
11
+ #
12
+ # FIXME
13
+ # @param [Pry::Hooks] hooks
14
+ #
15
+ def hooks=(hooks)
16
+ if hooks.is_a?(Hash)
17
+ warn "Hash-based hooks are now deprecated! Use a `Pry::Hooks` object " \
18
+ "instead! http://rubydoc.info/github/pry/pry/master/Pry/Hooks"
19
+ self["hooks"] = Pry::Hooks.from_hash(hooks)
20
+ else
21
+ self["hooks"] = hooks
109
22
  end
110
-
111
- # Get/Set the stack of input objects that a Pry instance switches
112
- # to when its current input object encounters EOF.
113
- # @return [Array] The array of input objects.
114
- # @example
115
- # Pry.config.input_stack = [StringIO.new("puts 'hello world'\nexit")]
116
- attr_accessor :input_stack
117
-
118
- # Get the array of Procs (or single Proc) to be used for the prompts by default by
119
- # all Pry instances.
120
- # Three parameters are passed into the prompt procs, (1) the
121
- # object that is the target of the session, (2) the current
122
- # nesting level, and (3) a reference to the associated Pry instance. These objects can be used in the prompt, if desired.
123
- # @return [Array<Proc>, Proc] The array of Procs to be used for the
124
- # prompts by default by all Pry instances.
125
- # @example
126
- # Pry.config.prompt = proc { |obj, nest_level, _pry_| "#{obj}:#{nest_level}> " }
127
- attr_accessor :prompt
128
-
129
- # The display name that is part of the prompt. Default is 'pry'.
130
- # You can set your own name so you can identify which project your current pry session
131
- # is using. This is useful if you have a local pryrc file in a Rails project for example.
132
- # @return [String]
133
- # @example
134
- # Pry.config.prompt_name = 'my_rails_project'
135
- attr_accessor :prompt_name
136
-
137
- # The default editor to use. Defaults to $VISUAL, $EDITOR, or a sensible fallback
138
- # for the platform.
139
- # If `editor` is a String then that string is used as the shell
140
- # command to invoke the editor. If `editor` is callable (e.g a
141
- # Proc) then `file`, `line`, and `reloading` are passed in as parameters and the
142
- # return value of that callable invocation is used as the exact
143
- # shell command to invoke the editor. `reloading` indicates whether Pry will be
144
- # reloading code after the shell command returns. Any or all of these parameters
145
- # can be omitted from the callable's signature.
146
- # @example String
147
- # Pry.config.editor = "emacsclient"
148
- # @example Callable
149
- # Pry.config.editor = proc { |file, line| "emacsclient #{file} +#{line}" }
150
- # @example Callable waiting only if reloading
151
- # Pry.config.editor = proc { |file, line, reloading| "subl #{'--wait' if reloading} #{file}:#{line}" }
152
- # @return [String, #call]
153
- attr_accessor :editor
154
-
155
- # A string that must precede all Pry commands (e.g., if command_prefix is
156
- # set to "%", the "cd" command must be invoked as "%cd").
157
- # @return [String]
158
- attr_accessor :command_prefix
159
-
160
- # @return [Boolean] Toggle Pry color on and off.
161
- attr_accessor :color
162
-
163
- # @return [Boolean] Toggle paging on and off.
164
- attr_accessor :pager
165
-
166
- # Determines whether the rc file (~/.pryrc) should be loaded.
167
- # @return [Boolean]
168
- attr_accessor :should_load_rc
169
-
170
- # Determines whether the local rc file (./.pryrc) should be loaded.
171
- # @return [Boolean]
172
- attr_accessor :should_load_local_rc
173
-
174
- # Determines whether plugins should be loaded.
175
- # @return [Boolean]
176
- attr_accessor :should_load_plugins
177
-
178
- # Determines whether to load files specified with the -r flag.
179
- # @return [Boolean]
180
- attr_accessor :should_load_requires
181
-
182
- # Determines whether to disable edit-method's auto-reloading behavior.
183
- # @return [Boolean]
184
- attr_accessor :disable_auto_reload
185
-
186
- # Determines whether Pry should trap SIGINT and cause it to raise an
187
- # Interrupt exception. This is only useful on jruby, MRI does this
188
- # for us.
189
- # @return [Boolean]
190
- attr_accessor :should_trap_interrupts
191
-
192
- # Config option for history.
193
- # sub-options include history.file, history.load, and history.save
194
- # history.file is the file to save/load history to, e.g
195
- # Pry.config.history.file = "~/.pry_history".
196
- # history.should_load is a boolean that determines whether history will be
197
- # loaded from history.file at session start.
198
- # history.should_save is a boolean that determines whether history will be
199
- # saved to history.file at session end.
200
- # @return [OpenStruct]
201
- attr_accessor :history
202
-
203
- # Config option for plugins:
204
- # sub-options include:
205
- # `plugins.strict_loading` (Boolean) which toggles whether referring to a non-existent plugin should raise an exception (defaults to `false`)
206
- # @return [OpenStruct]
207
- attr_accessor :plugins
208
-
209
- # @return [Array<String>] Ruby files to be required after loading any plugins.
210
- attr_accessor :requires
211
-
212
- # @return [Integer] Amount of results that will be stored into out
213
- attr_accessor :memory_size
214
-
215
- # @return [Proc] The proc that manages ^D presses in the REPL.
216
- # The proc is passed the current eval_string and the current pry instance.
217
- attr_accessor :control_d_handler
218
-
219
- # @return [Proc] The proc that runs system commands
220
- # The proc is passed the pry output object, the command string
221
- # to eval, and a reference to the pry instance
222
- attr_accessor :system
223
-
224
- # @return [Boolean] Whether or not code should be indented
225
- # using Pry::Indent.
226
- attr_accessor :auto_indent
227
-
228
- # @return [Boolean] Whether or not indentation should be corrected
229
- # after hitting enter. This feature is not supported by all terminals.
230
- attr_accessor :correct_indent
231
-
232
- # @return [Boolean] Whether or not a warning will be displayed when
233
- # a command name collides with a method/local in the current context.
234
- attr_accessor :collision_warning
235
-
236
-
237
- # Config option for gist.
238
- # sub-options include `gist.inspecter`,
239
- # `gist.inspecter` is a callable that defines how the expression output
240
- # will be displayed when using the `gist -i` command.
241
- # @example Pretty inspect output
242
- # Pry.config.gist.inspecter = proc { |v| v.pretty_inspect }
243
- # @example Regular inspect
244
- # Pry.config.gist.inspecter = proc &:inspect
245
- # @return [OpenStruct]
246
- attr_accessor :gist
247
-
248
- # @return [Hash] Additional sticky locals (to the standard ones) to use in Pry sessions.
249
- # @example Inject `random_number` sticky local into Pry session
250
- # Pry.config.extra_sticky_locals = { :random_number => proc {
251
- # rand(10) } }
252
- attr_accessor :extra_sticky_locals
253
-
254
- # @return [#build_completion_proc] A completer to use.
255
- attr_accessor :completer
256
23
  end
257
24
  end
258
-