debian-mirror-gitlab/lib/gitlab/ci/config/yaml/result.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
757 B
Ruby
Raw Normal View History

2023-05-27 22:25:52 +05:30
# frozen_string_literal: true
module Gitlab
module Ci
class Config
module Yaml
class Result
attr_reader :error
def initialize(config: nil, error: nil)
@config = Array.wrap(config)
@error = error
end
def valid?
error.nil?
end
def has_header?
2023-06-20 00:43:36 +05:30
return false unless @config.first.is_a?(Hash)
@config.size > 1 && @config.first.key?(:spec)
2023-05-27 22:25:52 +05:30
end
def header
raise ArgumentError unless has_header?
@config.first
end
def content
2023-06-20 00:43:36 +05:30
return @config.last if has_header?
@config.first
2023-05-27 22:25:52 +05:30
end
end
end
end
end
end