Class: Cfruby::Cfp_Stat

Inherits:
Object
  • Object
show all
Includes:
Cfp_ClassAccessor
Defined in:
lib/libcfenjin/cfp_stat.rb

Overview

Cfp_Stat holds the state of the Cfruby engine at runtime. With Cfruby engine classes it needs to be passed during class initialisation. Scripts can access state through the local @cfp variable.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Cfp_ClassAccessor

#assign, #cfgroup, #dump_classlist, #init_classlist, #isa, #isa?

Constructor Details

#initialize(verbose = 0, trace = 0, dry_run = true, quiet_mode = false, strict = false, defines = [], undefines = []) ⇒ Cfp_Stat

Returns a new instance of Cfp_Stat.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/libcfenjin/cfp_stat.rb', line 26

def initialize verbose=0, trace=0, dry_run=true, quiet_mode=false, strict=false, defines=[], undefines=[]
	@dry_run      = dry_run
	@strict       = strict
	@site         = Hash.new
	# Set up the main logger
	@cfp_logger	= Cfp_Logger.new self,verbose,trace,dry_run,quiet_mode
	# Set up the library logger (if not unit testing)
	@cfp_liblogger = Cfp_LibLogger.new @cfp_logger
	# ---- Set up flow monitor
	@logger = @cfp_logger
	# Only initialize flow monitor when not unit testing
	begin
		Test::Unit.class
	rescue NameError
		@cfp_controller = Cfp_FlowMonitor.new(@cfp_logger)
		@cfp_logger.trace TRACE_ALL,'Initialized engine state (Cfp_Stat)'
	end
	# ---- Get OS info
	@os           = OS::OSFactory.new.get_os
	# ---- Get package list
	if packagemanager = @os.get_package_manager()
		@packagelist = packagemanager.packages()
	end
	# ---- Get user list
	if usermanager = @os.get_user_manager()
		@usermanager = usermanager
	end
	@classlist = Cfp_ClassList.new defines,undefines
end

Instance Attribute Details

#cfp_libloggerObject (readonly)

Returns the value of attribute cfp_liblogger.



20
21
22
# File 'lib/libcfenjin/cfp_stat.rb', line 20

def cfp_liblogger
  @cfp_liblogger
end

#cfp_loggerObject (readonly)

Returns the value of attribute cfp_logger.



20
21
22
# File 'lib/libcfenjin/cfp_stat.rb', line 20

def cfp_logger
  @cfp_logger
end

#classlistObject (readonly)

Returns the value of attribute classlist.



21
22
23
# File 'lib/libcfenjin/cfp_stat.rb', line 21

def classlist
  @classlist
end

#dry_runObject

Returns the value of attribute dry_run.



22
23
24
# File 'lib/libcfenjin/cfp_stat.rb', line 22

def dry_run
  @dry_run
end

#osObject (readonly)

Returns the value of attribute os.



20
21
22
# File 'lib/libcfenjin/cfp_stat.rb', line 20

def os
  @os
end

#packagelistObject (readonly)

Returns the value of attribute packagelist.



20
21
22
# File 'lib/libcfenjin/cfp_stat.rb', line 20

def packagelist
  @packagelist
end

#siteObject

Returns the value of attribute site.



22
23
24
# File 'lib/libcfenjin/cfp_stat.rb', line 22

def site
  @site
end

#sitepathObject

Returns the value of attribute sitepath.



22
23
24
# File 'lib/libcfenjin/cfp_stat.rb', line 22

def sitepath
  @sitepath
end

#strictObject

Returns the value of attribute strict.



22
23
24
# File 'lib/libcfenjin/cfp_stat.rb', line 22

def strict
  @strict
end

#usermanagerObject (readonly)

Returns the value of attribute usermanager.



21
22
23
# File 'lib/libcfenjin/cfp_stat.rb', line 21

def usermanager
  @usermanager
end

Instance Method Details

#distributionObject



64
65
66
# File 'lib/libcfenjin/cfp_stat.rb', line 64

def distribution
	@os['distribution']
end

#hostnameObject



56
57
58
# File 'lib/libcfenjin/cfp_stat.rb', line 56

def hostname
	@os.hostname
end

#osnameObject



60
61
62
# File 'lib/libcfenjin/cfp_stat.rb', line 60

def osname
	@os['name']
end

#showtraceObject



68
69
70
71
72
# File 'lib/libcfenjin/cfp_stat.rb', line 68

def showtrace
	 @logger.trace TRACE_ON,"Trace=#{@logger.tracelevel}"
	 @logger.trace TRACE_ENGINE,"Verbose=#{@logger.verbose}"
	 @logger.trace TRACE_ENGINE,'Hostname='+hostname
end