Class: RicConf

Inherits:
Object
  • Object
show all
Defined in:
lib/classes/ricconf.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRicConf

Returns a new instance of RicConf.



35
36
37
38
39
40
41
42
43
44
# File 'lib/classes/ricconf.rb', line 35

def initialize()
  #puts "DEB RicConf::initialize(): Initializing a new #{self.class}"
  self.ver      = $RICLIB_VERSION
  self.home     = $HOME
  self.user     = $USER || get_username # = 'riccardo'
  self.path     = ENV['PATH'].split(':').uniq.sort # = 'riccardo'
  self.svn      = ENV['SVNRIC'] 
  self.nreloads ||= 0
  self.nreloads += 1   # lo riassegna quindi vale sempre uno a ogni costruzione..
end

Instance Attribute Details

#homeObject

Returns the value of attribute home.



32
33
34
# File 'lib/classes/ricconf.rb', line 32

def home
  @home
end

#nreloadsObject

Returns the value of attribute nreloads.



32
33
34
# File 'lib/classes/ricconf.rb', line 32

def nreloads
  @nreloads
end

#pathObject

Returns the value of attribute path.



32
33
34
# File 'lib/classes/ricconf.rb', line 32

def path
  @path
end

#svnObject

Returns the value of attribute svn.



32
33
34
# File 'lib/classes/ricconf.rb', line 32

def svn
  @svn
end

#userObject

Returns the value of attribute user.



32
33
34
# File 'lib/classes/ricconf.rb', line 32

def user
  @user
end

#verObject

Returns the value of attribute ver.



32
33
34
# File 'lib/classes/ricconf.rb', line 32

def ver
  @ver
end

Instance Method Details

#cool_eval(x) ⇒ Object

x is a string



56
57
58
59
60
# File 'lib/classes/ricconf.rb', line 56

def cool_eval(x)
  y = (eval(x.to_s)) rescue "CoolEvalEsception: '#{$!}'"
  deb "CoolEval('#{yellow x}' (#{x.class})) --> ''#{azure(y)}'' (class=#{y.class})"
  return y
end

#get_tagsObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/classes/ricconf.rb', line 62

def get_tags()
  deb "$network_conf is a #{$network_conf.class}"
  deb "$host_conf is a #{$hostconf.class}"
  [ '$host_conf', '$network_conf', '2+3', 'RicConf' ].each{|var| 
    # x = 'var.inspect()'
    #       y = eval(x)
    #       deb "Supercool: Evaluing('#{x}') for #{blue var} (#{var.class}) --> #{azure(y)} (class=#{y.class})"
    cool_eval(var)
  }
 # my_network_tags = $network_conf['tags'] rescue []
  tags = { 
  #  :conf_network => my_network_tags.split(',') ,
    :ENV_TAGS     => ENV['HOST_TAGS'].split(','),
    :ENV_SRVS     => ENV['HOST_SERVICES'].split(','),
  }
  tags[:conf_host]    = $host_conf['tags'].split(',') rescue [] # fatal("Conf missing for this host: #{$!}")
  tags[:conf_network] = $network_conf['tags'] .split(',') rescue [] # fatal("Conf missing for this host: #{$!}")
  tags.each{|k,v|
    deb "#{k}: #{v}"  
  }
  cleanup_tags = tags.values.flatten.compact.map{|x| x.strip }.uniq.sort
  deb tags.inspect
  # obsolete tags:
  my_obsolete_tags =  cleanup_tags & $obsolete_tags 
  deb "#Obsolete tags: #{red(my_obsolete_tags.map{|tag| "'#{tag}' from #{tags.map{|k,v| k if v.match(tag) }.compact }"}) }"
  return cleanup_tags - $obsolete_tags
end

#SVNRICObject

after migration svn!



51
52
53
# File 'lib/classes/ricconf.rb', line 51

def SVNRIC
  File.expand_path(ENV['SVNRIC'] || "~/git/gic" ) 
end

#to_sObject



46
47
48
# File 'lib/classes/ricconf.rb', line 46

def to_s
  "RicConf: #{yellow self.inspect}"
end