Permalink
Browse files

Module skeleton

  • Loading branch information...
yannk committed Apr 14, 2009
0 parents commit 26846e28d07b2416b626b7227ded463ebe71f903
Showing with 378 additions and 0 deletions.
  1. +12 −0 .gitignore
  2. +5 −0 .shipit
  3. +5 −0 Changes
  4. +11 −0 MANIFEST
  5. +14 −0 Makefile.PL
  6. +40 −0 README
  7. +98 −0 lib/Shrike.pm
  8. +24 −0 lib/Shrike/Driver.pm
  9. +33 −0 lib/Shrike/Mapper.pm
  10. +36 −0 lib/Shrike/Session.pm
  11. +12 −0 t/00-load.t
  12. +58 −0 t/boilerplate.t
  13. +18 −0 t/pod-coverage.t
  14. +12 −0 t/pod.t
@@ -0,0 +1,12 @@
+.*
+!.gitignore
+!.shipit
+Makefile*
+!Makefile.PL
+/blib
+/build
+_build*
+Build
+/inc
+/pm_to_blib
+Shrike-*
@@ -0,0 +1,5 @@
+steps = FindVersion, ChangeVersion, CheckChangeLog, CheckVersionsMatch, DistTest, Commit, Tag, MakeDist, DistClean
+
+git.tagpattern = %v
+
+CheckChangeLog.files = Changes
@@ -0,0 +1,5 @@
+Revision history for Shrike
+
+0.01 Date/time
+ First version, released on an unsuspecting world.
+
@@ -0,0 +1,11 @@
+Changes
+MANIFEST
+Makefile.PL
+README
+lib/Shrike.pm
+lib/Shrike/Driver.pm
+lib/Shrike/Mapper.pm
+lib/Shrike/Session.pm
+t/00-load.t
+t/pod-coverage.t
+t/pod.t
@@ -0,0 +1,14 @@
+use inc::Module::Install;
+
+name 'Shrike';
+all_from 'lib/Shrike.pm';
+author 'Yann Kerhervé <yannk@cpan.org>';
+license 'perl';
+
+build_requires 'Test::More';
+requires 'Moose';
+
+auto_install;
+
+WriteAll;
+
40 README
@@ -0,0 +1,40 @@
+Shrike
+
+INSTALLATION
+
+To install this module, run the following commands:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+SUPPORT AND DOCUMENTATION
+
+After installing, you can find documentation for this module with the
+perldoc command.
+
+ perldoc Shrike
+
+You can also look for information at:
+
+ RT, CPAN's request tracker
+ http://rt.cpan.org/NoAuth/Bugs.html?Dist=Shrike
+
+ AnnoCPAN, Annotated CPAN documentation
+ http://annocpan.org/dist/Shrike
+
+ CPAN Ratings
+ http://cpanratings.perl.org/d/Shrike
+
+ Search CPAN
+ http://search.cpan.org/dist/Shrike/
+
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2009 Yann Kerhervé
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
@@ -0,0 +1,98 @@
+package Shrike;
+
+use warnings;
+use strict;
+
+=head1 NAME
+
+Shrike - A fast persistent framework for Moose objects
+
+=head1 VERSION
+
+Version 0.01
+
+=cut
+
+our $VERSION = '0.01';
+
+
+=head1 SYNOPSIS
+
+Shrike allows you to persist your objects with great flexibility, and loosely
+couple your objects with their datastore(s).
+
+ package User;
+ has first_name => (is => 'rw', isa => 'Str');
+ has last_name => (is => 'rw', isa => 'Str');
+ has age => (is => 'rw', isa => 'Int');
+
+ package main;
+ $driver = get_driver();
+ $session = Shrike::Session->new;
+ $mapper = Shrike::Mapper->new;
+ $mapper->map(User => $driver);
+
+ $session->add($user);
+
+ ## write objects to the datastore
+ $session->sync;
+
+=head1 DESCRIPTION
+...
+
+=cut
+
+
+=head1 AUTHOR
+
+Yann Kerhervé, C<< <yannk at cpan.org> >>
+
+=head1 BUGS
+
+Please report any bugs or feature requests to C<bug-shrike at rt.cpan.org>,
+or through the web interface at
+L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Shrike>. I will be notified,
+and then you'll automatically be notified of progress on your bug as I make
+changes.
+
+
+=head1 SUPPORT
+
+You can find documentation for this module with the perldoc command.
+
+ perldoc Shrike
+
+
+You can also look for information at:
+
+=over 4
+
+=item * RT: CPAN's request tracker
+
+L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Shrike>
+
+=item * AnnoCPAN: Annotated CPAN documentation
+
+L<http://annocpan.org/dist/Shrike>
+
+=item * CPAN Ratings
+
+L<http://cpanratings.perl.org/d/Shrike>
+
+=item * Search CPAN
+
+L<http://search.cpan.org/dist/Shrike/>
+
+=back
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2009 Yann Kerhervé, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+
+=cut
+
+"http://en.wikipedia.org/wiki/The_Shrike";
@@ -0,0 +1,24 @@
+package Shrike::Driver;
+
+use warnings;
+use strict;
+
+=head1 NAME
+
+Shrike::Driver - Base class for all drivers in Shrike
+
+=head1 AUTHOR
+
+Yann Kerhervé, C<< <yannk at cpan.org> >>
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2009 Yann Kerhervé, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+
+=cut
+
+"Nobody reads that, really";
@@ -0,0 +1,33 @@
+package Shrike::Mapper;
+use Moose;
+
+=head1 NAME
+
+Shrike::Mapper - Maps classes to drivers.
+
+=head1 SYNOPSIS
+
+Mapper defines how classes are mapped to drivers.
+
+ use Shrike::Mapper;
+
+ $mapper = Shrike::Mapper->new;
+ $mapper->map( $class => $driver );
+
+=head1 DESCRIPTION
+
+=head1 AUTHOR
+
+Yann Kerhervé, C<< <yannk at cpan.org> >>
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2009 Yann Kerhervé, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+
+=cut
+
+"The Hegemony Consul sat on the balcony of his ebony spaceship...";
@@ -0,0 +1,36 @@
+package Shrike::Session;
+use Moose;
+
+=head1 NAME
+
+Shrike::Session - Responsible for maintaining the state of the dialog between
+objects and stores.
+
+=head1 SYNOPSIS
+
+ use Shrike::Session;
+
+ $session = Shrike::Session->new();
+ $session->add(@objects);
+ $session->delete($object);
+
+ $session->abort;
+ # - or -
+ $session->sync
+
+=head1 AUTHOR
+
+Yann Kerhervé, C<< <yannk at cpan.org> >>
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2009 Yann Kerhervé, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+
+=cut
+
+no Moose;
+"Put something smart here"
@@ -0,0 +1,12 @@
+#!perl -T
+
+use Test::More tests => 4;
+
+BEGIN {
+ use_ok( 'Shrike' );
+ use_ok( 'Shrike::Session' );
+ use_ok( 'Shrike::Mapper' );
+ use_ok( 'Shrike::Driver' );
+}
+
+diag( "Testing Shrike $Shrike::VERSION, Perl $], $^X" );
@@ -0,0 +1,58 @@
+#!perl -T
+
+use strict;
+use warnings;
+use Test::More tests => 6;
+
+sub not_in_file_ok {
+ my ($filename, %regex) = @_;
+ open( my $fh, '<', $filename )
+ or die "couldn't open $filename for reading: $!";
+
+ my %violated;
+
+ while (my $line = <$fh>) {
+ while (my ($desc, $regex) = each %regex) {
+ if ($line =~ $regex) {
+ push @{$violated{$desc}||=[]}, $.;
+ }
+ }
+ }
+
+ if (%violated) {
+ fail("$filename contains boilerplate text");
+ diag "$_ appears on lines @{$violated{$_}}" for keys %violated;
+ } else {
+ pass("$filename contains no boilerplate text");
+ }
+}
+
+sub module_boilerplate_ok {
+ my ($module) = @_;
+ not_in_file_ok($module =>
+ 'the great new $MODULENAME' => qr/ - The great new /,
+ 'boilerplate description' => qr/Quick summary of what the module/,
+ 'stub function definition' => qr/function[12]/,
+ );
+}
+
+TODO: {
+ local $TODO = "Need to replace the boilerplate text";
+
+ not_in_file_ok(README =>
+ "The README is used..." => qr/The README is used/,
+ "'version information here'" => qr/to provide version information/,
+ );
+
+ not_in_file_ok(Changes =>
+ "placeholder date/time" => qr(Date/time)
+ );
+
+ module_boilerplate_ok('lib/Shrike.pm');
+ module_boilerplate_ok('lib/Shrike/Session.pm');
+ module_boilerplate_ok('lib/Shrike/Mapper.pm');
+ module_boilerplate_ok('lib/Shrike/Driver.pm');
+
+
+}
+
@@ -0,0 +1,18 @@
+use strict;
+use warnings;
+use Test::More;
+
+# Ensure a recent version of Test::Pod::Coverage
+my $min_tpc = 1.08;
+eval "use Test::Pod::Coverage $min_tpc";
+plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"
+ if $@;
+
+# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
+# but older versions don't recognize some common documentation styles
+my $min_pc = 0.18;
+eval "use Pod::Coverage $min_pc";
+plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
+ if $@;
+
+all_pod_coverage_ok();
12 t/pod.t
@@ -0,0 +1,12 @@
+#!perl -T
+
+use strict;
+use warnings;
+use Test::More;
+
+# Ensure a recent version of Test::Pod
+my $min_tp = 1.22;
+eval "use Test::Pod $min_tp";
+plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
+
+all_pod_files_ok();

0 comments on commit 26846e2

Please sign in to comment.