1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Remove define of Pry class attributes from lib/pry/pry_class.rb to lib/pry.rb . pry/commands and Pry.config have circular-dependency. In rare case (c.f . #978) Pry.config is initialized not properly. We will fix this bug by this commit.

This commit is contained in:
yui-knk 2013-12-10 12:41:31 +09:00
parent dacafb80a8
commit 6d3f89439c
2 changed files with 51 additions and 50 deletions

View file

@ -120,6 +120,57 @@ class Pry
# IRB = Pry thing.
module ExtendCommandBundle; end
# class accessors
# define class attributes before pry library is required
# fix initialize step of Pry (#1037)
class << self
extend Forwardable
# convenience method
def self.delegate_accessors(delagatee, *names)
def_delegators delagatee, *names
def_delegators delagatee, *names.map { |v| "#{v}=" }
end
# Get/Set the Proc that defines extra Readline completions (on top
# of the ones defined for IRB).
# @return [Proc] The Proc that defines extra Readline completions (on top
# @example Add file names to completion list
# Pry.custom_completions = proc { Dir.entries('.') }
attr_accessor :custom_completions
# @return [Fixnum] The current input line.
attr_accessor :current_line
# @return [Array] The Array of evaluated expressions.
attr_accessor :line_buffer
# @return [String] The __FILE__ for the `eval()`. Should be "(pry)"
# by default.
attr_accessor :eval_path
# @return [OpenStruct] Return Pry's config object.
attr_accessor :config
# @return [History] Return Pry's line history object.
attr_accessor :history
# @return [Boolean] Whether Pry was activated from the command line.
attr_accessor :cli
# @return [Boolean] Whether Pry sessions are quiet by default.
attr_accessor :quiet
# @return [Exception, nil] The last pry internal error.
# (a CommandError in most cases)
attr_accessor :last_internal_error
# plugin forwardables
def_delegators :@plugin_manager, :plugins, :load_plugins, :locate_plugins
delegate_accessors :@config, :input, :output, :commands, :prompt, :print, :exception_handler,
:hooks, :color, :pager, :editor, :memory_size, :extra_sticky_locals
end
end
if Pry::Helpers::BaseHelpers.mri_18?

View file

@ -13,56 +13,6 @@ class Pry
Thread.current[:__pry__] ||= {}
end
# class accessors
class << self
extend Forwardable
# convenience method
def self.delegate_accessors(delagatee, *names)
def_delegators delagatee, *names
def_delegators delagatee, *names.map { |v| "#{v}=" }
end
# Get/Set the Proc that defines extra Readline completions (on top
# of the ones defined for IRB).
# @return [Proc] The Proc that defines extra Readline completions (on top
# @example Add file names to completion list
# Pry.custom_completions = proc { Dir.entries('.') }
attr_accessor :custom_completions
# @return [Fixnum] The current input line.
attr_accessor :current_line
# @return [Array] The Array of evaluated expressions.
attr_accessor :line_buffer
# @return [String] The __FILE__ for the `eval()`. Should be "(pry)"
# by default.
attr_accessor :eval_path
# @return [OpenStruct] Return Pry's config object.
attr_accessor :config
# @return [History] Return Pry's line history object.
attr_accessor :history
# @return [Boolean] Whether Pry was activated from the command line.
attr_accessor :cli
# @return [Boolean] Whether Pry sessions are quiet by default.
attr_accessor :quiet
# @return [Exception, nil] The last pry internal error.
# (a CommandError in most cases)
attr_accessor :last_internal_error
# plugin forwardables
def_delegators :@plugin_manager, :plugins, :load_plugins, :locate_plugins
delegate_accessors :@config, :input, :output, :commands, :prompt, :print, :exception_handler,
:hooks, :color, :pager, :editor, :memory_size, :extra_sticky_locals
end
# Load the given file in the context of `Pry.toplevel_binding`
# @param [String] file_name The unexpanded file path.
def self.load_file_at_toplevel(file)