BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
518b2062
Commit
518b2062
authored
Dec 19, 2015
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `parent` iteration implementation to `StringPath`
parent
80a71576
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
string_path.rb
lib/gitlab/string_path.rb
+9
-2
string_path_spec.rb
spec/lib/gitlab/string_path_spec.rb
+10
-1
No files found.
lib/gitlab/string_path.rb
View file @
518b2062
...
@@ -35,11 +35,12 @@ module Gitlab
...
@@ -35,11 +35,12 @@ module Gitlab
end
end
def
has_parent?
def
has_parent?
raise
NotImplementedError
@universe
.
include?
(
@path
.
sub
(
basename
,
''
))
end
end
def
parent
def
parent
raise
NotImplementedError
return
nil
unless
has_parent?
new
(
@path
.
sub
(
basename
,
''
))
end
end
def
directories
def
directories
...
@@ -58,5 +59,11 @@ module Gitlab
...
@@ -58,5 +59,11 @@ module Gitlab
def
==
(
other
)
def
==
(
other
)
@path
==
other
.
path
&&
@universe
==
other
.
universe
@path
==
other
.
path
&&
@universe
==
other
.
universe
end
end
private
def
new
(
path
)
self
.
class
.
new
(
path
,
@universe
)
end
end
end
end
end
spec/lib/gitlab/string_path_spec.rb
View file @
518b2062
...
@@ -19,6 +19,7 @@ describe Gitlab::StringPath do
...
@@ -19,6 +19,7 @@ describe Gitlab::StringPath do
it
{
is_expected
.
to
be_absolute
}
it
{
is_expected
.
to
be_absolute
}
it
{
is_expected
.
to_not
be_relative
}
it
{
is_expected
.
to_not
be_relative
}
it
{
is_expected
.
to
be_file
}
it
{
is_expected
.
to
be_file
}
it
{
is_expected
.
to_not
have_parent
}
describe
'#basename'
do
describe
'#basename'
do
subject
{
described_class
.
new
(
'/file/with/absolute_path'
,
universe
).
basename
}
subject
{
described_class
.
new
(
'/file/with/absolute_path'
,
universe
).
basename
}
...
@@ -32,9 +33,13 @@ describe Gitlab::StringPath do
...
@@ -32,9 +33,13 @@ describe Gitlab::StringPath do
it
{
is_expected
.
to
be_directory
}
it
{
is_expected
.
to
be_directory
}
it
{
is_expected
.
to
be_relative
}
it
{
is_expected
.
to
be_relative
}
it
{
is_expected
.
to_not
have_parent
}
end
end
describe
'path/dir_1/'
do
describe
'path/dir_1/'
do
subject
{
described_class
.
new
(
'path/dir_1/'
,
universe
)
}
it
{
is_expected
.
to
have_parent
}
describe
'#files'
do
describe
'#files'
do
subject
{
described_class
.
new
(
'path/dir_1/'
,
universe
).
files
}
subject
{
described_class
.
new
(
'path/dir_1/'
,
universe
).
files
}
...
@@ -45,8 +50,12 @@ describe Gitlab::StringPath do
...
@@ -45,8 +50,12 @@ describe Gitlab::StringPath do
describe
'#basename'
do
describe
'#basename'
do
subject
{
described_class
.
new
(
'path/dir_1/'
,
universe
).
basename
}
subject
{
described_class
.
new
(
'path/dir_1/'
,
universe
).
basename
}
it
{
is_expected
.
to
eq
'dir_1/'
}
it
{
is_expected
.
to
eq
'dir_1/'
}
end
end
describe
'#parent'
do
subject
{
described_class
.
new
(
'path/dir_1/'
,
universe
).
parent
}
it
{
is_expected
.
to
eq
Gitlab
::
StringPath
.
new
(
'path/'
,
universe
)
}
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