Class: MrMurano::Config::ConfigFile

Inherits:
Struct
  • Object
show all
Defined in:
lib/MrMurano/Config.rb

Overview

internal transient this-run-only things (also -c options)

specified   from --configfile
env         from ENV['MR_CONFIGFILE']
project     .mrmuranorc at project dir
user        .mrmuranorc at $HOME
system      .mrmuranorc at /etc
defaults    Internal hardcoded defaults

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



15
16
17
# File 'lib/MrMurano/Config.rb', line 15

def data
  @data
end

#kindObject

Returns the value of attribute kind

Returns:

  • (Object)

    the current value of kind



15
16
17
# File 'lib/MrMurano/Config.rb', line 15

def kind
  @kind
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



15
16
17
# File 'lib/MrMurano/Config.rb', line 15

def path
  @path
end

Instance Method Details

#loadObject



16
17
18
19
20
21
22
# File 'lib/MrMurano/Config.rb', line 16

def load()
  return if kind == :internal
  return if kind == :defaults
  self[:path] = Pathname.new(path) unless path.kind_of? Pathname
  self[:data] = IniFile.new(:filename=>path.to_s) if self[:data].nil?
  self[:data].restore
end

#writeObject



24
25
26
27
28
29
30
31
# File 'lib/MrMurano/Config.rb', line 24

def write()
  return if kind == :internal
  return if kind == :defaults
  self[:path] = Pathname.new(path) unless path.kind_of? Pathname
  self[:data] = IniFile.new(:filename=>path.to_s) if self[:data].nil?
  self[:data].save
  path.chmod(0600)
end