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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
69a3755c
Commit
69a3755c
authored
Jun 07, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Ci config entry that implements Null Object
parent
b95c60a0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
10 deletions
+46
-10
lib/gitlab/ci/config/node/entry.rb
lib/gitlab/ci/config/node/entry.rb
+12
-10
lib/gitlab/ci/config/node/null.rb
lib/gitlab/ci/config/node/null.rb
+17
-0
spec/lib/gitlab/ci/config/node/null_spec.rb
spec/lib/gitlab/ci/config/node/null_spec.rb
+17
-0
No files found.
lib/gitlab/ci/config/node/entry.rb
View file @
69a3755c
...
@@ -5,22 +5,28 @@ module Gitlab
...
@@ -5,22 +5,28 @@ module Gitlab
class
Entry
class
Entry
include
Config
::
ValidationHelpers
include
Config
::
ValidationHelpers
attr_reader
:value
,
:parent
attr_reader
:value
,
:
nodes
,
:
parent
def
initialize
(
value
,
config
,
parent
=
nil
)
def
initialize
(
value
,
config
,
parent
=
nil
)
@value
=
value
@value
=
value
@config
=
config
@config
=
config
@parent
=
parent
@parent
=
parent
@nodes
=
{}
@nodes
,
@errors
=
[],
[]
@errors
=
[]
keys
.
each_key
do
|
key
|
instance_variable_set
(
"@
#{
key
}
"
,
Null
.
new
(
nil
,
config
,
self
))
end
end
end
def
process!
def
process!
return
if
leaf?
return
if
leaf?
keys
.
each_pair
do
|
key
,
entry
|
keys
.
each
do
|
key
,
entry_class
|
next
unless
@value
.
include?
(
key
)
next
unless
@value
.
has_key?
(
key
)
@nodes
[
key
]
=
entry
.
new
(
@value
[
key
],
@config
,
self
)
entry
=
entry_class
.
new
(
@value
[
key
],
@config
,
self
)
instance_variable_set
(
"@
#{
key
}
"
,
entry
)
@nodes
.
append
(
entry
)
end
end
nodes
.
each
(
&
:process!
)
nodes
.
each
(
&
:process!
)
...
@@ -31,10 +37,6 @@ module Gitlab
...
@@ -31,10 +37,6 @@ module Gitlab
@errors
+
nodes
.
map
(
&
:errors
).
flatten
@errors
+
nodes
.
map
(
&
:errors
).
flatten
end
end
def
nodes
@nodes
.
values
end
def
valid?
def
valid?
errors
.
none?
errors
.
none?
end
end
...
...
lib/gitlab/ci/config/node/null.rb
0 → 100644
View file @
69a3755c
module
Gitlab
module
Ci
class
Config
module
Node
class
Null
<
Entry
def
keys
{}
end
def
method_missing
(
*
)
nil
end
end
end
end
end
end
spec/lib/gitlab/ci/config/node/null_spec.rb
0 → 100644
View file @
69a3755c
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Null
do
let
(
:entry
)
{
described_class
.
new
(
double
,
double
)
}
describe
'#leaf?'
do
it
'is leaf node'
do
expect
(
entry
).
to
be_leaf
end
end
describe
'#any_method'
do
it
'responds with nil'
do
expect
(
entry
.
any_method
).
to
be
nil
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