Module: Ore::Config
- Defined in:
- lib/ore/config.rb
Constant Summary collapse
- HOME =
The users home directory
Gem.user_home
- PATH =
Ore config directory
File.join(HOME,'.ore')
- OPTIONS_FILE =
Default options file.
File.join(PATH,'options.yml')
- TEMPLATES_DIR =
Custom Ore Templates directory
File.join(PATH,'templates')
- DATA_DIR =
The
data/
directory for Ore File.(File.join('..','..','data'),File.dirname(__FILE__))
- @@enabled =
Specifies whether user settings will be loaded
true
Class Method Summary collapse
-
.builtin_templates {|path| ... } ⇒ Object
The builtin templates.
-
.disable! ⇒ Object
Disables access to user settings.
-
.enable! ⇒ Object
Enables access to user settings.
-
.installed_templates {|path| ... } ⇒ Object
The installed templates.
-
.options ⇒ Hash
Loads the default options from
~/.ore/options.yml
.
Class Method Details
.builtin_templates {|path| ... } ⇒ Object
The builtin templates.
81 82 83 84 85 86 87 88 89 |
# File 'lib/ore/config.rb', line 81 def Config.builtin_templates path = File.join(DATA_DIR,'ore','templates') if File.directory?(path) Dir.glob("#{path}/*") do |template| yield template if File.directory?(template) end end end |
.disable! ⇒ Object
Disables access to user settings.
38 39 40 |
# File 'lib/ore/config.rb', line 38 def Config.disable! @@enabled = false end |
.enable! ⇒ Object
Enables access to user settings.
29 30 31 |
# File 'lib/ore/config.rb', line 29 def Config.enable! @@enabled = true end |
.installed_templates {|path| ... } ⇒ Object
The installed templates.
100 101 102 103 104 105 106 107 108 |
# File 'lib/ore/config.rb', line 100 def Config.installed_templates if @@enabled if File.directory?(TEMPLATES_DIR) Dir.glob("#{TEMPLATES_DIR}/*") do |template| yield template if File.directory?(template) end end end end |
.options ⇒ Hash
Loads the default options from ~/.ore/options.yml
.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/ore/config.rb', line 53 def Config. = {} if (@@enabled && File.file?(OPTIONS_FILE)) = YAML.load_file(OPTIONS_FILE) # default options must be a Hash unless .kind_of?(Hash) raise("#{OPTIONS_FILE} must contain a YAML encoded Hash") end .each do |name,value| [name.to_sym] = value end end return end |