Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
e0ce97fb
Commit
e0ce97fb
authored
Dec 08, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor ci status factories to DRY code a little
parent
feaf0180
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
29 deletions
+28
-29
lib/gitlab/ci/status/build/factory.rb
lib/gitlab/ci/status/build/factory.rb
+5
-6
lib/gitlab/ci/status/extended.rb
lib/gitlab/ci/status/extended.rb
+1
-1
lib/gitlab/ci/status/factory.rb
lib/gitlab/ci/status/factory.rb
+17
-13
lib/gitlab/ci/status/pipeline/factory.rb
lib/gitlab/ci/status/pipeline/factory.rb
+3
-5
lib/gitlab/ci/status/stage/factory.rb
lib/gitlab/ci/status/stage/factory.rb
+2
-4
No files found.
lib/gitlab/ci/status/build/factory.rb
View file @
e0ce97fb
...
@@ -3,14 +3,13 @@ module Gitlab
...
@@ -3,14 +3,13 @@ module Gitlab
module
Status
module
Status
module
Build
module
Build
class
Factory
<
Status
::
Factory
class
Factory
<
Status
::
Factory
private
def
self
.
extended_statuses
[
Status
::
Build
::
Stop
,
Status
::
Build
::
Play
,
def
extended_statuses
Status
::
Build
::
Cancelable
,
Status
::
Build
::
Retryable
]
[
Stop
,
Play
,
Cancelable
,
Retryable
]
end
end
def
core_statu
s
def
self
.
common_helper
s
super
.
extend
(
Status
::
Build
::
Common
)
Status
::
Build
::
Common
end
end
end
end
end
end
...
...
lib/gitlab/ci/status/extended.rb
View file @
e0ce97fb
...
@@ -2,7 +2,7 @@ module Gitlab
...
@@ -2,7 +2,7 @@ module Gitlab
module
Ci
module
Ci
module
Status
module
Status
module
Extended
module
Extended
def
matches?
(
_subject
)
def
matches?
(
_subject
,
_user
)
raise
NotImplementedError
raise
NotImplementedError
end
end
end
end
...
...
lib/gitlab/ci/status/factory.rb
View file @
e0ce97fb
...
@@ -2,10 +2,9 @@ module Gitlab
...
@@ -2,10 +2,9 @@ module Gitlab
module
Ci
module
Ci
module
Status
module
Status
class
Factory
class
Factory
attr_reader
:subject
def
initialize
(
subject
,
user
=
nil
)
def
initialize
(
subject
)
@subject
=
subject
@subject
=
subject
@user
=
user
end
end
def
fabricate!
def
fabricate!
...
@@ -16,27 +15,32 @@ module Gitlab
...
@@ -16,27 +15,32 @@ module Gitlab
end
end
end
end
def
self
.
extended_statuses
[]
end
def
self
.
common_helpers
Module
.
new
end
private
private
def
s
ubject
_status
def
s
imple
_status
@s
ubject_status
||=
subject
.
status
@s
imple_status
||=
@subject
.
status
||
:created
end
end
def
core_status
def
core_status
Gitlab
::
Ci
::
Status
Gitlab
::
Ci
::
Status
.
const_get
(
subject_status
.
capitalize
)
.
const_get
(
simple_status
.
capitalize
)
.
new
(
subject
)
.
new
(
@subject
)
.
extend
(
self
.
class
.
common_helpers
)
end
end
def
extended_status
def
extended_status
@extended
||=
extended_statuses
.
find
do
|
status
|
@extended
||=
self
.
class
.
extended_statuses
.
find
do
|
status
|
status
.
matches?
(
subject
)
status
.
matches?
(
@subject
,
@user
)
end
end
end
end
def
extended_statuses
[]
end
end
end
end
end
end
end
...
...
lib/gitlab/ci/status/pipeline/factory.rb
View file @
e0ce97fb
...
@@ -3,14 +3,12 @@ module Gitlab
...
@@ -3,14 +3,12 @@ module Gitlab
module
Status
module
Status
module
Pipeline
module
Pipeline
class
Factory
<
Status
::
Factory
class
Factory
<
Status
::
Factory
private
def
self
.
extended_statuses
def
extended_statuses
[
Pipeline
::
SuccessWithWarnings
]
[
Pipeline
::
SuccessWithWarnings
]
end
end
def
core_statu
s
def
self
.
common_helper
s
super
.
extend
(
Status
::
Pipeline
::
Common
)
Status
::
Pipeline
::
Common
end
end
end
end
end
end
...
...
lib/gitlab/ci/status/stage/factory.rb
View file @
e0ce97fb
...
@@ -3,10 +3,8 @@ module Gitlab
...
@@ -3,10 +3,8 @@ module Gitlab
module
Status
module
Status
module
Stage
module
Stage
class
Factory
<
Status
::
Factory
class
Factory
<
Status
::
Factory
private
def
self
.
common_helpers
Status
::
Stage
::
Common
def
core_status
super
.
extend
(
Status
::
Stage
::
Common
)
end
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment