Class: Outil::OCS::Config
- Inherits:
-
Object
- Object
- Outil::OCS::Config
- Defined in:
- lib/outil/ocs/config.rb
Constant Summary collapse
- INDEX_PATH =
'.outil'
- CONFIG_PATH =
'.outil.rc'
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
- #index ⇒ Object
-
#initialize(params = {}) ⇒ Config
constructor
A new instance of Config.
- #options ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Config
Returns a new instance of Config.
15 16 17 18 19 20 21 22 |
# File 'lib/outil/ocs/config.rb', line 15 def initialize(params={}) @params = params infer = Proc.new do |key, const| @params[key] = "#{self.class.home_path}/#{const}" end infer.call(:index, INDEX_PATH) infer.call(:path, CONFIG_PATH) end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
13 14 15 |
# File 'lib/outil/ocs/config.rb', line 13 def params @params end |
Class Method Details
.home_path ⇒ Object
8 9 10 11 |
# File 'lib/outil/ocs/config.rb', line 8 def self.home_path @home_path ||= File.( File.(ENV['HOME'] || '~')) end |
Instance Method Details
#index ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/outil/ocs/config.rb', line 39 def index @index ||= ( unless [:index] raise StandardError "Could not locate your Outil Index Path" end Index.new(:path => [:index]) ) end |
#options ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/outil/ocs/config.rb', line 24 def @options ||= ( unless File.exists?(@params[:path]) raise StandardError "Could not locate your Outil Config File" end indifference = Proc.new do |hash, x| hash[x.first] = x.last hash[x.first.to_sym] = x.last hash end YAML.load_file(@params[:path]) .inject(Hash.new, &indifference) ) end |