Class-Usul
view release on metacpan or search on metacpan
lib/Class/Usul/Functions.pm view on Meta::CPAN
__END__
=pod
=head1 Name
Class::Usul::Functions - Globally accessible functions
=head1 Synopsis
package MyBaseClass;
use Class::Usul::Functions qw( functions to import );
=head1 Description
Provides globally accessible functions
=head1 Subroutines/Methods
=head2 C<abs_path>
$absolute_untainted_path = abs_path $some_path;
Untaints path. Makes it an absolute path and returns it. Returns undef
otherwise. Traverses the filesystem
=head2 C<app_prefix>
$prefix = app_prefix __PACKAGE__;
Takes a class name and returns it lower cased with B<::> changed to
B<_>, e.g. C<App::Munchies> becomes C<app_munchies>
=head2 C<arg_list>
$args = arg_list @rest;
Returns a hash ref containing the passed parameter list. Enables
methods to be called with either a list or a hash ref as it's input
parameters
=head2 C<assert>
assert $ioc_object, $condition, $message;
By default does nothing. Does not evaluate the passed parameters. The
L<assert|Classs::Usul::Constants/ASSERT> constant can be set via
an inherited class attribute to do something useful with whatever parameters
are passed to it
=head2 C<assert_directory>
$untainted_path = assert_directory $path_to_directory;
Untaints directory path. Makes it an absolute path and returns it if it
exists. Returns undef otherwise
=head2 C<base64_decode_ns>
$decoded_value = base64_decode_ns $encoded_value;
Decode a scalar value encode using L</base64_encode_ns>
=head2 C<base64_encode_ns>
$encoded_value = base64_encode_ns $encoded_value;
Base 64 encode a scalar value using an output character set that preserves
the input values sort order (natural sort)
=head2 C<bsonid>
$bson_id = bsonid;
Generate a new C<BSON> id. Returns a 24 character string of hex digits that
are reasonably unique across hosts and are in ascending order. Use this
to create unique ids for data streams like message queues and file feeds
=head2 C<bsonid_time>
$seconds_elapsed_since_the_epoch = bsonid_time $bson_id;
Returns the time the C<BSON> id was generated as Unix time
=head2 C<bson64id>
$base64_encoded_extended_bson64_id = bson64id;
Like L</bsonid> but better thread long running process support. A custom
Base64 encoding is used to reduce the id length
=head2 C<bson64id_time>
$seconds_elapsed_since_the_epoch = bson64id_time $bson64_id;
Returns the time the C<BSON64> id was generated as Unix time
=head2 C<canonicalise>
$untainted_canonpath = canonicalise $base, $relpath;
Appends C<$relpath> to C<$base> using L<File::Spec::Functions>. The C<$base>
and C<$relpath> arguments can be an array reference or a scalar. The return
path is untainted and canonicalised
=head2 C<class2appdir>
$appdir = class2appdir __PACKAGE__;
Returns lower cased L</distname>, e.g. C<App::Munchies> becomes
C<app-munchies>
=head2 C<classdir>
$dir_path = classdir __PACKAGE__;
Returns the path (directory) of a given class. Like L</classfile> but
without the I<.pm> extension
=head2 C<classfile>
( run in 0.572 second using v1.01-cache-2.11-cpan-2398b32b56e )