Class: App

Inherits:
Object
  • Object
show all
Defined in:
lib/app.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

DEFAULT_LOG_LEVEL =

advanced settings

4
LOG_LEVELS =
{
  :highest => 7,
  :higher  => 6,
  :high    => 5,
  :normal  => 4,
  :low     => 3,
  :lower   => 2,
  :lowest  => 1,
}

Class Method Summary collapse

Class Method Details

.call(argv) ⇒ Object

called from exe/lizarb



11
12
13
14
15
16
17
18
# File 'lib/app.rb', line 11

def self.call argv
  log "#{$boot_time.diff}s to boot" if defined? $log_boot_high
  puts
  args = argv.dup
  argv.clear
  Liza[:DevBox].command args
  puts
end

.coding?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/app.rb', line 65

def self.coding?
  mode == :code
end

.cwdObject



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

def self.cwd
  Pathname Dir.pwd
end

.filenameObject



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

def self.filename
  root.join "#{$APP}.rb"
end

.folder(folder = nil) ⇒ Object

folder



36
37
38
39
40
41
42
43
44
45
# File 'lib/app.rb', line 36

def self.folder folder = nil
  raise "locked" if @locked
  if folder
    @folder = folder
    @relative_path = Pathname(folder)
    @path = Pathname("#{Lizarb::APP_DIR}/#{folder}")
  else
    @folder
  end
end

.get(key) ⇒ Object



92
93
94
# File 'lib/app.rb', line 92

def self.get key
  settings[key]
end

.global?Boolean

helpers

Returns:

  • (Boolean)


129
130
131
# File 'lib/app.rb', line 129

def self.global?
  $APP == "app_global"
end

.log(s) ⇒ Object



6
7
8
# File 'lib/app.rb', line 6

def self.log s
  puts s
end

.log_boot(level = nil) ⇒ Object

Raises:



112
113
114
115
116
117
118
# File 'lib/app.rb', line 112

def self.log_boot level = nil
  return @log_boot if level.nil?
  level = LOG_LEVELS[level] if level.is_a? Symbol
  raise Error, "invalid log level `#{level}`", caller unless LOG_LEVELS.values.include? level

  @log_boot = level
end

.log_level(level) ⇒ Object

Raises:



120
121
122
123
124
125
# File 'lib/app.rb', line 120

def self.log_level level
  level = LOG_LEVELS[level] if level.is_a? Symbol
  raise Error, "invalid log level `#{level}`", caller unless LOG_LEVELS.values.include? level

  set :log_level, level
end

.mode(mode = nil) ⇒ Object

mode



57
58
59
60
61
62
63
# File 'lib/app.rb', line 57

def self.mode mode = nil
  if mode
    @mode = mode.to_sym
  else
    @mode ||= (ENV["MODE"] || :code).to_sym
  end
end

.pathObject



47
48
49
# File 'lib/app.rb', line 47

def self.path
  @path
end

.relative_pathObject



51
52
53
# File 'lib/app.rb', line 51

def self.relative_path
  @relative_path or raise "@relative_path not set"
end

.rootObject



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

def self.root
  @root
end

.set(key, value) ⇒ Object



88
89
90
# File 'lib/app.rb', line 88

def self.set key, value
  settings[key] = value
end

.settingsObject

settings



84
85
86
# File 'lib/app.rb', line 84

def self.settings
  @settings ||= {}
end

.system(key) ⇒ Object



73
74
75
76
# File 'lib/app.rb', line 73

def self.system key
  raise "locked" if @locked
  @systems[key] = nil
end

.systemsObject



78
79
80
# File 'lib/app.rb', line 78

def self.systems
  @systems
end