diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-03-03 11:55:01 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-03-03 11:55:01 +0300 |
commit | a00520b15dc7745ba7591236067e167f79c906ef (patch) | |
tree | 3a6a34e2e63bbfb3d45fbae67677ba2450796938 /lib/gitlab/ci/config | |
parent | dc3a41f405f2ebe1b84560e3838d3f0a3a4b1be7 (diff) |
Restore Unspecified and we could discuss later
Also feedback in:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9666/diffs#note_24608283
Diffstat (limited to 'lib/gitlab/ci/config')
-rw-r--r-- | lib/gitlab/ci/config/entry/factory.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/ci/config/entry/node.rb | 21 | ||||
-rw-r--r-- | lib/gitlab/ci/config/entry/unspecified.rb | 19 |
3 files changed, 26 insertions, 20 deletions
diff --git a/lib/gitlab/ci/config/entry/factory.rb b/lib/gitlab/ci/config/entry/factory.rb index 3b6d10a5378..6be8288748f 100644 --- a/lib/gitlab/ci/config/entry/factory.rb +++ b/lib/gitlab/ci/config/entry/factory.rb @@ -37,7 +37,9 @@ module Gitlab # See issue #18775. # if @value.nil? - fabricate_unspecified + Entry::Unspecified.new( + fabricate_unspecified + ) else fabricate(@entry, @value) end @@ -54,7 +56,7 @@ module Gitlab fabricate(Entry::Undefined) else fabricate(@entry, @entry.default) - end.tap(&:unspecify) + end end def fabricate(entry, value = nil) diff --git a/lib/gitlab/ci/config/entry/node.rb b/lib/gitlab/ci/config/entry/node.rb index 1cacb9357f2..a6a914d79c1 100644 --- a/lib/gitlab/ci/config/entry/node.rb +++ b/lib/gitlab/ci/config/entry/node.rb @@ -15,7 +15,6 @@ module Gitlab @config = config @metadata = metadata @entries = {} - @specified = true @validator = self.class.validator.new(self) @validator.validate(:new) @@ -63,12 +62,8 @@ module Gitlab end end - def unspecify - @specified = false - end - def specified? - @specified + true end def relevant? @@ -76,18 +71,8 @@ module Gitlab end def inspect - val = if leaf? - config - else - descendants - end - - unspecified = if specified? - '' - else - '(unspecified) ' - end - + val = leaf? ? config : descendants + unspecified = specified? ? '' : '(unspecified) ' "#<#{self.class.name} #{unspecified}{#{key}: #{val.inspect}}>" end diff --git a/lib/gitlab/ci/config/entry/unspecified.rb b/lib/gitlab/ci/config/entry/unspecified.rb new file mode 100644 index 00000000000..fbb2551e870 --- /dev/null +++ b/lib/gitlab/ci/config/entry/unspecified.rb @@ -0,0 +1,19 @@ +module Gitlab + module Ci + class Config + module Entry + ## + # This class represents an unspecified entry. + # + # It decorates original entry adding method that indicates it is + # unspecified. + # + class Unspecified < SimpleDelegator + def specified? + false + end + end + end + end + end +end |