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
11c0d022
Commit
11c0d022
authored
Jun 13, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify ci config node factory
parent
7c8f3b0c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
16 deletions
+11
-16
lib/gitlab/ci/config/node/configurable.rb
lib/gitlab/ci/config/node/configurable.rb
+3
-3
lib/gitlab/ci/config/node/factory.rb
lib/gitlab/ci/config/node/factory.rb
+3
-8
spec/lib/gitlab/ci/config/node/factory_spec.rb
spec/lib/gitlab/ci/config/node/factory_spec.rb
+5
-5
No files found.
lib/gitlab/ci/config/node/configurable.rb
View file @
11c0d022
...
@@ -31,8 +31,8 @@ module Gitlab
...
@@ -31,8 +31,8 @@ module Gitlab
private
private
def
create_node
(
key
,
factory
)
def
create_node
(
key
,
factory
)
factory
.
with
_value
(
@value
[
key
])
factory
.
with
(
value:
@value
[
key
])
factory
.
null
_node
unless
@value
.
has_key?
(
key
)
factory
.
null
ify!
unless
@value
.
has_key?
(
key
)
factory
.
create!
factory
.
create!
end
end
...
@@ -45,7 +45,7 @@ module Gitlab
...
@@ -45,7 +45,7 @@ module Gitlab
def
allow_node
(
symbol
,
entry_class
,
metadata
)
def
allow_node
(
symbol
,
entry_class
,
metadata
)
factory
=
Node
::
Factory
.
new
(
entry_class
)
factory
=
Node
::
Factory
.
new
(
entry_class
)
.
with
_description
(
metadata
[
:description
])
.
with
(
description:
metadata
[
:description
])
define_method
(
symbol
)
do
define_method
(
symbol
)
do
raise
Entry
::
InvalidError
unless
valid?
raise
Entry
::
InvalidError
unless
valid?
...
...
lib/gitlab/ci/config/node/factory.rb
View file @
11c0d022
...
@@ -15,17 +15,12 @@ module Gitlab
...
@@ -15,17 +15,12 @@ module Gitlab
@attributes
=
{}
@attributes
=
{}
end
end
def
with
_value
(
value
)
def
with
(
attributes
)
@attributes
[
:value
]
=
value
@attributes
.
merge!
(
attributes
)
self
self
end
end
def
with_description
(
description
)
def
nullify!
@attributes
[
:description
]
=
description
self
end
def
null_node
@entry_class
=
Node
::
Null
@entry_class
=
Node
::
Null
self
self
end
end
...
...
spec/lib/gitlab/ci/config/node/factory_spec.rb
View file @
11c0d022
...
@@ -8,7 +8,7 @@ describe Gitlab::Ci::Config::Node::Factory do
...
@@ -8,7 +8,7 @@ describe Gitlab::Ci::Config::Node::Factory do
context
'when value setting value'
do
context
'when value setting value'
do
it
'creates entry with valid value'
do
it
'creates entry with valid value'
do
entry
=
factory
entry
=
factory
.
with
_value
(
[
'ls'
,
'pwd'
])
.
with
(
value:
[
'ls'
,
'pwd'
])
.
create!
.
create!
expect
(
entry
.
value
).
to
eq
"ls
\n
pwd"
expect
(
entry
.
value
).
to
eq
"ls
\n
pwd"
...
@@ -17,8 +17,8 @@ describe Gitlab::Ci::Config::Node::Factory do
...
@@ -17,8 +17,8 @@ describe Gitlab::Ci::Config::Node::Factory do
context
'when setting description'
do
context
'when setting description'
do
it
'creates entry with description'
do
it
'creates entry with description'
do
entry
=
factory
entry
=
factory
.
with
_value
(
[
'ls'
,
'pwd'
])
.
with
(
value:
[
'ls'
,
'pwd'
])
.
with
_description
(
'test description'
)
.
with
(
description:
'test description'
)
.
create!
.
create!
expect
(
entry
.
value
).
to
eq
"ls
\n
pwd"
expect
(
entry
.
value
).
to
eq
"ls
\n
pwd"
...
@@ -38,8 +38,8 @@ describe Gitlab::Ci::Config::Node::Factory do
...
@@ -38,8 +38,8 @@ describe Gitlab::Ci::Config::Node::Factory do
context
'when creating a null entry'
do
context
'when creating a null entry'
do
it
'creates a null entry'
do
it
'creates a null entry'
do
entry
=
factory
entry
=
factory
.
with
_value
(
nil
)
.
with
(
value:
nil
)
.
null
_node
.
null
ify!
.
create!
.
create!
expect
(
entry
).
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Null
expect
(
entry
).
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Null
...
...
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