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

NAME

Hub - Hub Library Interface

SYNOPSIS

We pollute our symbol table with all of our internal libraries' EXPORT_OK symbols so you don't have to.

    use Hub; # nothing imported
    print 'Why hello there, mister ', Hub::getname($0), "\n";

    use Hub ':standard';
    print 'Excuse me, mister ', getname($0), "\n";

In both cases, Hub::Data::File::getname(...) is the called method.

DESCRIPTION

PUBLIC METHODS

import

Get symbols from this library

This adapter method allows us to look at the requested tags before Exporter gets ahold of it. We want to dynamically load internal libraries based on the requested tag. In this way, you can create a new set of modules:

  /path/to/lib/Hub/Mystuff/Peak.pm
                          /Crescendo.pm

and use them in a file as:

  use Hub(:mystuff);

and you get the same facilities as this library itself. Meaning you can call EXPORT_OK subroutines of Peak.pm and Crescendo.pm as Hub::subroutine() or just subroutine().

Inside Peak.pm and Crescendo.pm, you should:

  use Hub(:lib);

So you get the standard set of external symbols, like import, carp, croak, cluck, confess, blessed, time, gettimeofday, tv_interval and cwd(). See _load_external_libs.

If you would like Crescendo.pm to use methods from Peak.pm, you should:

  use Hub(:lib :mystuff);

And then reference those methods as Hub::methodname(). This is not a requirement by any means, but half of the reasons for doing all this in the first place is to make refactoring simple. If you follow this route (note you should also be using Hub::mkinst('Peak') to create your objects) than you can move code around without changing the API.

mkinst

Create an instance (object) by its short name.
 Usage: mkinst $short_name

See also hubuse.

Example returns: true:

    ref(mkinst('Object')) eq 'Hub::Base::Object';

Example returns: abort:

    mkinst('DoesNotExist');

knot

Return the implementing package (full name) for the given knot
 Usage: knot $short_name

See also hubuse.

callback

Invocation method for persistent applications
 Usage: callback \&subroutine

Intended usage:

  #!/usr/bin/perl -w
  use strict;
  use Hub qw(:standard);
  while( my $req = ??? ) {
      callback( &main, $req );
  }
  sub main {
      my $req = shift;
      # your code here
  }

The callback method wraps your code with the necessary initialization and destruction code required to isolate this instance (run) from others.

regns

Register namespace.
 Usage: regns $name, [\%value]

Intended for Hub library modules only.

getns

Get namespace
 Usage: getns $name, [$address]

Intended for Hub library modules only.

trace

Warn with a stack trace
 Usage: trace @messages

about

Return an about message regarding this library
 Usage: about

version

Return the library version number
 Usage: version

INTERNAL METHODS

_load_external_libs

Load external modules.

Share minimal list of standard functions which every module in its right mind would use.

_load_internal_libs

We want to import all EXPORT_OK methods from packages.
 Usage: _load_internal_libs @list
 Usage: _load_internal_libs 'all'

Where each item in @list is the name of a directory beneath 'Hub'.

_findmodules

Recursively get module names
 Usage: _findmodules $directory, $package_name

Searches in the sub-directory of this top-level-module for all library files to represent. $package_name is the package (directory) name which corresponds to the given $directory.

Recursive.

_tagname

Return which EXPORT_TAGS key to which a module should belong.
 Usage: _tagname $module_name

END

Finish library wheel.

AUTHOR

Ryan Gies (ryangies@livesite.net)

COPYRIGHT

Copyright (C) 2006-2007 by Livesite Networks, LLC. All rights reserved.

Copyright (C) 2000-2005 by Ryan Gies. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

* The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.

* Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.

* The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

To the best of our knowledge, no patented algorithms have been used. However, we do not have the resources to carry out a patent search, and therefore cannot give any guarantee of the above statement.

UPDATED

08/02/2007