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

NAME

JavaScript::Dependency::Manager - Manage your JavaScript dependencies

VERSION

version 0.001002

SYNOPSIS

First, annotate your javascript files with provides and/or requires:

 // provides: Ack
 // requires: underscore
 var Ack = _.throttle(function(foo) {
   alert('ACK! ' + foo)
 }, 100)

 // etc, etc

Now you can use JavaScript::Dependency::Manager to automatically create a list of files needed for a given "provision".

 use JavaScript::Dependency::Manager;

 my $mgr = JavaScript::Dependency::Manager->new(
   lib_dir => ['root/js/lib'],
   provisions => {
     underscore => ['root/js/lib/underscore/underscore.js'],
   },
 );

 my @files = $mgr->file_list_for_provisions(['Lynx.ui.form.MWHY']);

Note that I manually set a provision above. That's because underscore is an external library, so I shouldn't edit it's source to set it's provisions.

DESCRIPTION

This module simply helps you automatically create a list of necessary files based on a list of "modules", which are merely your way of identifying functions, objects, classes, or whatever else that you would like to load. It will correctly order the list of files to load based on your defined requirements.

TERMS

requirement

A requirement is simply a module that a given file needs to run.

provision

A provision is simply a module that a given file has within it.

METHODS

file_list_for_provisions

 my @files = $mgr->file_list_for_provisions(['Foo', 'Bar'])

This method returns a list of files needed to load a list of provisions.

ATTRIBUTES

lib_dir

required. An ArrayRef of directories to scan to create the list of "requirement"s and "provision"s.

recurse

False by default. Set to true if you want the tool to recurse into subdirectories of the "lib_dir".

scan_files

True by default. Set to false if you want the tool not to scan files at all, but instead use a provided list of "requirement"s and "provision"s.

DEDICATION

JavaScript::Dependency::Manager module is dedicated to my namesake, Arthur Dale Schmidt. He was my grandfather as well as the inventor of a chemical called Sand Control 60 (SC60,) which was used in oil fields to reduce the need to redrill entire wells due to sand clogging.

AUTHOR

Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Arthur Axel "fREW" Schmidt.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.