Module: Chimps::Config
- Defined in:
- lib/chimps/config.rb
Overview
Defines methods to load the Chimps configuration.
Class Method Summary collapse
-
.chimps_root ⇒ String
The root of the Chimps source base.
-
.load ⇒ Object
Load the configuration settings from the configuration/identity file.
-
.load_plugins ⇒ Object
Require all ruby files in the directory Chimps::CONFIG.
-
.resolve_options! ⇒ Object
Ensure that certain options (verbosity, log file) that can be passed on the command-line override those stored in a configuration file (if present).
Class Method Details
.chimps_root ⇒ String
The root of the Chimps source base.
57 58 59 |
# File 'lib/chimps/config.rb', line 57 def self.chimps_root File. File.join(File.dirname(__FILE__), '../..') end |
.load ⇒ Object
Load the configuration settings from the configuration/identity file.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/chimps/config.rb', line 74 def self.load # FIXME this is a terrible hack...and it only goes to 2 deep! if File.exist?(COMMAND_LINE_OPTIONS[:identity_file]) require 'yaml' YAML.load_file(COMMAND_LINE_OPTIONS[:identity_file]).each_pair do |key, value| case when value.is_a?(Hash) && CONFIG.include?(key) CONFIG[key].merge!(value) when value.is_a?(Array) && CONFIG.include?(key) CONFIG[key] += value else CONFIG[key] = value end end end end |
.load_plugins ⇒ Object
Require all ruby files in the directory Chimps::CONFIG.
63 64 65 66 67 68 69 70 |
# File 'lib/chimps/config.rb', line 63 def self.load_plugins return if Chimps::CONFIG[:skip_plugins] plugin_dirs = Chimps::CONFIG[:plugins] return if plugin_dirs.blank? plugin_dirs.each do |dir| Dir[File.(dir) + "/*.rb"].each { |plugin| require plugin } end end |
.resolve_options! ⇒ Object
Ensure that certain options (verbosity, log file) that can be passed on the command-line override those stored in a configuration file (if present).
50 51 52 |
# File 'lib/chimps/config.rb', line 50 def self. Chimps::CONFIG.merge!(Chimps::COMMAND_LINE_OPTIONS) # overwrites from command line if necessary end |