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

4 commits

Author SHA1 Message Date
Kyrylo Silin
4b6fc303bb config: simplify structure
* Replace `require_relative` with `require`
  The project tries to use the `require` form everywhere where possible, which
  is the common form
* `require` from `pry.rb`
  Spreaded `require` statements where we require internal classes is confusing
* Fixed namespace definition for Config classes
  https://github.com/rubocop-hq/ruby-style-guide#namespace-definition recommends
  to use explicit nesting
2018-10-28 17:45:29 +08:00
Ryan Fitzgerald
7bf25494e2 Fix delegation of quiet? config method (fix #1261)
Because we were defining `quiet?` on Pry::Config::Default, calls to it
would always delegate to the default config object and then return
false. To make it possible to enable quiet mode, we need the
transformation from `quiet?` to `quiet` to happen earlier. The simplest
way to accomplish this is just to define the `quiet?` method explicitly.
2014-07-06 16:38:13 -07:00
Robert Gleeson
325016eb3a fix the failing Pry#prompt specs.
this is a strange and odd case. Pry.prompt is a delegate to Pry.config, as
it has always been. the same delegate was setup on an instance of Pry, but
never used because we define #prompt and #prompt= with our implementation.

the thing that would make the most sense (to me) is to not support Pry.prompt
anymore and recommend the use of Pry.config.prompt instead. a lot of code relies
on Pry.prompt though, so we have to support the delegate to config and implement
custom behavior for the pry instance.
2014-01-21 09:13:26 +01:00
Robert Gleeson
5db725eca6 implement Pry global and pry-local configuration.
maybe best explained with an example:
      [1] pry(main)> Pry.config.hi = "hi"
      => "hi"
      [2] pry(main)> _pry_.config.hi
      => "hi"
      [3] pry(main)> _pry_.config.x = 1
      => 1
      [4] pry(main)> Pry.config.x
      => nil
      [5] pry(main)>

'Pry.config' is an instance of Pry::Config::Default. it defines the initial
default configuration values an instance of 'Pry' is going to have. an instance
of 'Pry' uses an instance of Pry::Config who relies on Pry.config as a default
or fallback for keys it cannot find locally.

for example 'Pry.config.color = true' is seen by _all_ pry REPLs who are active
but _pry_.config.color = false is seen only by the REPL session being interacted
with. a number of "config shortcircuts" are still available, for example it is
possible to say `_pry_.input = StringIO.new` or `Pry.input = StringIO.new`. the
shortcuts are maintained for the Pry class and instances of the Pry class through
Pry::Config.shortcuts.

Pry::Config::Convenience adds a method called 'config_shortcuts' which can be used
to setup shortcut access to 'some_obj.config.blah' as 'some_obj.blah'

a lot of tests still fail, so work in progress.

this should help solve #1055.
2014-01-19 03:18:46 +01:00