Module: Kscript::Config

Defined in:
lib/kscript/config.rb

Constant Summary collapse

CONFIG_PATH =
File.expand_path('~/.kscript/.env')

Class Method Summary collapse

Class Method Details

.get(key, default = nil) ⇒ Object

Get config value from ENV, with optional default

Parameters:

  • key (String)

    ENV key

  • default (Object) (defaults to: nil)

    default value if not set



25
26
27
# File 'lib/kscript/config.rb', line 25

def self.get(key, default = nil)
  ENV[key] || default
end

.load!Object

Load ~/.kscript/.env using dotenv



15
16
17
18
19
20
# File 'lib/kscript/config.rb', line 15

def self.load!
  return if @loaded

  Dotenv.load(CONFIG_PATH)
  @loaded = true
end