[Catalyst-commits] r6401 - in trunk/Catalyst-Model-Net-Amazon: .
lib lib/Catalyst lib/Catalyst/Helper
lib/Catalyst/Helper/Model lib/Catalyst/Helper/Model/Net
lib/Catalyst/Model lib/Catalyst/Model/Net t t/lib
t/lib/TestApp t/lib/TestApp/Model
fireartist at dev.catalyst.perl.org
fireartist at dev.catalyst.perl.org
Mon May 14 18:03:14 GMT 2007
Author: fireartist
Date: 2007-05-14 18:03:12 +0100 (Mon, 14 May 2007)
New Revision: 6401
Added:
trunk/Catalyst-Model-Net-Amazon/Changes
trunk/Catalyst-Model-Net-Amazon/Makefile.PL
trunk/Catalyst-Model-Net-Amazon/README
trunk/Catalyst-Model-Net-Amazon/lib/
trunk/Catalyst-Model-Net-Amazon/lib/Catalyst/
trunk/Catalyst-Model-Net-Amazon/lib/Catalyst/Helper/
trunk/Catalyst-Model-Net-Amazon/lib/Catalyst/Helper/Model/
trunk/Catalyst-Model-Net-Amazon/lib/Catalyst/Helper/Model/Net/
trunk/Catalyst-Model-Net-Amazon/lib/Catalyst/Helper/Model/Net/Amazon.pm
trunk/Catalyst-Model-Net-Amazon/lib/Catalyst/Model/
trunk/Catalyst-Model-Net-Amazon/lib/Catalyst/Model/Net/
trunk/Catalyst-Model-Net-Amazon/lib/Catalyst/Model/Net/Amazon.pm
trunk/Catalyst-Model-Net-Amazon/t/
trunk/Catalyst-Model-Net-Amazon/t/01use.t
trunk/Catalyst-Model-Net-Amazon/t/lib/
trunk/Catalyst-Model-Net-Amazon/t/lib/TestApp.pm
trunk/Catalyst-Model-Net-Amazon/t/lib/TestApp/
trunk/Catalyst-Model-Net-Amazon/t/lib/TestApp/Model/
trunk/Catalyst-Model-Net-Amazon/t/lib/TestApp/Model/Amazon.pm
Log:
first pass at Net::Amazon model and helper
Added: trunk/Catalyst-Model-Net-Amazon/Changes
===================================================================
--- trunk/Catalyst-Model-Net-Amazon/Changes (rev 0)
+++ trunk/Catalyst-Model-Net-Amazon/Changes 2007-05-14 17:03:12 UTC (rev 6401)
@@ -0,0 +1,6 @@
+Revision history for Perl extension Catalyst::Model::Net::Amazon.
+
+0.01001 2007-05-14
+ - original version; created by h2xs 1.23 with options
+ -A -X -n Catalyst::Model::Net::Amazon -b 5.8.1 -v 0.01001
+
Added: trunk/Catalyst-Model-Net-Amazon/Makefile.PL
===================================================================
--- trunk/Catalyst-Model-Net-Amazon/Makefile.PL (rev 0)
+++ trunk/Catalyst-Model-Net-Amazon/Makefile.PL 2007-05-14 17:03:12 UTC (rev 6401)
@@ -0,0 +1,11 @@
+use inc::Module::Install;
+
+name 'Catalyst-Model-Net-Amazon';
+all_from 'lib/Catalyst/Model/Net/Amazon.pm';
+
+requires 'perl' => '5.8.1';
+
+no_index directory => 't/lib';
+
+auto_install;
+&WriteAll;
Added: trunk/Catalyst-Model-Net-Amazon/README
===================================================================
--- trunk/Catalyst-Model-Net-Amazon/README (rev 0)
+++ trunk/Catalyst-Model-Net-Amazon/README 2007-05-14 17:03:12 UTC (rev 6401)
@@ -0,0 +1,44 @@
+NAME
+ Catalyst::Model::Net::Amazon - Catalyst model for Net::Amazon SOAP
+ interface
+
+SYNOPSIS
+ # Use the helper to add an Net::Amazon model to your application...
+ script/myapp_create.pl create model Net::Amazon Net::Amazon
+
+ # This creates the following file...
+ # lib/MyApp/Model/Net/Amazon.pm
+
+ package MyApp::Model::Net::Amazon;
+
+ use base qw/ Catalyst::Model::S3 /;
+
+ __PACKAGE__->config(
+ token => 'my amazon secret token',
+ );
+
+ 1;
+
+ # Then in your Catalyst controller, you just need to do...
+ my $amazon = $c->model('Net::Amazon');
+
+METHODS
+ new
+ Instantiate a new Net::Amazon Model. See Net::Amazon's new method for
+ the options available.
+
+SEE ALSO
+ Catalyst::Helper::Net::Amazon, Net::Amazon
+
+ Catalyst::Model::S3
+
+AUTHOR
+ Carl Franks, "cfranks at cpan.org"
+
+COPYRIGHT AND LICENSE
+ Copyright (C) 2007 by Carl Franks
+
+ This library is free software; you can redistribute it and/or modify it
+ under the same terms as Perl itself, either Perl version 5.8.8 or, at
+ your option, any later version of Perl 5 you may have available.
+
Added: trunk/Catalyst-Model-Net-Amazon/lib/Catalyst/Helper/Model/Net/Amazon.pm
===================================================================
--- trunk/Catalyst-Model-Net-Amazon/lib/Catalyst/Helper/Model/Net/Amazon.pm (rev 0)
+++ trunk/Catalyst-Model-Net-Amazon/lib/Catalyst/Helper/Model/Net/Amazon.pm 2007-05-14 17:03:12 UTC (rev 6401)
@@ -0,0 +1,104 @@
+package Catalyst::Helper::Model::Net::Amazon;
+
+use strict;
+use warnings;
+
+use Carp qw/ croak /;
+
+our $VERSION = '0.01001';
+
+sub mk_compclass {
+ my ( $self, $helper, $token ) = @_;
+
+ $helper->{token} = $token;
+
+ $helper->render_file( 'net_amazon_class', $helper->{file} );
+}
+
+1;
+
+=head1 NAME
+
+Catalyst::Helper::Model::Net::Amazon - Helper for Net::Amazon Catalyst models
+
+
+=head1 SYNOPSIS
+
+ script/myapp_create.pl model ModelName Net::Amazon amazon_secret_token
+
+=head1 DESCRIPTION
+
+Use this module to set up a new L<Catalyst::Model::Net::Amazon> model for
+your Catalyst application.
+
+=head2 Arguments
+
+C<ModelName> is the short name for the Model class being generated (eg.
+C<Net::Amazon>)
+
+C<token> is your Amazon Web Services account's Access Key. For more
+information see: L<http://aws.amazon.com/s3>
+
+=head1 SEE ALSO
+
+L<Catalyst>, L<Catalyst::Helper>, L<Catalyst::Model::Net::Amazon>
+
+=head1 BUGS
+
+Please report any bugs or feature requests to
+L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Model-Net-Amazon>.
+
+=head1 AUTHOR
+
+Carl Franks, C<cfranks at cpan.org>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2007 by Carl Franks
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.8.8 or,
+at your option, any later version of Perl 5 you may have available.
+
+=cut
+
+__DATA__
+=begin pod_to_ignore
+
+__net_amazon_class__
+package [% class %];
+
+use strict;
+use warnings;
+
+use base qw/ Catalyst::Model::Net::Amazon /;
+[% IF token %]
+__PACKAGE__->config(
+ token => '[% token %]',
+);
+[% END %]
+=head1 NAME
+
+[% class %] - S3 Model Class
+
+
+=head1 SYNOPSIS
+
+See L<[% app %]>.
+
+=head1 DESCRIPTION
+
+Net::Amazon Model Class.
+
+=head1 AUTHOR
+
+[% author %]
+
+=head1 LICENSE
+
+This module is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself. See L<perlartistic>.
+
+=cut
+
+1;
Added: trunk/Catalyst-Model-Net-Amazon/lib/Catalyst/Model/Net/Amazon.pm
===================================================================
--- trunk/Catalyst-Model-Net-Amazon/lib/Catalyst/Model/Net/Amazon.pm (rev 0)
+++ trunk/Catalyst-Model-Net-Amazon/lib/Catalyst/Model/Net/Amazon.pm 2007-05-14 17:03:12 UTC (rev 6401)
@@ -0,0 +1,92 @@
+package Catalyst::Model::Net::Amazon;
+
+use 5.008001;
+use strict;
+use warnings;
+
+use base qw/ Catalyst::Model /;
+
+use Carp qw/ croak /;
+use Catalyst::Utils ();
+use Net::Amazon;
+use NEXT;
+
+our $VERSION = '0.01001';
+
+sub new {
+ my $self = shift->NEXT::new(@_);
+ my $class = ref($self);
+
+ my ( $c, $arg_ref ) = @_;
+
+ $arg_ref ||= {};
+
+ croak "->config->{token} must be set for $class\n" if !$self->{token};
+
+ my $args = Catalyst::Utils::merge_hashes( $arg_ref, $self->config );
+
+ $self->{'.net-amazon'} = Net::Amazon->new( %$args );
+
+ return $self;
+}
+
+sub ACCEPT_CONTEXT {
+ return shift->{'.net-amazon'};
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Catalyst::Model::Net::Amazon - Catalyst model for Net::Amazon SOAP interface
+
+=head1 SYNOPSIS
+
+ # Use the helper to add an Net::Amazon model to your application...
+ script/myapp_create.pl create model Net::Amazon Net::Amazon
+
+ # This creates the following file...
+ # lib/MyApp/Model/Net/Amazon.pm
+
+ package MyApp::Model::Net::Amazon;
+
+ use base qw/ Catalyst::Model::S3 /;
+
+ __PACKAGE__->config(
+ token => 'my amazon secret token',
+ );
+
+ 1;
+
+
+ # Then in your Catalyst controller, you just need to do...
+ my $amazon = $c->model('Net::Amazon');
+
+=head1 METHODS
+
+=head2 new
+
+Instantiate a new L<Net::Amazon> Model. See
+L<Net::Amazon's new method|Net::Amazon/new> for the options available.
+
+=head1 SEE ALSO
+
+L<Catalyst::Helper::Net::Amazon>, L<Net::Amazon>
+
+L<Catalyst::Model::S3>
+
+=head1 AUTHOR
+
+Carl Franks, C<cfranks at cpan.org>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2007 by Carl Franks
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.8.8 or,
+at your option, any later version of Perl 5 you may have available.
+
+=cut
Added: trunk/Catalyst-Model-Net-Amazon/t/01use.t
===================================================================
--- trunk/Catalyst-Model-Net-Amazon/t/01use.t (rev 0)
+++ trunk/Catalyst-Model-Net-Amazon/t/01use.t 2007-05-14 17:03:12 UTC (rev 6401)
@@ -0,0 +1,14 @@
+use strict;
+use warnings;
+use lib 't/lib';
+
+use Test::More tests => 3;
+
+use_ok('TestApp');
+
+my $amazon = TestApp->model('Amazon');
+
+isa_ok( $amazon, 'Net::Amazon' );
+can_ok( $amazon, 'search' );
+
+1;
Added: trunk/Catalyst-Model-Net-Amazon/t/lib/TestApp/Model/Amazon.pm
===================================================================
--- trunk/Catalyst-Model-Net-Amazon/t/lib/TestApp/Model/Amazon.pm (rev 0)
+++ trunk/Catalyst-Model-Net-Amazon/t/lib/TestApp/Model/Amazon.pm 2007-05-14 17:03:12 UTC (rev 6401)
@@ -0,0 +1,6 @@
+package
+ TestApp::Model::Amazon;
+
+use base qw/ Catalyst::Model::Net::Amazon /;
+
+1;
Added: trunk/Catalyst-Model-Net-Amazon/t/lib/TestApp.pm
===================================================================
--- trunk/Catalyst-Model-Net-Amazon/t/lib/TestApp.pm (rev 0)
+++ trunk/Catalyst-Model-Net-Amazon/t/lib/TestApp.pm 2007-05-14 17:03:12 UTC (rev 6401)
@@ -0,0 +1,19 @@
+package
+ TestApp;
+
+use strict;
+use warnings;
+
+use Catalyst;
+
+__PACKAGE__->config(
+ name => 'TestApp',
+
+ 'Model::Amazon' => {
+ token => 'fake key',
+ },
+);
+
+__PACKAGE__->setup;
+
+1;
More information about the Catalyst-commits
mailing list