blob: 6b20eeae20314d4b511ec91c8962d46b91521e86 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# frozen_string_literal: true
module Gitlab
module Ci
class Config
module Yaml
class Result
attr_reader :error, :error_class
def initialize(config: nil, error: nil, error_class: nil)
@config = Array.wrap(config)
@error = error
@error_class = error_class
end
def valid?
error.nil?
end
def has_header?
return false unless @config.first.is_a?(Hash)
@config.size > 1 && @config.first.key?(:spec)
end
def header
raise ArgumentError unless has_header?
@config.first
end
def content
return @config.last if has_header?
@config.first || {}
end
end
end
end
end
end
|