Class: Cfruby::Cfp_Stat
- Inherits:
-
Object
- Object
- Cfruby::Cfp_Stat
- 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
-
#cfp_liblogger ⇒ Object
readonly
Returns the value of attribute cfp_liblogger.
-
#cfp_logger ⇒ Object
readonly
Returns the value of attribute cfp_logger.
-
#classlist ⇒ Object
readonly
Returns the value of attribute classlist.
-
#dry_run ⇒ Object
Returns the value of attribute dry_run.
-
#os ⇒ Object
readonly
Returns the value of attribute os.
-
#packagelist ⇒ Object
readonly
Returns the value of attribute packagelist.
-
#site ⇒ Object
Returns the value of attribute site.
-
#sitepath ⇒ Object
Returns the value of attribute sitepath.
-
#strict ⇒ Object
Returns the value of attribute strict.
-
#usermanager ⇒ Object
readonly
Returns the value of attribute usermanager.
Instance Method Summary collapse
- #dev_version ⇒ Object
- #distribution ⇒ Object
- #hostname ⇒ Object
-
#initialize(version = nil, verbose = 0, trace = 0, dry_run = true, quiet_mode = false, strict = false, defines = [], undefines = []) ⇒ Cfp_Stat
constructor
A new instance of Cfp_Stat.
- #osname ⇒ Object
- #showtrace ⇒ Object
- #version ⇒ Object
Methods included from Cfp_ClassAccessor
#assign, #cfgroup, #dump_classlist, #init_classlist, #isa, #isa?
Constructor Details
#initialize(version = nil, verbose = 0, trace = 0, dry_run = true, quiet_mode = false, strict = false, defines = [], undefines = []) ⇒ Cfp_Stat
Returns a new instance of Cfp_Stat.
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 55 56 57 58 59 |
# File 'lib/libcfenjin/cfp_stat.rb', line 30 def initialize version=nil, verbose=0, trace=0, dry_run=true, quiet_mode=false, strict=false, defines=[], undefines=[] @version = version @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_liblogger ⇒ Object (readonly)
Returns the value of attribute cfp_liblogger.
24 25 26 |
# File 'lib/libcfenjin/cfp_stat.rb', line 24 def cfp_liblogger @cfp_liblogger end |
#cfp_logger ⇒ Object (readonly)
Returns the value of attribute cfp_logger.
24 25 26 |
# File 'lib/libcfenjin/cfp_stat.rb', line 24 def cfp_logger @cfp_logger end |
#classlist ⇒ Object (readonly)
Returns the value of attribute classlist.
25 26 27 |
# File 'lib/libcfenjin/cfp_stat.rb', line 25 def classlist @classlist end |
#dry_run ⇒ Object
Returns the value of attribute dry_run.
26 27 28 |
# File 'lib/libcfenjin/cfp_stat.rb', line 26 def dry_run @dry_run end |
#os ⇒ Object (readonly)
Returns the value of attribute os.
24 25 26 |
# File 'lib/libcfenjin/cfp_stat.rb', line 24 def os @os end |
#packagelist ⇒ Object (readonly)
Returns the value of attribute packagelist.
24 25 26 |
# File 'lib/libcfenjin/cfp_stat.rb', line 24 def packagelist @packagelist end |
#site ⇒ Object
Returns the value of attribute site.
26 27 28 |
# File 'lib/libcfenjin/cfp_stat.rb', line 26 def site @site end |
#sitepath ⇒ Object
Returns the value of attribute sitepath.
26 27 28 |
# File 'lib/libcfenjin/cfp_stat.rb', line 26 def sitepath @sitepath end |
#strict ⇒ Object
Returns the value of attribute strict.
26 27 28 |
# File 'lib/libcfenjin/cfp_stat.rb', line 26 def strict @strict end |
#usermanager ⇒ Object (readonly)
Returns the value of attribute usermanager.
25 26 27 |
# File 'lib/libcfenjin/cfp_stat.rb', line 25 def usermanager @usermanager end |
Instance Method Details
#dev_version ⇒ Object
80 81 82 83 84 85 |
# File 'lib/libcfenjin/cfp_stat.rb', line 80 def dev_version if @version and @version =~ /dev(\d+)/ return $1.to_i end 0 end |
#distribution ⇒ Object
69 70 71 |
# File 'lib/libcfenjin/cfp_stat.rb', line 69 def distribution @os['distribution'] end |
#hostname ⇒ Object
61 62 63 |
# File 'lib/libcfenjin/cfp_stat.rb', line 61 def hostname @os.hostname end |
#osname ⇒ Object
65 66 67 |
# File 'lib/libcfenjin/cfp_stat.rb', line 65 def osname @os['name'] end |
#showtrace ⇒ Object
87 88 89 90 91 |
# File 'lib/libcfenjin/cfp_stat.rb', line 87 def showtrace @logger.trace TRACE_ON,"Trace=#{@logger.tracelevel}" @logger.trace TRACE_ENGINE,"Verbose=#{@logger.verbose}" @logger.trace TRACE_ENGINE,'Hostname='+hostname end |
#version ⇒ Object
73 74 75 76 77 78 |
# File 'lib/libcfenjin/cfp_stat.rb', line 73 def version if @version and @version =~ /^(\d+\.\d+)/ return $1.to_f end 1.0 end |