Class: Thot::Varfiles
- Inherits:
-
Object
- Object
- Thot::Varfiles
- Extended by:
- Carioca::Injector
- Defined in:
- lib/thot/varfiles.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(varfile: nil, environment: nil, dotfiles: ["./.thot.env","~/.thot.env"]) ⇒ Varfiles
constructor
A new instance of Varfiles.
Constructor Details
#initialize(varfile: nil, environment: nil, dotfiles: ["./.thot.env","~/.thot.env"]) ⇒ Varfiles
Returns a new instance of Varfiles.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/thot/varfiles.rb', line 8 def initialize(varfile: nil, environment: nil, dotfiles: ["./.thot.env","~/.thot.env"]) @name = self.class @data = {} scanned_files = dotfiles scanned_files.push varfile unless varfile.nil? scanned_files.each do |file| real_file = File.(file) if File::exists? real_file then output.debug "Negociated files : #{real_file}, merging..." if self.respond_to?(:output) datafile = IniFile.load(real_file) @data.merge! datafile["global"] @data.merge! datafile[environment] if datafile.sections.include? environment.to_s end end @data.transform_keys!(&:to_sym) if self.respond_to?(:output) then if output.level == :debug then output.debug "merged data:" @data.each do |key,val| output.debug "* #{key} = #{val}" end end end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/thot/varfiles.rb', line 5 def data @data end |