Skip to content

Commit

Permalink
Merge pull request #2021 from pry/config-influence-reduction
Browse files Browse the repository at this point in the history
Reduce the influence of Pry::Config
  • Loading branch information
kyrylo committed Apr 29, 2019
2 parents af1c066 + 1e2cfbb commit 03afca9
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/pry/inspector.rb
Expand Up @@ -2,7 +2,7 @@ class Pry
class Inspector
MAP = {
"default" => {
value: Pry::Config.defaults.print,
value: Pry.config.print,
description: <<-DESCRIPTION.each_line.map(&:lstrip!)
The default Pry inspector. It has paging and color support, and uses
pretty_inspect when printing an object.
Expand Down
4 changes: 3 additions & 1 deletion lib/pry/plugins.rb
@@ -1,3 +1,5 @@
require 'ostruct'

class Pry
class PluginManager
PRY_PLUGIN_PREFIX = /^pry-/.freeze
Expand Down Expand Up @@ -57,7 +59,7 @@ def load_cli_options
# Does not reload plugin if it's already active.
def activate!
# Create the configuration object for the plugin.
Pry.config.send("#{gem_name.tr('-', '_')}=", Pry::Config.from_hash({}))
Pry.config.send("#{gem_name.tr('-', '_')}=", OpenStruct.new)

begin
require gem_name unless active?
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/pry_class.rb
Expand Up @@ -81,7 +81,7 @@ def self.main
# Returns a value store for an instance of Pry running on the current thread.
#
def self.current
Thread.current[:__pry__] ||= Pry::Config.from_hash({})
Thread.current[:__pry__] ||= {}
end

# Load the given file in the context of `Pry.toplevel_binding`
Expand Down
3 changes: 2 additions & 1 deletion lib/pry/pry_instance.rb
@@ -1,4 +1,5 @@
require 'method_source'
require 'ostruct'

##
# Pry is a powerful alternative to the standard IRB shell for Ruby. It
Expand Down Expand Up @@ -537,7 +538,7 @@ def select_prompt
object = current_binding.eval('self')
open_token = @indent.open_delimiters.last || @indent.stack.last

c = Pry::Config.assign(
c = OpenStruct.new(
object: object,
nesting_level: binding_stack.size - 1,
open_token: open_token,
Expand Down
2 changes: 1 addition & 1 deletion spec/commands/cd_spec.rb
Expand Up @@ -129,7 +129,7 @@ def old_stack
describe 'when using ^D (Control-D) key press' do
it 'should keep correct old binding' do
@t.eval 'cd :john_dogg', 'cd :mon_dogg', 'cd :kyr_dogg',
'Pry::Config.defaults.control_d_handler.call("", pry_instance)'
'Pry.config.control_d_handler.call("", pry_instance)'
expect(@t.mapped_binding_stack).to eq [@o, :john_dogg, :mon_dogg]

@t.eval 'cd -'
Expand Down
2 changes: 1 addition & 1 deletion spec/hooks_spec.rb
Expand Up @@ -411,7 +411,7 @@ class << o; attr_accessor :value; end

describe "after_session hook" do
it 'should always run, even if uncaught exception bubbles out of repl' do
o = Pry::Config.new
o = OpenStruct.new
o.great_escape = Class.new(StandardError)

old_ew = Pry.config.unrescued_exceptions
Expand Down
5 changes: 2 additions & 3 deletions spec/spec_helper.rb
Expand Up @@ -9,6 +9,7 @@
require 'pry/testable'
require 'English'
require 'stringio'
require 'ostruct'

Dir['./spec/support/**/*.rb'].map do |file|
require file
Expand All @@ -22,9 +23,7 @@ class Module
# rubocop:enable Style/AccessModifierDeclarations
end

Pad = Class.new do
include Pry::Config::Behavior
end.new(nil)
Pad = OpenStruct.new

# to help with tracking down bugs that cause an infinite loop in the test suite
if ENV["SET_TRACE_FUNC"]
Expand Down

0 comments on commit 03afca9

Please sign in to comment.