Module: Lemans::SetupFiles

Defined in:
lib/lemans/setup_files.rb

Overview

The files a phase's setup steps consume. Paths are confined to the directory that declared them and must exist at load time.

Constant Summary collapse

PHASES =
%i[environment verifier].freeze

Class Method Summary collapse

Class Method Details

.call(declared, root:, label:) ⇒ Object

Raises:



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/lemans/setup_files.rb', line 11

def self.call(declared, root:, label:)
  declared ||= {}
  raise ConfigError, "#{label}: files must name a phase (#{PHASES.join(", ")})" unless declared.is_a?(Hash)

  unknown = declared.keys.map(&:to_s) - PHASES.map(&:to_s)
  raise ConfigError, "#{label}: files.#{unknown.first} is not a phase (#{PHASES.join(", ")})" if unknown.any?

  root = Pathname(root)
  PHASES.to_h do |phase|
    [phase, Array(declared[phase.to_s]).map { checked(_1, phase, root: root, label: label) }.freeze]
  end.freeze
end