class Novika::Resolver::Disk
- Novika::Resolver::Disk
- Reference
- Object
Overview
A caching, resolver-specific file system access abstraction on top
of Crystal's Dir
and File
.
Defined in:
novika/resolver.crConstant Summary
-
InfoAbsent =
InfoAbsence.new
-
Singleton instance of
InfoAbsence
.
Constructors
Instance Method Summary
-
#dir?(path : Path) : Path | Nil
If path (symlink or not) points to a directory, returns the real path to that directory.
-
#env?(origin : Path) : Path | Nil
Determines and returns the path to the environment directory, if any.
-
#file?(path : Path) : Path | Nil
If path (symlink or not) points to a file, returns the real path to that file.
-
#glob(origin : Path, selector : GlobSelector, &fn : Path -> )
A simpler, Novika- and
Disk
-specific globbing mechanism. -
#info?(path : Path) : InfoPresence | Nil
Reads, caches, and returns the
InfoPresence
object for the given path. -
#read(path : Path) : String | Nil
Returns the content of the file that path points to.
-
#write(path : Path, & : IO -> )
Yields writable
IO
for the file that path points to.
Constructor Detail
Instance Method Detail
If path (symlink or not) points to a directory, returns the real path to that directory. Otherwise, returns nil.
Determines and returns the path to the environment directory, if any. Otherwise, returns nil.
Climbs up from origin until encountering:
- A file named '.nk.env'
- A directory named 'env' containing a file named '.nk.env'
- A directory named '.novika'
The result is cached, recursively, so you can call this method as many times as you'd like; your disk won't explode.
If path (symlink or not) points to a file, returns the real path to that file. Otherwise, returns nil.
A simpler, Novika- and Disk
-specific globbing mechanism.
Calls fn with paths in origin directory that match the given selector.
Reads, caches, and returns the InfoPresence
object for the
given path. Returns nil if there is nothing at path. The
absence is also cached.
path is assumed to be absolute and normalized.
If path is a symlink, the symlink is visited. Therefore, the
returned InfoPresence
will contain the real path rather than
path. So prefer to use the resulting InfoPresence#path
in
favor of path after calling this method.
Returns the content of the file that path points to.
Raises if path doesn't point to a file.
Yields writable IO
for the file that path points to. The
file is created if it does not exist; its content is cleared
if it does.