From 91d412c044f174a2c50d1583a3f34c1f0f795e7d Mon Sep 17 00:00:00 2001 From: Robert Gleeson Date: Tue, 21 Jan 2014 11:11:42 +0100 Subject: [PATCH] remove openstruct dependency from all of pry. --- lib/pry.rb | 2 +- lib/pry/command.rb | 2 +- lib/pry/plugins.rb | 2 +- lib/pry/pry_instance.rb | 4 ++-- spec/helper.rb | 2 +- spec/prompt_spec.rb | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/pry.rb b/lib/pry.rb index 845b81e2..5fd42609 100644 --- a/lib/pry.rb +++ b/lib/pry.rb @@ -102,7 +102,7 @@ class Pry else # Otherwise, saves current binding stack as old stack and pops last # binding out of binding stack (the old stack still has that binding). - _pry_.command_state["cd"] ||= OpenStruct.new # FIXME + _pry_.command_state["cd"] ||= Pry::Config.from_hash({}) # FIXME _pry_.command_state['cd'].old_stack = _pry_.binding_stack.dup _pry_.binding_stack.pop end diff --git a/lib/pry/command.rb b/lib/pry/command.rb index 77d9f9b8..0527ade7 100644 --- a/lib/pry/command.rb +++ b/lib/pry/command.rb @@ -284,7 +284,7 @@ class Pry # state.my_state = "my state" # this will not conflict with any # # `state.my_state` used in another command. def state - _pry_.command_state[match] ||= OpenStruct.new + _pry_.command_state[match] ||= Pry::Config.from_hash({}) end # Revaluate the string (str) and perform interpolation. diff --git a/lib/pry/plugins.rb b/lib/pry/plugins.rb index e9bce09a..0813be35 100644 --- a/lib/pry/plugins.rb +++ b/lib/pry/plugins.rb @@ -43,7 +43,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.gsub('-', '_')}=", OpenStruct.new) + Pry.config.send("#{gem_name.gsub('-', '_')}=", Pry::Config.from_hash({})) begin require gem_name if !active? diff --git a/lib/pry/pry_instance.rb b/lib/pry/pry_instance.rb index e2b287e6..647bc960 100644 --- a/lib/pry/pry_instance.rb +++ b/lib/pry/pry_instance.rb @@ -522,7 +522,7 @@ class Pry open_token = @indent.open_delimiters.any? ? @indent.open_delimiters.last : @indent.stack.last - c = OpenStruct.new( + c = Pry::Config.from_hash({ :object => object, :nesting_level => binding_stack.size - 1, :open_token => open_token, @@ -533,7 +533,7 @@ class Pry :binding_stack => binding_stack, :input_array => input_array, :eval_string => @eval_string, - :cont => !@eval_string.empty?) + :cont => !@eval_string.empty?}) Pry.critical_section do # If input buffer is empty then use normal prompt diff --git a/spec/helper.rb b/spec/helper.rb index f48fc108..60193949 100644 --- a/spec/helper.rb +++ b/spec/helper.rb @@ -9,7 +9,7 @@ unless Object.const_defined? 'Pry' end require 'mocha/api' - +require "ostruct" require 'pry/test/helper' require 'spec_helpers/bacon' require 'spec_helpers/mock_pry' diff --git a/spec/prompt_spec.rb b/spec/prompt_spec.rb index 5de2a442..b7aa79a5 100644 --- a/spec/prompt_spec.rb +++ b/spec/prompt_spec.rb @@ -7,7 +7,7 @@ describe "Prompts" do redirect_pry_io(InputTester.new("exit-all")) do Pry.start(self, :prompt => proc { |v| config = v }) end - config.is_a?(OpenStruct).should == true + config.is_a?(Pry::Config).should == true end it 'should get full config object, when using a proc array' do @@ -15,7 +15,7 @@ describe "Prompts" do redirect_pry_io(InputTester.new("exit-all")) do Pry.start(self, :prompt => [proc { |v| config1 = v }, proc { |v| config2 = v }]) end - config1.is_a?(OpenStruct).should == true + config1.is_a?(Pry::Config).should == true end it 'should receive correct data in the config object' do