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
33
34
35
# File 'lib/ufo/core.rb', line 13

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

  if @@config_loaded
    config.app
  else
    call_line = caller.find {|l| l.include?('.ufo') }
    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.

      Called from:

          #{call_line}

    EOL
    exit 1
  end
end

#configObject

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



71
72
73
74
75
# File 'lib/ufo/core.rb', line 71

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

#configure(&block) ⇒ Object



60
61
62
# File 'lib/ufo/core.rb', line 60

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

#envObject

v5: development is default v6: dev is default



39
40
41
# File 'lib/ufo/core.rb', line 39

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

#extraObject



44
45
46
47
48
# File 'lib/ufo/core.rb', line 44

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

#log_rootObject



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

def log_root
  "#{root}/log"
end

#loggerObject



80
81
82
83
84
85
86
87
88
89
# File 'lib/ufo/core.rb', line 80

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



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

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