Class: AwsSsmEnv::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-ssm-env/loader.rb

Overview

このgemのエントリポイントとなるクラス。メイン処理を行う。 AWS EC2 Parameters Storeからパラメータを取得してENVに書き込む。

Author:

  • Ryohei Sonoda

Since:

  • 0.1.0

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ Loader

Returns a new instance of Loader.

Since:

  • 0.1.0



16
17
18
19
20
21
22
23
# File 'lib/aws-ssm-env/loader.rb', line 16

def initialize(**args)
  parse_options(**args)
  if @logger
    @logger.debug("#{self.class.name} overwrite: #{@overwrite}")
    @logger.debug("#{self.class.name} fetcher: #{@fetcher}")
    @logger.debug("#{self.class.name} naming_strategy: #{@naming_strategy}")
  end
end

Class Method Details

.load(**args) ⇒ Object

メイン処理。引数の詳細は AwsSsmEnv#load を参照。

Since:

  • 0.1.0



12
13
14
# File 'lib/aws-ssm-env/loader.rb', line 12

def self.load(**args)
  new(**args).load
end

Instance Method Details

#loadObject

Since:

  • 0.1.0



25
26
27
28
29
30
31
# File 'lib/aws-ssm-env/loader.rb', line 25

def load
  @fetcher.each do |parameter|
    var_name = @naming_strategy.parse_name(parameter)
    @logger&.debug("#{self.class.name} #{parameter.name} parameter value into ENV['#{var_name}']")
    send(@applier, var_name, parameter.value)
  end
end