summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklin Yu <franklinyu@hotmail.com>2017-05-16 15:39:21 -0400
committerFranklin Yu <franklinyu@hotmail.com>2018-10-09 21:08:07 -0400
commita0be0cc7b2070edff61c0c7f10fa37fce9b730bd (patch)
tree87331f3847109263c427b46fb00b7eb31646b2cb
parentbaa29048cf13f04e4066b8794191cfb31279f01c (diff)
downloadpry-a0be0cc7b2070edff61c0c7f10fa37fce9b730bd.tar.gz
Find configuration file in XDG Base Directory
Find configuration file in XDG Base Directory only if `PRYRC` is not set, and `~/.pryrc` does not exist, therefore not confusing current users. Note that cache file path is not modified.
-rw-r--r--lib/pry/pry_class.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/pry/pry_class.rb b/lib/pry/pry_class.rb
index 6b8d5f9d..985eead1 100644
--- a/lib/pry/pry_class.rb
+++ b/lib/pry/pry_class.rb
@@ -1,7 +1,18 @@
require 'pry/config'
class Pry
- HOME_RC_FILE = ENV["PRYRC"] || "~/.pryrc"
+ HOME_RC_FILE =
+ if ENV.key?('PRYRC')
+ ENV['PRYRC']
+ elsif File.exist?(File.expand_path('~/.pryrc'))
+ '~/.pryrc'
+ elsif ENV.key?('XDG_CONFIG_HOME') && ENV['XDG_CONFIG_HOME'] != ''
+ # See XDG Base Directory Specification at
+ # https://standards.freedesktop.org/basedir-spec/basedir-spec-0.8.html
+ ENV['XDG_CONFIG_HOME'] + '/pry/pryrc'
+ else
+ '~/.config/pry/config'
+ end
LOCAL_RC_FILE = "./.pryrc"
class << self