Fix all warnings on startup in 1.9.3
This commit is contained in:
parent
79e3c4f4ca
commit
493c085888
|
@ -152,7 +152,7 @@ class Pry
|
|||
case Pry::Method(block).source_file
|
||||
when %r{/pry/.*_commands/(.*).rb}
|
||||
$1.capitalize.gsub(/_/, " ")
|
||||
when %r{(pry-[\w_]+)-([\d\.]+)}
|
||||
when %r{(pry-[\w]+)-([\d\.]+)}
|
||||
name, version = $1, $2
|
||||
"#{name.to_s} (v#{version.to_s})"
|
||||
when /pryrc/
|
||||
|
@ -316,7 +316,7 @@ class Pry
|
|||
# Note that if we find the '| do' or '| {' we delete this and the
|
||||
# elements following it from `arg_string`.
|
||||
def pass_block(arg_string)
|
||||
block_index = arg_string.rindex /\| *(?:do|\{)/
|
||||
block_index = arg_string.rindex(/\| *(?:do|\{)/)
|
||||
|
||||
return if !block_index
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ class Pry
|
|||
exec "pry"
|
||||
end
|
||||
|
||||
create_command /wtf([?!]*)/, "Show the backtrace of the most recent exception" do
|
||||
create_command(/wtf([?!]*)/, "Show the backtrace of the most recent exception") do
|
||||
options :listing => 'wtf?'
|
||||
|
||||
banner <<-BANNER
|
||||
|
@ -129,7 +129,7 @@ class Pry
|
|||
end
|
||||
|
||||
# N.B. using a regular expresion here so that "raise-up 'foo'" does the right thing.
|
||||
create_command /raise-up(!?\b.*)/, :listing => 'raise-up' do
|
||||
create_command(/raise-up(!?\b.*)/, :listing => 'raise-up') do
|
||||
description "Raise an exception out of the current pry instance."
|
||||
banner <<-BANNER
|
||||
Raise up, like exit, allows you to quit pry. Instead of returning a value however, it raises an exception.
|
||||
|
|
|
@ -366,7 +366,7 @@ class Pry
|
|||
end
|
||||
opt.on :c, :command, "Play a command's source.", true do |command_name|
|
||||
command = find_command(command_name)
|
||||
block = Pry::Method.new(find_command(command_name).block)
|
||||
block = Pry::Method.new(command.block)
|
||||
self.content << block.source
|
||||
end
|
||||
opt.on :f, :file, "Play a file.", true do |file|
|
||||
|
|
|
@ -100,7 +100,7 @@ class Pry
|
|||
next if klass.autoload?(name)
|
||||
begin
|
||||
const = klass.const_get(name)
|
||||
rescue RescuableException => e
|
||||
rescue RescuableException
|
||||
# constant loading is an inexact science at the best of times,
|
||||
# this often happens when a constant was .autoload? but someone
|
||||
# tried to load it. It's now not .autoload? but will still raise
|
||||
|
@ -158,7 +158,7 @@ class Pry
|
|||
search_all_methods(namespace) do |meth|
|
||||
begin
|
||||
meth.source =~ regex
|
||||
rescue RescuableException => e
|
||||
rescue RescuableException
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -78,7 +78,7 @@ class Pry
|
|||
end
|
||||
opt.on :c, :command, "Gist a command's source.", true do |command_name|
|
||||
command = find_command(command_name)
|
||||
block = Pry::Method.new(find_command(command_name).block)
|
||||
block = Pry::Method.new(command.block)
|
||||
self.content << block.source << "\n"
|
||||
end
|
||||
opt.on :k, :class, "Gist a class's source.", true do |class_name|
|
||||
|
@ -97,7 +97,6 @@ class Pry
|
|||
:as => Range, :default => -5..-1 do |range|
|
||||
range = convert_to_range(range)
|
||||
|
||||
output_results = []
|
||||
range.each do |v|
|
||||
self.content << Pry.config.gist.inspecter.call(_pry_.output_array[v])
|
||||
end
|
||||
|
@ -217,7 +216,7 @@ class Pry
|
|||
end
|
||||
opt.on :c, :command, "Save a command's source.", true do |command_name|
|
||||
command = find_command(command_name)
|
||||
block = Pry::Method.new(find_command(command_name).block)
|
||||
block = Pry::Method.new(command.block)
|
||||
self.content << block.source
|
||||
end
|
||||
opt.on :f, :file, "Save a file.", true do |file|
|
||||
|
@ -228,7 +227,6 @@ class Pry
|
|||
:as => Range, :default => -5..-1 do |range|
|
||||
range = convert_to_range(range)
|
||||
|
||||
output_results = []
|
||||
range.each do |v|
|
||||
self.content << Pry.config.gist.inspecter.call(_pry_.output_array[v])
|
||||
end
|
||||
|
|
|
@ -89,7 +89,7 @@ class Pry
|
|||
File.open(history_file, 'a') do |f|
|
||||
lines.each { |ln| f.puts ln }
|
||||
end
|
||||
rescue Errno::EACCES => error
|
||||
rescue Errno::EACCES
|
||||
# We should probably create an option Pry.show_warnings?!?!?!
|
||||
warn 'Unable to write to your history file, history not saved'
|
||||
end
|
||||
|
|
|
@ -106,8 +106,7 @@ class Pry
|
|||
# @return [String] The indented version of +input+.
|
||||
#
|
||||
def indent(input)
|
||||
output = ''
|
||||
open_tokens = OPEN_TOKENS.keys
|
||||
output = ''
|
||||
prefix = indent_level
|
||||
|
||||
input.lines.each do |line|
|
||||
|
@ -320,9 +319,9 @@ class Pry
|
|||
Readline.respond_to?(:get_screen_size) && Readline.get_screen_size,
|
||||
|
||||
# Otherwise try to use the environment (this may be out of date due
|
||||
# to window resizing, but it better than nothing).
|
||||
# to window resizing, but it's better than nothing).
|
||||
[ENV["ROWS"], ENV["COLUMNS"]]
|
||||
].detect do |(rows, cols)|
|
||||
].detect do |(_, cols)|
|
||||
cols.to_i > 0
|
||||
end
|
||||
end
|
||||
|
|
|
@ -273,12 +273,10 @@ class Pry
|
|||
info = pry_doc_info
|
||||
info.docstring if info
|
||||
when :ruby
|
||||
if Helpers::BaseHelpers.rbx? && !pry_method?
|
||||
strip_leading_hash_and_whitespace_from_ruby_comments(core_doc)
|
||||
if Helpers::BaseHelpers.rbx? && !pry_method?
|
||||
strip_leading_hash_and_whitespace_from_ruby_comments(core_doc)
|
||||
elsif pry_method?
|
||||
# raise CommandError, "Can't view doc for a REPL-defined
|
||||
# method."
|
||||
strip_leading_hash_and_whitespace_from_ruby_comments(doc_for_pry_method)
|
||||
strip_leading_hash_and_whitespace_from_ruby_comments(doc_for_pry_method)
|
||||
else
|
||||
strip_leading_hash_and_whitespace_from_ruby_comments(@method.comment)
|
||||
end
|
||||
|
@ -438,10 +436,10 @@ class Pry
|
|||
|
||||
# FIXME: a very similar method to this exists on WrappedModule: extract_doc_for_candidate
|
||||
def doc_for_pry_method
|
||||
_, line = source_location
|
||||
_, line_num = source_location
|
||||
|
||||
buffer = ""
|
||||
Pry.line_buffer[0..(line - 1)].each do |line|
|
||||
Pry.line_buffer[0..(line_num - 1)].each do |line|
|
||||
# Add any line that is a valid ruby comment,
|
||||
# but clear as soon as we hit a non comment line.
|
||||
if (line =~ /^\s*#/) || (line =~ /^\s*$/)
|
||||
|
|
|
@ -324,7 +324,7 @@ class Pry
|
|||
begin
|
||||
require 'coderay/encoders/term'
|
||||
CodeRay::Encoders::Term::TOKEN_COLORS
|
||||
rescue => e
|
||||
rescue
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -194,7 +194,6 @@ class Pry
|
|||
# Pry.new.repl(Object.new)
|
||||
def repl(target=TOPLEVEL_BINDING)
|
||||
target = Pry.binding_for(target)
|
||||
target_self = target.eval('self')
|
||||
|
||||
repl_prologue(target)
|
||||
|
||||
|
@ -270,7 +269,6 @@ class Pry
|
|||
target = Pry.binding_for(target)
|
||||
@suppress_output = false
|
||||
|
||||
val = ""
|
||||
loop do
|
||||
begin
|
||||
# eval_string will probably be mutated by this method
|
||||
|
@ -344,7 +342,7 @@ class Pry
|
|||
# Handle <Ctrl+C> like Bash, empty the current input buffer but do not quit.
|
||||
# This is only for ruby-1.9; other versions of ruby do not let you send Interrupt
|
||||
# from within Readline.
|
||||
rescue Interrupt => e
|
||||
rescue Interrupt
|
||||
output.puts ""
|
||||
eval_string.replace("")
|
||||
return
|
||||
|
|
|
@ -122,8 +122,6 @@ class Pry
|
|||
def doc
|
||||
return @doc if @doc
|
||||
|
||||
file_name, line = source_location
|
||||
|
||||
if yard_docs?
|
||||
from_yard = YARD::Registry.at(name)
|
||||
@doc = from_yard.docstring
|
||||
|
@ -216,7 +214,7 @@ class Pry
|
|||
search_lines = host_file_lines[0..(line - 2)]
|
||||
idx = search_lines.rindex { |v| class_regex1 =~ v || class_regex2 =~ v }
|
||||
|
||||
source_location = [file, idx + 1]
|
||||
[file, idx + 1]
|
||||
rescue Pry::RescuableException
|
||||
nil
|
||||
end
|
||||
|
@ -226,10 +224,10 @@ class Pry
|
|||
end
|
||||
|
||||
def extract_doc_for_candidate(idx)
|
||||
file_name, line = module_source_location_for_candidate(idx)
|
||||
_, line_num = module_source_location_for_candidate(idx)
|
||||
|
||||
buffer = ""
|
||||
lines_for_file(source_file_for_candidate(idx))[0..(line - 2)].each do |line|
|
||||
lines_for_file(source_file_for_candidate(idx))[0..(line_num - 2)].each do |line|
|
||||
# Add any line that is a valid ruby comment,
|
||||
# but clear as soon as we hit a non comment line.
|
||||
if (line =~ /^\s*#/) || (line =~ /^\s*$/)
|
||||
|
@ -284,9 +282,8 @@ class Pry
|
|||
end
|
||||
|
||||
def method_candidates
|
||||
@method_candidtates ||= all_source_locations_by_popularity.map do |group|
|
||||
sorted_by_lowest_line_number = group.last.sort_by(&:source_line)
|
||||
best_candidate_for_group = sorted_by_lowest_line_number.first
|
||||
@method_candidates ||= all_source_locations_by_popularity.map do |group|
|
||||
group.last.sort_by(&:source_line).first # best candidate for group
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue