Class: Gitlab::Ci::Config::External::File::Base
- Inherits:
-
Object
- Object
- Gitlab::Ci::Config::External::File::Base
show all
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/ci/config/external/file/base.rb
Constant Summary
collapse
- YAML_WHITELIST_EXTENSION =
/.+\.(yml|yaml)$/i.freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
#clear_memoization, #strong_memoize, #strong_memoized?
Constructor Details
#initialize(params, context) ⇒ Base
Returns a new instance of Base.
15
16
17
18
19
20
21
|
# File 'lib/gitlab/ci/config/external/file/base.rb', line 15
def initialize(params, context)
@params = params
@context = context
@errors = []
validate!
end
|
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context
11
12
13
|
# File 'lib/gitlab/ci/config/external/file/base.rb', line 11
def context
@context
end
|
#errors ⇒ Object
Returns the value of attribute errors
11
12
13
|
# File 'lib/gitlab/ci/config/external/file/base.rb', line 11
def errors
@errors
end
|
#location ⇒ Object
Returns the value of attribute location
11
12
13
|
# File 'lib/gitlab/ci/config/external/file/base.rb', line 11
def location
@location
end
|
#params ⇒ Object
Returns the value of attribute params
11
12
13
|
# File 'lib/gitlab/ci/config/external/file/base.rb', line 11
def params
@params
end
|
Instance Method Details
#content ⇒ Object
43
44
45
|
# File 'lib/gitlab/ci/config/external/file/base.rb', line 43
def content
raise NotImplementedError, 'subclass must implement fetching raw content'
end
|
#error_message ⇒ Object
39
40
41
|
# File 'lib/gitlab/ci/config/external/file/base.rb', line 39
def error_message
errors.first
end
|
#invalid_extension? ⇒ Boolean
31
32
33
|
# File 'lib/gitlab/ci/config/external/file/base.rb', line 31
def invalid_extension?
location.nil? || !::File.basename(location).match?(YAML_WHITELIST_EXTENSION)
end
|
#invalid_location_type? ⇒ Boolean
27
28
29
|
# File 'lib/gitlab/ci/config/external/file/base.rb', line 27
def invalid_location_type?
!location.is_a?(String)
end
|
#matching? ⇒ Boolean
23
24
25
|
# File 'lib/gitlab/ci/config/external/file/base.rb', line 23
def matching?
location.present?
end
|
#to_hash ⇒ Object
47
48
49
|
# File 'lib/gitlab/ci/config/external/file/base.rb', line 47
def to_hash
expanded_content_hash
end
|
#valid? ⇒ Boolean
35
36
37
|
# File 'lib/gitlab/ci/config/external/file/base.rb', line 35
def valid?
errors.none?
end
|