Module: Forger::Core
Constant Summary collapse
- @@env =
nil
Instance Method Summary collapse
- #build_root ⇒ Object
-
#cloudwatch_enabled?(options) ⇒ Boolean
cloudwatch cli option takes higher precedence than when its set in the config/settings.yml file.
- #env ⇒ Object
- #root ⇒ Object
-
#set_aws_profile! ⇒ Object
Overrides AWS_PROFILE based on the Forger.env if set in config/settings.yml 2-way binding.
-
#settings ⇒ Object
Do not use the Setting#data to load the profile because it can cause an infinite loop then if we decide to use Forger.env from within settings class.
- #validate_in_project! ⇒ Object
Instance Method Details
#build_root ⇒ Object
40 41 42 |
# File 'lib/forger/core.rb', line 40 def build_root Base::BUILD_ROOT end |
#cloudwatch_enabled?(options) ⇒ Boolean
cloudwatch cli option takes higher precedence than when its set in the config/settings.yml file.
14 15 16 17 18 |
# File 'lib/forger/core.rb', line 14 def cloudwatch_enabled?() ![:cloudwatch].nil? ? [:cloudwatch] : # options can use symbols because this the options hash from Thor settings["cloudwatch"] # settings uses strings as keys end |
#env ⇒ Object
33 34 35 36 37 38 |
# File 'lib/forger/core.rb', line 33 def env return @@env if @@env env = env_from_profile(ENV['AWS_PROFILE']) || 'development' env = ENV['FORGER_ENV'] if ENV['FORGER_ENV'] # highest precedence @@env = env end |
#root ⇒ Object
20 21 22 23 |
# File 'lib/forger/core.rb', line 20 def root path = ENV['FORGER_ROOT'] || '.' Pathname.new(path) end |
#set_aws_profile! ⇒ Object
Overrides AWS_PROFILE based on the Forger.env if set in config/settings.yml 2-way binding.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/forger/core.rb', line 46 def set_aws_profile! return if ENV['TEST'] return unless File.exist?("#{Forger.root}/config/settings.yml") # for rake docs return unless settings # Only load if within Ufo project and there's a settings.yml data = settings[Forger.env] || {} if data["aws_profile"] puts "Using AWS_PROFILE=#{data["aws_profile"]} from FORGER_ENV=#{Forger.env} in config/settings.yml" ENV['AWS_PROFILE'] = data["aws_profile"] end end |
#settings ⇒ Object
Do not use the Setting#data to load the profile because it can cause an infinite loop then if we decide to use Forger.env from within settings class.
59 60 61 |
# File 'lib/forger/core.rb', line 59 def settings Setting.new.data end |
#validate_in_project! ⇒ Object
25 26 27 28 29 30 |
# File 'lib/forger/core.rb', line 25 def validate_in_project! unless File.exist?("#{root}/profiles") puts "Could not find a profiles folder in the current directory. It does not look like you are running this command within a forger project. Please confirm that you are in a forger project and try again.".color(:red) exit end end |