Module: Ufo::Core

Extended by:
Memoist
Includes:
Utils::Pretty
Included in:
Ufo
Defined in:
lib/ufo/core.rb

Instance Method Summary collapse

Methods included from Utils::Pretty

#pretty_home, #pretty_path, #pretty_time

Instance Method Details

#appObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ufo/core.rb', line 13

def app
  return ENV['UFO_APP'] if ENV['UFO_APP']

  if @@config_loaded
    config.app
  else
    puts "ERROR: Using Ufo.app or :APP expansion very early in the UFO boot process".color(:red)
    puts <<~EOL.color(:red)
      The Ufo.app or :APP expansions are not yet available at this point
      You can either:

      1. Use the UFO_APP env var to set it, which allows it to be used.
      2. Hard code your actual app name.

    EOL
    call_line = caller.find {|l| l.include?('.ufo') }
    DslEvaluator.print_code(call_line)
    exit 1
  end
end

#configObject

In general, use the Ufo.config instead of Config.instance.config since it guarantees the load_project_config call



68
69
70
71
72
# File 'lib/ufo/core.rb', line 68

def config
  Config.instance.load_project_config
  @@config_loaded = true
  Config.instance.config
end

#configure(&block) ⇒ Object



57
58
59
# File 'lib/ufo/core.rb', line 57

def configure(&block)
  Config.instance.configure(&block)
end

#envObject

v5: development is default v6: dev is default



36
37
38
# File 'lib/ufo/core.rb', line 36

def env
  ENV['UFO_ENV'] || 'dev'
end

#extraObject



41
42
43
44
45
# File 'lib/ufo/core.rb', line 41

def extra
  extra = ENV['UFO_EXTRA'] if ENV['UFO_EXTRA'] # highest precedence
  return if extra&.empty?
  extra
end

#log_rootObject



53
54
55
# File 'lib/ufo/core.rb', line 53

def log_root
  "#{root}/log"
end

#loggerObject



77
78
79
80
81
82
83
84
85
86
# File 'lib/ufo/core.rb', line 77

def logger
  if @@config_loaded
    @@logger = config.logger
  else
    # When .ufo/config.rb is not yet loaded. IE: a helper method like waf
    # gets called in the .ufo/config.rb itself and uses the logger.
    # This avoids an infinite loop. Note: It does create a different Logger
    @@logger ||= Logger.new(ENV['UFO_LOG_PATH'] || $stderr)
  end
end

#roleObject



9
10
11
# File 'lib/ufo/core.rb', line 9

def role
  ENV['UFO_ROLE'] || 'web'
end

#rootObject



48
49
50
51
# File 'lib/ufo/core.rb', line 48

def root
  path = ENV['UFO_ROOT'] || '.'
  Pathname.new(path)
end