From 3ff75dd20a102caee90b6fef539a4d09ef170c53 Mon Sep 17 00:00:00 2001 From: Lee Jarvis Date: Mon, 18 Apr 2011 22:31:39 +0100 Subject: [PATCH] whitespace cleanup in one hit --- lib/pry.rb | 2 +- lib/pry/command_base.rb | 18 +++++++++--------- lib/pry/command_base_helpers.rb | 24 ++++++++++++------------ lib/pry/command_helpers.rb | 30 +++++++++++++++--------------- lib/pry/command_processor.rb | 14 +++++++------- lib/pry/completion.rb | 2 +- lib/pry/hooks.rb | 2 +- lib/pry/prompts.rb | 4 ++-- lib/pry/pry_instance.rb | 2 +- lib/pry/version.rb | 2 +- 10 files changed, 50 insertions(+), 50 deletions(-) diff --git a/lib/pry.rb b/lib/pry.rb index 788a7705..de85af60 100644 --- a/lib/pry.rb +++ b/lib/pry.rb @@ -15,7 +15,7 @@ if RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/ begin require 'win32console' rescue LoadError - $stderr.puts "Need to `gem install win32console`" + $stderr.puts "Need to `gem install win32console`" exit 1 end end diff --git a/lib/pry/command_base.rb b/lib/pry/command_base.rb index 06035421..22d56451 100644 --- a/lib/pry/command_base.rb +++ b/lib/pry/command_base.rb @@ -9,7 +9,7 @@ class Pry class CommandBase class << self include CommandBaseHelpers - + attr_accessor :commands attr_accessor :opts, :output, :target @@ -17,7 +17,7 @@ class Pry # that the location where the block is defined has the `opts` # method in scope. private - + # Defines a new Pry command. # @param [String, Array] names The name of the command (or array of # command name aliases). @@ -48,7 +48,7 @@ class Pry :keep_retval => false, :requires_gem => nil }.merge!(options) - + @commands ||= {} if command_dependencies_met?(options) @@ -91,7 +91,7 @@ class Pry # end def run(name, *args) command_processor = CommandProcessor.new(target.eval('_pry_')) - + if command_processor.system_command?(name) command_processor.execute_system_command("#{name} #{args.join(' ')}", target) else @@ -139,13 +139,13 @@ class Pry commands[name][:description] = description end end - + command "help", "This menu." do |cmd| command_info = opts[:commands] if !cmd output.puts - help_text = heading("Command List:") + "\n" + help_text = heading("Command List:") + "\n" command_info.each do |k, data| if !data[:stub_info] help_text << ("#{k}".ljust(18) + data[:description] + "\n") if !data[:description].empty? @@ -180,7 +180,7 @@ class Pry output.puts "Installing `#{g}` gem..." begin - Gem::DependencyInstaller.new.install(g) + Gem::DependencyInstaller.new.install(g) rescue Gem::GemNotFoundException output.puts "Required Gem: `#{g}` not found. Aborting command installation." gem_install_failed = true @@ -188,7 +188,7 @@ class Pry end end next if gem_install_failed - + Gem.refresh load "#{File.dirname(__FILE__)}/commands.rb" output.puts "Installation of `#{name}` successful! Type `help #{name}` for information" @@ -198,6 +198,6 @@ class Pry def self.inherited(klass) klass.commands = commands.dup end - + end end diff --git a/lib/pry/command_base_helpers.rb b/lib/pry/command_base_helpers.rb index e7ea4217..dcb677b3 100644 --- a/lib/pry/command_base_helpers.rb +++ b/lib/pry/command_base_helpers.rb @@ -3,7 +3,7 @@ class Pry module CommandBaseHelpers private - + def gem_installed?(gem_name) require 'rubygems' !!Gem.source_index.find_name(gem_name).first @@ -49,16 +49,16 @@ class Pry # [ :gray, :red, :green, :yellow, :blue, :purple, :cyan, :white ].each_with_index do |color, i| define_method "bright_#{color}" do |str| - Pry.color ? "\033[1;#{30+i}m#{str}\033[0m" : str + Pry.color ? "\033[1;#{30+i}m#{str}\033[0m" : str end - + define_method color do |str| Pry.color ? "\033[0;#{30+i}m#{str}\033[0m" : str end end alias_method :magenta, :purple alias_method :bright_magenta, :bright_purple - + def bold(text) Pry.color ? "\e[1m#{text}\e[0m" : text end @@ -72,7 +72,7 @@ class Pry def page_size 27 end - + # a simple pager for systems without `less`. A la windows. def simple_pager(text) text_array = text.lines.to_a @@ -80,12 +80,12 @@ class Pry output.puts chunk.join break if chunk.size < page_size if text_array.size > page_size - output.puts "\n --- Press enter to continue ( q to break ) --- " + output.puts "\n --- Press enter to continue ( q to break ) --- " break if $stdin.gets.chomp == "q" end end end - + # Try to use `less` for paging, if it fails then use # simple_pager. Also do not page if Pry.pager is falsey def stagger_output(text) @@ -105,9 +105,9 @@ class Pry else options = {} end - + output = args.first if args.any? - + params = [] params << "-R" unless options[:color] == false params << "-S" unless options[:wrap] == true @@ -117,7 +117,7 @@ class Pry $stderr.puts "Seeking to end of stream..." end params << "-X" - + IO.popen("less #{params * ' '}", "w") do |less| if output less.puts output @@ -125,10 +125,10 @@ class Pry yield less end end - end + end end end end - + diff --git a/lib/pry/command_helpers.rb b/lib/pry/command_helpers.rb index 71d5cd56..fba0618f 100644 --- a/lib/pry/command_helpers.rb +++ b/lib/pry/command_helpers.rb @@ -1,18 +1,18 @@ class Pry class Commands < CommandBase - module CommandHelpers + module CommandHelpers private def try_to_load_pry_doc - # YARD crashes on rbx, so do not require it + # YARD crashes on rbx, so do not require it if !Object.const_defined?(:RUBY_ENGINE) || RUBY_ENGINE !~ /rbx/ require "pry-doc" end rescue LoadError end - + def meth_name_from_binding(b) meth_name = b.eval('__method__') if [:__script__, nil, :__binding__, :__binding_impl__].include?(meth_name) @@ -29,7 +29,7 @@ class Pry target.eval("_file_ = $_file_temp") target.eval("_dir_ = $_dir_temp") end - + def add_line_numbers(lines, start_line) line_array = lines.each_line.to_a line_array.each_with_index.map do |line, idx| @@ -110,7 +110,7 @@ class Pry if !meth_name return nil end - + if options[:M] target.eval("instance_method(:#{meth_name})") elsif options[:m] @@ -127,7 +127,7 @@ class Pry end end end - + def make_header(meth, code_type, content) num_lines = "Number of lines: #{bold(content.each_line.count.to_s)}" case code_type @@ -147,11 +147,11 @@ class Pry def should_use_pry_doc?(meth) Pry.has_pry_doc && is_a_c_method?(meth) end - + def code_type_for(meth) # only C methods if should_use_pry_doc?(meth) - info = Pry::MethodInfo.info_for(meth) + info = Pry::MethodInfo.info_for(meth) if info && info.source code_type = :c else @@ -169,7 +169,7 @@ class Pry end code_type end - + def file_map { [".c", ".h"] => :c, @@ -188,7 +188,7 @@ class Pry ".json" => :json } end - + def syntax_highlight_by_file_type_or_specified(contents, file_name, file_type) _, language_detected = file_map.find do |k, v| Array(k).any? do |matcher| @@ -205,7 +205,7 @@ class Pry def normalized_line_number(line_number, total_lines) line_number < 0 ? line_number + total_lines : line_number end - + # returns the file content between the lines and the normalized # start and end line numbers. def read_between_the_lines(file_name, start_line, end_line) @@ -280,11 +280,11 @@ class Pry optstring = opts.join("/") # case maintained defaults = opts.select{|o| o.upcase == o } opts = opts.map{|o| o.downcase} - + raise "Error: Too many default values for the prompt: #{default.inspect}" if defaults.size > 1 - + default = defaults.first - + loop do response = Pry.input.readline("#{message} (#{optstring}) ").downcase case response @@ -297,7 +297,7 @@ class Pry end end end - + end end end diff --git a/lib/pry/command_processor.rb b/lib/pry/command_processor.rb index c5819a0c..acdaf2b8 100644 --- a/lib/pry/command_processor.rb +++ b/lib/pry/command_processor.rb @@ -6,15 +6,15 @@ class Pry SYSTEM_COMMAND_REGEX = /^#{Regexp.escape(SYSTEM_COMMAND_DELIMITER)}(.*)/ extend Forwardable - + attr_accessor :pry_instance - + def initialize(pry_instance) @pry_instance = pry_instance end def_delegators :@pry_instance, :commands, :nesting, :output - + # Is the string a command valid? # @param [String] val The string passed in from the Pry prompt. # @return [Boolean] Whether the string is a valid command. @@ -59,7 +59,7 @@ class Pry def execute_system_command(val, target) SYSTEM_COMMAND_REGEX =~ val cmd = interpolate_string($1, target) - + if cmd =~ /^cd\s+(.+)/i begin Dir.chdir(File.expand_path($1)) @@ -73,7 +73,7 @@ class Pry # Tick, tock, im getting rid of this shit soon. val.replace("") end - + # Determine whether a Pry command was matched and return command data # and argument string. # This method should not need to be invoked directly. @@ -114,7 +114,7 @@ class Pry args = args_string ? Shellwords.shellwords(args_string) : [] action = cmd_data[:action] keep_retval = cmd_data[:keep_retval] - + options = { :val => val, :eval_string => eval_string, @@ -157,7 +157,7 @@ class Pry # Tick, tock, im getting rid of this shit soon. options[:val].clear - + ret_val end end diff --git a/lib/pry/completion.rb b/lib/pry/completion.rb index c23f2334..01c050ee 100644 --- a/lib/pry/completion.rb +++ b/lib/pry/completion.rb @@ -6,7 +6,7 @@ class Pry # Implements tab completion for Readline in Pry module InputCompleter - + if Readline.respond_to?("basic_word_break_characters=") Readline.basic_word_break_characters= " \t\n\"\\'`><=;|&{(" end diff --git a/lib/pry/hooks.rb b/lib/pry/hooks.rb index 134eb007..363743d8 100644 --- a/lib/pry/hooks.rb +++ b/lib/pry/hooks.rb @@ -2,7 +2,7 @@ class Pry # The default hooks - display messages when beginning and ending Pry sessions. DEFAULT_HOOKS = { - + :before_session => proc do |out, target| # ensure we're actually in a method meth_name = target.eval('__method__') diff --git a/lib/pry/prompts.rb b/lib/pry/prompts.rb index 35d7a8b8..9f42d71a 100644 --- a/lib/pry/prompts.rb +++ b/lib/pry/prompts.rb @@ -1,6 +1,6 @@ class Pry - + # The default prompt; includes the target and nesting level DEFAULT_PROMPT = [ proc do |target_self, nest_level| @@ -11,7 +11,7 @@ class Pry "pry(#{Pry.view_clip(target_self)}):#{Pry.view_clip(nest_level)}> " end end, - + proc do |target_self, nest_level| if nest_level == 0 "pry(#{Pry.view_clip(target_self)})* " diff --git a/lib/pry/pry_instance.rb b/lib/pry/pry_instance.rb index 9fc6de5b..0fa39532 100644 --- a/lib/pry/pry_instance.rb +++ b/lib/pry/pry_instance.rb @@ -301,7 +301,7 @@ class Pry else input.readline end - + rescue EOFError self.input = Readline "" diff --git a/lib/pry/version.rb b/lib/pry/version.rb index eb1c4a11..6bcc9db7 100644 --- a/lib/pry/version.rb +++ b/lib/pry/version.rb @@ -1,3 +1,3 @@ class Pry - VERSION = "0.8.0pre9" + VERSION = "0.8.0pre9" end