Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial import

  • Loading branch information...
commit a8ece1ca14d5bf6fd5ea97fe3e9ff4bc0ce8407b 0 parents
Ricardo Signes authored
9 .cvsignore
@@ -0,0 +1,9 @@
+blib*
+Makefile
+Makefile.old
+pm_to_blib*
+*.tar.gz
+.lwpcookies
+.releaserc
+Module-Starter-Plugin-SimpleStore-*
+cover_db
3  .releaserc
@@ -0,0 +1,3 @@
+cpan_user RJBS
+sf_user <none>
+passive_ftp y
14 Changes
@@ -0,0 +1,14 @@
+Revision history for Module-Starter-Plugin-SimpleStore
+
+0.14 2004-10-01 22:05
+ fixed incredible error: broken package declaration in ModuleStore
+
+0.12 2004-09-30 08:30
+ added ModuleStore
+ added (lousy) ms-pack
+
+0.10 2004-09-20 19:55
+ get the template_dir or template_file from config if possible
+
+0.02 2004-08-19 10:50 EDT
+ Stable enough for use. Will benefit greatly from global config file
12 MANIFEST
@@ -0,0 +1,12 @@
+Changes
+MANIFEST
+META.yml # Will be created by "make dist"
+Makefile.PL
+README
+bin/ms-pack
+lib/Module/Starter/Plugin/DirStore.pm
+lib/Module/Starter/Plugin/InlineStore.pm
+lib/Module/Starter/Plugin/ModuleStore.pm
+t/00.load.t
+t/pod-coverage.t
+t/pod.t
18 Makefile.PL
@@ -0,0 +1,18 @@
+use strict;
+use warnings;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ NAME => 'Module::Starter::Plugin::DirStore',
+ ABSTRACT => 'template storage methods for Module::Starter',
+ DISTNAME => 'Module-Starter-Plugin-SimpleStore',
+ AUTHOR => 'Ricardo SIGNES <rjbs@cpan.org>',
+ VERSION_FROM => 'lib/Module/Starter/Plugin/DirStore.pm',
+ PL_FILES => {},
+ PREREQ_PM => {
+ 'Test::More' => 0,
+ 'Module::Starter' => 1.32
+ },
+ dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
+ clean => { FILES => 'Module-Starter-Plugin-SimpleStore-*' },
+);
20 README
@@ -0,0 +1,20 @@
+README for Module-Starter-Plugin-SimpleStore
+
+This is a set of simple plugins for Module::Starter to provide methods of
+retrieving templates.
+
+INSTALLATION
+
+To install this module, run the following commands:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2004 Ricardo SIGNES
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
75 bin/ms-pack
@@ -0,0 +1,75 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use File::Basename;
+use Getopt::Long;
+
+GetOptions(
+ "o|output=s" => \(my $output_name),
+ "m|module=s" => \(my $module),
+);
+
+my @files = @ARGV or <*>;
+
+my $templates;
+
+for (@files) {
+ next unless -f $_ and -r $_;
+ open my $file, '<', $_;
+ $templates .= "___" . basename($_) . "___\n";
+ while (<$file>) { $templates .= $_ }
+ close $file;
+}
+
+open my $output_file, '>', $output_name;
+if ($module) {
+ print $output_file "package $module;\n1;\n__DATA__\n";
+}
+print $output_file $templates;
+close $output_file;
+
+__END__
+
+=head1 NAME
+
+ms-pack - pack up a directory of templates
+
+=head1 SYNOPSIS
+
+ ms-pack -o Templates.pm -m Foo::Templates templates/*
+
+=head1 VERSION
+
+ $Id: ms-pack,v 1.2 2004/09/30 13:18:40 rjbs Exp $
+
+=head1 DESCRIPTION
+
+This program packs up a set of template files into a single inlined template.
+The name of the file to be written is given with the -o option. The file is
+suitable for use as a template store with InlineStore. If a module name is
+given with the -m option, the file will be made into a Perl module for use with
+ModuleStore.
+
+All other arguments are the names of files to pack.
+
+=head1 WARNINGS
+
+This code was hastily written and not tested. It isn't really very good, but
+it makes my life easier. I'll get around to making it nicer as time goes on.
+
+=head1 TODO
+
+Plenty.
+
+=head1 AUTHOR
+
+Ricardo SIGNES, <C<rjbs@cpan.org>>
+
+=head1 COPYRIGHT
+
+This code is Copyright 2004, Ricardo SIGNES. It is licensed under the same
+terms as Perl itself.
+
+=cut
92 lib/Module/Starter/Plugin/DirStore.pm
@@ -0,0 +1,92 @@
+package Module::Starter::Plugin::DirStore;
+
+our $VERSION = '0.14';
+
+use warnings;
+use strict;
+
+use File::Basename;
+
+=head1 NAME
+
+Module::Starter::Plugin::DirStore -- module template files in a directory
+
+=head1 VERSION
+
+version 0.14
+
+ $Id: DirStore.pm,v 1.8 2004/10/02 02:08:30 rjbs Exp $
+
+=head1 SYNOPSIS
+
+ use Module::Starter qw(
+ Module::Starter::Simple
+ Module::Starter::Plugin::Template
+ Module::Starter::Plugin::DirStore
+ ...
+ );
+
+ Module::Starter->create_distro( ... );
+
+=head1 DESCRIPTION
+
+This Module::Starter plugin is intended to be loaded after
+Module::Starter::Plugin::Template. It implements the C<templates> method,
+required by the Template plugin. The C<DirStore> plugin stores all the
+required templates as files in a directory.
+
+=cut
+
+=head1 METHODS
+
+=head2 C<< templates >>
+
+This method reads in the template files and populates the object's C<templates>
+attribute. The module template directory is found by checking the
+MODULE_TEMPLATE_DIR environment variable and then the config option
+"template_dir".
+
+=cut
+
+sub templates {
+ my $self = shift;
+ my %template;
+
+ my $template_dir = ($ENV{MODULE_TEMPLATE_DIR} || $self->{template_dir})
+ or die "template dir not defined";
+ die "template dir does not exist: $template_dir"
+ unless -d $template_dir;
+
+ foreach (<$template_dir/*>) {
+ my $basename = basename $_;
+ next if (not -f $_) or ($basename =~ /^\./);
+ open my $template_file, '<', $_ or die "couldn't open template: $_";
+ local $/;
+ $template{$basename} = <$template_file>;
+ close $template_file;
+ }
+
+ return %template;
+}
+
+=head1 AUTHOR
+
+Ricardo SIGNES, C<< <rjbs@cpan.org> >>
+
+=head1 Bugs
+
+Please report any bugs or feature requests to
+C<bug-module-starter-plugin-inlinestore@rt.cpan.org>, or through the web
+interface at L<http://rt.cpan.org>. I will be notified, and then you'll
+automatically be notified of progress on your bug as I make changes.
+
+=head1 COPYRIGHT
+
+Copyright 2004 Ricardo SIGNES, All Rights Reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+1;
112 lib/Module/Starter/Plugin/InlineStore.pm
@@ -0,0 +1,112 @@
+package Module::Starter::Plugin::InlineStore;
+
+our $VERSION = '0.14';
+
+use warnings;
+use strict;
+
+=head1 NAME
+
+Module::Starter::Plugin::InlineStore -- inline module template files
+
+=head1 VERSION
+
+version 0.14
+
+ $Id: InlineStore.pm,v 1.7 2004/10/02 02:08:30 rjbs Exp $
+
+=head1 SYNOPSIS
+
+ use Module::Starter qw(
+ Module::Starter::Simple
+ Module::Starter::Plugin::Template
+ Module::Starter::Plugin::InlineStore
+ ...
+ );
+
+ Module::Starter->create_distro( ... );
+
+=head1 DESCRIPTION
+
+This Module::Starter plugin is intended to be loaded after
+Module::Starter::Plugin::Template. It implements the C<templates> method,
+required by the Template plugin. The C<InlineStore> plugin stores all the
+required templates in a single file, delimited with filenames between
+triple-underscores. In other words, a very simple template file might look
+like this:
+
+ ___Module.pm___
+ package {modulename};
+ 1;
+ ___Makefile.PL___
+ die "lousy template"
+
+Originally, this module was to use Inline::Files, or at least standard
+double-underscore indication of file names, but it's just simpler this way.
+Patches welcome.
+
+=cut
+
+=head1 METHODS
+
+=head2 C<< templates >>
+
+This method reads in the template file (described above) and populates the
+object's C<templates> attribute. The module template file is found by checking
+the MODULE_TEMPLATE_FILE environment variable and then the "template_file"
+config option.
+
+=cut
+
+sub _template_filehandle {
+ my $self = shift;
+
+ my $template_filename =
+ ($ENV{MODULE_TEMPLATE_FILE} || $self->{template_file})
+ or die "no template file defined";
+ open my $template_file, '<', $template_filename
+ or die "couldn't open template file: $template_filename";
+
+ return $template_file;
+}
+
+sub templates {
+ my $self = shift;
+ my %template;
+
+ my $template_file = $self->_template_filehandle;
+
+ my $fn = '_';
+ while (<$template_file>) {
+ if (/^___([-_.0-9A-Za-z]+)___$/) {
+ $fn = $1;
+ $template{$fn} = '';
+ next;
+ }
+ $template{$fn} .= $_;
+ }
+
+ return %template;
+}
+
+=head1 AUTHOR
+
+Ricardo SIGNES, C<< <rjbs@cpan.org> >>
+
+=head1 Bugs
+
+Please report any bugs or feature requests to
+C<bug-module-starter-plugin-inlinestore@rt.cpan.org>, or through the web
+interface at L<http://rt.cpan.org>. I will be notified, and then you'll
+automatically be notified of progress on your bug as I make changes.
+
+=head1 COPYRIGHT
+
+Copyright 2004 Ricardo SIGNES, All Rights Reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+1;
99 lib/Module/Starter/Plugin/ModuleStore.pm
@@ -0,0 +1,99 @@
+package Module::Starter::Plugin::ModuleStore;
+
+our $VERSION = '0.14';
+
+use warnings;
+use strict;
+
+=head1 NAME
+
+Module::Starter::Plugin::ModuleStore -- store inline templates in modules
+
+=head1 VERSION
+
+version 0.14
+
+ $Id: ModuleStore.pm,v 1.3 2004/10/02 02:08:30 rjbs Exp $
+
+=head1 SYNOPSIS
+
+ use Module::Starter qw(
+ Module::Starter::Simple
+ Module::Starter::Plugin::Template
+ Module::Starter::Plugin::ModuleStore
+ ...
+ );
+
+ Module::Starter->create_distro( ... );
+
+=head1 DESCRIPTION
+
+This Module::Starter plugin is intended to be loaded after
+Module::Starter::Plugin::Template. It implements the C<templates> method,
+required by the Template plugin. It works like InlineStore, but instead of
+loading a physical file, loads the DATA section of a Perl module.
+
+=cut
+
+=head1 METHODS
+
+=head2 C<< templates >>
+
+This method reads in the template module (described above) and populates the
+object's C<templates> attribute. The module template module is found by
+checking the MODULE_TEMPLATE_MODULE environment variable and then the
+"template_module" config option.
+
+=cut
+
+sub _template_filehandle {
+ my $self = shift;
+
+ my $template_module =
+ ($ENV{MODULE_TEMPLATE_MODULE} || $self->{template_module});
+ eval "require $template_module"
+ or die "couldn't load template store module $template_module\: $@";
+ no strict 'refs';
+ return \*{"$template_module\::DATA"};
+}
+
+sub templates {
+ my $self = shift;
+ my %template;
+
+ my $template_file = $self->_template_filehandle;
+
+ my $fn = '_';
+ while (<$template_file>) {
+ if (/^___([-_.0-9A-Za-z]+)___$/) {
+ $fn = $1;
+ $template{$fn} = '';
+ next;
+ }
+ $template{$fn} .= $_;
+ }
+
+ return %template;
+}
+
+=head1 AUTHOR
+
+Ricardo SIGNES, C<< <rjbs@cpan.org> >>
+
+=head1 Bugs
+
+Please report any bugs or feature requests to
+C<bug-module-starter-plugin-inlinestore@rt.cpan.org>, or through the web
+interface at L<http://rt.cpan.org>. I will be notified, and then you'll
+automatically be notified of progress on your bug as I make changes.
+
+=head1 COPYRIGHT
+
+Copyright 2004 Ricardo SIGNES, All Rights Reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+1;
9 t/00.load.t
@@ -0,0 +1,9 @@
+use Test::More tests => 3;
+
+BEGIN {
+ use_ok( 'Module::Starter::Plugin::DirStore' );
+ use_ok( 'Module::Starter::Plugin::InlineStore' );
+ use_ok( 'Module::Starter::Plugin::ModuleStore' );
+}
+
+diag( "Testing Module-Starter-Plugin-SimpleStore $Module::Starter::Plugin::DirStore::VERSION" );
6 t/pod-coverage.t
@@ -0,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+all_pod_coverage_ok();
6 t/pod.t
@@ -0,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+all_pod_files_ok();
Please sign in to comment.
Something went wrong with that request. Please try again.