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
VERSION | = | "0.14.0" |
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 | -> | / |
encoding | [W] | |
encoding | [W] |
— @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 —
— 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 —
— @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 —
— @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 —
— @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> —
— 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 —
— 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> —
— @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> —