Class: Jets::Dotenv
- Inherits:
-
Object
- Object
- Jets::Dotenv
- Extended by:
- Memoist
- Includes:
- AwsServices, Util::Logging
- Defined in:
- lib/jets/dotenv.rb,
lib/jets/dotenv/ssm.rb,
lib/jets/dotenv/var.rb,
lib/jets/dotenv/convention.rb
Defined Under Namespace
Classes: Convention, Ssm, Var
Constant Summary collapse
- @@load =
nil
- @@parse =
nil
Class Method Summary collapse
Instance Method Summary collapse
-
#dotenv_files ⇒ Object
dotenv files with the following precedence:.
- #load! ⇒ Object
- #load? ⇒ Boolean
- #parse ⇒ Object
Methods included from Util::Logging
Methods included from AwsServices
#apigateway, #aws_options, #cfn, #codebuild, #dynamodb, #lambda_client, #logs, #s3, #s3_resource, #sns, #sqs, #ssm, #sts, #wafv2
Methods included from AwsServices::StackStatus
Methods included from AwsServices::GlobalMemoist
Class Method Details
.load! ⇒ Object
47 48 49 |
# File 'lib/jets/dotenv.rb', line 47 def load! @@load ||= new.load! end |
.parse ⇒ Object
53 54 55 |
# File 'lib/jets/dotenv.rb', line 53 def parse @@parse ||= new.parse end |
Instance Method Details
#dotenv_files ⇒ Object
dotenv files with the following precedence:
-
config/jets/env/.env.dev.extra (highest)
-
config/jets/env/.env.dev
-
config/jets/env/.env - The original (lowest)
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/jets/dotenv.rb', line 33 def dotenv_files files = [] files << ".env.#{Jets.env}.#{Jets.extra}" if Jets.extra files << ".env.#{Jets.env}" files << ".env" files.map! { |f| Jets.root.join("config/jets/env", f) }.compact files.map(&:to_s) end |
#load! ⇒ Object
8 9 10 11 12 |
# File 'lib/jets/dotenv.rb', line 8 def load! return unless load? variables = ::Dotenv.load(*dotenv_files) Ssm.new(variables).interpolate! end |
#load? ⇒ Boolean
20 21 22 23 24 25 |
# File 'lib/jets/dotenv.rb', line 20 def load? enabled = ENV["JETS_DOTENV"] != "0" # allow to disable with JETS_DOTENV=0 # Prevent ssm calls when on AWS Lambda but will call if on AWS CodeBuild on_aws = (ENV["ON_AWS"] || ENV["_HANDLER"]) && !ENV["CODEBUILD_CI"] enabled && !on_aws end |
#parse ⇒ Object
14 15 16 17 18 |
# File 'lib/jets/dotenv.rb', line 14 def parse return {} unless load? variables = ::Dotenv.parse(*dotenv_files) Ssm.new(variables).interpolate! end |