mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
whitespace cleanup in one hit
This commit is contained in:
parent
02668e07f9
commit
3ff75dd20a
10 changed files with 50 additions and 50 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<page break> --- Press enter to continue ( q<enter> to break ) --- <page break>"
|
||||
output.puts "\n<page break> --- Press enter to continue ( q<enter> to break ) --- <page 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
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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__')
|
||||
|
|
|
@ -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)})* "
|
||||
|
|
|
@ -301,7 +301,7 @@ class Pry
|
|||
else
|
||||
input.readline
|
||||
end
|
||||
|
||||
|
||||
rescue EOFError
|
||||
self.input = Readline
|
||||
""
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
class Pry
|
||||
VERSION = "0.8.0pre9"
|
||||
VERSION = "0.8.0pre9"
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue