summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-12-05 12:07:14 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-12-05 12:07:14 +0100
commitd28f5e776b90a648a83246beac94518cd8183af4 (patch)
treef2a6765449814b965b7f7ef3401362ba456f221b /lib/gitlab/ci
parentb86d8afe23524d10956cfbc1b87337fd2ce75e8c (diff)
downloadgitlab-ce-d28f5e776b90a648a83246beac94518cd8183af4.tar.gz
Implement pipeline status factory with extended status
Diffstat (limited to 'lib/gitlab/ci')
-rw-r--r--lib/gitlab/ci/status/pipeline/factory.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/gitlab/ci/status/pipeline/factory.rb b/lib/gitlab/ci/status/pipeline/factory.rb
new file mode 100644
index 00000000000..71d27bf7cf5
--- /dev/null
+++ b/lib/gitlab/ci/status/pipeline/factory.rb
@@ -0,0 +1,39 @@
+module Gitlab
+ module Ci
+ module Status
+ module Pipeline
+ class Factory
+ EXTENDED_STATUSES = [Pipeline::SuccessWithWarnings]
+
+ def initialize(pipeline)
+ @pipeline = pipeline
+ @status = pipeline.status || :created
+ end
+
+ def fabricate!
+ if extended_status
+ extended_status.new(core_status)
+ else
+ core_status
+ end
+ end
+
+ private
+
+ def core_status
+ Gitlab::Ci::Status
+ .const_get(@status.capitalize)
+ .new(@pipeline)
+ .extend(Status::Pipeline::Common)
+ end
+
+ def extended_status
+ @extended ||= EXTENDED_STATUSES.find do |status|
+ status.matches?(@pipeline)
+ end
+ end
+ end
+ end
+ end
+ end
+end