summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyrylo Silin <silin@kyrylo.org>2019-04-30 00:48:35 +0300
committerKyrylo Silin <silin@kyrylo.org>2019-04-30 01:28:28 +0300
commit1e2cfbb7f9d7f2cc3e46dd7ab96bf6b4ee151f56 (patch)
tree46b88fa2e7eda94711e1b88d2fb557bf0c7a479c
parentaf1c0664df0fc043ba27b32f6b7d376ab7bae6a9 (diff)
downloadpry-1e2cfbb7f9d7f2cc3e46dd7ab96bf6b4ee151f56.tar.gz
Reduce the influence of Pry::Config
This is one of preliminary steps for #1843 (Rework the Pry config). In this commit we replace calls to `Pry::Config` where possible, therefore we reduce coupling between the config and other components.
-rw-r--r--lib/pry/inspector.rb2
-rw-r--r--lib/pry/plugins.rb4
-rw-r--r--lib/pry/pry_class.rb2
-rw-r--r--lib/pry/pry_instance.rb3
-rw-r--r--spec/commands/cd_spec.rb2
-rw-r--r--spec/hooks_spec.rb2
-rw-r--r--spec/spec_helper.rb5
7 files changed, 11 insertions, 9 deletions
diff --git a/lib/pry/inspector.rb b/lib/pry/inspector.rb
index afe58690..ee993018 100644
--- a/lib/pry/inspector.rb
+++ b/lib/pry/inspector.rb
@@ -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.
diff --git a/lib/pry/plugins.rb b/lib/pry/plugins.rb
index 22a7f2dd..56a1bed8 100644
--- a/lib/pry/plugins.rb
+++ b/lib/pry/plugins.rb
@@ -1,3 +1,5 @@
+require 'ostruct'
+
class Pry
class PluginManager
PRY_PLUGIN_PREFIX = /^pry-/.freeze
@@ -57,7 +59,7 @@ class Pry
# 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?
diff --git a/lib/pry/pry_class.rb b/lib/pry/pry_class.rb
index 3489b9b8..a58e8bab 100644
--- a/lib/pry/pry_class.rb
+++ b/lib/pry/pry_class.rb
@@ -81,7 +81,7 @@ class Pry
# 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`
diff --git a/lib/pry/pry_instance.rb b/lib/pry/pry_instance.rb
index e1309ce9..03840142 100644
--- a/lib/pry/pry_instance.rb
+++ b/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
@@ -537,7 +538,7 @@ class Pry
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,
diff --git a/spec/commands/cd_spec.rb b/spec/commands/cd_spec.rb
index 38830ace..ae715a3a 100644
--- a/spec/commands/cd_spec.rb
+++ b/spec/commands/cd_spec.rb
@@ -129,7 +129,7 @@ describe 'cd' do
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 -'
diff --git a/spec/hooks_spec.rb b/spec/hooks_spec.rb
index 5ee30b80..465ed236 100644
--- a/spec/hooks_spec.rb
+++ b/spec/hooks_spec.rb
@@ -411,7 +411,7 @@ describe Pry::Hooks do
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
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index a0b0c848..b6111e27 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -9,6 +9,7 @@ require 'rspec'
require 'pry/testable'
require 'English'
require 'stringio'
+require 'ostruct'
Dir['./spec/support/**/*.rb'].map do |file|
require file
@@ -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"]