Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

dzil conversion

  • Loading branch information...
commit 61514acea018e3c2e0f747a39d7227c4824cb334 1 parent f0304b1
@gphat authored
View
3  Changes
@@ -1,5 +1,8 @@
Revision history for Data-Manager
+{{$NEXT}}
+ - Convert to Dist::Zilla
+
0.07 Jul 1, 2011
- Fix typos in POD (arcanez)
View
18 MANIFEST
@@ -1,18 +0,0 @@
-Changes
-ignore.txt
-inc/Module/Install.pm
-inc/Module/Install/Base.pm
-inc/Module/Install/Can.pm
-inc/Module/Install/Fetch.pm
-inc/Module/Install/Makefile.pm
-inc/Module/Install/Metadata.pm
-inc/Module/Install/Win32.pm
-inc/Module/Install/WriteAll.pm
-lib/Data/Manager.pm
-Makefile.PL
-MANIFEST This list of files
-META.yml
-README
-t/00-load.t
-t/serialize.t
-t/simple.t
View
17 Makefile.PL
@@ -1,17 +0,0 @@
-use inc::Module::Install;
-
-name 'Data-Manager';
-all_from 'lib/Data/Manager.pm';
-author q{Cory G Watson <gphat@cpan.org>};
-license 'perl';
-
-build_requires 'Test::More';
-
-requires 'Data::Verifier' => '0.34';
-requires 'Message::Stack::Parser' => '0.01';
-requires 'Message::Stack' => '0.17';
-requires 'MooseX::Storage';
-requires 'JSON::Any';
-
-WriteAll;
-
View
55 README
@@ -1,55 +0,0 @@
-Data-Manager
-
-The README is used to introduce the module and provide instructions on
-how to install the module, any machine dependencies it may have (for
-example C compilers and installed libraries) and any other information
-that should be provided before the module is installed.
-
-A README file is required for CPAN modules since CPAN extracts the README
-file from a module distribution so that people browsing the archive
-can use it to get an idea of the module's uses. It is usually a good idea
-to provide version information here so that people can decide whether
-fixes for the module are worth downloading.
-
-
-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 Data::Manager
-
-You can also look for information at:
-
- RT, CPAN's request tracker
- http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data-Manager
-
- AnnoCPAN, Annotated CPAN documentation
- http://annocpan.org/dist/Data-Manager
-
- CPAN Ratings
- http://cpanratings.perl.org/d/Data-Manager
-
- Search CPAN
- http://search.cpan.org/dist/Data-Manager/
-
-
-COPYRIGHT AND LICENCE
-
-Copyright (C) 2009 Cory G Watson
-
-This program is free software; you can redistribute it and/or modify it
-under the terms of either: the GNU General Public License as published
-by the Free Software Foundation; or the Artistic License.
-
-See http://dev.perl.org/licenses/ for more information.
-
View
10 dist.ini
@@ -0,0 +1,10 @@
+name = Data-Manager
+author = Cory G Watson <gphat@cpan.org>
+license = Perl_5
+copyright_holder= Cory G Watson
+
+[@GPHAT]
+
+[Prereqs]
+JSON::Any = 0
+JSON::XS = 0
View
214 lib/Data/Manager.pm
@@ -4,93 +4,11 @@ use MooseX::Storage;
with 'MooseX::Storage::Deferred';
+# ABSTRACT: The Marriage of Message::Stack & Data::Verifier
+
use Message::Stack;
use Message::Stack::Parser::DataVerifier;
-our $VERSION = '0.07';
-
-has 'messages' => (
- is => 'ro',
- isa => 'Message::Stack',
- lazy_build => 1,
- handles => {
- 'messages_for_scope' => 'for_scope',
- }
-);
-
-has '_parser' => (
- is => 'ro',
- isa => 'Message::Stack::DataVerifier',
-);
-
-has 'results' => (
- traits => [ 'Hash' ],
- is => 'ro',
- isa => 'HashRef',
- default => sub { {} },
- handles => {
- 'set_results' => 'set',
- 'get_results' => 'get'
- }
-);
-
-has 'verifiers' => (
- traits => [ 'Hash', 'DoNotSerialize' ],
- is => 'ro',
- isa => 'HashRef',
- default => sub { {} },
- handles => {
- 'set_verifier' => 'set',
- 'get_verifier' => 'get'
- }
-);
-
-sub _build_messages {
- my ($self) = @_;
-
- # We lazily build the messages to avoid parsing the results until the last
- # possible moment. This lets the user fiddle with the results if they
- # want.
-
- my $stack = Message::Stack->new;
- foreach my $scope (keys %{ $self->results }) {
- my $results = $self->get_results($scope);
- Message::Stack::Parser::DataVerifier->parse($stack, $scope, $results);
- }
-
- return $stack;
-}
-
-sub success {
- my ($self) = @_;
-
- foreach my $res (keys %{ $self->results }) {
- return 0 unless $self->get_results($res)->success;
- }
-
- return 1;
-}
-
-sub verify {
- my ($self, $scope, $data) = @_;
-
- my $verifier = $self->get_verifier($scope);
- die("No verifier for scope: $scope") unless defined($verifier);
-
- my $results = $verifier->verify($data);
- $self->set_results($scope, $results);
-
- return $results;
-}
-
-1;
-
-__END__
-
-=head1 NAME
-
-Data::Manager - The Marriage of Message::Stack & Data::Verifier
-
=head1 DESCRIPTION
Data::Manager provides a convenient mechanism for managing multiple
@@ -148,6 +66,8 @@ redirects.
my $ship_results = $dm->get_results('shipping_address');
my $ship_stack = $dm->messages_for_scope('shipping_address');
+=begin :prelude
+
=head1 SERIALIZATION
The Data::Manager object may be serialized thusly:
@@ -160,52 +80,132 @@ This is possible thanks to the magic of L<MooseX::Storage>. All attributes
B<except> C<verifiers> are stored. B<Serialization causes the verifiers
attribute to be set to undefined, as those objects are not serializable>.
-=head1 ATTRIBUTES
+=end :prelude
-=head2 messages
+=attr messages
The L<Message::Stack> object for this manager. This attribute is lazily
populated, parsing the L<Data::Verifier::Results> objects. After fetching
this attribute any changes to the results B<will not be reflected in the
message stack>.
-=head2 results
+=method messages_for_scope ($scope)
-HashRef of L<Data::Verifier::Results> objects, keyed by scope.
+Returns a L<Message::Stack> object containing messages for the specified
+scope.
-=head2 verifiers
+=cut
-HashRef of L<Data::Verifier> objects, keyed by scope.
+has 'messages' => (
+ is => 'ro',
+ isa => 'Message::Stack',
+ lazy_build => 1,
+ handles => {
+ 'messages_for_scope' => 'for_scope',
+ }
+);
-=head1 METHODS
+has '_parser' => (
+ is => 'ro',
+ isa => 'Message::Stack::DataVerifier',
+);
-=head2 get_results ($scope)
+=attr results
-Gets the L<Data::Verifier::Results> object for the specified scope.
+HashRef of L<Data::Verifier::Results> objects, keyed by scope.
-=head2 messages_for_scope ($scope)
+=method get_results ($scope)
-Returns a L<Message::Stack> object containing messages for the specified
-scope.
+Gets the L<Data::Verifier::Results> object for the specified scope.
-=head2 set_results ($scope, $results)
+=method set_results ($scope, $results)
Sets the L<Data::Verifier::Results> object for the specified scope.
-=head2 success
+=cut
+
+has 'results' => (
+ traits => [ 'Hash' ],
+ is => 'ro',
+ isa => 'HashRef',
+ default => sub { {} },
+ handles => {
+ 'set_results' => 'set',
+ 'get_results' => 'get'
+ }
+);
+
+=attr verifiers
+
+HashRef of L<Data::Verifier> objects, keyed by scope.
+
+=cut
+
+has 'verifiers' => (
+ traits => [ 'Hash', 'DoNotSerialize' ],
+ is => 'ro',
+ isa => 'HashRef',
+ default => sub { {} },
+ handles => {
+ 'set_verifier' => 'set',
+ 'get_verifier' => 'get'
+ }
+);
+
+sub _build_messages {
+ my ($self) = @_;
+
+ # We lazily build the messages to avoid parsing the results until the last
+ # possible moment. This lets the user fiddle with the results if they
+ # want.
+
+ my $stack = Message::Stack->new;
+ foreach my $scope (keys %{ $self->results }) {
+ my $results = $self->get_results($scope);
+ Message::Stack::Parser::DataVerifier->parse($stack, $scope, $results);
+ }
+
+ return $stack;
+}
+
+=method success
Convenience method that checks C<success> on each of the results in this
manager. Returns false if any are false.
-=head2 verify ($scope, $data);
+=cut
+
+sub success {
+ my ($self) = @_;
+
+ foreach my $res (keys %{ $self->results }) {
+ return 0 unless $self->get_results($res)->success;
+ }
+
+ return 1;
+}
+
+=method verify ($scope, $data);
Verify the data against the specified scope. After verification the results
and messages will be automatically created and stored. The
L<Data::Verifier::Results> class will be returned.
-=head1 AUTHOR
+=cut
-Cory G Watson, C<< <gphat at cpan.org> >>
+sub verify {
+ my ($self, $scope, $data) = @_;
+
+ my $verifier = $self->get_verifier($scope);
+ die("No verifier for scope: $scope") unless defined($verifier);
+
+ my $results = $verifier->verify($data);
+ $self->set_results($scope, $results);
+
+ return $results;
+}
+
+=begin :postlude
=head1 ACKNOWLEDGEMENTS
@@ -215,13 +215,11 @@ Jay Shirley
Brian Cassidy
-=head1 COPYRIGHT & LICENSE
-
-Copyright 2009 Cory G Watson.
+=end :postlude
-This program is free software; you can redistribute it and/or modify it
-under the terms of either: the GNU General Public License as published
-by the Free Software Foundation; or the Artistic License.
+=cut
-See http://dev.perl.org/licenses/ for more information.
+__PACKAGE__->meta->make_immutable;
+no Moose;
+1;
View
23 weaver.ini
@@ -0,0 +1,23 @@
+[@CorePrep]
+
+[Name]
+[Version]
+
+[Generic / SYNOPSIS]
+[Generic / DESCRIPTION]
+[Generic / OVERVIEW]
+
+[Region / prelude]
+
+[Leftovers]
+
+[Collect / ATTRIBUTES]
+command = attr
+
+[Collect / METHODS]
+command = method
+
+[Region / postlude]
+
+[Authors]
+[Legal]
Please sign in to comment.
Something went wrong with that request. Please try again.