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
Kazuhiko Shiozaki
gitlab-ce
Commits
73d2c7a5
Commit
73d2c7a5
authored
Dec 18, 2015
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new methods to StringPath
parent
f5d53086
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
3 deletions
+49
-3
lib/gitlab/string_path.rb
lib/gitlab/string_path.rb
+17
-2
spec/lib/gitlab/string_path_spec.rb
spec/lib/gitlab/string_path_spec.rb
+32
-1
No files found.
lib/gitlab/string_path.rb
View file @
73d2c7a5
...
@@ -7,11 +7,17 @@ module Gitlab
...
@@ -7,11 +7,17 @@ module Gitlab
#
#
#
#
class
StringPath
class
StringPath
attr_reader
:path
,
:universe
def
initialize
(
path
,
universe
)
def
initialize
(
path
,
universe
)
@path
=
path
@path
=
path
@universe
=
universe
@universe
=
universe
end
end
def
to_s
@path
end
def
absolute?
def
absolute?
@path
.
start_with?
(
'/'
)
@path
.
start_with?
(
'/'
)
end
end
...
@@ -28,8 +34,17 @@ module Gitlab
...
@@ -28,8 +34,17 @@ module Gitlab
!
directory?
!
directory?
end
end
def
to_s
def
files
@path
raise
NotImplementedError
end
def
basename
name
=
@path
.
split
(
::
File
::
SEPARATOR
).
last
directory?
?
name
+
::
File
::
SEPARATOR
:
name
end
def
==
(
other
)
@path
==
other
.
path
&&
@universe
==
other
.
universe
end
end
end
end
end
end
spec/lib/gitlab/string_path_spec.rb
View file @
73d2c7a5
...
@@ -2,8 +2,10 @@ require 'spec_helper'
...
@@ -2,8 +2,10 @@ require 'spec_helper'
describe
Gitlab
::
StringPath
do
describe
Gitlab
::
StringPath
do
let
(
:universe
)
do
let
(
:universe
)
do
[
'path/dir_1/'
,
[
'path/'
,
'path/dir_1/'
,
'path/dir_1/file_1'
,
'path/dir_1/file_1'
,
'path/dir_1/file_b'
,
'path/second_dir'
,
'path/second_dir'
,
'path/second_dir/dir_3/file_2'
,
'path/second_dir/dir_3/file_2'
,
'path/second_dir/dir_3/file_3'
,
'path/second_dir/dir_3/file_3'
,
...
@@ -17,5 +19,34 @@ describe Gitlab::StringPath do
...
@@ -17,5 +19,34 @@ 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
}
describe
'#basename'
do
subject
{
described_class
.
new
(
'/file/with/absolute_path'
,
universe
).
basename
}
it
{
is_expected
.
to
eq
'absolute_path'
}
end
end
describe
'path/'
do
subject
{
described_class
.
new
(
'path/'
,
universe
)
}
it
{
is_expected
.
to
be_directory
}
it
{
is_expected
.
to
be_relative
}
end
describe
'path/dir_1/'
do
describe
'#files'
do
subject
{
described_class
.
new
(
'path/dir_1/'
,
universe
).
files
}
pending
{
is_expected
.
to
all
(
be_an_instance_of
described_class
)
}
pending
{
is_expected
.
to
be
eq
[
Gitlab
::
StringPath
.
new
(
'path/dir_1/file_1'
,
universe
),
Gitlab
::
StringPath
.
new
(
'path/dir_1/file_b'
,
universe
)]
}
end
describe
'#basename'
do
subject
{
described_class
.
new
(
'path/dir_1/'
,
universe
).
basename
}
it
{
is_expected
.
to
eq
'dir_1/'
}
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