diff --git a/CHANGELOG.md b/CHANGELOG.md index 12f1d17c..fb81f7f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ### HEAD +* Add `Pry.configure` as an alternative to the current way of changing configuration options in `.pryrc` files. * Remove Slop as a runtime dependency by vendoring v3.4 as Pry::Slop. People can depend on Slop v4 and Pry at the same time without running into version conflicts. ([#1497](https://github.com/pry/pry/issues/1497)) * Fix auto-indentation of code that uses a single-line rescue ([#1450](https://github.com/pry/pry/issues/1450)) diff --git a/lib/pry/pry_class.rb b/lib/pry/pry_class.rb index 8f44e82d..8f98af4b 100644 --- a/lib/pry/pry_class.rb +++ b/lib/pry/pry_class.rb @@ -32,6 +32,14 @@ class Pry def history @history ||= History.new end + + # + # @return [void] + # Yields a block with {Pry.config} as its argument. + # + def configure + yield config + end end # diff --git a/spec/pry_spec.rb b/spec/pry_spec.rb index fdc85856..a52871d0 100644 --- a/spec/pry_spec.rb +++ b/spec/pry_spec.rb @@ -5,6 +5,15 @@ describe Pry do @str_output = StringIO.new end + describe "Pry.configure" do + it "yields a block with Pry.config as its argument" do + Pry.configure do |config| + config.foo = "bar" + end + expect(Pry.config.foo).to eq("bar") + end + end + describe "Exotic object support" do # regression test for exotic object support it "Should not error when return value is a BasicObject instance" do