Class: Gitlab::Ci::Build::Artifacts::Path
- Inherits:
-
Object
- Object
- Gitlab::Ci::Build::Artifacts::Path
- Defined in:
- lib/gitlab/ci/build/artifacts/path.rb
Instance Method Summary collapse
- #directory? ⇒ Boolean
-
#initialize(path) ⇒ Path
constructor
A new instance of Path.
- #name ⇒ Object
- #nodes ⇒ Object
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(path) ⇒ Path
Returns a new instance of Path.
8 9 10 |
# File 'lib/gitlab/ci/build/artifacts/path.rb', line 8 def initialize(path) @path = path.dup.force_encoding('UTF-8') end |
Instance Method Details
#directory? ⇒ Boolean
16 17 18 |
# File 'lib/gitlab/ci/build/artifacts/path.rb', line 16 def directory? @path.end_with?('/') end |
#name ⇒ Object
20 21 22 |
# File 'lib/gitlab/ci/build/artifacts/path.rb', line 20 def name @path.split('/').last.to_s end |
#nodes ⇒ Object
24 25 26 |
# File 'lib/gitlab/ci/build/artifacts/path.rb', line 24 def nodes @path.count('/') end |
#to_s ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/gitlab/ci/build/artifacts/path.rb', line 28 def to_s @path.tap do |path| unless nonzero? raise ArgumentError, 'Path contains zero byte character!' end unless utf8? raise ArgumentError, 'Path contains non-UTF-8 byte sequence!' end end end |
#valid? ⇒ Boolean
12 13 14 |
# File 'lib/gitlab/ci/build/artifacts/path.rb', line 12 def valid? nonzero? && utf8? end |