Class Pathutil
In: lib/pathutil/helpers.rb
lib/pathutil/version.rb
lib/pathutil.rb
Parent: Object

Frozen-string-literal: true Copyright: 2015-2016 Jordon Bedwell - MIT License Encoding: utf-8

Methods

Classes and Modules

Module Pathutil::Helpers

Constants

VERSION = "0.14.0"

External Aliases

pwd -> gcwd
pwd -> cwd
join -> +
 
rm -> delete
rm_r -> rmtree
to_s -> to_path
basename -> last
symlink -> make_symlink
link -> make_link
dirname -> first
rm_r -> rmdir
rm -> unlink
join -> /

Attributes

encoding  [W] 
encoding  [W] 

Public Class methods

— @note A lot of this class can be compatible with Pathname. Initialize a new instance. @return Pathutil

Public Instance methods

— @example Pathutil.new("/") < Pathutil.new("/hello") # => true Strictly check to see if a path is behind other path but within it. @return true|false —

— Check to see if a path is behind the other path but within it. @example Pathutil.new("/hello") < Pathutil.new("/hello") # => true @example Pathutil.new("/") < Pathutil.new("/hello") # => true @return true|false —

— @see `String#==` for more details. A stricter version of `==` that also makes sure the object matches. @return true|false —

— @example Pathutil.new("/hello/world") > Pathutil.new("/hello") # => true Strictly checks to see if a path is deeper but within the path of the other. @return true|false —

— @example Pathutil.new("/hello") >= Pathutil.new("/") # => true @example Pathutil.new("/hello") >= Pathutil.new("/hello") # => true Checks to see if a path falls within a path and deeper or is the other. @return true|false —

— Make a path absolute

— @note "./" is considered relative. Check to see if the path is absolute, as in: starts with "/" @return true|false —

— rubocop:disable Metrics/AbcSize rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity —

— @yield Pathutil Break apart the path and yield each with the previous parts. @example Pathutil.new("/hello/world").ascend.to_a # => ["/", "/hello", "/hello/world"] @example Pathutil.new("/hello/world").ascend { |path| $stdout.puts path } @return Enum —

— @note You can set the default encodings via the class. Binread took two steroid shots: it can normalize your string, and encode. @return String —

— @note You can set the default encodings via the class. Binwrite took two steroid shots: it can normalize your string, and encode. @return Fixnum<Bytes> —

— @yield &block Move to the current directory temporarily (or for good) and do work son. @note you do not need to ship a block at all. @return nil —

— @return Array<Pathutil> Grab all of the children from the current directory, including hidden. @yield Pathutil

— @see Pathname#cleanpath. @note This is a wholesale rip and cleanup of Pathname#cleanpath @return Pathutil

— @yield Pathutil Break apart the path in reverse order and descend into the path. @example Pathutil.new("/hello/world").descend.to_a # => ["/hello/world", "/hello", "/"] @example Pathutil.new("/hello/world").descend { |path| $stdout.puts path } @return Enum —

— @yield Pathutil Splits the path returning each part (filename) back to you. @return Enum —

— @yield Pathutil @example Pathutil.new("/hello/world").each_line { |line| $stdout.puts line } Wraps `readlines` and allows you to yield on the result. @return Enum —

— @see `self.class.encoding` as this is an alias. —

— Expands the path and left joins the root to the path. @return Pathutil

— @yield Pathutil Find all files without care and yield the given block. @return Enum —

— @example Pathutil.new("/hello").fnmatch?("/hello") # => true Unlike traditional `fnmatch`, with this one `Regexp` is allowed. @example Pathutil.new("/hello").fnmatch?(/h/) # => true @see `File#fnmatch` for more information. @return true|false —

— @yield Pathutil Allows you to glob however you wish to glob in the current `Pathutil` @see `File::Constants` for a list of flags. @return Enum —

— Allows you to check if the current path is in the path you want. @return true|false —

— @see `self.class.normalize` as this is an alias. —

— Get the parent of the current path. @note This will simply return self if "/". @return Pathutil

— @note You can set the default encodings via the class. Read took two steroid shots: it can normalize your string, and encode. @return String —

— Read the file as a JSON file turning it into an object. @see self.class.read_json as this is a direct alias of that method. @return Hash —

— Read the file as a YAML file turning it into an object. @see self.class.load_yaml as this a direct alias of that method. @return Hash —

— @note You can set the default encodings via the class. Readlines took two steroid shots: it can normalize your string, and encode. @return Array<String> —

— Make a path relative. —

— A less complex version of `relative_path_from` that simply uses a `Regexp` and returns the full path if it cannot be determined. @return Pathutil

— Allows you to quickly determine if the file is the root folder. @return true|false —

— Copy a directory, allowing symlinks if the link falls inside of the root. This is indented for people who wish some safety to their copies. @note Ignore is ignored on safe_copy file because it‘s explicit. @return nil —

— @yield Pathutil @note It will return all results that it finds across all ascending paths. @example Pathutil.new("~/").expand_path.search_backwards(".bashrc") => [#<Pathutil:/home/user/.bashrc>] Search backwards for a file (like Rakefile, _config.yml, opts.yml). @return Enum —

— @yield Pathutil Split the file into its dirname and basename, so you can do stuff. @return nil —

— @note The blank part is intentionally left there so that you can rejoin. Splits the path into all parts so that you can do step by step comparisons @example Pathutil.new("/my/path").split_path # => ["", "my", "path"] @return Array<String> —

— Strips the windows drive from the path. —

— @note Your extension should start with "." Replace a files extension with your given extension. @return Pathutil

— @note You can set the default encodings via the class. Write took two steroid shots: it can normalize your string, and encode. @return Fixnum<Bytes> —

[Validate]