1
0
Fork 0
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:
Conrad Irwin 2013-03-02 16:01:55 -08:00
parent 1201c3c937
commit d6ef67cfa7
17 changed files with 38 additions and 42 deletions

View file

@ -193,10 +193,6 @@ end.process_options do |opts|
exit
end
if Pry.config.should_load_plugins
parser = Slop.new
end
# Start the session (running any code passed with -e, if there is any)
Pry.start(context, :input => StringIO.new(exec_string))
end

View file

@ -119,7 +119,7 @@ class Pry
def abs_path(filename)
abs_path = [File.expand_path(filename, Dir.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,
"Cannot open #{filename.inspect} for reading."
end

View file

@ -22,7 +22,8 @@ class Pry
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
# parameter, `start_line`. Otherwise, leave it as it is.

View file

@ -30,13 +30,13 @@ class Pry
@command_options[:listing] = arg.is_a?(String) ? arg : arg.inspect
@match = arg
end
@match
@match ||= nil
end
# Define or get the command's description
def description(arg=nil)
@description = arg if arg
@description
@description ||= nil
end
# Define or get the command's options
@ -201,7 +201,7 @@ class Pry
case Pry::Method(block).source_file
when %r{/pry/.*_commands/(.*).rb}
$1.capitalize.gsub(/_/, " ")
when %r{(pry-\w+)-([\d\.]+([\w\d\.]+)?)}
when %r{(pry-\w+)-([\d\.]+([\w\.]+)?)}
name, version = $1, $2
"#{name.to_s} (v#{version.to_s})"
when /pryrc/

View file

@ -368,9 +368,9 @@ class Pry
if command = find_command(search)
command.new(context).complete(search)
else
commands.keys.select do |x|
String === x && x.start_with?(search)
end.map{ |command| command + " " } + Bond::DefaultMission.completions
commands.keys.select do |key|
String === key && key.start_with?(search)
end.map{ |key| key + " " } + Bond::DefaultMission.completions
end
end
end

View file

@ -1,6 +1,6 @@
class Pry
class Command::AmendLine < Pry::ClassCommand
match /amend-line(?: (-?\d+)(?:\.\.(-?\d+))?)?/
match(/amend-line(?: (-?\d+)(?:\.\.(-?\d+))?)?/)
group 'Editing'
description 'Amend a line of input in multi-line mode.'
command_options :interpolate => false, :listing => 'amend-line'

View file

@ -13,7 +13,7 @@ class Pry
# perform the patch
def perform_patch
file_name, line = file_and_line
file_name, _ = file_and_line
lines = state.dynamical_ex_file || File.read(file_name)
source = Pry::Editor.edit_tempfile_with_content(lines)

View file

@ -114,7 +114,7 @@ class Pry
nesting = Pry::Code.from_file(code_object.source_file).nesting_at(code_object.source_line)
(nesting + [source] + nesting.map{ "end" } + [""]).join("\n")
rescue Pry::Indent::UnparseableNestingError => e
rescue Pry::Indent::UnparseableNestingError
source
end
end

View file

@ -1,7 +1,7 @@
class Pry
# N.B. using a regular expresion here so that "raise-up 'foo'" does the right thing.
class Command::RaiseUp < Pry::ClassCommand
match /raise-up(!?\b.*)/
match(/raise-up(!?\b.*)/)
group 'Context'
description 'Raise an exception out of the current pry instance.'
command_options :listing => 'raise-up'

View file

@ -1,6 +1,6 @@
class Pry
class Command::ShellCommand < Pry::ClassCommand
match /\.(.*)/
match(/\.(.*)/)
group 'Input and Output'
description "All text following a '.' is forwarded to the shell."
command_options :listing => '.<shell command>', :use_prefix => false,

View file

@ -180,7 +180,7 @@ class Pry
prefix, search = [$1, $2]
methods = begin
Pry::Method.all_from_class(binding.eval(prefix))
rescue RescuableException => e
rescue RescuableException
return super
end
methods.map do |method|

View file

@ -1,6 +1,6 @@
class Pry
class Command::Wtf < Pry::ClassCommand
match /wtf([?!]*)/
match(/wtf([?!]*)/)
group 'Context'
description 'Show the backtrace of the most recent exception.'
options :listing => 'wtf?'
@ -50,8 +50,8 @@ class Pry
def size_of_backtrace
[captures[0].size, 0.5].max * 10
end
end
end
Pry::Commands.add_command(Pry::Command::Wtf)
Pry::Commands.add_command(Pry::Command::Wtf)
end

View file

@ -23,10 +23,6 @@ class Pry
# Implements tab completion for Readline in Pry
module InputCompleter
def self.call(input, options)
build_completion_proc(options[:target], options[:pry], options[:custom_completions]).call input
end
def self.start
if Readline.respond_to?("basic_word_break_characters=")
Readline.basic_word_break_characters = " \t\n\"\\'`><=;|&{("
@ -279,15 +275,15 @@ class Pry
def self.build_path(input)
# 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?('/')
contexts = input.chomp('/').split(/\//)
input = contexts[-1]
path = proc do |input|
p = contexts[0..-2].push(input).join('/')
p += '/' if trailing_slash && !input.nil?
path = proc do |i|
p = contexts[0..-2].push(i).join('/')
p += '/' if trailing_slash && !i.nil?
p
end

View file

@ -84,14 +84,14 @@ class Object
# it has the nice property that we can memoize this check.
begin
# 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
# 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.
rescue TypeError
# 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

View file

@ -28,8 +28,8 @@ class Pry
public_delegates = [:wrapped, :module?, :class?, :name, :nonblank_name]
def_delegators :@wrapper, *(private_delegates + public_delegates)
private *private_delegates
public *public_delegates
private(*private_delegates)
public(*public_delegates)
# @raise [Pry::CommandError] If `rank` is out of bounds.
# @param [Pry::WrappedModule] wrapper The associated

View file

@ -52,9 +52,6 @@ class Pry
# @return [Boolean] Whether Pry sessions are quiet by default.
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.
# (a CommandError in most cases)
attr_accessor :last_internal_error
@ -266,7 +263,7 @@ Readline version #{ver} detected - will not auto_resize! correctly.
end
trap :WINCH do
begin
Readline.set_screen_size *Terminal.size!
Readline.set_screen_size(*Terminal.size!)
rescue => e
warn "\nPry.auto_resize!'s Readline.set_screen_size failed: #{e}"
end
@ -430,7 +427,7 @@ Readline version #{ver} detected - will not auto_resize! correctly.
end
def self.toplevel_binding
unless @toplevel_binding
unless defined?(@toplevel_binding) && @toplevel_binding
# Grab a copy of the TOPLEVEL_BINDING without any local variables.
# This binding has a default definee of Object, and new methods are
# private (just as in TOPLEVEL_BINDING).
@ -446,12 +443,18 @@ Readline version #{ver} detected - will not auto_resize! correctly.
@toplevel_binding
end
def self.toplevel_binding=(binding)
@toplevel_binding = binding
end
def self.in_critical_section?
@critical_section.to_i > 0
@critical_section ||= 0
@critical_section > 0
end
def self.critical_section(&block)
@critical_section = @critical_section.to_i + 1
@critical_section ||= 0
@critical_section += 1
yield
ensure
@critical_section -= 1

View file

@ -23,9 +23,9 @@ class Pry
Gem.source_index.find_name(name)
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
# List gems matching a pattern.