Skip to content

Commit

Permalink
Tidy inline code
Browse files Browse the repository at this point in the history
  • Loading branch information
kentfredric committed Jul 10, 2015
1 parent 70ae9d5 commit 986d714
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
22 changes: 13 additions & 9 deletions README.pod
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ version 0.000002

#!/usr/bin/env perl
use Asset::Pack;

# lib/MyApp/Asset/FooJS.pm will embed assets/foo.js
write_module('assets/foo.js','MyApp::Asset::FooJS','lib');
write_module( 'assets/foo.js', 'MyApp::Asset::FooJS', 'lib' );

# Or better still, this discovers them all and namespaces under MyApp::Asset
find_and_pack('assets', 'MyApp::Asset');
find_and_pack( 'assets', 'MyApp::Asset' );

# It also writes MyApp::Asset which is an index file

=head1 DESCRIPTION
Expand All @@ -40,9 +43,10 @@ a human (or analyzed if it fails as part of a build).

=head2 C<write_module>

write_module($source, $module, $libdir?, $metadata?)
# write_module( $source, $module, $libdir?, $metadata? );

write_module( "./foo.js", "Foo::Bar", "./" );

write_module("./foo.js", "Foo::Bar", "./")
# ./Foo/Bar.pm now contains a uuencoded copy of foo.js

Given a source asset path, a module name and a library directory, packs the
Expand All @@ -52,7 +56,7 @@ to C<$libdir>
Later, getting the file is simple:

use Foo::Bar;
print $Foo::Bar::content; # File Content is a string.
print $Foo::Bar::content; # File Content is a string.

=head3 options:

Expand All @@ -72,9 +76,9 @@ Defaults to C<./lib>.

=head2 C<write_index>

write_index($index, $module, $libdir?, $metadata? )
# write_index( $index, $module, $libdir?, $metadata? );

write_index({ "A" => "X.js" }, "Foo::Bar", "./");
write_index( { "A" => "X.js" }, "Foo::Bar", "./" );

Creates a file index. This allows creation of a map of:

Expand All @@ -83,7 +87,7 @@ Creates a file index. This allows creation of a map of:
Entries that will be available in a constructed module as follows:

use Module::Name;
$Module::Name::index->{ "Module::Name" } # A String Path
$Module::Name::index->{"Module::Name"} # A String Path

These generated files do B<NOT> have a C<__DATA__> section

Expand All @@ -105,7 +109,7 @@ Defaults to C<./lib>.

=head2 C<find_and_pack>

find_and_pack( $root_dir, $namespace_prefix, $libdir ) -> Hash
# find_and_pack( $root_dir, $namespace_prefix, $libdir? ) -> Hash

Creates copies of all the contents of C<$root_dir> and constructs
( or reconstructs ) the relevant modules using C<$namespace_prefix>
Expand Down
22 changes: 13 additions & 9 deletions lib/Asset/Pack.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ our @EXPORT = qw(write_module write_index find_and_pack);

=func C<write_module>
write_module($source, $module, $libdir?, $metadata?)
# write_module( $source, $module, $libdir?, $metadata? );
write_module( "./foo.js", "Foo::Bar", "./" );
write_module("./foo.js", "Foo::Bar", "./")
# ./Foo/Bar.pm now contains a uuencoded copy of foo.js
Given a source asset path, a module name and a library directory, packs the
Expand All @@ -31,7 +32,7 @@ to C<$libdir>
Later, getting the file is simple:
use Foo::Bar;
print $Foo::Bar::content; # File Content is a string.
print $Foo::Bar::content; # File Content is a string.
=head3 options:
Expand Down Expand Up @@ -61,9 +62,9 @@ sub write_module {

=func C<write_index>
write_index($index, $module, $libdir?, $metadata? )
# write_index( $index, $module, $libdir?, $metadata? );
write_index({ "A" => "X.js" }, "Foo::Bar", "./");
write_index( { "A" => "X.js" }, "Foo::Bar", "./" );
Creates a file index. This allows creation of a map of:
Expand All @@ -72,7 +73,7 @@ Creates a file index. This allows creation of a map of:
Entries that will be available in a constructed module as follows:
use Module::Name;
$Module::Name::index->{ "Module::Name" } # A String Path
$Module::Name::index->{"Module::Name"} # A String Path
These generated files do B<NOT> have a C<__DATA__> section
Expand Down Expand Up @@ -104,7 +105,7 @@ sub write_index {

=func C<find_and_pack>
find_and_pack( $root_dir, $namespace_prefix, $libdir ) -> Hash
# find_and_pack( $root_dir, $namespace_prefix, $libdir? ) -> Hash
Creates copies of all the contents of C<$root_dir> and constructs
( or reconstructs ) the relevant modules using C<$namespace_prefix>
Expand Down Expand Up @@ -299,10 +300,13 @@ __END__
#!/usr/bin/env perl
use Asset::Pack;
# lib/MyApp/Asset/FooJS.pm will embed assets/foo.js
write_module('assets/foo.js','MyApp::Asset::FooJS','lib');
write_module( 'assets/foo.js', 'MyApp::Asset::FooJS', 'lib' );
# Or better still, this discovers them all and namespaces under MyApp::Asset
find_and_pack('assets', 'MyApp::Asset');
find_and_pack( 'assets', 'MyApp::Asset' );
# It also writes MyApp::Asset which is an index file
=head1 DESCRIPTION
Expand Down

0 comments on commit 986d714

Please sign in to comment.