Class: Git::Path
- Inherits:
-
Object
show all
- Defined in:
- lib/git/path.rb
Overview
A base class that represents and validates a filesystem path
Use for tracking things relevant to a Git repository, such as the working
directory or index file.
Instance Method Summary
collapse
Constructor Details
#initialize(path, must_exist: true) ⇒ Path
Returns a new instance of Path.
18
19
20
21
22
23
24
|
# File 'lib/git/path.rb', line 18
def initialize(path, must_exist: true)
path = File.expand_path(path)
raise ArgumentError, 'path does not exist', [path] if must_exist && !File.exist?(path)
@path = path
end
|
Instance Method Details
#path
10
11
12
13
14
15
16
|
# File 'lib/git/path.rb', line 10
def path
Git::Deprecation.warn(
'The .path accessor is deprecated and will be removed in v5.0. ' \
'Use .to_s instead.'
)
@path
end
|
#readable? ⇒ Boolean
26
27
28
|
# File 'lib/git/path.rb', line 26
def readable?
File.readable?(@path)
end
|
#to_s
34
35
36
|
# File 'lib/git/path.rb', line 34
def to_s
@path
end
|
#writable? ⇒ Boolean
30
31
32
|
# File 'lib/git/path.rb', line 30
def writable?
File.writable?(@path)
end
|