diff options
author | Conrad Irwin <conrad.irwin@gmail.com> | 2013-03-02 16:01:55 -0800 |
---|---|---|
committer | Conrad Irwin <conrad.irwin@gmail.com> | 2013-03-02 16:01:55 -0800 |
commit | d6ef67cfa7cd5ff2b6da5aa2c9946969c033b105 (patch) | |
tree | 80d21f5cf9ce77753e25394ba6b188d4e7f44a99 | |
parent | 1201c3c937a0718c4ae40a0436b4019bf261adb3 (diff) | |
download | pry-d6ef67cfa7cd5ff2b6da5aa2c9946969c033b105.tar.gz |
Remove warnings [Fixes #869]
-rw-r--r-- | lib/pry/cli.rb | 4 | ||||
-rw-r--r-- | lib/pry/code.rb | 2 | ||||
-rw-r--r-- | lib/pry/code/code_range.rb | 3 | ||||
-rw-r--r-- | lib/pry/command.rb | 6 | ||||
-rw-r--r-- | lib/pry/command_set.rb | 6 | ||||
-rw-r--r-- | lib/pry/commands/amend_line.rb | 2 | ||||
-rw-r--r-- | lib/pry/commands/edit/exception_patcher.rb | 2 | ||||
-rw-r--r-- | lib/pry/commands/edit/method_patcher.rb | 2 | ||||
-rw-r--r-- | lib/pry/commands/raise_up.rb | 2 | ||||
-rw-r--r-- | lib/pry/commands/shell_command.rb | 2 | ||||
-rw-r--r-- | lib/pry/commands/show_info.rb | 2 | ||||
-rw-r--r-- | lib/pry/commands/wtf.rb | 6 | ||||
-rw-r--r-- | lib/pry/completion.rb | 12 | ||||
-rw-r--r-- | lib/pry/core_extensions.rb | 4 | ||||
-rw-r--r-- | lib/pry/module_candidate.rb | 4 | ||||
-rw-r--r-- | lib/pry/pry_class.rb | 17 | ||||
-rw-r--r-- | lib/pry/rubygem.rb | 4 |
17 files changed, 38 insertions, 42 deletions
diff --git a/lib/pry/cli.rb b/lib/pry/cli.rb index 635c9926..7da8e6aa 100644 --- a/lib/pry/cli.rb +++ b/lib/pry/cli.rb @@ -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 diff --git a/lib/pry/code.rb b/lib/pry/code.rb index 08fac67c..82fe05d9 100644 --- a/lib/pry/code.rb +++ b/lib/pry/code.rb @@ -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 diff --git a/lib/pry/code/code_range.rb b/lib/pry/code/code_range.rb index 13ae2540..043be02e 100644 --- a/lib/pry/code/code_range.rb +++ b/lib/pry/code/code_range.rb @@ -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. diff --git a/lib/pry/command.rb b/lib/pry/command.rb index 907ac6db..81f4eb26 100644 --- a/lib/pry/command.rb +++ b/lib/pry/command.rb @@ -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/ diff --git a/lib/pry/command_set.rb b/lib/pry/command_set.rb index ff934430..ecefa8b1 100644 --- a/lib/pry/command_set.rb +++ b/lib/pry/command_set.rb @@ -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 diff --git a/lib/pry/commands/amend_line.rb b/lib/pry/commands/amend_line.rb index 77e92be1..cb4ef415 100644 --- a/lib/pry/commands/amend_line.rb +++ b/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' diff --git a/lib/pry/commands/edit/exception_patcher.rb b/lib/pry/commands/edit/exception_patcher.rb index e7bff32a..048662ee 100644 --- a/lib/pry/commands/edit/exception_patcher.rb +++ b/lib/pry/commands/edit/exception_patcher.rb @@ -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) diff --git a/lib/pry/commands/edit/method_patcher.rb b/lib/pry/commands/edit/method_patcher.rb index a33e3106..eac69e66 100644 --- a/lib/pry/commands/edit/method_patcher.rb +++ b/lib/pry/commands/edit/method_patcher.rb @@ -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 diff --git a/lib/pry/commands/raise_up.rb b/lib/pry/commands/raise_up.rb index 745556c0..418d7c34 100644 --- a/lib/pry/commands/raise_up.rb +++ b/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' diff --git a/lib/pry/commands/shell_command.rb b/lib/pry/commands/shell_command.rb index 3c20123a..2181947f 100644 --- a/lib/pry/commands/shell_command.rb +++ b/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, diff --git a/lib/pry/commands/show_info.rb b/lib/pry/commands/show_info.rb index 8862f652..04817d40 100644 --- a/lib/pry/commands/show_info.rb +++ b/lib/pry/commands/show_info.rb @@ -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| diff --git a/lib/pry/commands/wtf.rb b/lib/pry/commands/wtf.rb index 37d1da74..2d47dfac 100644 --- a/lib/pry/commands/wtf.rb +++ b/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?' @@ -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 diff --git a/lib/pry/completion.rb b/lib/pry/completion.rb index 047eea5f..03e5e74d 100644 --- a/lib/pry/completion.rb +++ b/lib/pry/completion.rb @@ -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 diff --git a/lib/pry/core_extensions.rb b/lib/pry/core_extensions.rb index b5ddbba9..c86d83b5 100644 --- a/lib/pry/core_extensions.rb +++ b/lib/pry/core_extensions.rb @@ -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 diff --git a/lib/pry/module_candidate.rb b/lib/pry/module_candidate.rb index 0a295b67..9e8a8071 100644 --- a/lib/pry/module_candidate.rb +++ b/lib/pry/module_candidate.rb @@ -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 diff --git a/lib/pry/pry_class.rb b/lib/pry/pry_class.rb index 24648af2..a619a9f3 100644 --- a/lib/pry/pry_class.rb +++ b/lib/pry/pry_class.rb @@ -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 diff --git a/lib/pry/rubygem.rb b/lib/pry/rubygem.rb index ad8e1b70..147f1fd8 100644 --- a/lib/pry/rubygem.rb +++ b/lib/pry/rubygem.rb @@ -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. |