summaryrefslogtreecommitdiff
path: root/lib/gitlab
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2015-12-19 09:31:52 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-01-14 12:48:13 +0100
commit518b206287318006f9b57382a747b1474b6795a4 (patch)
tree010b3b7f59798770288b574cfce3a285dbc0b93e /lib/gitlab
parent80a71576ba27d84b3406a8b929328359e2edc9da (diff)
downloadgitlab-ce-518b206287318006f9b57382a747b1474b6795a4.tar.gz
Add `parent` iteration implementation to `StringPath`
Diffstat (limited to 'lib/gitlab')
-rw-r--r--lib/gitlab/string_path.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/gitlab/string_path.rb b/lib/gitlab/string_path.rb
index 3aa6200b572..3add56d2213 100644
--- a/lib/gitlab/string_path.rb
+++ b/lib/gitlab/string_path.rb
@@ -35,11 +35,12 @@ module Gitlab
end
def has_parent?
- raise NotImplementedError
+ @universe.include?(@path.sub(basename, ''))
end
def parent
- raise NotImplementedError
+ return nil unless has_parent?
+ new(@path.sub(basename, ''))
end
def directories
@@ -58,5 +59,11 @@ module Gitlab
def ==(other)
@path == other.path && @universe == other.universe
end
+
+ private
+
+ def new(path)
+ self.class.new(path, @universe)
+ end
end
end