Pathutil tries to be a faster pure Ruby impelementation of Pathname. It arose out of a need to fix basic problems with Pathname, such as suscepetibility to join overrides, need for automatic encoding, and normalization (for stuff like Jekyll) and the ability to do other safe-style operations in an encapsulated format, like copying files and folders with symlinks but only if they originate from the given root.
Diverging (or New/Extra) Methods
encoding=- Set the read/write encoding.
=~- Regexp operations on the path, behaves normally.
search_backwards- Allows you to search backwards for a file or folder.
>- Check if a file is in but ahead of a path:
Pathutil.new("/tmp/hello") > "/tmp" # => true
in_path?- Check if a file is within a given path:
Pathutil.new("/tmp/hello").in_path?("/tmp") # => true
<- Check if a file is in but below a path:
Pathutil.new("/tmp") < "/tmp/hello" # => true
read_yaml- a wrapper around
SafeYAMLto make reading
children- behaves like Pathname, except it accepts a block to work on the path.
safe_copy- Copy files, disallowing symlinks unless
enforce_root- Force a root if not already in that root.
read_yaml- Read YAML with or without safe.
unlink- Behaves like File.
first (alias of
gsub (works on
chomp (works on
to_str (alias of
to_a (alias of
last (alias of
Current (All) Methods
Pathutil has and responds to all methods that Pathname provides and forwards
them where they need to go with wrappers if necessary and with our
the first argumement on our behalf. It is a true encapsulator with a few
extra helpers to make your life easy.