Class: MrMurano::Config::ConfigFile
- Inherits:
-
Struct
- Object
- Struct
- MrMurano::Config::ConfigFile
- Defined in:
- lib/MrMurano/Config.rb
Instance Attribute Summary collapse
-
#cfg ⇒ Object
Returns the value of attribute cfg.
-
#data ⇒ Object
Returns the value of attribute data.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
Instance Attribute Details
#cfg ⇒ Object
Returns the value of attribute cfg
33 34 35 |
# File 'lib/MrMurano/Config.rb', line 33 def cfg @cfg end |
#data ⇒ Object
Returns the value of attribute data
33 34 35 |
# File 'lib/MrMurano/Config.rb', line 33 def data @data end |
#kind ⇒ Object
Returns the value of attribute kind
33 34 35 |
# File 'lib/MrMurano/Config.rb', line 33 def kind @kind end |
#path ⇒ Object
Returns the value of attribute path
33 34 35 |
# File 'lib/MrMurano/Config.rb', line 33 def path @path end |
Instance Method Details
#load ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/MrMurano/Config.rb', line 34 def load return if kind == :internal return if kind == :defaults # DEVs: Uncomment if you're trying to figure where settings are coming from. # See also: murano config --locations #puts "Loading config at: #{path}" self[:path] = Pathname.new(path) unless path.is_a? Pathname self[:data] = IniFile.new(filename: path.to_s) if self[:data].nil? self[:data].restore end |
#write ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/MrMurano/Config.rb', line 45 def write return if kind == :internal return if kind == :defaults if !self[:cfg].nil? && self[:cfg]['tool.dry'] # $cfg.nil? when run from spec tests that don't load it with: # include_context "CI_CMD" warning('--dry: Not writing config file') return end self[:path] = Pathname.new(path) unless path.is_a?(Pathname) # Ensure path to the file exists. unless path.dirname.exist? path.dirname.mkpath MrMurano::Config.fix_modes(path.dirname) end self[:data] = IniFile.new(filename: path.to_s) if self[:data].nil? self[:data].save path.chmod(0o600) nil end |