Class: Gitlab::Ci::Config::External::Mapper

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/ci/config/external/mapper.rb

Constant Summary collapse

MAX_INCLUDES =
100
FILE_CLASSES =
[
  External::File::Remote,
  External::File::Template,
  External::File::Local,
  External::File::Project,
  External::File::Artifact
].freeze
Error =
Class.new(StandardError)
AmbigiousSpecificationError =
Class.new(Error)
DuplicateIncludesError =
Class.new(Error)
TooManyIncludesError =
Class.new(Error)

Instance Method Summary collapse

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(values, context) ⇒ Mapper

Returns a new instance of Mapper.


25
26
27
28
# File 'lib/gitlab/ci/config/external/mapper.rb', line 25

def initialize(values, context)
  @locations = Array.wrap(values.fetch(:include, []))
  @context = context
end

Instance Method Details

#processObject


30
31
32
33
34
35
36
37
38
# File 'lib/gitlab/ci/config/external/mapper.rb', line 30

def process
  return [] if locations.empty?

  locations
    .compact
    .map(&method(:normalize_location))
    .each(&method(:verify_duplicates!))
    .map(&method(:select_first_matching))
end