PassiveSupport.Path.Sigil.sigil_P
sigil_P
, go back to PassiveSupport.Path.Sigil module for more information.
Quickly and idiomatically build filesystem paths
import PassiveSupport.Path.Sigil
causes ~P
to invoke
various functions within the Path
module, for quick and idiomatic
usage of filesystem paths. As its default behavior, ~P[path/to/something]
will expand to the output of Path.absname("path/to/something")
, but other
behaviors can be exposed depending on the modifier provided following the
closing delimiter. The enabled modifiers are currently:
'a'
forPath.absname/1
(default)'b'
forPath.basename/1
'd'
forPath.dirname/1
'x'
forPath.expand/1
'w'
forPath.wildcard/1
- and
'wd'
forPath.wildcard(path, match_dot: true)
Beyond that, there is no means of modifying function behavior any further,
and interpolation through ~p
is not yet implemented. They both are on
the roadmap for this module, but being that this maintainer fundamentally
works on this library in his spare time, the ready date for those
functionalities is decidedly TBD.
Examples
iex> ~P[foo]
Path.absname("foo")
iex> ~P[bar]a
Path.absname("bar")
iex> ~P[bat]b
"bat"
iex> ~P[bat/boy]b
"boy"
iex> ~P[fizz/buzz]d
"fizz"
iex> ~P[/etc/hosts]d
"/etc"
iex> ~P[/etc/config.d/nginx.conf]d
"/etc/config.d"
iex> ~P[./deps/phoenix/lib]x
Path.expand("./deps/phoenix/lib")
iex> ~P[~/.bash_profile]x
Path.expand("~/.bash_profile")
iex> ~P[**/*.txt]w
Path.wildcard("**/*.txt")