module Lono::Core

Public Instance Methods

blueprint_root() click to toggle source
# File lib/lono/core.rb, line 20
def blueprint_root; @@blueprint_root ; end
blueprint_root=(v) click to toggle source
# File lib/lono/core.rb, line 21
def blueprint_root=(v) ; @@blueprint_root = v ; end
config() click to toggle source
# File lib/lono/core.rb, line 7
def config
  Config.new
end
env() click to toggle source
# File lib/lono/core.rb, line 23
def env
  # 2-way binding
  env = env_from_profile(ENV['AWS_PROFILE']) || 'development'
  env = ENV['LONO_ENV'] if ENV['LONO_ENV'] # highest precedence
  env
end
lono_pro_installed?() click to toggle source
# File lib/lono/core.rb, line 64
def lono_pro_installed?
  Lono::Pro::VERSION
  true
rescue NameError
  false
end
lono_pro_removal_check!() click to toggle source
# File lib/lono/core.rb, line 53
    def lono_pro_removal_check!
      if lono_pro_installed?
        puts "ERROR: A lono-pro gem installation has been detected.".color(:red)
        puts <<~EOL
          The lono-pro gem is now a part of lono itself. The lono-pro gem has been deprecated.
          Please uninstall the lono-pro gem and remove it from your Gemfile to continue.
        EOL
        exit 1
      end
    end
root() click to toggle source
# File lib/lono/core.rb, line 13
def root
  path = @@root || ENV['LONO_ROOT'] || Dir.pwd
  Pathname.new(path)
end
set_aws_profile!() click to toggle source

Overrides AWS_PROFILE based on the Lono.env if set in configs/settings.yml 2-way binding.

# File lib/lono/core.rb, line 33
def set_aws_profile!
  return unless settings # Only load if within lono project and there's a settings.yml
  data = settings[Lono.env] || {}
  if data["aws_profile"]
    # puts "Using AWS_PROFILE=#{data["aws_profile"]} from LONO_ENV=#{Lono.env} in configs/settings.yml"
    ENV['AWS_PROFILE'] = data["aws_profile"]
  end
end
settings() click to toggle source

Do not use the Setting#data to load the profile because it can cause an infinite loop then if we decide to use Lono.env from within settings class.

# File lib/lono/core.rb, line 44
def settings
  setting = Setting.new(false) # check_lono_project to account for `lono new`
  settings_path = setting.lookup_project_settings_path
  return unless settings_path # in case outside of lono project

  YAML.load_file(settings_path)
end

Private Instance Methods

env_from_profile(aws_profile) click to toggle source
# File lib/lono/core.rb, line 72
def env_from_profile(aws_profile)
  return unless settings
  env = settings.find do |_env, settings|
    settings ||= {}
    profiles = settings['aws_profile']
    profiles && profiles == aws_profile
  end
  env.first if env
end