summaryrefslogtreecommitdiff
path: root/lib/config.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/config.rb')
-rw-r--r--lib/config.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/config.rb b/lib/config.rb
index b0123e0..2a13ae0 100644
--- a/lib/config.rb
+++ b/lib/config.rb
@@ -1,9 +1,19 @@
-require 'toml'
+begin
+ require 'toml'
+ TOML_AVAILABLE = true
+rescue LoadError
+ TOML_AVAILABLE = false
+end
module RCM
- # Configuration
+ # Configuration — config.toml is optional. If the toml gem is not installed
+ # or no config.toml exists, config() will raise a helpful error when called.
module Config
- @@config = File.exist?('config.toml') ? TOML.load_file('config.toml') : {}
+ @@config = if TOML_AVAILABLE && File.exist?('config.toml')
+ TOML.load_file('config.toml')
+ else
+ {}
+ end
def config(key)
raise "No such config key: #{key}" unless @@config.key?(key)