mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
config: simplify structure
* Replace `require_relative` with `require` The project tries to use the `require` form everywhere where possible, which is the common form * `require` from `pry.rb` Spreaded `require` statements where we require internal classes is confusing * Fixed namespace definition for Config classes https://github.com/rubocop-hq/ruby-style-guide#namespace-definition recommends to use explicit nesting
This commit is contained in:
parent
7608ff1523
commit
4b6fc303bb
7 changed files with 475 additions and 455 deletions
|
@ -113,6 +113,12 @@ require 'pry/command_set'
|
|||
require 'pry/commands'
|
||||
require 'pry/plugins'
|
||||
require 'pry/core_extensions'
|
||||
require 'pry/basic_object'
|
||||
require 'pry/config/behavior'
|
||||
require 'pry/config/memoization'
|
||||
require 'pry/config/default'
|
||||
require 'pry/config/convenience'
|
||||
require 'pry/config'
|
||||
require 'pry/pry_class'
|
||||
require 'pry/pry_instance'
|
||||
require 'pry/cli'
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
require_relative 'basic_object'
|
||||
class Pry::Config < Pry::BasicObject
|
||||
require_relative 'config/behavior'
|
||||
require_relative 'config/memoization'
|
||||
require_relative 'config/default'
|
||||
require_relative 'config/convenience'
|
||||
include Pry::Config::Behavior
|
||||
class Pry
|
||||
class Config < Pry::BasicObject
|
||||
include Behavior
|
||||
|
||||
def self.shortcuts
|
||||
Convenience::SHORTCUTS
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
module Pry::Config::Behavior
|
||||
class Pry
|
||||
class Config < Pry::BasicObject
|
||||
module Behavior
|
||||
ASSIGNMENT = "=".freeze
|
||||
NODUP = [TrueClass, FalseClass, NilClass, Symbol, Numeric, Module, Proc].freeze
|
||||
INSPECT_REGEXP = /#{Regexp.escape "default=#<"}/
|
||||
|
@ -212,6 +214,7 @@ module Pry::Config::Behavior
|
|||
end
|
||||
|
||||
private
|
||||
|
||||
def __clip_inspect(obj)
|
||||
"#{obj.class}:0x%x" % obj.object_id
|
||||
end
|
||||
|
@ -248,3 +251,5 @@ private
|
|||
@lookup.delete(key)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
module Pry::Config::Convenience
|
||||
class Pry
|
||||
class Config < Pry::BasicObject
|
||||
module Convenience
|
||||
SHORTCUTS = [
|
||||
:input,
|
||||
:output,
|
||||
|
@ -13,7 +15,6 @@ module Pry::Config::Convenience
|
|||
:extra_sticky_locals
|
||||
]
|
||||
|
||||
|
||||
def config_shortcut(*names)
|
||||
names.each do |name|
|
||||
reader = name
|
||||
|
@ -23,3 +24,5 @@ module Pry::Config::Convenience
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
class Pry::Config::Default
|
||||
include Pry::Config::Behavior
|
||||
include Pry::Config::Memoization
|
||||
class Pry
|
||||
class Config < Pry::BasicObject
|
||||
class Default
|
||||
include Config::Behavior
|
||||
include Config::Memoization
|
||||
|
||||
def_memoized({
|
||||
input: proc {
|
||||
|
@ -135,6 +137,7 @@ class Pry::Config::Default
|
|||
end
|
||||
|
||||
private
|
||||
|
||||
def lazy_readline
|
||||
require 'readline'
|
||||
Readline
|
||||
|
@ -147,3 +150,5 @@ class Pry::Config::Default
|
|||
raise
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
module Pry::Config::Memoization
|
||||
class Pry
|
||||
class Config < Pry::BasicObject
|
||||
module Memoization
|
||||
MEMOIZED_METHODS = Hash.new {|h,k| h[k] = [] }
|
||||
|
||||
module ClassMethods
|
||||
|
@ -42,3 +44,5 @@ module Pry::Config::Memoization
|
|||
MEMOIZED_METHODS[self.class]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
require 'pry/config'
|
||||
class Pry
|
||||
|
||||
HOME_RC_FILE =
|
||||
|
|
Loading…
Reference in a new issue