Class: Pinspec::Setup::ContextBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/pinspec/setup/context_builder.rb

Constant Summary collapse

MAX_GENERATIONS =
3

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target:, profile:, imports: [], generation: 1, tz: nil) ⇒ ContextBuilder

Returns a new instance of ContextBuilder.



16
17
18
19
20
21
22
23
# File 'lib/pinspec/setup/context_builder.rb', line 16

def initialize(target:, profile:, imports: [], generation: 1, tz: nil)
  @target     = target
  @profile    = profile
  @imports    = imports
  @generation = generation
  @tz         = tz || Runner::Sandbox::FORCED_ENV.fetch("TZ")
  @resolver   = DependencyResolver.new(profile.schema, profile.factories)
end

Class Method Details

.build(target:, profile:, imports: [], generation: 1, tz: nil) ⇒ Object



11
12
13
# File 'lib/pinspec/setup/context_builder.rb', line 11

def build(target:, profile:, imports: [], generation: 1, tz: nil)
  new(target: target, profile: profile, imports: imports, generation: generation, tz: tz).build
end

Instance Method Details

#buildObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pinspec/setup/context_builder.rb', line 25

def build
  @steps    = []
  @bindings = {}
  @notes    = []
  @counters = Hash.new(0)
  @refs     = {}

  refuse_unsupported_tenancy!
  refuse_attachment_targets!

  environment_steps
  record_steps
  import_steps
  context_steps
  subject_step

  plan
end