class ConfigLoader

Constants

ARN_CONFIG_FILE_PATH

Public Class Methods

build() click to toggle source
# File lib/aws_mfa/config_loader.rb, line 7
def self.build
  config_file = File.join(ENV["HOME"], ARN_CONFIG_FILE_PATH)

  raise AwsMfa::Errors::ConfigurationNotFound, "Configuration not found." unless File.readable?(config_file)

  new(config_file)
end
new(config_file) click to toggle source
# File lib/aws_mfa/config_loader.rb, line 15
def initialize(config_file)
  @config_file = config_file
end

Public Instance Methods

load() click to toggle source
# File lib/aws_mfa/config_loader.rb, line 19
def load
  config = IniFile.load(@config_file).to_h
  config.each_with_object({}) do |(key, value), acc|
    key =
      if key.start_with?("profile ")
        key.gsub("profile ", "")
      else
        key
      end

    acc[key] = value
  end
end