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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
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
private
def
create_node
(
key
,
factory
)
factory
.
with
_value
(
@value
[
key
])
factory
.
null
_node
unless
@value
.
has_key?
(
key
)
factory
.
with
(
value:
@value
[
key
])
factory
.
null
ify!
unless
@value
.
has_key?
(
key
)
factory
.
create!
end
...
...
@@ -45,7 +45,7 @@ module Gitlab
def
allow_node
(
symbol
,
entry_class
,
metadata
)
factory
=
Node
::
Factory
.
new
(
entry_class
)
.
with
_description
(
metadata
[
:description
])
.
with
(
description:
metadata
[
:description
])
define_method
(
symbol
)
do
raise
Entry
::
InvalidError
unless
valid?
...
...
lib/gitlab/ci/config/node/factory.rb
View file @
11c0d022
...
...
@@ -15,17 +15,12 @@ module Gitlab
@attributes
=
{}
end
def
with
_value
(
value
)
@attributes
[
:value
]
=
value
def
with
(
attributes
)
@attributes
.
merge!
(
attributes
)
self
end
def
with_description
(
description
)
@attributes
[
:description
]
=
description
self
end
def
null_node
def
nullify!
@entry_class
=
Node
::
Null
self
end
...
...
spec/lib/gitlab/ci/config/node/factory_spec.rb
View file @
11c0d022
...
...
@@ -8,7 +8,7 @@ describe Gitlab::Ci::Config::Node::Factory do
context
'when value setting value'
do
it
'creates entry with valid value'
do
entry
=
factory
.
with
_value
(
[
'ls'
,
'pwd'
])
.
with
(
value:
[
'ls'
,
'pwd'
])
.
create!
expect
(
entry
.
value
).
to
eq
"ls
\n
pwd"
...
...
@@ -17,8 +17,8 @@ describe Gitlab::Ci::Config::Node::Factory do
context
'when setting description'
do
it
'creates entry with description'
do
entry
=
factory
.
with
_value
(
[
'ls'
,
'pwd'
])
.
with
_description
(
'test description'
)
.
with
(
value:
[
'ls'
,
'pwd'
])
.
with
(
description:
'test description'
)
.
create!
expect
(
entry
.
value
).
to
eq
"ls
\n
pwd"
...
...
@@ -38,8 +38,8 @@ describe Gitlab::Ci::Config::Node::Factory do
context
'when creating a null entry'
do
it
'creates a null entry'
do
entry
=
factory
.
with
_value
(
nil
)
.
null
_node
.
with
(
value:
nil
)
.
null
ify!
.
create!
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