Module: Pray::Config
- Defined in:
- lib/pray/config.rb
Defined Under Namespace
Classes: PrayConfig, PrayLocalConfig
Class Method Summary
collapse
Class Method Details
.load_user_config ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/pray/config.rb', line 21
def load_user_config
path = user_config_path
return PrayConfig.new unless path && File.file?(path)
data = TomlRB.load_file(path)
PrayConfig.new(
local: PrayLocalConfig.new(
package: data.dig("local", "package") || {},
source: data.dig("local", "source") || {}
)
)
rescue TomlRB::ParseError => error
raise Error.parse("config", "#{path}: #{error.message}")
end
|
.user_config_path ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/pray/config.rb', line 36
def user_config_path
if (path = ENV["PRAY_CONFIG"])
return path
end
if (home = ENV["PRAY_HOME"])
candidate = File.join(home, "config.toml")
return candidate if File.file?(candidate)
end
home = ENV["HOME"]
return nil unless home
File.join(home, ".config", "pray", "config.toml")
end
|