mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Require files from pry.rb; deps from each file that uses them
This change brings some order to how we require files. Previously, we required app files from everywhere, including pry.rb. Now we require app files only from pry.rb. External and stdlib dependencies are required at places where they're used, not globally.
This commit is contained in:
parent
03b7446d01
commit
edaa1383f2
55 changed files with 193 additions and 98 deletions
158
lib/pry.rb
158
lib/pry.rb
|
@ -1,51 +1,143 @@
|
|||
require 'pp'
|
||||
require 'pry/forwardable'
|
||||
require 'pry/input_lock'
|
||||
require 'pry/exceptions'
|
||||
require 'pry/helpers/base_helpers'
|
||||
require 'pry/hooks'
|
||||
|
||||
require 'method_source'
|
||||
require 'shellwords'
|
||||
require 'stringio'
|
||||
require 'strscan'
|
||||
require 'coderay'
|
||||
require 'pry/slop'
|
||||
require 'rbconfig'
|
||||
require 'tempfile'
|
||||
require 'pathname'
|
||||
|
||||
require 'pry/version'
|
||||
require 'pry/last_exception'
|
||||
require 'pry/input_completer'
|
||||
require 'pry/repl'
|
||||
require 'pry/code'
|
||||
require 'pry/ring'
|
||||
require 'pry/forwardable'
|
||||
|
||||
require 'pry/helpers/base_helpers'
|
||||
require 'pry/helpers/documentation_helpers'
|
||||
require 'pry/helpers'
|
||||
|
||||
require 'pry/basic_object'
|
||||
require 'pry/prompt'
|
||||
require 'pry/plugins'
|
||||
require 'pry/code_object'
|
||||
require 'pry/method'
|
||||
require 'pry/wrapped_module'
|
||||
require 'pry/history'
|
||||
require 'pry/exceptions'
|
||||
require 'pry/hooks'
|
||||
require 'pry/input_completer'
|
||||
require 'pry/command'
|
||||
require 'pry/command_set'
|
||||
require 'pry/commands'
|
||||
require 'pry/plugins'
|
||||
require 'pry/core_extensions'
|
||||
require 'pry/basic_object'
|
||||
require "pry/prompt"
|
||||
|
||||
Pry::Commands = Pry::CommandSet.new unless defined?(Pry::Commands)
|
||||
|
||||
require 'pry/commands/ls/jruby_hacks'
|
||||
require 'pry/commands/ls/methods_helper'
|
||||
require 'pry/commands/ls/interrogatable'
|
||||
require 'pry/commands/ls/grep'
|
||||
require 'pry/commands/ls/formatter'
|
||||
require 'pry/commands/ls/globals'
|
||||
require 'pry/commands/ls/constants'
|
||||
require 'pry/commands/ls/methods'
|
||||
require 'pry/commands/ls/self_methods'
|
||||
require 'pry/commands/ls/instance_vars'
|
||||
require 'pry/commands/ls/local_names'
|
||||
require 'pry/commands/ls/local_vars'
|
||||
require 'pry/commands/ls/interrogatable'
|
||||
require 'pry/commands/ls/ls_entity'
|
||||
require 'pry/commands/ls/methods_helper'
|
||||
require 'pry/commands/ls'
|
||||
|
||||
require 'pry/config/convenience'
|
||||
require 'pry/config/lazy'
|
||||
require 'pry/config/behavior'
|
||||
require 'pry/config/convenience'
|
||||
require 'pry/config'
|
||||
|
||||
require 'pry/pry_class'
|
||||
require 'pry/pry_instance'
|
||||
require 'pry/cli'
|
||||
require 'pry/inspector'
|
||||
require 'pry/color_printer'
|
||||
require 'pry/pager'
|
||||
require 'pry/terminal'
|
||||
require 'pry/editor'
|
||||
require 'pry/rubygem'
|
||||
require "pry/indent"
|
||||
require "pry/inspector"
|
||||
require 'pry/indent'
|
||||
require 'pry/object_path'
|
||||
require 'pry/output'
|
||||
require 'pry/input_lock'
|
||||
require 'pry/repl'
|
||||
require 'pry/code'
|
||||
require 'pry/ring'
|
||||
require 'pry/method'
|
||||
|
||||
require 'pry/wrapped_module'
|
||||
require 'pry/wrapped_module/candidate'
|
||||
|
||||
require 'pry/slop'
|
||||
require 'pry/cli'
|
||||
require 'pry/history'
|
||||
require 'pry/core_extensions'
|
||||
require 'pry/repl_file_loader'
|
||||
|
||||
require 'pry/code/loc'
|
||||
require 'pry/code/code_range'
|
||||
require 'pry/code/code_file'
|
||||
|
||||
require 'pry/method/weird_method_locator'
|
||||
require 'pry/method/disowned'
|
||||
require 'pry/method/patcher'
|
||||
|
||||
require 'pry/commands/amend_line'
|
||||
require 'pry/commands/bang'
|
||||
require 'pry/commands/bang_pry'
|
||||
|
||||
require 'pry/commands/cat'
|
||||
require 'pry/commands/cat/abstract_formatter.rb'
|
||||
require 'pry/commands/cat/input_expression_formatter.rb'
|
||||
require 'pry/commands/cat/exception_formatter.rb'
|
||||
require 'pry/commands/cat/file_formatter.rb'
|
||||
|
||||
require 'pry/commands/cd'
|
||||
require 'pry/commands/change_inspector'
|
||||
require 'pry/commands/change_prompt'
|
||||
require 'pry/commands/clear_screen'
|
||||
require 'pry/commands/code_collector'
|
||||
require 'pry/commands/disable_pry'
|
||||
require 'pry/commands/disabled_commands'
|
||||
require 'pry/commands/easter_eggs'
|
||||
|
||||
require 'pry/commands/edit'
|
||||
require 'pry/commands/edit/exception_patcher'
|
||||
require 'pry/commands/edit/file_and_line_locator'
|
||||
|
||||
require 'pry/commands/exit'
|
||||
require 'pry/commands/exit_all'
|
||||
require 'pry/commands/exit_program'
|
||||
require 'pry/commands/find_method'
|
||||
require 'pry/commands/fix_indent'
|
||||
require 'pry/commands/gem_cd'
|
||||
require 'pry/commands/gem_install'
|
||||
require 'pry/commands/gem_list'
|
||||
require 'pry/commands/gem_open'
|
||||
require 'pry/commands/gem_readme'
|
||||
require 'pry/commands/gem_search'
|
||||
require 'pry/commands/gem_stats'
|
||||
require 'pry/commands/gist'
|
||||
require 'pry/commands/help'
|
||||
require 'pry/commands/hist'
|
||||
require 'pry/commands/import_set'
|
||||
require 'pry/commands/install_command'
|
||||
require 'pry/commands/jump_to'
|
||||
require 'pry/commands/list_inspectors'
|
||||
|
||||
require 'pry/commands/nesting'
|
||||
require 'pry/commands/play'
|
||||
require 'pry/commands/pry_backtrace'
|
||||
require 'pry/commands/pry_version'
|
||||
require 'pry/commands/raise_up'
|
||||
require 'pry/commands/reload_code'
|
||||
require 'pry/commands/reset'
|
||||
require 'pry/commands/ri'
|
||||
require 'pry/commands/save_file'
|
||||
require 'pry/commands/shell_command'
|
||||
require 'pry/commands/shell_mode'
|
||||
require 'pry/commands/show_info'
|
||||
require 'pry/commands/show_doc'
|
||||
require 'pry/commands/show_input'
|
||||
require 'pry/commands/show_source'
|
||||
require 'pry/commands/stat'
|
||||
require 'pry/commands/switch_to'
|
||||
require 'pry/commands/toggle_color'
|
||||
|
||||
require 'pry/commands/watch_expression'
|
||||
require 'pry/commands/watch_expression/expression.rb'
|
||||
|
||||
require 'pry/commands/whereami'
|
||||
require 'pry/commands/wtf'
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'stringio'
|
||||
|
||||
class Pry
|
||||
# Manage the processing of command line options
|
||||
class CLI
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
require 'pry/code/loc'
|
||||
require 'pry/code/code_range'
|
||||
require 'pry/code/code_file'
|
||||
require 'coderay'
|
||||
require 'method_source'
|
||||
|
||||
class Pry
|
||||
class << self
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'method_source'
|
||||
|
||||
class Pry
|
||||
class CodeFile
|
||||
DEFAULT_EXT = '.rb'.freeze
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'coderay'
|
||||
|
||||
class Pry
|
||||
class Code
|
||||
# Represents a range of lines in a code listing.
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'coderay'
|
||||
|
||||
class Pry
|
||||
class Code
|
||||
# Represents a line of code (which may, in fact, contain multiple lines if
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
require 'pp'
|
||||
require 'coderay'
|
||||
|
||||
# PP subclass for streaming inspect output in color.
|
||||
class Pry
|
||||
class ColorPrinter < ::PP
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'delegate'
|
||||
require 'pry/helpers/documentation_helpers'
|
||||
require 'shellwords'
|
||||
|
||||
class Pry
|
||||
# The super-class of all commands, new commands should be created by calling
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
# Default commands used by Pry.
|
||||
Pry::Commands = Pry::CommandSet.new
|
||||
|
||||
Dir[File.expand_path('../commands', __FILE__) << '/*.rb'].each do |file|
|
||||
require file
|
||||
end
|
|
@ -1,11 +1,6 @@
|
|||
class Pry
|
||||
class Command
|
||||
class Cat < Pry::ClassCommand
|
||||
require 'pry/commands/cat/abstract_formatter.rb'
|
||||
require 'pry/commands/cat/input_expression_formatter.rb'
|
||||
require 'pry/commands/cat/exception_formatter.rb'
|
||||
require 'pry/commands/cat/file_formatter.rb'
|
||||
|
||||
match 'cat'
|
||||
group 'Input and Output'
|
||||
description "Show code from a file, Pry's input buffer, or the last exception."
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
class Pry
|
||||
class Command
|
||||
class Edit < Pry::ClassCommand
|
||||
require 'pry/commands/edit/exception_patcher'
|
||||
require 'pry/commands/edit/file_and_line_locator'
|
||||
|
||||
match 'edit'
|
||||
group 'Editing'
|
||||
description 'Invoke the default editor on a file.'
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
require 'pry/commands/ls/ls_entity'
|
||||
class Pry
|
||||
class Command
|
||||
class Ls < Pry::ClassCommand
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
require 'pry/commands/ls/interrogatable'
|
||||
|
||||
class Pry
|
||||
class Command
|
||||
class Ls < Pry::ClassCommand
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
require 'pry/commands/ls/interrogatable'
|
||||
|
||||
class Pry
|
||||
class Command
|
||||
class Ls < Pry::ClassCommand
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class Pry
|
||||
class Command
|
||||
class Ls
|
||||
class Ls < Pry::ClassCommand
|
||||
module Interrogatable
|
||||
private
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class Pry
|
||||
class Command
|
||||
class Ls
|
||||
class Ls < Pry::ClassCommand
|
||||
module JRubyHacks
|
||||
private
|
||||
|
||||
|
|
|
@ -1,13 +1,3 @@
|
|||
require 'pry/commands/ls/grep'
|
||||
require 'pry/commands/ls/formatter'
|
||||
require 'pry/commands/ls/globals'
|
||||
require 'pry/commands/ls/constants'
|
||||
require 'pry/commands/ls/methods'
|
||||
require 'pry/commands/ls/self_methods'
|
||||
require 'pry/commands/ls/instance_vars'
|
||||
require 'pry/commands/ls/local_names'
|
||||
require 'pry/commands/ls/local_vars'
|
||||
|
||||
class Pry
|
||||
class Command
|
||||
class Ls < Pry::ClassCommand
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
require 'pry/commands/ls/methods_helper'
|
||||
require 'pry/commands/ls/interrogatable'
|
||||
|
||||
class Pry
|
||||
class Command
|
||||
class Ls < Pry::ClassCommand
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
require 'pry/commands/ls/jruby_hacks'
|
||||
|
||||
class Pry
|
||||
class Command
|
||||
class Ls
|
||||
class Ls < Pry::ClassCommand
|
||||
module MethodsHelper
|
||||
include Pry::Command::Ls::JRubyHacks
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
require 'pry/commands/ls/interrogatable'
|
||||
require 'pry/commands/ls/methods_helper'
|
||||
|
||||
class Pry
|
||||
class Command
|
||||
class Ls < Pry::ClassCommand
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'stringio'
|
||||
|
||||
class Pry
|
||||
class Command
|
||||
class Ri < Pry::ClassCommand
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
require 'pry/commands/code_collector'
|
||||
|
||||
class Pry
|
||||
class Command
|
||||
class SaveFile < Pry::ClassCommand
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
require 'pry/commands/show_info'
|
||||
|
||||
class Pry
|
||||
class Command
|
||||
class ShowDoc < Command::ShowInfo
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
require 'pry/commands/show_info'
|
||||
|
||||
class Pry
|
||||
class Command
|
||||
class ShowSource < Command::ShowInfo
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
class Pry
|
||||
class Command
|
||||
class WatchExpression < Pry::ClassCommand
|
||||
require 'pry/commands/watch_expression/expression.rb'
|
||||
|
||||
match 'watch'
|
||||
group 'Context'
|
||||
description 'Watch the value of an expression and print a notification ' \
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'method_source'
|
||||
|
||||
class Pry
|
||||
class Command
|
||||
class Whereami < Pry::ClassCommand
|
||||
|
|
|
@ -54,7 +54,7 @@ class Pry
|
|||
'[warning] Pry.config.exception_whitelist is deprecated, ' \
|
||||
'please use Pry.config.unrescued_exceptions instead.'
|
||||
)
|
||||
Pry::DEFAULT_UNRESCUED_EXCEPTIONS
|
||||
[::SystemExit, ::SignalException, Pry::TooSafeException]
|
||||
end,
|
||||
|
||||
# The default hooks - display messages when beginning and ending Pry
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'shellwords'
|
||||
|
||||
class Pry
|
||||
class Editor
|
||||
include Pry::Helpers::CommandHelpers
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'coderay'
|
||||
|
||||
class Pry
|
||||
module Helpers
|
||||
module BaseHelpers
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'tempfile'
|
||||
|
||||
class Pry
|
||||
module Helpers
|
||||
# rubocop:disable Metrics/ModuleLength
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'coderay'
|
||||
|
||||
class Pry
|
||||
module Helpers
|
||||
# This class contains methods useful for extracting
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'rbconfig'
|
||||
|
||||
class Pry
|
||||
module Helpers
|
||||
# Contains methods for querying the platform that Pry is running on
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require 'pry/helpers/documentation_helpers'
|
||||
require 'coderay'
|
||||
require 'method_source'
|
||||
|
||||
class Pry
|
||||
class << self
|
||||
|
@ -16,10 +17,6 @@ class Pry
|
|||
# This class wraps the normal `Method` and `UnboundMethod` classes
|
||||
# to provide extra functionality useful to Pry.
|
||||
class Method # rubocop:disable Metrics/ClassLength
|
||||
require 'pry/method/weird_method_locator'
|
||||
require 'pry/method/disowned'
|
||||
require 'pry/method/patcher'
|
||||
|
||||
extend Helpers::BaseHelpers
|
||||
include Helpers::BaseHelpers
|
||||
include Helpers::DocumentationHelpers
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'strscan'
|
||||
|
||||
class Pry
|
||||
# `ObjectPath` implements the resolution of "object paths", which are strings
|
||||
# that are similar to filesystem paths but meant for traversing Ruby objects.
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
require 'pry/terminal'
|
||||
|
||||
# A pager is an `IO`-like object that accepts text and either prints it
|
||||
# immediately, prints it one page at a time, or streams it to an external
|
||||
# program to print one page at a time.
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
require 'stringio'
|
||||
require 'pathname'
|
||||
|
||||
class Pry
|
||||
HOME_RC_FILE =
|
||||
if ENV.key?('PRYRC')
|
||||
|
@ -212,7 +215,6 @@ you can add "Pry.config.windows_console_warning = false" to your pryrc.
|
|||
# Execute the file through the REPL loop, non-interactively.
|
||||
# @param [String] file_name File name to load through the REPL.
|
||||
def self.load_file_through_repl(file_name)
|
||||
require "pry/repl_file_loader"
|
||||
REPLFileLoader.new(file_name).load
|
||||
end
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'method_source'
|
||||
|
||||
##
|
||||
# Pry is a powerful alternative to the standard IRB shell for Ruby. It
|
||||
# features syntax highlighting, a flexible plugin architecture, runtime
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'stringio'
|
||||
|
||||
class Pry
|
||||
module Testable
|
||||
module Mockable
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'stringio'
|
||||
|
||||
class Pry
|
||||
module Testable
|
||||
class PryTester
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'tempfile'
|
||||
|
||||
class Pry
|
||||
module Testable
|
||||
module Utility
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
require 'pry/wrapped_module/candidate'
|
||||
|
||||
class Pry
|
||||
class << self
|
||||
# If the given object is a `Pry::WrappedModule`, return it unaltered. If it's
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
require 'pry/helpers/documentation_helpers'
|
||||
|
||||
class Pry
|
||||
class WrappedModule
|
||||
# This class represents a single candidate for a module/class definition.
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'method_source'
|
||||
|
||||
describe Pry::Code do
|
||||
describe '.from_file' do
|
||||
specify 'read lines from a file on disk' do
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'tempfile'
|
||||
|
||||
describe "cat" do
|
||||
before do
|
||||
@str_output = StringIO.new
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require 'pathname'
|
||||
require 'tempfile'
|
||||
|
||||
describe "edit" do
|
||||
before do
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'tempfile'
|
||||
|
||||
describe "save-file" do
|
||||
before do
|
||||
@tf = Tempfile.new(["pry", ".py"])
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'method_source'
|
||||
|
||||
describe "whereami" do
|
||||
it 'should work with methods that have been undefined' do
|
||||
class Cor
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require 'tempfile'
|
||||
require 'rbconfig'
|
||||
|
||||
describe Pry do
|
||||
before do
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'rbconfig'
|
||||
|
||||
RSpec.describe 'Bundler' do
|
||||
let(:ruby) { RbConfig.ruby.shellescape }
|
||||
let(:pry_dir) { File.expand_path(File.join(__FILE__, '../../../lib')).shellescape }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'rbconfig'
|
||||
|
||||
RSpec.describe 'The bin/pry CLI' do
|
||||
let(:ruby) { RbConfig.ruby.shellescape }
|
||||
let(:pry_dir) { File.expand_path(File.join(__FILE__, '../../../lib')).shellescape }
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require "shellwords"
|
||||
require 'rbconfig'
|
||||
|
||||
RSpec.describe "Hanami integration" do
|
||||
before :all do
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# REPL is started.
|
||||
|
||||
require "shellwords"
|
||||
require 'rbconfig'
|
||||
|
||||
RSpec.describe "Readline" do
|
||||
before :all do
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'coderay'
|
||||
|
||||
describe "Pry::Pager" do
|
||||
describe "PageTracker" do
|
||||
before do
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'coderay'
|
||||
|
||||
describe Pry do
|
||||
describe "output failsafe" do
|
||||
after { Pry.config.print = Pry::Config.defaults.print }
|
||||
|
|
|
@ -8,6 +8,7 @@ require 'rspec'
|
|||
|
||||
require 'pry/testable'
|
||||
require 'English'
|
||||
require 'stringio'
|
||||
|
||||
Dir['./spec/support/**/*.rb'].map do |file|
|
||||
require file
|
||||
|
|
Loading…
Add table
Reference in a new issue