Module: Genesis::Framework::Utils
- Defined in:
- lib/genesisframework/utils.rb
Constant Summary collapse
- @@config_cache =
Hash.new
- @@collins_conn =
nil- @@facter =
nil- @@loggers =
nil
Class Method Summary collapse
- .collins ⇒ Object
-
.config_cache ⇒ Object
mimicking rail’s cattr_accessor.
- .config_cache=(obj) ⇒ Object
- .facter ⇒ Object
- .log(subsystem, message) ⇒ Object
- .tmp_path(filename, sandbox = "") ⇒ Object
Class Method Details
.collins ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/genesisframework/utils.rb', line 27 def self.collins if @@collins_conn.nil? cfg = { :host => self.config_cache['collins']['host'], :username => self.config_cache['collins']['username'], :password => self.config_cache['collins']['password'] } @@collins_conn = ::Collins::Client.new(cfg) end @@collins_conn end |
.config_cache ⇒ Object
mimicking rail’s cattr_accessor
19 20 21 |
# File 'lib/genesisframework/utils.rb', line 19 def self.config_cache @@config_cache end |
.config_cache=(obj) ⇒ Object
23 24 25 |
# File 'lib/genesisframework/utils.rb', line 23 def self.config_cache= (obj) @@config_cache = obj end |
.facter ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/genesisframework/utils.rb', line 36 def self.facter if @@facter.nil? @@facter = Facter.to_hash end @@facter end |
.log(subsystem, message) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/genesisframework/utils.rb', line 44 def self.log subsystem, logline = subsystem.to_s + " :: " + puts logline # Load external logging modules and send log to them if @@loggers.nil? @@loggers = self.config_cache[:loggers].map {|logger| begin require "logging/#{logger.downcase}" Logging.const_get(logger.to_sym) rescue LoadError puts "Could not load logger #{logger}" end }.compact end @@loggers.each {|logger| logger.log logline} end |
.tmp_path(filename, sandbox = "") ⇒ Object
7 8 9 10 11 |
# File 'lib/genesisframework/utils.rb', line 7 def self.tmp_path filename, sandbox = "" location = File.join(ENV['GENESIS_ROOT'], "tmp", sandbox) Dir.mkdir(location, 0755) unless File.directory? location File.join(location, filename) end |