Class: Formatron::External

Inherits:
Object
  • Object
show all
Defined in:
lib/formatron/external.rb,
lib/formatron/external/dsl.rb,
lib/formatron/external/outputs.rb

Overview

downloads and merges config from dependencies

Defined Under Namespace

Modules: DSL Classes: Outputs

Constant Summary collapse

DSL_KEY =
'dsl'
CONFIG_KEY =
'config'
OUTPUTS_KEY =
'outputs'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aws:, target:, config:) ⇒ External

Returns a new instance of External.



20
21
22
23
24
25
26
27
# 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

Instance Attribute Details

#formatronObject (readonly)

Returns the value of attribute formatron.



15
16
17
# File 'lib/formatron/external.rb', line 15

def formatron
  @formatron
end

#outputsObject (readonly)

Returns the value of attribute outputs.



15
16
17
# File 'lib/formatron/external.rb', line 15

def outputs
  @outputs
end

Instance Method Details

#export(formatron:) ⇒ Object

rubocop:enable Metrics/MethodLength



51
52
53
54
55
56
57
58
59
60
# 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:) ⇒ Object

rubocop:disable Metrics/MethodLength



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# 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