class Formatron::External

downloads and merges config from dependencies

Constants

CONFIG_KEY
DSL_KEY
OUTPUTS_KEY

Attributes

formatron[R]
outputs[R]

Public Class Methods

new(aws:, target:, config:) click to toggle source
# File lib/formatron/external.rb, line 20
def initialize(aws:, target:, config:)
  @aws = aws
  @target = target
  @config = config
  @local_config = Marshal.load Marshal.dump(@config)
  @formatron = Formatron::DSL::Formatron.new external: nil, aws: @aws
  @outputs = Outputs.new aws: @aws, target: @target
end

Public Instance Methods

export(formatron:) click to toggle source

rubocop:enable Metrics/MethodLength

# File lib/formatron/external.rb, line 51
def export(formatron:)
  dsl = DSL.export formatron: @formatron
  local_dsl = DSL.export formatron: formatron
  dsl.deep_merge! local_dsl
  {
    CONFIG_KEY => @config,
    DSL_KEY => dsl,
    OUTPUTS_KEY => @outputs.hash
  }
end
merge(bucket:, dependency:) click to toggle source

rubocop:disable Metrics/MethodLength

# File lib/formatron/external.rb, line 30
def merge(bucket:, dependency:)
  configuration = S3::Configuration.get(
    aws: @aws,
    bucket: bucket,
    name: dependency,
    target: @target
  )
  DSL.merge(
    formatron: @formatron,
    configuration: configuration[DSL_KEY]
  )
  @config.deep_merge! configuration[CONFIG_KEY]
  @config.deep_merge! @local_config
  @outputs.merge(
    bucket: bucket,
    dependency: dependency,
    configuration: configuration[OUTPUTS_KEY]
  )
end