The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Hyper::Functions - common functions for the Hyper Framework

VERSION

This document describes Hyper::Functions 0.01

SYNOPSIS

use Hyper::Functions;

DESCRIPTION

Hyper::Functions provides some basic subroutines which need no oop things.

SUBROUTINES/METHODS

listify :Export

    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_via_string :Export

    use Hyper::Functions qw(use_via_string);
    my $class = use_via_string('My::Package');

Allows you to use a package with a string.

get_path_for :Export

    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).

find_file :Export

    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.

class_to_path :Export

    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.

fix_class_name :Export

    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.

get_path_from_file :Export

    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.

DIAGNOSTICS

CONFIGURATION AND ENVIRONMENT

Use Hyper::Singleton::Context for your configuration.

Sample for your Context.ini

    [Global]
    base_path=/srv/web/www.example.com/

DEPENDENCIES

  • version

  • UNIVERSAL::require

  • Perl6::Export::Attrs

  • File::Spec

  • File::Basename

  • Readonly

INCOMPATIBILITIES

BUGS AND LIMITATIONS

RCS INFORMATIONS

Last changed by

$Author: ac0v $

Id

$Id: Functions.pm 317 2008-02-16 01:52:33Z ac0v $

Revision

$Revision: 317 $

Date

$Date: 2008-02-16 02:52:33 +0100 (Sa, 16 Feb 2008) $

HeadURL

$HeadURL: http://svn.hyper-framework.org/Hyper/Hyper/tags/0.05/lib/Hyper/Functions.pm $

AUTHOR

Andreas Specht <ACID@cpan.org>

LICENSE AND COPYRIGHT

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.