Module: Totem

Defined in:
lib/totem.rb,
lib/totem/shell.rb,
lib/totem/version.rb,
lib/totem/shell_cmds/new.rb,
lib/totem/shell_cmds/base.rb,
lib/totem/shell_cmds/console.rb

Defined Under Namespace

Modules: ShellCmds Classes: Shell

Constant Summary collapse

VERSION =
'0.0.7'

Class Method Summary collapse

Class Method Details

.componentObject



41
42
43
# File 'lib/totem.rb', line 41

def self.component
  return @component ||= ENV['TOTEM_COMPONENT']
end

.component=(val) ⇒ Object



45
46
47
48
# File 'lib/totem.rb', line 45

def self.component=(val)
  raise 'component may only be set once and must be set before calling logger' if @logger || @component
  @component = val
end

.envObject



28
29
30
# File 'lib/totem.rb', line 28

def self.env
  return (@env ||= (ENV['TOTEM_ENV'] || 'development'))
end

.env=(val) ⇒ Object



32
33
34
35
# File 'lib/totem.rb', line 32

def self.env=(val)
  raise 'env may only be set once and must be set before calling logger' if @logger || @env
  @env = val
end

.initialize(root) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/totem.rb', line 10

def self.initialize(root)
  raise 'Already initialized.' if @setup

  @setup = true
  @root = root
  Bundler.require(Totem.env.to_sym)
  run_callbacks(:before_load_app)
  $LOAD_PATH.unshift(root + '/app')
  load_app
  run_callbacks(:after_load_app)

  return true
end

.instanceObject



50
51
52
# File 'lib/totem.rb', line 50

def self.instance
  return @instance || ENV['TOTEM_INSTANCE']
end

.instance=(val) ⇒ Object



54
55
56
57
# File 'lib/totem.rb', line 54

def self.instance=(val)
  raise 'instance may only be set once and must be set before calling logger' if @logger || @instance
  @instance = val
end

.load_appObject



37
38
39
# File 'lib/totem.rb', line 37

def self.load_app
  require "#{Totem.root}/app/loader.rb"
end

.log_file_pathObject



86
87
88
# File 'lib/totem.rb', line 86

def self.log_file_path
  return File.join(root, 'log', "#{process_name}.log")
end

.loggerObject



63
64
65
66
67
68
69
# File 'lib/totem.rb', line 63

def self.logger
  return @logger if @logger

  log_to_file

  return @logger
end

.logger=(val) ⇒ Object



59
60
61
# File 'lib/totem.rb', line 59

def self.logger=(val)
  return @logger = val
end

.process_nameObject



78
79
80
81
82
83
84
# File 'lib/totem.rb', line 78

def self.process_name
  name = "#{env}"
  name << "_#{component}" if component && component.length > 0
  name << "_#{instance}" if instance && instance.length > 0

  return name
end

.register_callback(type, callback = nil, &block) ⇒ Object



71
72
73
74
75
76
# File 'lib/totem.rb', line 71

def self.register_callback(type, callback=nil, &block)
  @callbacks ||= {}
  (@callbacks[type] ||= []) << (callback || block)

  return true
end

.rootObject



24
25
26
# File 'lib/totem.rb', line 24

def self.root
  return @root
end