Skip to content

Commit

Permalink
Remove warnings [Fixes pry#869]
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradIrwin committed Mar 3, 2013
1 parent 1201c3c commit d6ef67c
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 42 deletions.
4 changes: 0 additions & 4 deletions lib/pry/cli.rb
Expand Up @@ -193,10 +193,6 @@ def parse_options(args=ARGV.dup)
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
2 changes: 1 addition & 1 deletion lib/pry/code.rb
Expand Up @@ -119,7 +119,7 @@ def type_from_filename(filename, default = :ruby)
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
Expand Down
3 changes: 2 additions & 1 deletion lib/pry/code/code_range.rb
Expand Up @@ -22,7 +22,8 @@ def indices_range(lines)

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.
Expand Down
6 changes: 3 additions & 3 deletions lib/pry/command.rb
Expand Up @@ -30,13 +30,13 @@ def match(arg=nil)
@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
Expand Down Expand Up @@ -201,7 +201,7 @@ def group(name=nil)
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/
Expand Down
6 changes: 3 additions & 3 deletions lib/pry/command_set.rb
Expand Up @@ -368,9 +368,9 @@ def complete(search, context={})
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
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/commands/amend_line.rb
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/commands/edit/exception_patcher.rb
Expand Up @@ -13,7 +13,7 @@ def initialize(_pry_, state, exception_file_and_line)

# 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)
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/commands/edit/method_patcher.rb
Expand Up @@ -114,7 +114,7 @@ def wrap_for_nesting(source)
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
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/commands/raise_up.rb
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/commands/shell_command.rb
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/commands/show_info.rb
Expand Up @@ -180,7 +180,7 @@ def complete(input)
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|
Expand Down
6 changes: 3 additions & 3 deletions lib/pry/commands/wtf.rb
@@ -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?'
Expand Down Expand Up @@ -50,8 +50,8 @@ def backtrace

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
12 changes: 4 additions & 8 deletions lib/pry/completion.rb
Expand Up @@ -23,10 +23,6 @@ def self.start
# 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\"\\'`><=;|&{("
Expand Down Expand Up @@ -279,15 +275,15 @@ def self.select_message(path, receiver, message, candidates)
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

Expand Down
4 changes: 2 additions & 2 deletions lib/pry/core_extensions.rb
Expand Up @@ -84,14 +84,14 @@ def __binding__
# 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

Expand Down
4 changes: 2 additions & 2 deletions lib/pry/module_candidate.rb
Expand Up @@ -28,8 +28,8 @@ class Candidate
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
Expand Down
17 changes: 10 additions & 7 deletions lib/pry/pry_class.rb
Expand Up @@ -52,9 +52,6 @@ def self.delegate_accessors(delagatee, *names)
# @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
Expand Down Expand Up @@ -266,7 +263,7 @@ def self.auto_resize!
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
Expand Down Expand Up @@ -430,7 +427,7 @@ def self.binding_for(target)
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).
Expand All @@ -446,12 +443,18 @@ class << self; undef __pry__; end
@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
Expand Down
4 changes: 2 additions & 2 deletions lib/pry/rubygem.rb
Expand Up @@ -23,9 +23,9 @@ def spec(name)
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.
Expand Down

0 comments on commit d6ef67c

Please sign in to comment.