Hyper::Functions - common functions for the Hyper Framework
This document describes Hyper::Functions 0.01
use Hyper::Functions;
Hyper::Functions provides some basic subroutines which need no oop things.
use Hyper::Functions qw(listify); my $array_ref = listify('text');
or
use Hyper::Functions; $array_ref = Hyper::Functions::listify(['text']);
Returns the original list reference or put the given parameters into a list reference, which is returned.
A single undef is converted into an empty list ref
use Hyper::Functions qw(use_via_string); my $class = use_via_string('My::Package');
Allows you to use a package with a string.
use Hyper::Functions qw(get_path_for); my $path = get_path_for('template'); # template, config, package
Get path for a specific type (eg. template will result in var).
use Hyper::Functions qw(find_file); my $full_path = find_file(template => 'my/file.htc');
Returns the original filename if its absolute. For relative filenames If the filename is relative we search for the file in the the base_path from Context.ini and the Hyper Template storage. The first param (eg. template) is used as file type to get the type part for the paths. I think nobody knows what I mean, so look at this examples:
find_file(template => 'my/file.htc'); # searches in $base_path/var/my/file.htc # and $hyper_template_path/var/my/file.htc find_file(config => 'my/file.ini'); # searches in $base_path/etc/my/file.ini # and $hyper_template_path/etc/my/file.ini find_file(package => 'my/file.pm'); # searches in $base_path/lib/my/file.pm # and $hyper_template_path/lib/my/file.pm
If no file was found an failure will be thrown.
use Hyper::Functions qw(class_to_path); my $path = class_to_path('My::Class'); $path eq 'My/Class';
Replace all double : chars with a /. This function is used for guessing template and config paths for Controls.
use Hyper::Functions qw(fix_class_name); my $class = fix_class_name('My.Class'); $class eq 'My::Class';
Replace all . chars with two : chars. This function is used to fix the class names used in the config syntax.
use Hyper::Functions qw(get_path_from_file); my $path = get_path_from_file('/etc/passwd'); $path eq '/etc';
Returns the absolute path of the directory where the file is located.
Use Hyper::Singleton::Context for your configuration.
Sample for your Context.ini
[Global] base_path=/srv/web/www.example.com/
version
UNIVERSAL::require
Perl6::Export::Attrs
File::Spec
File::Basename
Readonly
$Author: ac0v $
$Id: Functions.pm 317 2008-02-16 01:52:33Z ac0v $
$Revision: 317 $
$Date: 2008-02-16 02:52:33 +0100 (Sa, 16 Feb 2008) $
$HeadURL: http://svn.hyper-framework.org/Hyper/Hyper/tags/0.05/lib/Hyper/Functions.pm $
Andreas Specht <ACID@cpan.org>
<ACID@cpan.org>
Copyright (c) 2007, Andreas Specht <ACID@cpan.org>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Hyper, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Hyper
CPAN shell
perl -MCPAN -e shell install Hyper
For more information on module installation, please visit the detailed CPAN module installation guide.