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.4'

Class Method Summary collapse

Class Method Details

.componentObject



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

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

.envObject



26
27
28
# File 'lib/totem.rb', line 26

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

.init_logger(output) ⇒ Object



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

def self.init_logger(output)
  raise 'Logger is already initialized' if @logger

  @logger = Logger.new(output)
  @logger.formatter = proc do |severity, datetime, progname, msg|
    "#{datetime} :: #{msg}\n"
  end

  return nil
end

.initialize(root) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# 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)
  $LOAD_PATH.unshift(root + '/app')
  load_app

  return true
end

.instanceObject



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

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

.load_appObject



30
31
32
# File 'lib/totem.rb', line 30

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

.log_file_pathObject



60
61
62
63
64
65
66
67
# File 'lib/totem.rb', line 60

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

  return File.join(root, 'log', name)
end

.log_to_fileObject



69
70
71
72
73
# File 'lib/totem.rb', line 69

def self.log_to_file
  init_logger(log_file_path)

  return nil
end

.log_to_stdoutObject



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

def self.log_to_stdout
  init_logger($stdout)

  return nil
end

.loggerObject



46
47
48
49
50
51
52
# File 'lib/totem.rb', line 46

def self.logger
  return @logger if @logger

  log_to_file

  return @logger
end

.logger=(val) ⇒ Object



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

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

.rootObject



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

def self.root
  return @root
end