diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pry/config.rb | 19 | ||||
-rw-r--r-- | lib/pry/pry_class.rb | 2 |
2 files changed, 9 insertions, 12 deletions
diff --git a/lib/pry/config.rb b/lib/pry/config.rb index 48c4089d..0c6a0edc 100644 --- a/lib/pry/config.rb +++ b/lib/pry/config.rb @@ -301,17 +301,14 @@ class Pry end def default_rc_file - if (pryrc = Pry::Env['PRYRC']) - pryrc - elsif (xdg_home = Pry::Env['XDG_CONFIG_HOME']) - # See XDG Base Directory Specification at - # https://standards.freedesktop.org/basedir-spec/basedir-spec-0.8.html - xdg_home + '/pry/pryrc' - elsif File.exist?(File.expand_path('~/.pryrc')) - '~/.pryrc' - else - '~/.config/pry/pryrc' - end + [Pry::Env['PRYRC'], + # See XDG Base Directory Specification at + # https://specifications.freedesktop.org/basedir-spec/latest/ + "#{Pry::Env['XDG_CONFIG_HOME']}/pry/pryrc", + File.expand_path('~/.pryrc'), + File.expand_path('~/.config/pry/pryrc')] + .compact + .find { |file| File.exist?(file) } end end end diff --git a/lib/pry/pry_class.rb b/lib/pry/pry_class.rb index 118102dd..651cf67e 100644 --- a/lib/pry/pry_class.rb +++ b/lib/pry/pry_class.rb @@ -85,7 +85,7 @@ class Pry # Load the local RC file (./.pryrc) def self.rc_files_to_load files = [] - files << Pry.config.rc_file if Pry.config.should_load_rc + files << Pry.config.rc_file if Pry.config.rc_file && Pry.config.should_load_rc files << LOCAL_RC_FILE if Pry.config.should_load_local_rc files.map { |file| real_path_to(file) }.compact.uniq end |