Pinto::Util - Static utility functions for Pinto
version 0.0995
This is a private module for internal use only. There is nothing for you to see here (yet). All API documentation is purely for my own reference.
Throws a Pinto::Exception with the given message. If given a reference to a Pinto::Exception object, then it just throws it again.
Writes the message on STDERR if the PINTO_DEBUG environment variable is true. If the argument is a subroutine, it will be invoked and its output will be written instead. Always returns true.
PINTO_DEBUG
Just calls warn(), but always appends the newline so that line numbers are suppressed.
Given the name of an $author, returns the directory where the distributions for that author belong (as a Path::Class::Dir). The optional @base can be a series of Path::Class:Dir or path parts (as strings). If @base is given, it will be prepended to the directory that is returned.
$author
@base
Asserts whether var is a blessed reference and is an instance of the $class.
$class
Parses a path like the ones you would see in a full URI to a distribution in a CPAN repository, or the URI fragment you would see in a CPAN index. Returns the author and file name of the distribution. Subdirectories between the author name and the file name are discarded.
Return true if $path_or_uri appears to point to a release of perl itself. This is based on some file naming patterns that I've seen in the wild. It may not be completely accurate.
$path_or_uri
Returns the last modification time (in epoch seconds) for the file. The argument is required and the file must exist or an exception will be thrown.
file
Returns the MD-5 digest (as a hex string) for the $file. The argument is required and the file must exist on an exception will be thrown.
MD-5
$file
Returns the SHA-256 digest (as a hex string) for the $file. The argument is required and the file must exist on an exception will be thrown.
SHA-256
Throws an exception if the property name is invalid. Currently, property names must be alphanumeric plus any underscores or hyphens.
Throws an exception if the stack name is invalid. Currently, stack names must be alphanumeric plus underscores or hyphens.
Returns the current time (in epoch seconds) unless the current time has been overridden by $Pinto::Globals::current_utc_time.
$Pinto::Globals::current_utc_time
Returns the offset between current UTC time and the local time in seconds, unless overridden by $Pinto::Globals::current_time_offset. The current_time function is used to determine the current UTC time.
$Pinto::Globals::current_time_offset
current_time
Returns the username of the current user unless it has been overridden by $Pinto::Globals::current_username. The username can be defined through a number of environment variables. Throws an exception if no username can be determined.
$Pinto::Globals::current_username
Returns the author id of the current user unless it has been overridden by $Pinto::Globals::current_author_id. The author id can be defined through environment variables. Otherwise it defaults to the upper-case form of the current_username. And since PAUSE only allows letters and numbers in the author id, then we remove all of those from the current_username too.
$Pinto::Globals::current_author_id
current_username
Returns true if the process is connected to an interactive terminal (i.e. a keyboard & screen) unless it has been overridden by $Pinto::Globals::is_interactive.
$Pinto::Globals::is_interactive
Performs interpolation on a literal string. The string should not include anything that looks like a variable. Only metacharacters (like \n) will be interpolated correctly.
Returns the string with all leading and trailing whitespace removed.
Returns all the characters in $string before the first newline. If there is no newline, returns the entire $string.
$string
Returns all the characters in $string after the first newline. If there is no newline, returns an empty string.
Truncates the $string and appends $elipses if the $string is longer than $length characters. $elipses defaults to '...' if not specified.
$elipses
$length
Returns the string forced to lower case and words separated by underscores. For example FooBar becomes foo_bar.
FooBar
foo_bar
Returns a copy of $string with each line indented by $n spaces. In other words, it puts 4n spaces immediately after each newline in $string. The original $string is not modified.
$n
4n
Creates a symlink between the two files. No checks are performed to see if either path is valid or already exists. Throws an exception if the operation fails or is not supported.
Returns true if $string is the name of a system property.
Returns a UUID as a string. Currently, the UUID is derived from random numbers.
Returns a reference to an array containing the names of the colors pinto can use. This can be influenced by setting the PINTO_COLORS or PINTO_COLOURS environment variables.
PINTO_COLORS
PINTO_COLOURS
Returns true if the string is undefined, empty, or contains only whitespace.
Returns true if the string contains any non-whitespace characters.
Masks the parts the string that look like a password embedded in an http or https URI. For example, http://joe:secret@foo.com would return http://joe:*password*@foo.com
http://joe:secret@foo.com
http://joe:*password*@foo.com
Returns true if the argument looks like a URI to a remote repository
Jeffrey Ryan Thalhammer <jeff@stratopan.com>
This software is copyright (c) 2013 by Jeffrey Ryan Thalhammer.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Pinto, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Pinto
CPAN shell
perl -MCPAN -e shell install Pinto
For more information on module installation, please visit the detailed CPAN module installation guide.