pry 0.10.3 → 0.12.2

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.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +251 -16
  3. data/LICENSE +1 -1
  4. data/README.md +35 -51
  5. data/bin/pry +3 -11
  6. data/lib/pry/basic_object.rb +6 -0
  7. data/lib/pry/cli.rb +50 -52
  8. data/lib/pry/code/code_file.rb +13 -6
  9. data/lib/pry/code/code_range.rb +3 -3
  10. data/lib/pry/code/loc.rb +14 -8
  11. data/lib/pry/code.rb +12 -5
  12. data/lib/pry/code_object.rb +27 -4
  13. data/lib/pry/color_printer.rb +20 -10
  14. data/lib/pry/command.rb +76 -45
  15. data/lib/pry/command_set.rb +17 -45
  16. data/lib/pry/commands/amend_line.rb +3 -4
  17. data/lib/pry/commands/bang.rb +1 -1
  18. data/lib/pry/commands/cat/exception_formatter.rb +10 -8
  19. data/lib/pry/commands/cat/file_formatter.rb +7 -3
  20. data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
  21. data/lib/pry/commands/cat.rb +7 -6
  22. data/lib/pry/commands/change_prompt.rb +29 -9
  23. data/lib/pry/commands/clear_screen.rb +14 -0
  24. data/lib/pry/commands/code_collector.rb +25 -23
  25. data/lib/pry/commands/easter_eggs.rb +12 -12
  26. data/lib/pry/commands/edit/file_and_line_locator.rb +1 -1
  27. data/lib/pry/commands/edit.rb +15 -10
  28. data/lib/pry/commands/exit.rb +2 -1
  29. data/lib/pry/commands/find_method.rb +12 -14
  30. data/lib/pry/commands/gem_cd.rb +1 -1
  31. data/lib/pry/commands/gem_install.rb +2 -2
  32. data/lib/pry/commands/gem_list.rb +2 -2
  33. data/lib/pry/commands/gem_open.rb +2 -2
  34. data/lib/pry/commands/gem_readme.rb +25 -0
  35. data/lib/pry/commands/gem_search.rb +40 -0
  36. data/lib/pry/commands/gem_stats.rb +83 -0
  37. data/lib/pry/commands/gist.rb +7 -6
  38. data/lib/pry/commands/help.rb +3 -3
  39. data/lib/pry/commands/hist.rb +11 -10
  40. data/lib/pry/commands/import_set.rb +2 -1
  41. data/lib/pry/commands/install_command.rb +7 -6
  42. data/lib/pry/commands/jump_to.rb +7 -7
  43. data/lib/pry/commands/list_inspectors.rb +2 -2
  44. data/lib/pry/commands/ls/constants.rb +14 -3
  45. data/lib/pry/commands/ls/formatter.rb +4 -2
  46. data/lib/pry/commands/ls/globals.rb +0 -2
  47. data/lib/pry/commands/ls/grep.rb +0 -2
  48. data/lib/pry/commands/ls/instance_vars.rb +0 -1
  49. data/lib/pry/commands/ls/jruby_hacks.rb +2 -2
  50. data/lib/pry/commands/ls/local_names.rb +0 -2
  51. data/lib/pry/commands/ls/local_vars.rb +0 -2
  52. data/lib/pry/commands/ls/ls_entity.rb +0 -1
  53. data/lib/pry/commands/ls/methods.rb +0 -3
  54. data/lib/pry/commands/ls/methods_helper.rb +1 -1
  55. data/lib/pry/commands/ls/self_methods.rb +2 -1
  56. data/lib/pry/commands/ls.rb +30 -31
  57. data/lib/pry/commands/play.rb +3 -4
  58. data/lib/pry/commands/pry_backtrace.rb +1 -1
  59. data/lib/pry/commands/raise_up.rb +2 -1
  60. data/lib/pry/commands/reload_code.rb +2 -2
  61. data/lib/pry/commands/ri.rb +9 -4
  62. data/lib/pry/commands/shell_command.rb +36 -9
  63. data/lib/pry/commands/shell_mode.rb +6 -6
  64. data/lib/pry/commands/show_doc.rb +5 -7
  65. data/lib/pry/commands/show_info.rb +41 -20
  66. data/lib/pry/commands/show_source.rb +5 -2
  67. data/lib/pry/commands/stat.rb +1 -1
  68. data/lib/pry/commands/watch_expression/expression.rb +1 -1
  69. data/lib/pry/commands/watch_expression.rb +9 -7
  70. data/lib/pry/commands/whereami.rb +16 -9
  71. data/lib/pry/commands/wtf.rb +15 -2
  72. data/lib/pry/config/behavior.rb +230 -114
  73. data/lib/pry/config/convenience.rb +24 -21
  74. data/lib/pry/config/default.rb +151 -153
  75. data/lib/pry/config/memoization.rb +48 -0
  76. data/lib/pry/config.rb +30 -19
  77. data/lib/pry/core_extensions.rb +15 -4
  78. data/lib/pry/editor.rb +5 -12
  79. data/lib/pry/exceptions.rb +1 -3
  80. data/lib/pry/forwardable.rb +23 -0
  81. data/lib/pry/helpers/base_helpers.rb +197 -110
  82. data/lib/pry/helpers/command_helpers.rb +5 -4
  83. data/lib/pry/helpers/documentation_helpers.rb +3 -2
  84. data/lib/pry/helpers/options_helpers.rb +6 -6
  85. data/lib/pry/helpers/platform.rb +58 -0
  86. data/lib/pry/helpers/table.rb +20 -15
  87. data/lib/pry/helpers/text.rb +82 -74
  88. data/lib/pry/helpers.rb +1 -0
  89. data/lib/pry/history.rb +44 -10
  90. data/lib/pry/hooks.rb +50 -109
  91. data/lib/pry/indent.rb +21 -19
  92. data/lib/pry/input_completer.rb +146 -123
  93. data/lib/pry/input_lock.rb +0 -2
  94. data/lib/pry/last_exception.rb +2 -2
  95. data/lib/pry/method/disowned.rb +3 -1
  96. data/lib/pry/method/patcher.rb +2 -5
  97. data/lib/pry/method/weird_method_locator.rb +21 -11
  98. data/lib/pry/method.rb +44 -38
  99. data/lib/pry/object_path.rb +5 -4
  100. data/lib/pry/output.rb +37 -37
  101. data/lib/pry/pager.rb +195 -181
  102. data/lib/pry/platform.rb +91 -0
  103. data/lib/pry/plugins.rb +27 -8
  104. data/lib/pry/prompt.rb +144 -25
  105. data/lib/pry/pry_class.rb +83 -33
  106. data/lib/pry/pry_instance.rb +94 -59
  107. data/lib/pry/repl.rb +70 -11
  108. data/lib/pry/repl_file_loader.rb +2 -3
  109. data/lib/pry/ring.rb +84 -0
  110. data/lib/pry/rubygem.rb +9 -7
  111. data/lib/pry/slop/LICENSE +20 -0
  112. data/lib/pry/slop/commands.rb +195 -0
  113. data/lib/pry/slop/option.rb +206 -0
  114. data/lib/pry/slop.rb +661 -0
  115. data/lib/pry/terminal.rb +18 -6
  116. data/lib/pry/testable/evalable.rb +15 -0
  117. data/lib/pry/testable/mockable.rb +14 -0
  118. data/lib/pry/testable/pry_tester.rb +73 -0
  119. data/lib/pry/testable/utility.rb +26 -0
  120. data/lib/pry/testable/variables.rb +46 -0
  121. data/lib/pry/testable.rb +70 -0
  122. data/lib/pry/version.rb +1 -1
  123. data/lib/pry/{module_candidate.rb → wrapped_module/candidate.rb} +9 -14
  124. data/lib/pry/wrapped_module.rb +22 -21
  125. data/lib/pry.rb +21 -50
  126. metadata +35 -46
  127. data/lib/pry/commands/list_prompts.rb +0 -35
  128. data/lib/pry/commands/simple_prompt.rb +0 -22
  129. data/lib/pry/history_array.rb +0 -121
  130. data/lib/pry/rbx_path.rb +0 -22
  131. data/lib/pry/test/helper.rb +0 -170
@@ -59,7 +59,7 @@ class Pry
59
59
  # @param [Array<Pry::Command>] commands
60
60
  # @return [String] The generated help string.
61
61
  def help_text_for_commands(name, commands)
62
- "#{text.bold(name.capitalize)}\n" << commands.map do |command|
62
+ "#{bold(name.capitalize)}\n" << commands.map do |command|
63
63
  " #{command.options[:listing].to_s.ljust(18)} #{command.description.capitalize}"
64
64
  end.join("\n")
65
65
  end
@@ -75,14 +75,14 @@ class Pry
75
75
  # @param [Array<Pry::Command>] commands The commands to sort
76
76
  # @return [Array<Pry::Command>] commands sorted by listing name.
77
77
  def sorted_commands(commands)
78
- commands.sort_by{ |command| command.options[:listing].to_s }
78
+ commands.sort_by { |command| command.options[:listing].to_s }
79
79
  end
80
80
 
81
81
  # Display help for an individual command or group.
82
82
  #
83
83
  # @param [String] search The string to search for.
84
84
  def display_search(search)
85
- if command = command_set.find_command_for_help(search)
85
+ if (command = command_set.find_command_for_help(search))
86
86
  display_command(command)
87
87
  else
88
88
  display_filtered_search_results(search)
@@ -21,13 +21,13 @@ class Pry
21
21
 
22
22
  def options(opt)
23
23
  opt.on :a, :all, "Display all history"
24
- opt.on :H, :head, "Display the first N items", :optional_argument => true, :as => Integer
25
- opt.on :T, :tail, "Display the last N items", :optional_argument => true, :as => Integer
26
- opt.on :s, :show, "Show the given range of lines", :optional_argument => true, :as => Range
27
- opt.on :G, :grep, "Show lines matching the given pattern", :argument => true, :as => String
24
+ opt.on :H, :head, "Display the first N items", optional_argument: true, as: Integer
25
+ opt.on :T, :tail, "Display the last N items", optional_argument: true, as: Integer
26
+ opt.on :s, :show, "Show the given range of lines", optional_argument: true, as: Range
27
+ opt.on :G, :grep, "Show lines matching the given pattern", argument: true, as: String
28
28
  opt.on :c, :clear , "Clear the current session's history"
29
- opt.on :r, :replay, "Replay a line or range of lines", :argument => true, :as => Range
30
- opt.on :save, "Save history to a file", :argument => true, :as => Range
29
+ opt.on :r, :replay, "Replay a line or range of lines", argument: true, as: Range
30
+ opt.on :save, "Save history to a file", argument: true, as: Range
31
31
  opt.on :e, :'exclude-pry', "Exclude Pry commands from the history"
32
32
  opt.on :n, :'no-numbers', "Omit line numbers"
33
33
  end
@@ -43,7 +43,8 @@ class Pry
43
43
  @history = @history.grep(opts[:grep])
44
44
  end
45
45
 
46
- @history = case
46
+ @history =
47
+ case
47
48
  when opts.present?(:head)
48
49
  @history.take_lines(1, opts[:head] || 10)
49
50
  when opts.present?(:tail)
@@ -119,7 +120,7 @@ class Pry
119
120
  check_for_juxtaposed_replay(replay_sequence)
120
121
 
121
122
  replay_sequence.lines.each do |line|
122
- _pry_.eval line, :generated => true
123
+ _pry_.eval line, generated: true
123
124
  end
124
125
  end
125
126
 
@@ -170,8 +171,8 @@ class Pry
170
171
  else
171
172
  Pry.history.to_a.last(Pry.history.session_line_count)
172
173
  end
173
- # The last value in history will be the 'hist' command itself.
174
- Pry::Code(h[0..-2])
174
+
175
+ Pry::Code(Pry.history.filter(h[0..-2]))
175
176
  end
176
177
  end
177
178
 
@@ -10,7 +10,8 @@ class Pry
10
10
  Import a Pry command set.
11
11
  BANNER
12
12
 
13
- def process(command_set_name)
13
+ # TODO: resolve unused parameter.
14
+ def process(_command_set_name)
14
15
  raise CommandError, "Provide a command set name" if command_set.nil?
15
16
 
16
17
  set = target.eval(arg_string)
@@ -16,21 +16,22 @@ class Pry
16
16
  command = find_command(name)
17
17
 
18
18
  unless command
19
- output.puts "Command #{ text.green(name) } is not found"
19
+ output.puts "Command #{ green(name) } is not found"
20
20
  return
21
21
  end
22
22
 
23
23
  if command_dependencies_met?(command.options)
24
- output.puts "Dependencies for #{ text.green(name) } are met. Nothing to do"
24
+ output.puts "Dependencies for #{ green(name) } are met. Nothing to do"
25
25
  return
26
26
  end
27
27
 
28
- output.puts "Attempting to install #{ text.green(name) } command..."
28
+ output.puts "Attempting to install #{ green(name) } command..."
29
29
  gems_to_install = Array(command.options[:requires_gem])
30
30
 
31
31
  gems_to_install.each do |g|
32
32
  next if Rubygem.installed?(g)
33
- output.puts "Installing #{ text.green(g) } gem..."
33
+
34
+ output.puts "Installing #{ green(g) } gem..."
34
35
  Rubygem.install(g)
35
36
  end
36
37
 
@@ -38,14 +39,14 @@ class Pry
38
39
  begin
39
40
  require g
40
41
  rescue LoadError
41
- fail_msg = "Required gem #{ text.green(g) } installed but not found."
42
+ fail_msg = "Required gem #{ green(g) } installed but not found."
42
43
  fail_msg += " Aborting command installation\n"
43
44
  fail_msg += 'Tips: 1. Check your PATH; 2. Run `bundle update`'
44
45
  raise CommandError, fail_msg
45
46
  end
46
47
  end
47
48
 
48
- output.puts "Installation of #{ text.green(name) } successful! Type `help #{name}` for information"
49
+ output.puts "Installation of #{ green(name) } successful! Type `help #{name}` for information"
49
50
  end
50
51
  end
51
52
 
@@ -9,18 +9,18 @@ class Pry
9
9
  BANNER
10
10
 
11
11
  def process(break_level)
12
- break_level = break_level.to_i
13
- nesting_level = _pry_.binding_stack.size - 1
12
+ break_level = break_level.to_i
13
+ nesting_level = _pry_.binding_stack.size - 1
14
+ max_nest_level = nesting_level - 1
14
15
 
15
16
  case break_level
16
17
  when nesting_level
17
18
  output.puts "Already at nesting level #{nesting_level}"
18
- when (0...nesting_level)
19
- _pry_.binding_stack.slice!(break_level + 1, _pry_.binding_stack.size)
20
-
19
+ when 0..max_nest_level
20
+ _pry_.binding_stack = _pry_.binding_stack[0..break_level]
21
21
  else
22
- max_nest_level = nesting_level - 1
23
- output.puts "Invalid nest level. Must be between 0 and #{max_nest_level}. Got #{break_level}."
22
+ output.puts "Invalid nest level. Must be between 0 and " \
23
+ "#{max_nest_level}. Got #{break_level}."
24
24
  end
25
25
  end
26
26
  end
@@ -12,7 +12,7 @@ class Pry::Command::ListInspectors < Pry::ClassCommand
12
12
  def process
13
13
  output.puts heading("Available inspectors") + "\n"
14
14
  inspector_map.each do |name, inspector|
15
- output.write "Name: #{text.bold(name)}"
15
+ output.write "Name: #{bold(name)}"
16
16
  output.puts selected_inspector?(inspector) ? selected_text : ""
17
17
  output.puts inspector[:description]
18
18
  output.puts
@@ -25,7 +25,7 @@ private
25
25
  end
26
26
 
27
27
  def selected_text
28
- text.red " (selected) "
28
+ red " (selected) "
29
29
  end
30
30
 
31
31
  def selected_inspector?(inspector)
@@ -3,15 +3,17 @@ require 'pry/commands/ls/interrogatable'
3
3
  class Pry
4
4
  class Command::Ls < Pry::ClassCommand
5
5
  class Constants < Pry::Command::Ls::Formatter
6
+ DEPRECATED_CONSTANTS = [:Data, :Fixnum, :Bignum, :TimeoutError, :NIL, :FALSE, :TRUE]
7
+ DEPRECATED_CONSTANTS << :JavaPackageModuleTemplate if Helpers::Platform.jruby?
6
8
  include Pry::Command::Ls::Interrogatable
7
9
 
8
-
9
10
  def initialize(interrogatee, no_user_opts, opts, _pry_)
10
11
  super(_pry_)
11
12
  @interrogatee = interrogatee
12
13
  @no_user_opts = no_user_opts
13
14
  @default_switch = opts[:constants]
14
15
  @verbose_switch = opts[:verbose]
16
+ @dconstants = opts.dconstants?
15
17
  end
16
18
 
17
19
  def correct_opts?
@@ -26,9 +28,19 @@ class Pry
26
28
 
27
29
  private
28
30
 
31
+ def show_deprecated_constants?
32
+ @dconstants == true
33
+ end
34
+
29
35
  def format(mod, constants)
30
36
  constants.sort_by(&:downcase).map do |name|
31
- if const = (!mod.autoload?(name) && (mod.const_get(name) || true) rescue nil)
37
+ if Object.respond_to?(:deprecate_constant) and
38
+ DEPRECATED_CONSTANTS.include?(name) and
39
+ !show_deprecated_constants?
40
+ next
41
+ end
42
+
43
+ if (const = (!mod.autoload?(name) && (mod.const_get(name) || true) rescue nil))
32
44
  if (const < Exception rescue false)
33
45
  color(:exception_constant, name)
34
46
  elsif (Module === mod.const_get(name) rescue false)
@@ -41,7 +53,6 @@ class Pry
41
53
  end
42
54
  end
43
55
  end
44
-
45
56
  end
46
57
  end
47
58
  end
@@ -7,10 +7,12 @@ class Pry
7
7
  def initialize(_pry_)
8
8
  @_pry_ = _pry_
9
9
  @target = _pry_.current_context
10
+ @default_switch = nil
10
11
  end
11
12
 
12
13
  def write_out
13
14
  return false unless correct_opts?
15
+
14
16
  output_self
15
17
  end
16
18
 
@@ -24,8 +26,9 @@ class Pry
24
26
  # Outputs nothing if the section would be empty.
25
27
  def output_section(heading, body)
26
28
  return '' if body.compact.empty?
29
+
27
30
  fancy_heading = Pry::Helpers::Text.bold(color(:heading, heading))
28
- Pry::Helpers.tablify_or_one_line(fancy_heading, body)
31
+ Pry::Helpers.tablify_or_one_line(fancy_heading, body, @_pry_.config)
29
32
  end
30
33
 
31
34
  def format_value(value)
@@ -43,7 +46,6 @@ class Pry
43
46
  def grep
44
47
  @grep || proc { |x| x }
45
48
  end
46
-
47
49
  end
48
50
  end
49
51
  end
@@ -1,7 +1,6 @@
1
1
  class Pry
2
2
  class Command::Ls < Pry::ClassCommand
3
3
  class Globals < Pry::Command::Ls::Formatter
4
-
5
4
  # Taken from "puts global_variables.inspect".
6
5
  BUILTIN_GLOBALS =
7
6
  %w($" $$ $* $, $-0 $-F $-I $-K $-W $-a $-d $-i $-l $-p $-v $-w $. $/ $\\
@@ -42,7 +41,6 @@ class Pry
42
41
  end
43
42
  end
44
43
  end
45
-
46
44
  end
47
45
  end
48
46
  end
@@ -1,7 +1,6 @@
1
1
  class Pry
2
2
  class Command::Ls < Pry::ClassCommand
3
3
  class Grep
4
-
5
4
  def initialize(grep_regexp)
6
5
  @grep_regexp = grep_regexp
7
6
  end
@@ -15,7 +14,6 @@ class Pry
15
14
  end
16
15
  }
17
16
  end
18
-
19
17
  end
20
18
  end
21
19
  end
@@ -33,7 +33,6 @@ class Pry
33
33
  def format(type, vars)
34
34
  vars.sort_by { |var| var.to_s.downcase }.map { |var| color(type, var) }
35
35
  end
36
-
37
36
  end
38
37
  end
39
38
  end
@@ -19,7 +19,7 @@ module Pry::Command::Ls::JRubyHacks
19
19
  m.name.sub(/\A(is|get|set)(?=[A-Z_])/, '').gsub(/[_?=]/, '').downcase
20
20
  end
21
21
 
22
- grouped.map do |key, values|
22
+ grouped.flat_map do |key, values|
23
23
  values = values.sort_by do |m|
24
24
  rubbishness(m.name)
25
25
  end
@@ -28,7 +28,7 @@ module Pry::Command::Ls::JRubyHacks
28
28
  values.select do |x|
29
29
  (!found.any? { |y| x == y }) && found << x
30
30
  end
31
- end.flatten(1)
31
+ end
32
32
  end
33
33
 
34
34
  # When removing jruby aliases, we want to keep the alias that is
@@ -1,7 +1,6 @@
1
1
  class Pry
2
2
  class Command::Ls < Pry::ClassCommand
3
3
  class LocalNames < Pry::Command::Ls::Formatter
4
-
5
4
  def initialize(no_user_opts, args, _pry_)
6
5
  super(_pry_)
7
6
  @no_user_opts = no_user_opts
@@ -29,7 +28,6 @@ class Pry
29
28
  end
30
29
  end
31
30
  end
32
-
33
31
  end
34
32
  end
35
33
  end
@@ -1,7 +1,6 @@
1
1
  class Pry
2
2
  class Command::Ls < Pry::ClassCommand
3
3
  class LocalVars < Pry::Command::Ls::Formatter
4
-
5
4
  def initialize(opts, _pry_)
6
5
  super(_pry_)
7
6
  @default_switch = opts[:locals]
@@ -33,7 +32,6 @@ class Pry
33
32
  pad = desired_width + color_escape_padding
34
33
  "%-#{pad}s = %s" % [color(:local_var, colorized_lhs), rhs]
35
34
  end
36
-
37
35
  end
38
36
  end
39
37
  end
@@ -10,7 +10,6 @@ require 'pry/commands/ls/local_vars'
10
10
 
11
11
  class Pry
12
12
  class Command::Ls < Pry::ClassCommand
13
-
14
13
  class LsEntity
15
14
  attr_reader :_pry_
16
15
 
@@ -4,7 +4,6 @@ require 'pry/commands/ls/interrogatable'
4
4
  class Pry
5
5
  class Command::Ls < Pry::ClassCommand
6
6
  class Methods < Pry::Command::Ls::Formatter
7
-
8
7
  include Pry::Command::Ls::Interrogatable
9
8
  include Pry::Command::Ls::MethodsHelper
10
9
 
@@ -37,7 +36,6 @@ class Pry
37
36
  super || @instance_methods_switch || @ppp_switch || @no_user_opts
38
37
  end
39
38
 
40
-
41
39
  # Get a lambda that can be used with `take_while` to prevent over-eager
42
40
  # traversal of the Object's ancestry graph.
43
41
  def below_ceiling
@@ -51,7 +49,6 @@ class Pry
51
49
  end
52
50
  lambda { |klass| !ceiling.include?(klass) }
53
51
  end
54
-
55
52
  end
56
53
  end
57
54
  end
@@ -14,7 +14,7 @@ module Pry::Command::Ls::MethodsHelper
14
14
  Pry::Method.all_from_obj(@interrogatee)
15
15
  end
16
16
 
17
- if Pry::Helpers::BaseHelpers.jruby? && !@jruby_switch
17
+ if Pry::Helpers::Platform.jruby? && !@jruby_switch
18
18
  methods = trim_jruby_aliases(methods)
19
19
  end
20
20
 
@@ -11,6 +11,8 @@ class Pry
11
11
  super(_pry_)
12
12
  @interrogatee = interrogatee
13
13
  @no_user_opts = no_user_opts
14
+ @ppp_switch = opts[:ppp]
15
+ @jruby_switch = opts['all-java']
14
16
  end
15
17
 
16
18
  def output_self
@@ -26,7 +28,6 @@ class Pry
26
28
  def correct_opts?
27
29
  @no_user_opts && interrogating_a_module?
28
30
  end
29
-
30
31
  end
31
32
  end
32
33
  end
@@ -2,31 +2,30 @@ require 'pry/commands/ls/ls_entity'
2
2
  class Pry
3
3
  class Command::Ls < Pry::ClassCommand
4
4
  DEFAULT_OPTIONS = {
5
- :heading_color => :bright_blue,
6
- :public_method_color => :default,
7
- :private_method_color => :blue,
8
- :protected_method_color => :blue,
9
- :method_missing_color => :bright_red,
10
- :local_var_color => :yellow,
11
- :pry_var_color => :default, # e.g. _, _pry_, _file_
12
- :instance_var_color => :blue, # e.g. @foo
13
- :class_var_color => :bright_blue, # e.g. @@foo
14
- :global_var_color => :default, # e.g. $CODERAY_DEBUG, $eventmachine_library
15
- :builtin_global_color => :cyan, # e.g. $stdin, $-w, $PID
16
- :pseudo_global_color => :cyan, # e.g. $~, $1..$9, $LAST_MATCH_INFO
17
- :constant_color => :default, # e.g. VERSION, ARGF
18
- :class_constant_color => :blue, # e.g. Object, Kernel
19
- :exception_constant_color => :magenta, # e.g. Exception, RuntimeError
20
- :unloaded_constant_color => :yellow, # Any constant that is still in .autoload? state
21
- :separator => " ",
22
- :ceiling => [Object, Module, Class]
5
+ heading_color: :bright_blue,
6
+ public_method_color: :default,
7
+ private_method_color: :blue,
8
+ protected_method_color: :blue,
9
+ method_missing_color: :bright_red,
10
+ local_var_color: :yellow,
11
+ pry_var_color: :default, # e.g. _, _pry_, _file_
12
+ instance_var_color: :blue, # e.g. @foo
13
+ class_var_color: :bright_blue, # e.g. @@foo
14
+ global_var_color: :default, # e.g. $CODERAY_DEBUG, $eventmachine_library
15
+ builtin_global_color: :cyan, # e.g. $stdin, $-w, $PID
16
+ pseudo_global_color: :cyan, # e.g. $~, $1..$9, $LAST_MATCH_INFO
17
+ constant_color: :default, # e.g. VERSION, ARGF
18
+ class_constant_color: :blue, # e.g. Object, Kernel
19
+ exception_constant_color: :magenta, # e.g. Exception, RuntimeError
20
+ unloaded_constant_color: :yellow, # Any constant that is still in .autoload? state
21
+ separator: " ",
22
+ ceiling: [Object, Module, Class]
23
23
  }
24
24
 
25
-
26
25
  match 'ls'
27
26
  group 'Context'
28
27
  description 'Show the list of vars and methods in the current scope.'
29
- command_options :shellwords => false, :interpolate => false
28
+ command_options shellwords: false, interpolate: false
30
29
 
31
30
  banner <<-'BANNER'
32
31
  Usage: ls [-m|-M|-p|-pM] [-q|-v] [-c|-i] [Object]
@@ -48,9 +47,8 @@ class Pry
48
47
  Also check out `find-method` command (run `help find-method`).
49
48
  BANNER
50
49
 
51
-
52
50
  def options(opt)
53
- opt.on :m, :methods, "Show public methods defined on the Object"
51
+ opt.on :m, :methods, "Show public methods defined on the Object"
54
52
  opt.on :M, "instance-methods", "Show public methods defined in a Module or Class"
55
53
  opt.on :p, :ppp, "Show public, protected (in yellow) and private (in green) methods"
56
54
  opt.on :q, :quiet, "Show only methods defined on object.singleton_class and object.class"
@@ -60,9 +58,11 @@ class Pry
60
58
  opt.on :c, :constants, "Show constants, highlighting classes (in blue), and exceptions (in purple).\n" <<
61
59
  " " * 32 << "Constants that are pending autoload? are also shown (in yellow)"
62
60
  opt.on :i, :ivars, "Show instance variables (in blue) and class variables (in bright blue)"
63
- opt.on :G, :grep, "Filter output by regular expression", :argument => true
64
-
65
- if jruby?
61
+ opt.on :G, :grep, "Filter output by regular expression", argument: true
62
+ if Object.respond_to?(:deprecate_constant)
63
+ opt.on :d, :dconstants, "Show deprecated constants"
64
+ end
65
+ if Helpers::Platform.jruby?
66
66
  opt.on :J, "all-java", "Show all the aliases for methods from java (default is to show only prettiest)"
67
67
  end
68
68
  end
@@ -78,11 +78,11 @@ class Pry
78
78
  @interrogatee = args.empty? ? target_self : target.eval(args.join(' '))
79
79
  raise_errors_if_arguments_are_weird
80
80
  ls_entity = LsEntity.new({
81
- :interrogatee => @interrogatee,
82
- :no_user_opts => no_user_opts?,
83
- :opts => opts,
84
- :args => args,
85
- :_pry_ => _pry_
81
+ interrogatee: @interrogatee,
82
+ no_user_opts: no_user_opts?,
83
+ opts: opts,
84
+ args: args,
85
+ _pry_: _pry_
86
86
  })
87
87
 
88
88
  _pry_.pager.page ls_entity.entities_table
@@ -107,7 +107,6 @@ class Pry
107
107
  raise Pry::CommandError, message if opts.present?(option) && invalid_expr
108
108
  end
109
109
  end
110
-
111
110
  end
112
111
 
113
112
  Pry::Commands.add_command(Pry::Command::Ls)
@@ -12,7 +12,7 @@ class Pry
12
12
 
13
13
  play --lines 149..153 # assumes current context
14
14
  play -i 20 --lines 1..3 # assumes lines of the input expression at 20
15
- play -o 4 # the output of of an expression at 4
15
+ play -o 4 # the output of an expression at 4
16
16
  play Pry#repl -l 1..-1 # play the contents of Pry#repl method
17
17
  play -e 2 # play from specified line until end of valid expression
18
18
  play hello.rb # play a file
@@ -31,7 +31,7 @@ class Pry
31
31
  ' "open". `amend-line` can then be used to' \
32
32
  ' modify the method.'
33
33
 
34
- opt.on :e, :expression=, 'Executes until end of valid expression', :as => Integer
34
+ opt.on :e, :expression=, 'Executes until end of valid expression', as: Integer
35
35
  opt.on :p, :print, 'Prints executed code'
36
36
  end
37
37
 
@@ -53,7 +53,6 @@ class Pry
53
53
  end
54
54
  end
55
55
 
56
-
57
56
  def content_after_options
58
57
  if opts.present?(:open)
59
58
  restrict_to_lines(content, (0..-2))
@@ -91,7 +90,7 @@ class Pry
91
90
  end
92
91
 
93
92
  def file_content
94
- if default_file && File.exists?(default_file)
93
+ if default_file && File.exist?(default_file)
95
94
  @cc.restrict_to_lines(File.read(default_file), @cc.line_range)
96
95
  else
97
96
  raise CommandError, "File does not exist! File was: #{default_file.inspect}"
@@ -17,7 +17,7 @@ class Pry
17
17
  BANNER
18
18
 
19
19
  def process
20
- _pry_.pager.page text.bold('Backtrace:') << "\n--\n" << _pry_.backtrace.join("\n")
20
+ _pry_.pager.page bold('Backtrace:') << "\n--\n" << _pry_.backtrace.join("\n")
21
21
  end
22
22
  end
23
23
 
@@ -4,7 +4,7 @@ class Pry
4
4
  match(/raise-up(!?\b.*)/)
5
5
  group 'Context'
6
6
  description 'Raise an exception out of the current pry instance.'
7
- command_options :listing => 'raise-up'
7
+ command_options listing: 'raise-up'
8
8
 
9
9
  banner <<-BANNER
10
10
  Raise up, like exit, allows you to quit pry. Instead of returning a value
@@ -23,6 +23,7 @@ class Pry
23
23
 
24
24
  def process
25
25
  return _pry.pager.page help if captures[0] =~ /(-h|--help)\b/
26
+
26
27
  # Handle 'raise-up', 'raise-up "foo"', 'raise-up RuntimeError, 'farble' in a rubyesque manner
27
28
  target.eval("_pry_.raise_up#{captures[0]}")
28
29
  end
@@ -31,7 +31,7 @@ class Pry
31
31
  end
32
32
 
33
33
  def reload_current_file
34
- if !File.exists?(current_file)
34
+ if !File.exist?(current_file)
35
35
  raise CommandError, "Current file: #{current_file} cannot be found on disk!"
36
36
  end
37
37
 
@@ -49,7 +49,7 @@ class Pry
49
49
  def check_for_reloadability(code_object, identifier)
50
50
  if !code_object || !code_object.source_file
51
51
  raise CommandError, "Cannot locate #{identifier}!"
52
- elsif !File.exists?(code_object.source_file)
52
+ elsif !File.exist?(code_object.source_file)
53
53
  raise CommandError,
54
54
  "Cannot reload #{identifier} as it has no associated file on disk. " \
55
55
  "File found was: #{code_object.source_file}"
@@ -14,6 +14,10 @@ class Pry
14
14
  BANNER
15
15
 
16
16
  def process(spec)
17
+ unless spec
18
+ return output.puts "Please provide a class, module, or method name (e.g: ri Array#push)"
19
+ end
20
+
17
21
  # Lazily load RI
18
22
  require 'rdoc/ri/driver'
19
23
 
@@ -27,13 +31,14 @@ class Pry
27
31
  @pager = pager
28
32
  super opts
29
33
  end
34
+
30
35
  def page
31
36
  paging_text = StringIO.new
32
37
  yield paging_text
33
38
  @pager.page(paging_text.string)
34
39
  end
35
40
 
36
- def formatter(io)
41
+ def formatter(_io)
37
42
  if @formatter_klass
38
43
  @formatter_klass.new
39
44
  else
@@ -42,14 +47,14 @@ class Pry
42
47
  end
43
48
  end
44
49
 
45
- RDoc::RI.const_set :PryDriver, subclass # hook it up!
50
+ RDoc::RI.const_set :PryDriver, subclass # hook it up!
46
51
  end
47
52
 
48
53
  # Spin-up an RI insance.
49
- ri = RDoc::RI::PryDriver.new _pry_.pager, :use_stdout => true, :interactive => false
54
+ ri = RDoc::RI::PryDriver.new _pry_.pager, use_stdout: true, interactive: false
50
55
 
51
56
  begin
52
- ri.display_names [spec] # Get the documentation (finally!)
57
+ ri.display_names [spec] # Get the documentation (finally!)
53
58
  rescue RDoc::RI::Driver::NotFoundError => e
54
59
  output.puts "error: '#{e.name}' not found"
55
60
  end