=head1 NAME

Data::Hub::FileSystem::PerlModule - 

=head1 SYNOPSIS



=head1 EXPORTS

Nothing exported by default

=over



=back

=head1 DEPENDENCIES

This module requires these other modules and libraries:

    Error::Logical
    Error::Programatic
    Perl::Module
    Data::Hub::Util

=head1 DESCRIPTION


PerlModule now inserts an @INC hook which looks for your file in Hub context.
Meaning, you may now:

  require '/web/scripts/util.pm';
  require '../shared.pm';
  require './share.pm';

from within your module.  Note that this hook is inserted at beginning of @INC
and will be run first.  Modules which exist in the same directory as the calling
module must be prefixed with './', as in:

  require './share.pm'; # correct
  require 'share.pm';   # not found

When calling routines, if the module has defined an ACCESS function, it will be
called (once per checkpoint) before calling a routine.

  sub ACCESS {
    return 1;   # return true (access allowed) or false (access denied)
  }





=head1 PACKAGE INTERNALS

=head2 __content

=over

=item Get/Set file contents






=back


=head2 FETCH

=over

=item Get subroutine




Note, do not eval, i.e., require, the contents until a sub is invoked. This 
is a security consideration, as eval is obviously dangerous. The intention 
is that one can access the contents of the file using this FileSystem  object,
without its contents being eval'd.

The downside is that we will return a valide CODE reference no matter what
key is being fetched. This could be handled with some /^sub\s+(\w+)/ type
magic in __parse_content.



=back


=head2 STORE

=over

=item Store subroutine value, fatal error!






=back


=head2 __use_content

=over

=item Eval file contents (use as a module)



The package name is determined from its absolute path



=back


=head2 __require_hook

=over

=item Evaluate paths in current Hub scope




Apache2::Reload considers every value in %INC to be a file path.  By default
the hook is placed in %INC in place of the file name (see %INC in perlvar).
Apache2::Reload will issue a warning when trying to reload the array, so we
set the %INC entry ourselves.



=back


=head2 __scan

=over

=item Read from disk if necessary






=back


=head2 __parse_content

=over

=item Generate dynamic package name




The perl-module should begin with (on its own line!):

  # PerlModule

which will be replaced with:


  package _home_user_test_module_pm;

presuming the file is located at /home/user/test/module.pm

Note:


  .-------------------  No whitespace is allowed before the pound-sign (#)
  v
  # PerlModule
   ^
   '------------------  Whitespace between the pound-sign and first word is 
                        optional.

If the content defines a package, e.g., C<package Local;> no modification is
performed.

If the content does not include the C<# PerlModule> crown, it will be 
inserted.

DEPRICATED

If the first line is:


  package PACKAGE;

it will be replaced with the dynamic package name.



=back


=head2 __sig_warn

=over

=item Replace '(eval ##)' with file name






=back


=head2 __sig_die

=over

=item Replace '(eval ##)' with file name






=back


=head2 __unload

=over

=item Unload a previously loaded package from this file path



Taken from ModPerl::Util::unload_package_pp



=back



=head1 AUTHORS

    Ryan Gies <ryangies@cpan.org>

=head1 COPYRIGHT

    Copyright (C) 2014-2016 by Ryan Gies. All rights reserved.
    Copyright (C) 2006-2013 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.

=cut

