mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Remove warnings [Fixes #869]
This commit is contained in:
parent
1201c3c937
commit
d6ef67cfa7
17 changed files with 38 additions and 42 deletions
|
@ -193,10 +193,6 @@ end.process_options do |opts|
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|
||||||
if Pry.config.should_load_plugins
|
|
||||||
parser = Slop.new
|
|
||||||
end
|
|
||||||
|
|
||||||
# Start the session (running any code passed with -e, if there is any)
|
# Start the session (running any code passed with -e, if there is any)
|
||||||
Pry.start(context, :input => StringIO.new(exec_string))
|
Pry.start(context, :input => StringIO.new(exec_string))
|
||||||
end
|
end
|
||||||
|
|
|
@ -119,7 +119,7 @@ class Pry
|
||||||
def abs_path(filename)
|
def abs_path(filename)
|
||||||
abs_path = [File.expand_path(filename, Dir.pwd),
|
abs_path = [File.expand_path(filename, Dir.pwd),
|
||||||
File.expand_path(filename, Pry::INITIAL_PWD)
|
File.expand_path(filename, Pry::INITIAL_PWD)
|
||||||
].detect { |abs_path| File.readable?(abs_path) }
|
].detect { |path| File.readable?(path) }
|
||||||
abs_path or raise MethodSource::SourceNotFoundError,
|
abs_path or raise MethodSource::SourceNotFoundError,
|
||||||
"Cannot open #{filename.inspect} for reading."
|
"Cannot open #{filename.inspect} for reading."
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,7 +22,8 @@ class Pry
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
attr_reader :start_line, :end_line
|
def start_line; @start_line; end
|
||||||
|
def end_line; @end_line; end
|
||||||
|
|
||||||
# If `end_line` is equal to `nil`, then calculate it from the first
|
# If `end_line` is equal to `nil`, then calculate it from the first
|
||||||
# parameter, `start_line`. Otherwise, leave it as it is.
|
# parameter, `start_line`. Otherwise, leave it as it is.
|
||||||
|
|
|
@ -30,13 +30,13 @@ class Pry
|
||||||
@command_options[:listing] = arg.is_a?(String) ? arg : arg.inspect
|
@command_options[:listing] = arg.is_a?(String) ? arg : arg.inspect
|
||||||
@match = arg
|
@match = arg
|
||||||
end
|
end
|
||||||
@match
|
@match ||= nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Define or get the command's description
|
# Define or get the command's description
|
||||||
def description(arg=nil)
|
def description(arg=nil)
|
||||||
@description = arg if arg
|
@description = arg if arg
|
||||||
@description
|
@description ||= nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Define or get the command's options
|
# Define or get the command's options
|
||||||
|
@ -201,7 +201,7 @@ class Pry
|
||||||
case Pry::Method(block).source_file
|
case Pry::Method(block).source_file
|
||||||
when %r{/pry/.*_commands/(.*).rb}
|
when %r{/pry/.*_commands/(.*).rb}
|
||||||
$1.capitalize.gsub(/_/, " ")
|
$1.capitalize.gsub(/_/, " ")
|
||||||
when %r{(pry-\w+)-([\d\.]+([\w\d\.]+)?)}
|
when %r{(pry-\w+)-([\d\.]+([\w\.]+)?)}
|
||||||
name, version = $1, $2
|
name, version = $1, $2
|
||||||
"#{name.to_s} (v#{version.to_s})"
|
"#{name.to_s} (v#{version.to_s})"
|
||||||
when /pryrc/
|
when /pryrc/
|
||||||
|
|
|
@ -368,9 +368,9 @@ class Pry
|
||||||
if command = find_command(search)
|
if command = find_command(search)
|
||||||
command.new(context).complete(search)
|
command.new(context).complete(search)
|
||||||
else
|
else
|
||||||
commands.keys.select do |x|
|
commands.keys.select do |key|
|
||||||
String === x && x.start_with?(search)
|
String === key && key.start_with?(search)
|
||||||
end.map{ |command| command + " " } + Bond::DefaultMission.completions
|
end.map{ |key| key + " " } + Bond::DefaultMission.completions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class Pry
|
class Pry
|
||||||
class Command::AmendLine < Pry::ClassCommand
|
class Command::AmendLine < Pry::ClassCommand
|
||||||
match /amend-line(?: (-?\d+)(?:\.\.(-?\d+))?)?/
|
match(/amend-line(?: (-?\d+)(?:\.\.(-?\d+))?)?/)
|
||||||
group 'Editing'
|
group 'Editing'
|
||||||
description 'Amend a line of input in multi-line mode.'
|
description 'Amend a line of input in multi-line mode.'
|
||||||
command_options :interpolate => false, :listing => 'amend-line'
|
command_options :interpolate => false, :listing => 'amend-line'
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Pry
|
||||||
|
|
||||||
# perform the patch
|
# perform the patch
|
||||||
def perform_patch
|
def perform_patch
|
||||||
file_name, line = file_and_line
|
file_name, _ = file_and_line
|
||||||
lines = state.dynamical_ex_file || File.read(file_name)
|
lines = state.dynamical_ex_file || File.read(file_name)
|
||||||
|
|
||||||
source = Pry::Editor.edit_tempfile_with_content(lines)
|
source = Pry::Editor.edit_tempfile_with_content(lines)
|
||||||
|
|
|
@ -114,7 +114,7 @@ class Pry
|
||||||
nesting = Pry::Code.from_file(code_object.source_file).nesting_at(code_object.source_line)
|
nesting = Pry::Code.from_file(code_object.source_file).nesting_at(code_object.source_line)
|
||||||
|
|
||||||
(nesting + [source] + nesting.map{ "end" } + [""]).join("\n")
|
(nesting + [source] + nesting.map{ "end" } + [""]).join("\n")
|
||||||
rescue Pry::Indent::UnparseableNestingError => e
|
rescue Pry::Indent::UnparseableNestingError
|
||||||
source
|
source
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class Pry
|
class Pry
|
||||||
# N.B. using a regular expresion here so that "raise-up 'foo'" does the right thing.
|
# N.B. using a regular expresion here so that "raise-up 'foo'" does the right thing.
|
||||||
class Command::RaiseUp < Pry::ClassCommand
|
class Command::RaiseUp < Pry::ClassCommand
|
||||||
match /raise-up(!?\b.*)/
|
match(/raise-up(!?\b.*)/)
|
||||||
group 'Context'
|
group 'Context'
|
||||||
description 'Raise an exception out of the current pry instance.'
|
description 'Raise an exception out of the current pry instance.'
|
||||||
command_options :listing => 'raise-up'
|
command_options :listing => 'raise-up'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class Pry
|
class Pry
|
||||||
class Command::ShellCommand < Pry::ClassCommand
|
class Command::ShellCommand < Pry::ClassCommand
|
||||||
match /\.(.*)/
|
match(/\.(.*)/)
|
||||||
group 'Input and Output'
|
group 'Input and Output'
|
||||||
description "All text following a '.' is forwarded to the shell."
|
description "All text following a '.' is forwarded to the shell."
|
||||||
command_options :listing => '.<shell command>', :use_prefix => false,
|
command_options :listing => '.<shell command>', :use_prefix => false,
|
||||||
|
|
|
@ -180,7 +180,7 @@ class Pry
|
||||||
prefix, search = [$1, $2]
|
prefix, search = [$1, $2]
|
||||||
methods = begin
|
methods = begin
|
||||||
Pry::Method.all_from_class(binding.eval(prefix))
|
Pry::Method.all_from_class(binding.eval(prefix))
|
||||||
rescue RescuableException => e
|
rescue RescuableException
|
||||||
return super
|
return super
|
||||||
end
|
end
|
||||||
methods.map do |method|
|
methods.map do |method|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class Pry
|
class Pry
|
||||||
class Command::Wtf < Pry::ClassCommand
|
class Command::Wtf < Pry::ClassCommand
|
||||||
match /wtf([?!]*)/
|
match(/wtf([?!]*)/)
|
||||||
group 'Context'
|
group 'Context'
|
||||||
description 'Show the backtrace of the most recent exception.'
|
description 'Show the backtrace of the most recent exception.'
|
||||||
options :listing => 'wtf?'
|
options :listing => 'wtf?'
|
||||||
|
@ -50,8 +50,8 @@ class Pry
|
||||||
|
|
||||||
def size_of_backtrace
|
def size_of_backtrace
|
||||||
[captures[0].size, 0.5].max * 10
|
[captures[0].size, 0.5].max * 10
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
Pry::Commands.add_command(Pry::Command::Wtf)
|
Pry::Commands.add_command(Pry::Command::Wtf)
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,10 +23,6 @@ class Pry
|
||||||
# Implements tab completion for Readline in Pry
|
# Implements tab completion for Readline in Pry
|
||||||
module InputCompleter
|
module InputCompleter
|
||||||
|
|
||||||
def self.call(input, options)
|
|
||||||
build_completion_proc(options[:target], options[:pry], options[:custom_completions]).call input
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.start
|
def self.start
|
||||||
if Readline.respond_to?("basic_word_break_characters=")
|
if Readline.respond_to?("basic_word_break_characters=")
|
||||||
Readline.basic_word_break_characters = " \t\n\"\\'`><=;|&{("
|
Readline.basic_word_break_characters = " \t\n\"\\'`><=;|&{("
|
||||||
|
@ -279,15 +275,15 @@ class Pry
|
||||||
def self.build_path(input)
|
def self.build_path(input)
|
||||||
|
|
||||||
# check to see if the input is a regex
|
# check to see if the input is a regex
|
||||||
return proc {|input| input.to_s }, input if input[/\/\./]
|
return proc {|i| i.to_s }, input if input[/\/\./]
|
||||||
|
|
||||||
trailing_slash = input.end_with?('/')
|
trailing_slash = input.end_with?('/')
|
||||||
contexts = input.chomp('/').split(/\//)
|
contexts = input.chomp('/').split(/\//)
|
||||||
input = contexts[-1]
|
input = contexts[-1]
|
||||||
|
|
||||||
path = proc do |input|
|
path = proc do |i|
|
||||||
p = contexts[0..-2].push(input).join('/')
|
p = contexts[0..-2].push(i).join('/')
|
||||||
p += '/' if trailing_slash && !input.nil?
|
p += '/' if trailing_slash && !i.nil?
|
||||||
p
|
p
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -84,14 +84,14 @@ class Object
|
||||||
# it has the nice property that we can memoize this check.
|
# it has the nice property that we can memoize this check.
|
||||||
begin
|
begin
|
||||||
# instance_eval sets the default definee to the object's singleton class
|
# instance_eval sets the default definee to the object's singleton class
|
||||||
instance_eval *Pry::BINDING_METHOD_IMPL
|
instance_eval(*Pry::BINDING_METHOD_IMPL)
|
||||||
|
|
||||||
# If we can't define methods on the Object's singleton_class. Then we fall
|
# If we can't define methods on the Object's singleton_class. Then we fall
|
||||||
# back to setting the default definee to be the Object's class. That seems
|
# back to setting the default definee to be the Object's class. That seems
|
||||||
# nicer than having a REPL in which you can't define methods.
|
# nicer than having a REPL in which you can't define methods.
|
||||||
rescue TypeError
|
rescue TypeError
|
||||||
# class_eval sets the default definee to self.class
|
# class_eval sets the default definee to self.class
|
||||||
self.class.class_eval *Pry::BINDING_METHOD_IMPL
|
self.class.class_eval(*Pry::BINDING_METHOD_IMPL)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@ class Pry
|
||||||
public_delegates = [:wrapped, :module?, :class?, :name, :nonblank_name]
|
public_delegates = [:wrapped, :module?, :class?, :name, :nonblank_name]
|
||||||
|
|
||||||
def_delegators :@wrapper, *(private_delegates + public_delegates)
|
def_delegators :@wrapper, *(private_delegates + public_delegates)
|
||||||
private *private_delegates
|
private(*private_delegates)
|
||||||
public *public_delegates
|
public(*public_delegates)
|
||||||
|
|
||||||
# @raise [Pry::CommandError] If `rank` is out of bounds.
|
# @raise [Pry::CommandError] If `rank` is out of bounds.
|
||||||
# @param [Pry::WrappedModule] wrapper The associated
|
# @param [Pry::WrappedModule] wrapper The associated
|
||||||
|
|
|
@ -52,9 +52,6 @@ class Pry
|
||||||
# @return [Boolean] Whether Pry sessions are quiet by default.
|
# @return [Boolean] Whether Pry sessions are quiet by default.
|
||||||
attr_accessor :quiet
|
attr_accessor :quiet
|
||||||
|
|
||||||
# @return [Binding] A top level binding with no local variables
|
|
||||||
attr_accessor :toplevel_binding
|
|
||||||
|
|
||||||
# @return [Exception, nil] The last pry internal error.
|
# @return [Exception, nil] The last pry internal error.
|
||||||
# (a CommandError in most cases)
|
# (a CommandError in most cases)
|
||||||
attr_accessor :last_internal_error
|
attr_accessor :last_internal_error
|
||||||
|
@ -266,7 +263,7 @@ Readline version #{ver} detected - will not auto_resize! correctly.
|
||||||
end
|
end
|
||||||
trap :WINCH do
|
trap :WINCH do
|
||||||
begin
|
begin
|
||||||
Readline.set_screen_size *Terminal.size!
|
Readline.set_screen_size(*Terminal.size!)
|
||||||
rescue => e
|
rescue => e
|
||||||
warn "\nPry.auto_resize!'s Readline.set_screen_size failed: #{e}"
|
warn "\nPry.auto_resize!'s Readline.set_screen_size failed: #{e}"
|
||||||
end
|
end
|
||||||
|
@ -430,7 +427,7 @@ Readline version #{ver} detected - will not auto_resize! correctly.
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.toplevel_binding
|
def self.toplevel_binding
|
||||||
unless @toplevel_binding
|
unless defined?(@toplevel_binding) && @toplevel_binding
|
||||||
# Grab a copy of the TOPLEVEL_BINDING without any local variables.
|
# Grab a copy of the TOPLEVEL_BINDING without any local variables.
|
||||||
# This binding has a default definee of Object, and new methods are
|
# This binding has a default definee of Object, and new methods are
|
||||||
# private (just as in TOPLEVEL_BINDING).
|
# private (just as in TOPLEVEL_BINDING).
|
||||||
|
@ -446,12 +443,18 @@ Readline version #{ver} detected - will not auto_resize! correctly.
|
||||||
@toplevel_binding
|
@toplevel_binding
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.toplevel_binding=(binding)
|
||||||
|
@toplevel_binding = binding
|
||||||
|
end
|
||||||
|
|
||||||
def self.in_critical_section?
|
def self.in_critical_section?
|
||||||
@critical_section.to_i > 0
|
@critical_section ||= 0
|
||||||
|
@critical_section > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.critical_section(&block)
|
def self.critical_section(&block)
|
||||||
@critical_section = @critical_section.to_i + 1
|
@critical_section ||= 0
|
||||||
|
@critical_section += 1
|
||||||
yield
|
yield
|
||||||
ensure
|
ensure
|
||||||
@critical_section -= 1
|
@critical_section -= 1
|
||||||
|
|
|
@ -23,9 +23,9 @@ class Pry
|
||||||
Gem.source_index.find_name(name)
|
Gem.source_index.find_name(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
spec = specs.sort_by{ |spec| Gem::Version.new(spec.version) }.first
|
first_spec = specs.sort_by{ |spec| Gem::Version.new(spec.version) }.first
|
||||||
|
|
||||||
spec or raise CommandError, "Gem `#{name}` not found"
|
first_spec or raise CommandError, "Gem `#{name}` not found"
|
||||||
end
|
end
|
||||||
|
|
||||||
# List gems matching a pattern.
|
# List gems matching a pattern.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue