Module: IMW::Config
- Defined in:
- lib/imw/boot.rb
Overview
IMW looks for configuration settings in the following places, in order of increasing precedence:
1. Settings defined directly in this file.
2. From the <tt>etc/imwrc</tt> file in the IMW root directory.
3. From the <tt>.imwrc</tt> file in the user's home directory (the
filename can be changed; see
<tt>IMW::Config::USER_CONFIG_FILE_BASENAME</tt>).
4. From the file defined by the environment variable +IMWRC+ (the
value can be changed; see
<tt>IMW::Config::USER_CONFIG_FILE_ENV_VARIABLE</tt>
Settings not found in one configuration location will be searched for in locations of lesser precedence.
Note: configuration files are plain Ruby code that will be directly evaluated.
Relevant settings include
-
interfaces with external programs (
tar
,wget
, &c.) -
paths to directories where IMW reads/writes files
-
correspondences between file extensions and IMW file classes
For more detailed information, see the default configuration file, etc/imwrc
.
Constant Summary collapse
- USER_CONFIG_FILE =
User configuration file
By default, the file ~/.imwrc (.imwrc, in your home directory – note no .rb extension) is sourced at top level. If the $IMWRC environment variable is set, that file will be sourced instead.
Any code within this file will override settings in /etc/imwrc.rb which itself overrides IMW_ROOT/etc/imwrc.rb
File.join(ENV['HOME'] || '', '.imwrc')
- ENV_CONFIG_FILE =
Environment variable to override user configuration file location.
"IMWRC"
- SITE_CONFIG_FILE =
Path to site-wide config file (overwrites IMW defaults but overridden by user defaults).
"/etc/imwrc.rb"
Class Method Summary collapse
-
.default_config_file ⇒ Object
:nodoc:.
-
.imw_root ⇒ Object
Root of the IMW source base.
-
.load_config ⇒ Object
Source the config files.
-
.site_config_file ⇒ Object
:nodoc:.
-
.user_config_file ⇒ Object
:nodoc:.
Class Method Details
.default_config_file ⇒ Object
:nodoc:
65 66 67 |
# File 'lib/imw/boot.rb', line 65 def self.default_config_file # :nodoc: File.join(imw_root, "etc/imwrc.rb") end |
.imw_root ⇒ Object
Root of the IMW source base.
37 38 39 |
# File 'lib/imw/boot.rb', line 37 def self.imw_root File. File.join(File.dirname(__FILE__), '../..') end |
.load_config ⇒ Object
Source the config files
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/imw/boot.rb', line 70 def self.load_config if File.exist?(user_config_file) load user_config_file end if File.exist?(site_config_file) load site_config_file end load default_config_file end |
.site_config_file ⇒ Object
:nodoc:
61 62 63 |
# File 'lib/imw/boot.rb', line 61 def self.site_config_file # :nodoc: SITE_CONFIG_FILE end |
.user_config_file ⇒ Object
:nodoc:
54 55 56 |
# File 'lib/imw/boot.rb', line 54 def self.user_config_file # :nodoc: File.(ENV[ENV_CONFIG_FILE] || USER_CONFIG_FILE) end |