pry 0.9.9.6pre2-java → 0.9.10-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/CHANGELOG +41 -0
  2. data/CONTRIBUTORS +27 -26
  3. data/README.markdown +4 -4
  4. data/Rakefile +2 -2
  5. data/lib/pry.rb +25 -19
  6. data/lib/pry/cli.rb +31 -10
  7. data/lib/pry/code.rb +41 -83
  8. data/lib/pry/command.rb +87 -76
  9. data/lib/pry/command_set.rb +13 -20
  10. data/lib/pry/completion.rb +139 -121
  11. data/lib/pry/config.rb +4 -0
  12. data/lib/pry/core_extensions.rb +88 -31
  13. data/lib/pry/default_commands/cd.rb +31 -8
  14. data/lib/pry/default_commands/context.rb +4 -58
  15. data/lib/pry/default_commands/easter_eggs.rb +1 -1
  16. data/lib/pry/default_commands/editing.rb +21 -14
  17. data/lib/pry/default_commands/find_method.rb +5 -7
  18. data/lib/pry/default_commands/gist.rb +187 -0
  19. data/lib/pry/default_commands/hist.rb +6 -6
  20. data/lib/pry/default_commands/input_and_output.rb +73 -129
  21. data/lib/pry/default_commands/introspection.rb +107 -52
  22. data/lib/pry/default_commands/ls.rb +1 -1
  23. data/lib/pry/default_commands/misc.rb +0 -5
  24. data/lib/pry/default_commands/whereami.rb +92 -0
  25. data/lib/pry/helpers/base_helpers.rb +6 -1
  26. data/lib/pry/helpers/command_helpers.rb +30 -9
  27. data/lib/pry/helpers/documentation_helpers.rb +7 -7
  28. data/lib/pry/helpers/options_helpers.rb +1 -1
  29. data/lib/pry/helpers/text.rb +7 -9
  30. data/lib/pry/history.rb +15 -2
  31. data/lib/pry/hooks.rb +1 -1
  32. data/lib/pry/indent.rb +17 -10
  33. data/lib/pry/method.rb +35 -19
  34. data/lib/pry/module_candidate.rb +130 -0
  35. data/lib/pry/pry_class.rb +54 -22
  36. data/lib/pry/pry_instance.rb +71 -14
  37. data/lib/pry/repl_file_loader.rb +80 -0
  38. data/lib/pry/version.rb +1 -1
  39. data/lib/pry/wrapped_module.rb +121 -142
  40. data/pry.gemspec +13 -13
  41. data/test/candidate_helper1.rb +11 -0
  42. data/test/candidate_helper2.rb +8 -0
  43. data/test/helper.rb +16 -0
  44. data/test/test_code.rb +1 -1
  45. data/test/test_command.rb +364 -270
  46. data/test/test_command_integration.rb +235 -267
  47. data/test/test_completion.rb +36 -0
  48. data/test/test_control_d_handler.rb +45 -0
  49. data/test/test_default_commands/example.erb +5 -0
  50. data/test/test_default_commands/test_cd.rb +316 -11
  51. data/test/test_default_commands/test_context.rb +143 -192
  52. data/test/test_default_commands/test_documentation.rb +81 -14
  53. data/test/test_default_commands/test_find_method.rb +10 -2
  54. data/test/test_default_commands/test_input.rb +102 -111
  55. data/test/test_default_commands/test_introspection.rb +17 -12
  56. data/test/test_default_commands/test_ls.rb +8 -6
  57. data/test/test_default_commands/test_shell.rb +18 -15
  58. data/test/test_default_commands/test_show_source.rb +170 -44
  59. data/test/test_exception_whitelist.rb +6 -2
  60. data/test/test_hooks.rb +32 -0
  61. data/test/test_input_stack.rb +19 -16
  62. data/test/test_method.rb +0 -4
  63. data/test/test_prompt.rb +60 -0
  64. data/test/test_pry.rb +23 -31
  65. data/test/test_pry_defaults.rb +75 -57
  66. data/test/test_syntax_checking.rb +12 -11
  67. data/test/test_wrapped_module.rb +103 -0
  68. metadata +72 -26
data/CHANGELOG CHANGED
@@ -1,3 +1,44 @@
1
+ 14/07/2012 version 0.9.10
2
+ dependency changes:
3
+ * #561 upgrade the slop gem to version 3
4
+ * #590 move to the jist gem from gist.
5
+ * upgrade method_source to 0.8
6
+
7
+ new features:
8
+ * #572 add --hist, -o and -k flags to gist command
9
+ * #584 support show-source/doc on methods defined in class-eval
10
+ * #585 support show-source/doc on gem methods defined in C
11
+ * #596 add --disable-plugin and --select-plugin options
12
+ * #597 allow "cd -" to switch between bindings
13
+ * #612 add Pry.config.should_load_local_rc to turn off ./.pryrc
14
+ * allow running a file of pry input with pry <file>
15
+ * support colours in "ri" command
16
+ * add before_eval hook
17
+ * prompt now gets a lot more data when proc arity is 1
18
+
19
+ bug fixes &c.
20
+ * #554 removed the "req" command
21
+ * #567 fix rendering bugs when starting pry
22
+ * #568 fix Array#pretty_print on Jruby
23
+ * #575 fix "edit" on windows
24
+ * #576 fix "find-method" in the presence of badly behaved objects
25
+ * #580 fix "whereami" in erb files on rails
26
+ * #632 raise fewer exceptions while tab completing
27
+ * #605 dont immediately quite pry when an error happens in readline
28
+ * #606 support for ansicon to give jruby windows users colour
29
+ * #613 massive speed improvements to show-source for modules
30
+ * #620 improve whereami command when not in a binding.pry
31
+ * #622 support embedded documents (=begin ... =end)
32
+ * #627 support editing files with spaces in the name
33
+ * changed __binding_impl__ to __pry__
34
+ * support for absolute paths in $EDITOR
35
+ * fix "cat" command on files with unknown extensions
36
+ * many many internal refactorings and tidyings
37
+
38
+ 09/05/2012 version 0.9.9.6 fixes #558
39
+ * #558 has been a thorn in our side for long enough, hopefully this properly fixes it
40
+ (though im not to confident :P)
41
+
1
42
  09/05/2012 version 0.9.9.5 minor bugfix
2
43
  * fixed ZeroDivisionError in correct_indentation, bug #558
3
44
  * fix double highlighting in rdoc, bug #562
@@ -1,36 +1,37 @@
1
- 887 John Mair
2
- 232 Conrad Irwin
3
- 132 Ryan Fitzgerald
4
- 89 Rob Gleeson
5
- 51 Lee Jarvis
6
- 49 Mon ouïe
7
- 39 Jordon Bedwell
1
+ 938 banisterfiend
2
+ 290 cirwin
3
+ 140 ryanf
4
+ 93 robgleeson
5
+ 51 injekt
6
+ 49 Mon_Ouie
7
+ 39 envygeeks
8
+ 28 yorickpeterse
8
9
  18 David Palm
9
- 13 epitron
10
- 10 Matt Carey
11
- 9 Yorick Peterse
12
- 8 Eero Saynatkari
10
+ 15 epitron
11
+ 15 kyrylo
12
+ 10 swarley
13
+ 8 rue
13
14
  3 Darrick Wiebe
14
- 3 fowlmouth
15
+ 3 fowl
15
16
  3 misfo
16
17
  2 Ben Langfeld
17
- 2 Bram Swenson
18
18
  2 Eric Christopherson
19
- 2 Erik Michaels-Ober
20
19
  2 Kelsey Judson
21
20
  2 Xavier Shay
22
- 2 robgleeson
23
- 1 Kirill Lashuk
24
- 1 Reginald Tan
25
- 1 Jordan Running
26
- 1 Robert Gleeson
27
- 1 Jonathan Soeder
28
- 1 Shawn Anderson
29
- 1 Sherin C
30
- 1 Tim Pope
21
+ 2 sferic
22
+ 2 shadowshell
31
23
  1 Gerbert Olivé
32
- 1 Jonathan Jackson
33
- 1 Joe Peduto
34
24
  1 Gosha Arinich
35
- 1 Lars Haugseth
25
+ 1 Joe Peduto
26
+ 1 Jonathan Jackson
27
+ 1 Jonathan Soeder
28
+ 1 Jordan Running
36
29
  1 Josh Cheek
30
+ 1 KL-7
31
+ 1 Lars Haugseth
32
+ 1 Reginald Tan
33
+ 1 Renato Mascarenhas
34
+ 1 Shawn Anderson
35
+ 1 Sherin C
36
+ 1 sonnym
37
+ 1 tpope
@@ -21,8 +21,8 @@
21
21
  </center>
22
22
 
23
23
  Pry is a powerful alternative to the standard IRB shell for Ruby. It is
24
- written from scratch to provide a number of advanced features, some of
25
- these include:
24
+ written from scratch to provide a number of advanced features,
25
+ including:
26
26
 
27
27
  * Source code browsing (including core C source with the pry-doc gem)
28
28
  * Documentation browsing
@@ -280,7 +280,7 @@ picked up by `rdoc`. Pry also has a basic understanding of both the
280
280
  rdoc and yard formats and will attempt to syntax highlight the
281
281
  documentation appropriately.
282
282
 
283
- Nonetheless The `ri` functionality is very good and
283
+ Nonetheless, the `ri` functionality is very good and
284
284
  has an advantage over Pry's system in that it allows documentation
285
285
  lookup for classes as well as methods. Pry therefore has good
286
286
  integration with `ri` through the `ri` command. The syntax
@@ -391,7 +391,7 @@ between commands and running commands in background
391
391
 
392
392
  ### Contact
393
393
 
394
- Problems or questions contact me at [github](http://github.com/banister)
394
+ Problems or questions? file an issue at [github](https://github.com/pry/pry/issues)
395
395
 
396
396
  ### Contributors
397
397
 
data/Rakefile CHANGED
@@ -20,8 +20,8 @@ def apply_spec_defaults(s)
20
20
  s.files = `git ls-files`.split("\n")
21
21
  s.test_files = `git ls-files -- test/*`.split("\n")
22
22
  s.add_dependency('coderay', '~> 1.0.5')
23
- s.add_dependency('slop', ['>= 2.4.4', '< 3'])
24
- s.add_dependency('method_source','~> 0.7.1')
23
+ s.add_dependency('slop', ['~> 3.3.1'])
24
+ s.add_dependency('method_source','~> 0.8')
25
25
  s.add_development_dependency('bacon', '~> 1.1')
26
26
  s.add_development_dependency('open4', '~> 1.3')
27
27
  s.add_development_dependency('rake', '~> 0.9')
data/lib/pry.rb CHANGED
@@ -10,13 +10,7 @@ class Pry
10
10
  # The default hooks - display messages when beginning and ending Pry sessions.
11
11
  DEFAULT_HOOKS = Pry::Hooks.new.add_hook(:before_session, :default) do |out, target, _pry_|
12
12
  next if _pry_.quiet?
13
- # ensure we're actually in a method
14
- file = target.eval('__FILE__')
15
-
16
- # /unknown/ for rbx
17
- if file !~ /(\(.*\))|<.*>/ && file !~ /__unknown__/ && file != "" && file != "-e" || file == Pry.eval_path
18
- _pry_.run_command("whereami", "", target)
19
- end
13
+ _pry_.run_command("whereami --quiet", "", target)
20
14
  end
21
15
 
22
16
  # The default print
@@ -89,13 +83,13 @@ class Pry
89
83
  # A prompt that includes the full object path as well as
90
84
  # input/output (_in_ and _out_) information. Good for navigation.
91
85
  NAV_PROMPT = [
92
- proc do |_, level, pry|
93
- tree = pry.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / "
94
- "[#{pry.input_array.size}] (pry) #{tree}: #{level}> "
86
+ proc do |conf|
87
+ tree = conf.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / "
88
+ "[#{conf.expr_number}] (pry) #{tree}: #{conf.nesting_level}> "
95
89
  end,
96
- proc do |_, level, pry|
97
- tree = pry.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / "
98
- "[#{pry.input_array.size}] (pry) #{tree}: #{level}* "
90
+ proc do |conf|
91
+ tree = conf.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / "
92
+ "[#{conf.expr_number}] (pry) #{tree}: #{conf.nesting_level}* "
99
93
  end,
100
94
  ]
101
95
 
@@ -106,14 +100,16 @@ class Pry
106
100
  # 3) In a nested session - behave like `cd ..` (pop a binding)
107
101
  DEFAULT_CONTROL_D_HANDLER = proc do |eval_string, _pry_|
108
102
  if !eval_string.empty?
109
- # clear input buffer
103
+ # Clear input buffer.
110
104
  eval_string.replace("")
111
105
  elsif _pry_.binding_stack.one?
112
- # ^D at top-level breaks out of loop
106
+ # ^D at top-level breaks out of a REPL loop.
113
107
  _pry_.binding_stack.clear
114
108
  throw(:breakout)
115
109
  else
116
- # otherwise just pops a binding
110
+ # Otherwise, saves current binding stack as old stack and pops last
111
+ # binding out of binding stack (the old stack still has that binding).
112
+ _pry_.command_state["cd"].old_stack = _pry_.binding_stack.dup
117
113
  _pry_.binding_stack.pop
118
114
  end
119
115
  end
@@ -168,13 +164,20 @@ end
168
164
 
169
165
  require "method_source"
170
166
  require 'shellwords'
171
- require "readline"
172
167
  require "stringio"
173
168
  require "coderay"
174
169
  require "optparse"
175
170
  require "slop"
176
171
  require "rbconfig"
177
172
 
173
+ begin
174
+ require 'readline'
175
+ rescue LoadError
176
+ warn "You're running a version of ruby with no Readline support"
177
+ warn "Please `gem install rb-readline` or recompile ruby --with-readline."
178
+ exit!
179
+ end
180
+
178
181
  if Pry::Helpers::BaseHelpers.jruby?
179
182
  begin
180
183
  require 'ffi'
@@ -183,11 +186,14 @@ if Pry::Helpers::BaseHelpers.jruby?
183
186
  end
184
187
  end
185
188
 
186
- if Pry::Helpers::BaseHelpers.windows?
189
+ if Pry::Helpers::BaseHelpers.windows? && !Pry::Helpers::BaseHelpers.windows_ansi?
187
190
  begin
188
191
  require 'win32console'
192
+ # The mswin and mingw versions of pry require win32console, so this should
193
+ # only fail on jruby (where win32console doesn't work).
194
+ # Instead we'll recommend ansicon, which does.
189
195
  rescue LoadError
190
- warn "You should: `gem install win32console` for better auto-indent and color support."
196
+ warn "For a better pry experience, please use ansicon: http://adoxa.3eeweb.com/ansicon/"
191
197
  end
192
198
  end
193
199
 
@@ -14,6 +14,10 @@ class Pry
14
14
  # @return [Array] The Procs that process the parsed options.
15
15
  attr_accessor :option_processors
16
16
 
17
+ # @return [Array<String>] The input array of strings to process
18
+ # as CLI options.
19
+ attr_accessor :input_args
20
+
17
21
  # Add another set of CLI options (a Slop block)
18
22
  def add_options(&block)
19
23
  if options
@@ -55,7 +59,9 @@ class Pry
55
59
  def parse_options(args=ARGV.dup)
56
60
  raise NoOptionsError, "No command line options defined! Use Pry::CLI.add_options to add command line options." if !options
57
61
 
58
- opts = Slop.parse(args, :help => true, :multiple_switches => false, &options)
62
+ self.input_args = args
63
+
64
+ opts = Slop.parse!(args, :help => true, :multiple_switches => false, &options)
59
65
  option_processors.each { |processor| processor.call(opts) } if option_processors # option processors are optional
60
66
 
61
67
  self
@@ -78,7 +84,7 @@ See: `https://github.com/pry` for more information.
78
84
  Copyright (c) 2011 John Mair (banisterfiend)
79
85
  --
80
86
  }
81
- on :e, :exec, "A line of code to execute in context before the session starts", true
87
+ on :e, :exec, "A line of code to execute in context before the session starts", :argument => true
82
88
 
83
89
  on "no-pager", "Disable pager for long output" do
84
90
  Pry.config.pager = false
@@ -92,13 +98,21 @@ Copyright (c) 2011 John Mair (banisterfiend)
92
98
  Pry.color = false
93
99
  end
94
100
 
95
- on :f, "Suppress loading of ~/.pryrc" do
96
- # load ~/.pryrc, if not suppressed with -f option
101
+ on :f, "Suppress loading of ~/.pryrc and ./.pryrc" do
97
102
  Pry.config.should_load_rc = false
103
+ Pry.config.should_load_local_rc = false
104
+ end
105
+
106
+ on :s, "select-plugin", "Only load specified plugin (and no others).", :argument => true do |plugin_name|
107
+ Pry.config.should_load_plugins = false
108
+ Pry.plugins[plugin_name].activate!
109
+ end
110
+
111
+ on :d, "disable-plugin", "Disable a specific plugin.", :argument => true do |plugin_name|
112
+ Pry.plugins[plugin_name].disable!
98
113
  end
99
114
 
100
115
  on "no-plugins", "Suppress loading of plugins." do
101
- # suppress plugins if given --no-plugins optino
102
116
  Pry.config.should_load_plugins = false
103
117
  end
104
118
 
@@ -115,11 +129,11 @@ Copyright (c) 2011 John Mair (banisterfiend)
115
129
  Pry.config.prompt = Pry::SIMPLE_PROMPT
116
130
  end
117
131
 
118
- on :r, :require, "`require` a Ruby script at startup", true do |file|
132
+ on :r, :require, "`require` a Ruby script at startup", :argument => true do |file|
119
133
  Pry.config.requires << file
120
134
  end
121
135
 
122
- on :I, "Add a path to the $LOAD_PATH", true do |path|
136
+ on :I, "Add a path to the $LOAD_PATH", :argument => true do |path|
123
137
  $LOAD_PATH << path
124
138
  end
125
139
 
@@ -130,17 +144,24 @@ Copyright (c) 2011 John Mair (banisterfiend)
130
144
 
131
145
  on(:c, :context,
132
146
  "Start the session in the specified context. Equivalent to `context.pry` in a session.",
133
- true,
134
- :default => "TOPLEVEL_BINDING"
147
+ :argument => true,
148
+ :default => "Pry.toplevel_binding"
135
149
  )
136
150
  end.process_options do |opts|
151
+
152
+ exit if opts.help?
153
+
137
154
  # invoked via cli
138
155
  Pry.cli = true
139
156
 
140
157
  # create the actual context
141
158
  context = Pry.binding_for(eval(opts[:context]))
142
159
 
143
- if opts[:exec]
160
+ if Pry::CLI.input_args.any? && Pry::CLI.input_args != ["pry"]
161
+ full_name = File.expand_path(Pry::CLI.input_args.first)
162
+ Pry.load_file_through_repl(full_name)
163
+ exit
164
+ elsif opts[:exec]
144
165
  exec_string = opts[:exec] + "\n"
145
166
  else
146
167
  exec_string = ""
@@ -27,79 +27,15 @@ class Pry
27
27
  # object.
28
28
  class Code
29
29
  class << self
30
-
31
- # Determine if a string of code is a complete Ruby expression.
32
- # @param [String] code The code to validate.
33
- # @return [Boolean] Whether or not the code is a complete Ruby expression.
34
- # @raise [SyntaxError] Any SyntaxError that does not represent incompleteness.
35
- # @example
36
- # complete_expression?("class Hello") #=> false
37
- # complete_expression?("class Hello; end") #=> true
38
- def complete_expression?(str)
39
- if defined?(Rubinius::Melbourne19) && RUBY_VERSION =~ /^1\.9/
40
- Rubinius::Melbourne19.parse_string(str, Pry.eval_path)
41
- elsif defined?(Rubinius::Melbourne)
42
- Rubinius::Melbourne.parse_string(str, Pry.eval_path)
43
- else
44
- catch(:valid) do
45
- Helpers::BaseHelpers.silence_warnings do
46
- eval("BEGIN{throw :valid}\n#{str}", binding, Pry.eval_path)
47
- end
48
- end
49
- end
50
-
51
- # Assert that a line which ends with a , or \ is incomplete.
52
- str !~ /[,\\]\s*\z/
53
- rescue SyntaxError => e
54
- if incomplete_user_input_exception?(e)
55
- false
56
- else
57
- raise e
58
- end
59
- end
60
-
61
- # Check whether the exception indicates that the user should input more.
62
- #
63
- # @param [SyntaxError] the exception object that was raised.
64
- # @param [Array<String>] The stack frame of the function that executed eval.
65
- # @return [Boolean]
66
- #
67
- def incomplete_user_input_exception?(ex)
68
- case ex.message
69
- when /unexpected (\$end|end-of-file|END_OF_FILE)/, # mri, jruby, ironruby
70
- /unterminated (quoted string|string|regexp) meets end of file/, # "quoted string" is ironruby
71
- /missing 'end' for/, /: expecting '[})\]]'$/, /can't find string ".*" anywhere before EOF/, /: expecting keyword_end/, /expecting kWHEN/ # rbx
72
- true
73
- else
74
- false
75
- end
76
- end
77
- private :incomplete_user_input_exception?
78
-
79
- # Retrieve the first complete expression from the passed string.
80
- #
81
- # @param [String, Array<String>] str The string (or array of lines) to extract the complete
82
- # expression from.
83
- # @return [String, nil] The first complete expression, or `nil` if
84
- # none found.
85
- def retrieve_complete_expression_from(str_or_lines)
86
- lines = str_or_lines.is_a?(Array) ? str_or_lines : str_or_lines.each_line.to_a
87
-
88
- code = ""
89
- lines.each do |v|
90
- code << v
91
- return code if complete_expression?(code)
92
- end
93
- nil
94
- end
30
+ include MethodSource::CodeHelpers
95
31
 
96
32
  # Instantiate a `Code` object containing code loaded from a file or
97
33
  # Pry's line buffer.
98
34
  #
99
35
  # @param [String] fn The name of a file, or "(pry)".
100
- # @param [Symbol] code_type (:ruby) The type of code the file contains.
36
+ # @param [Symbol] code_type The type of code the file contains.
101
37
  # @return [Code]
102
- def from_file(fn, code_type=nil)
38
+ def from_file(fn, code_type = nil)
103
39
  if fn == Pry.eval_path
104
40
  f = Pry.line_buffer.drop(1)
105
41
  else
@@ -107,7 +43,7 @@ class Pry
107
43
  f = File.open(fn, 'r')
108
44
  code_type = type_from_filename(fn)
109
45
  else
110
- raise CommandError, "Cannot open #{fn.inspect} for reading."
46
+ raise MethodSource::SourceNotFoundError, "Cannot open #{fn.inspect} for reading."
111
47
  end
112
48
  end
113
49
  new(f, 1, code_type || :ruby)
@@ -120,8 +56,8 @@ class Pry
120
56
  #
121
57
  # @param [::Method, UnboundMethod, Proc, Pry::Method] meth The method
122
58
  # object.
123
- # @param [Fixnum, nil] The line number to start on, or nil to use the
124
- # method's original line numbers.
59
+ # @param [Fixnum, nil] start_line The line number to start on, or nil to
60
+ # use the method's original line numbers.
125
61
  # @return [Code]
126
62
  def from_method(meth, start_line=nil)
127
63
  meth = Pry::Method(meth)
@@ -132,11 +68,16 @@ class Pry
132
68
  # Attempt to extract the source code for module (or class) `mod`.
133
69
  #
134
70
  # @param [Module, Class] mod The module (or class) of interest.
71
+ # @param [Fixnum, nil] start_line The line number to start on, or nil to use the
72
+ # method's original line numbers.
73
+ # @param [Fixnum] candidate_rank The module candidate (by rank)
74
+ # to use (see `Pry::WrappedModule::Candidate` for more information).
135
75
  # @return [Code]
136
- def from_module(mod, start_line=nil)
137
- mod = Pry::WrappedModule(mod)
138
- start_line ||= mod.source_line || 1
139
- new(mod.source, start_line, :ruby)
76
+ def from_module(mod, start_line=nil, candidate_rank=0)
77
+ candidate = Pry::WrappedModule(mod).candidate(candidate_rank)
78
+
79
+ start_line ||= candidate.line
80
+ new(candidate.source, start_line, :ruby)
140
81
  end
141
82
 
142
83
  protected
@@ -171,6 +112,7 @@ class Pry
171
112
  end
172
113
  end
173
114
 
115
+ # @return [Symbol] The type of code stored in this wrapper.
174
116
  attr_accessor :code_type
175
117
 
176
118
  # Instantiate a `Code` object containing code from the given `Array`,
@@ -179,8 +121,8 @@ class Pry
179
121
  # empty `Code` object and then use `#push` to insert the lines.
180
122
  #
181
123
  # @param [Array<String>, String, IO] lines
182
- # @param [Fixnum?] (1) start_line
183
- # @param [Symbol?] (:ruby) code_type
124
+ # @param [Fixnum?] start_line
125
+ # @param [Symbol?] code_type
184
126
  def initialize(lines=[], start_line=1, code_type=:ruby)
185
127
  if lines.is_a? String
186
128
  lines = lines.lines
@@ -269,7 +211,7 @@ class Pry
269
211
  # Remove all lines except for the `lines` up to and excluding `line_num`.
270
212
  #
271
213
  # @param [Fixnum] line_num
272
- # @param [Fixnum] (1) lines
214
+ # @param [Fixnum] lines
273
215
  # @return [Code]
274
216
  def before(line_num, lines=1)
275
217
  return self unless line_num
@@ -283,7 +225,7 @@ class Pry
283
225
  # `line_num`.
284
226
  #
285
227
  # @param [Fixnum] line_num
286
- # @param [Fixnum] (1) lines
228
+ # @param [Fixnum] lines
287
229
  # @return [Code]
288
230
  def around(line_num, lines=1)
289
231
  return self unless line_num
@@ -296,7 +238,7 @@ class Pry
296
238
  # Remove all lines except for the `lines` after and excluding `line_num`.
297
239
  #
298
240
  # @param [Fixnum] line_num
299
- # @param [Fixnum] (1) lines
241
+ # @param [Fixnum] lines
300
242
  # @return [Code]
301
243
  def after(line_num, lines=1)
302
244
  return self unless line_num
@@ -321,7 +263,7 @@ class Pry
321
263
 
322
264
  # Format output with line numbers next to it, unless `y_n` is falsy.
323
265
  #
324
- # @param [Boolean?] (true) y_n
266
+ # @param [Boolean?] y_n
325
267
  # @return [Code]
326
268
  def with_line_numbers(y_n=true)
327
269
  alter do
@@ -332,7 +274,7 @@ class Pry
332
274
  # Format output with a marker next to the given `line_num`, unless `line_num`
333
275
  # is falsy.
334
276
  #
335
- # @param [Fixnum?] (1) line_num
277
+ # @param [Fixnum?] line_num
336
278
  # @return [Code]
337
279
  def with_marker(line_num=1)
338
280
  alter do
@@ -344,7 +286,7 @@ class Pry
344
286
  # Format output with the specified number of spaces in front of every line,
345
287
  # unless `spaces` is falsy.
346
288
  #
347
- # @param [Fixnum?] (0) spaces
289
+ # @param [Fixnum?] spaces
348
290
  # @return [Code]
349
291
  def with_indentation(spaces=0)
350
292
  alter do
@@ -375,7 +317,7 @@ class Pry
375
317
  max_width = lines.last.last.to_s.length if lines.length > 0
376
318
  lines.each do |l|
377
319
  padded_line_num = l[1].to_s.rjust(max_width)
378
- l[0] = "#{Pry::Helpers::Text.blue(padded_line_num)}: #{l[0]}"
320
+ l[0] = "#{Pry::Helpers::BaseHelpers.colorize_code(padded_line_num.to_s)}: #{l[0]}"
379
321
  end
380
322
  end
381
323
 
@@ -398,6 +340,22 @@ class Pry
398
340
  lines.map { |l| "#{l.first}\n" }.join
399
341
  end
400
342
 
343
+ # Get the comment that describes the expression on the given line number.
344
+ #
345
+ # @param [Fixnum] line_number (1-based)
346
+ # @return [String] the code.
347
+ def comment_describing(line_number)
348
+ self.class.comment_describing(raw, line_number)
349
+ end
350
+
351
+ # Get the multiline expression that starts on the given line number.
352
+ #
353
+ # @param [Fixnum] line_number (1-based)
354
+ # @return [String] the code.
355
+ def expression_at(line_number, consume=0)
356
+ self.class.expression_at(raw, line_number, :consume => consume)
357
+ end
358
+
401
359
  # Return an unformatted String of the code.
402
360
  #
403
361
  # @return [String]