PGObject-Simple-Role-1.12.0/0000755000175000017500000000000012657432232014366 5ustar chrischrisPGObject-Simple-Role-1.12.0/README0000755000175000017500000000527012657430251015254 0ustar chrischrisPGObject-Simple-Role PGObject::Simple::Role is a Moo/Moose mapper for minimalist PGObject framework (embodied in PGObject::Simple). Basically it provides a way to easily map stored procedures using the conventions of PGObject::Simple for Moo/Moose environments. PGObject::Simple::Role is a Moo role which allows you to use this functionality in Moo and Moose environments. The role itself makes no assumptions about database state, but provides hooks for classes to use to retrieve or create database handles for their use. This module is suited to quick and easy integration of PostgreSQL stored procedures with Moo and Moose object models. It is quite powerful and it makes developing in such environments relatively easy. 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 PGObject::Simple::Role You can also look for information at: RT, CPAN's request tracker (report bugs here) http://rt.cpan.org/NoAuth/Bugs.html?Dist=PGObject-Simple-Role AnnoCPAN, Annotated CPAN documentation http://annocpan.org/dist/PGObject-Simple-Role CPAN Ratings http://cpanratings.perl.org/d/PGObject-Simple-Role Search CPAN http://search.cpan.org/dist/PGObject-Simple-Role/ LICENSE AND COPYRIGHT Copyright (C) 2013 Chris Travers Redistribution and use in source and compiled forms with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code (Perl) must retain the above copyright notice, this list of conditions and the following disclaimer as the first lines of this file unmodified. * Redistributions in compiled form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the source code, documentation, and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. PGObject-Simple-Role-1.12.0/META.json0000664000175000017500000000173012657432232016012 0ustar chrischris{ "abstract" : "Moo/Moose mappers for minimalist PGObject framework", "author" : [ "Chris Travers, " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150001", "license" : [ "bsd" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "PGObject-Simple-Role", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Moo::Role" : "0", "PGObject::Simple" : "0", "Test::More" : "0" } } }, "release_status" : "stable", "version" : "v1.12.0" } PGObject-Simple-Role-1.12.0/TODO0000755000175000017500000000005712657430251015062 0ustar chrischrisTODO for 1.0: Done, just need more test cases PGObject-Simple-Role-1.12.0/MYMETA.json0000644000175000017500000000173012657432214016256 0ustar chrischris{ "abstract" : "Moo/Moose mappers for minimalist PGObject framework", "author" : [ "Chris Travers, " ], "dynamic_config" : 0, "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150001", "license" : [ "bsd" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "PGObject-Simple-Role", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Moo::Role" : "0", "PGObject::Simple" : "0", "Test::More" : "0" } } }, "release_status" : "stable", "version" : "v1.12.0" } PGObject-Simple-Role-1.12.0/Makefile.PL0000755000175000017500000000126112657430251016342 0ustar chrischrisuse 5.006; use strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'PGObject::Simple::Role', AUTHOR => q{Chris Travers, }, VERSION_FROM => 'lib/PGObject/Simple/Role.pm', ABSTRACT_FROM => 'lib/PGObject/Simple/Role.pm', ($ExtUtils::MakeMaker::VERSION >= 6.3002 ? ('LICENSE'=> 'bsd') : ()), PL_FILES => {}, PREREQ_PM => { 'Test::More' => 0, 'Moo::Role' => 0, 'PGObject::Simple' => 0, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'PGObject-Simple-Role-*' }, ); PGObject-Simple-Role-1.12.0/Changes0000755000175000017500000000255312657431216015672 0ustar chrischrisRevision history for PGObject-Simple-Role 1.12.0 2016-02-12 Fixing warning about unitialized value in subroutine entry 1.11.0 2014-08-25 Now safe regarding memoized PGObject catalog lookups 1.10.01 2014-05-01 Fixed wrong licensing reference in Makefile 1.01 2014-02-25 Handling of per-class default schemas 1.00 2014-02-18 Correct handling of lazy attributes Removed dbmethod() and documented why Contextual return of results so scalars return first row. 0.71 2014-02-15 Fixed Makefile.PL to ensure proper dependencies 0.70 2014-02-15 dbmethod() refactored so it is usable by libraries other than this one, is better tested, and more general. Use of the export here is now deprecated. 0.52 2014-01-14 Fixed funcprefix handling with call_procedure 0.51 2013-11-20 Fixed inability to push funcprefix through to PGObject::Simple 0.50 2013-11-13 Refactored to centralize logic in PGObject::Simple Added dbmethod() for declaratively defining database methods. 0.13 2013-11-06 Fixed test cases requiring Carp::Always, which was not in makefile. 0.12 2013-11-05 call_procedure can now be called on subclasses by package name if desired. 0.11 2013-05-31 Fixed an issue with the Makefile not reporting Moo::Role as a dependency 0.10 2013-05-30 First version, released on an unsuspecting world. PGObject-Simple-Role-1.12.0/lib/0000755000175000017500000000000012657432232015134 5ustar chrischrisPGObject-Simple-Role-1.12.0/lib/PGObject/0000755000175000017500000000000012657432232016571 5ustar chrischrisPGObject-Simple-Role-1.12.0/lib/PGObject/Simple/0000755000175000017500000000000012657432232020022 5ustar chrischrisPGObject-Simple-Role-1.12.0/lib/PGObject/Simple/Role.pm0000644000175000017500000002214412657431150021262 0ustar chrischrispackage PGObject::Simple::Role; use 5.006; use strict; use warnings; use Moo::Role; use PGObject::Simple; use Carp; =head1 NAME PGObject::Simple::Role - Moo/Moose mappers for minimalist PGObject framework =head1 VERSION Version 1.12.0 =cut our $VERSION = '1.12.0'; =head1 SYNOPSIS Take the following (Moose) class: package MyAPP::Foo; use PGObject::Util::DBMethod; use Moose; with 'PGObject::Simple::Role'; has id => (is => 'ro', isa => 'Int', required => 0); has foo => (is => 'ro', isa => 'Str', required => 0); has bar => (is => 'ro', isa => 'Str', required => 0); has baz => (is => 'ro', isa => 'Int', required => 0); sub get_dbh { return DBI->connect('dbi:Pg:dbname=foobar'); } # PGObject::Util::DBMethod exports this dbmethod int => (funcname => 'foo_to_int'); And a stored procedure: CREATE OR REPLACE FUNCTION foo_to_int (in_id int, in_foo text, in_bar text, in_baz int) RETURNS INT LANGUAGE SQL AS $$ select char_length($2) + char_length($3) + $1 * $4; $$; Then the following Perl code would work to invoke it: my $foobar = MyApp->foo(id => 3, foo => 'foo', bar => 'baz', baz => 33); $foobar->call_dbmethod(funcname => 'foo_to_int'); The following will also work since you have the dbmethod call above: my $int = $foobar->int; The full interface of call_dbmethod and call_procedure from PGObject::Simple are supported, and call_dbmethod is effectively wrapped by dbmethod(), allowing a declarative mapping. =head1 DESCRIPTION =head1 ATTRIBUTES AND LAZY GETTERS =cut # Private attribute for database handle, not intended to be directly set. has _DBH => ( is => 'lazy', isa => sub { croak "Expected a database handle. Got $_[0] instead" unless eval {$_[0]->isa('DBI::db')}; }, ); sub _build__DBH { my ($self) = @_; return $self->_get_dbh; } has _Registry => (is => 'lazy'); sub _build__Registry { return _get_registry(); } =head2 _get_registry This is a method the consuming classes can override in order to set the registry of the calls for type mapping purposes. =cut sub _get_registry{ return undef; } has _funcschema => (is => 'lazy'); =head2 _get_schema Returns the default schema associated with the object. =cut sub _build__funcschema { return $_[0]->_get_schema; } sub _get_schema { return undef; } has _funcprefix => (is => 'lazy'); =head2 _get_prefix Returns string, default is an empty string, used to set a prefix for mapping stored prcedures to an object class. =cut sub _build__funcprefix { return $_[0]->_get_prefix; } sub _get_prefix { return ''; } has _PGObject_Simple => ( is => 'lazy', ); sub _build__PGObject_Simple { my ($self) = @_; return PGObject::Simple->new() unless ref $self; $self->_DBH; $self->_funcprefix; my $obj = PGObject::Simple->new(%$self); $obj->_set_registry($self->_registry); return $obj; } has _registry => ( is => 'lazy' ); sub _build__registry { return _get_registry(); } =head2 _get_dbh Subclasses or sub-roles MUST implement a function which returns a DBI database handle (DBD::Pg 2.0 or hgher required). If this is not overridden an exception will be raised. =cut sub _get_dbh { croak 'Subclasses MUST set their own get_dbh methods!'; } =head2 call_procedure Identical interface to PGObject::Simple->call_procedure. This can be used on objects or on the packages themselves. I.e. mypackage->call_procedure() and $myobject->call_procedure() both work. =cut sub call_procedure { my $self = shift @_; my %args = @_; my $obj = _build__PGObject_Simple($self); $obj->{_DBH} = $self->_DBH if ref $self and !$args{dbh}; $obj->{_DBH} = "$self"->_get_dbh unless ref $self or $args{dbh}; if (ref $self){ $args{funcprefix} = $self->_funcprefix unless defined $args{funcprefix} or !ref $self; $args{funcschema} = $self->_funcschema unless defined $args{funcschema} or !ref $self; } else { $args{funcprefix} = "$self"->_get_prefix unless defined $args{funcprefix} or ref $self; $args{funcschema} = "$self"->_get_schema unless defined $args{funcschema} or ref $self; } my @rows = $obj->call_procedure(%args); for my $row (@rows){ for (keys %$row){ delete $row->{$_} unless defined $row->{$_}; } } return @rows if wantarray; return shift @rows; } =head2 call_dbmethod Identical interface to PGObject::Simple->call_dbmethod This can be used on objects or on the packages themselves. I.e. mypackage->call_dbmethod() and $myobject->call_dbmethod() both work. =cut sub call_dbmethod { my $self = shift @_; my %args = @_; croak 'No function name provided' unless $args{funcname}; $args{dbh} = $self->_DBH if ref $self and !$args{dbh}; $args{dbh} = "$self"->_get_dbh() unless $args{dbh}; if (ref $self){ $args{funcprefix} = $self->_funcprefix unless defined $args{funcprefix}; $args{funcschema} = $self->_funcschema unless $args{funcschema}; } else { $args{funcprefix} = "$self"->_get_prefix unless defined $args{funcprefix}; $args{funcschema} = "$self"->_get_schema unless $args{funcschema}; } $args{funcprefix} ||= ''; my $info = PGObject->function_info(%args); my $dbargs = []; @$dbargs = map { my $argname = $_->{name}; my $db_arg; $argname =~ s/^in_//; local $@; eval { $db_arg = $self->can($argname)->($self) } if ref $self and $argname; $db_arg = $args{args}->{$argname} if $args{args}->{$argname}; $db_arg = $db_arg->to_db if eval {$db_arg->can('to_db')}; $db_arg = { type => 'bytea', value => $db_arg} if $_->{type} eq 'bytea'; $db_arg; } @{$info->{args}}; $args{args} = $dbargs; my @rows; if (ref $self){ @rows = $self->call_procedure(%args); } else { @rows = "$self"->call_procedure(%args); } return @rows if wantarray; return shift @rows; } =head1 REMOVED METHODS These methods were once part of this package but have been removed due to the philosophy of not adding framework dependencies when an application dependency can work just as well. =head2 dbmethod Included in versions 0.50 - 0.71. Instead of using this directly, use: use PGObject::Util::DBMethod; instead. Ideally this should be done in your actual class since that will allow you to dispense with the extra parentheses. However, if you need a backwards-compatible and central solution, since PGObject::Simple::Role generally assumes sub-roles will be created for managing db connections etc. you can put the use statement there and it will have the same impact as it did here when it was removed with the benefit of better testing. =head1 AUTHOR Chris Travers,, C<< >> =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. 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 PGObject::Simple::Role You can also look for information at: =over 4 =item * RT: CPAN's request tracker (report bugs here) L =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * Search CPAN L =back =head1 ACKNOWLEDGEMENTS =head1 LICENSE AND COPYRIGHT Copyright 2013-2014 Chris Travers,. Redistribution and use in source and compiled forms with or without modification, are permitted provided that the following conditions are met: =over =item Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer as the first lines of this file unmodified. =item Redistributions in compiled form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the source code, documentation, and/or other materials provided with the distribution. =back THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =cut 1; # End of PGObject::Simple::Role PGObject-Simple-Role-1.12.0/README.md0000644000175000017500000000527012657430251015650 0ustar chrischrisPGObject-Simple-Role PGObject::Simple::Role is a Moo/Moose mapper for minimalist PGObject framework (embodied in PGObject::Simple). Basically it provides a way to easily map stored procedures using the conventions of PGObject::Simple for Moo/Moose environments. PGObject::Simple::Role is a Moo role which allows you to use this functionality in Moo and Moose environments. The role itself makes no assumptions about database state, but provides hooks for classes to use to retrieve or create database handles for their use. This module is suited to quick and easy integration of PostgreSQL stored procedures with Moo and Moose object models. It is quite powerful and it makes developing in such environments relatively easy. 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 PGObject::Simple::Role You can also look for information at: RT, CPAN's request tracker (report bugs here) http://rt.cpan.org/NoAuth/Bugs.html?Dist=PGObject-Simple-Role AnnoCPAN, Annotated CPAN documentation http://annocpan.org/dist/PGObject-Simple-Role CPAN Ratings http://cpanratings.perl.org/d/PGObject-Simple-Role Search CPAN http://search.cpan.org/dist/PGObject-Simple-Role/ LICENSE AND COPYRIGHT Copyright (C) 2013 Chris Travers Redistribution and use in source and compiled forms with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code (Perl) must retain the above copyright notice, this list of conditions and the following disclaimer as the first lines of this file unmodified. * Redistributions in compiled form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the source code, documentation, and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. PGObject-Simple-Role-1.12.0/MANIFEST0000644000175000017500000000064312657432232015522 0ustar chrischrisChanges ignore.txt lib/PGObject/Simple/Role.pm LICENSE Makefile.PL MANIFEST This list of files MANIFEST.SKIP MYMETA.json README README.md t/00-load.t t/01-basic-constructor.t t/02-dbtests.t t/boilerplate.t t/manifest.t t/pod-coverage.t t/pod.t TODO META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) PGObject-Simple-Role-1.12.0/t/0000755000175000017500000000000012657432232014631 5ustar chrischrisPGObject-Simple-Role-1.12.0/t/01-basic-constructor.t0000644000175000017500000000217412657430251020703 0ustar chrischris ######### package test1; use Moo; with('PGObject::Simple::Role'); has 'id' => (is => 'ro'); has 'foo' => (is => 'ro'); has 'bar' => (is => 'ro'); has 'baz' => (is => 'ro'); package test2; use Moo; with('PGObject::Simple::Role'); has 'id' => (is => 'ro'); sub _get_dbh { return 1; } ########## package main; use Test::More tests => 10; use Test::Exception; use DBI; my %args = ( id => 3, foo => 'test1', bar => 'test2', baz => 33, biz => 112, ); my $obj; lives_ok {$obj = test1->new(%args)} 'created new object without crashing'; ok(eval {$obj->isa('test1')}, 'ISA test passed'); is($obj->id, 3, 'attribute id passed'); is($obj->foo, 'test1', 'attribute foo passed'); is($obj->bar, 'test2', 'attribute bar passed'); is($obj->baz, 33, 'attribute baz passed'); ok(!defined($obj->can('biz')), 'No dbh method exists'); throws_ok {$obj->_build__DBH(1)} qr/Subclasses MUST set/, 'Threw exception, "Subclasses MUST set"'; lives_ok {$obj = test2->new(%args)} 'created new object without crashing'; throws_ok {$obj->_DBH} qr/Expected a database handle/, 'Threw exception, "Expected a database handle"'; PGObject-Simple-Role-1.12.0/t/pod-coverage.t0000644000175000017500000000104712657430251017372 0ustar chrischrisuse 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(); PGObject-Simple-Role-1.12.0/t/manifest.t0000644000175000017500000000042012657430251016617 0ustar chrischris#!perl -T use strict; use warnings; use Test::More; unless ( $ENV{RELEASE_TESTING} ) { plan( skip_all => "Author tests not required for installation" ); } eval "use Test::CheckManifest 0.9"; plan skip_all => "Test::CheckManifest 0.9 required" if $@; ok_manifest(); PGObject-Simple-Role-1.12.0/t/02-dbtests.t0000644000175000017500000001120312657430251016701 0ustar chrischrispackage test; use Moo; with 'PGObject::Simple::Role'; has id => (is => 'ro'); has foo => (is => 'ro'); has bar => (is => 'ro'); has baz => (is => 'ro'); has id2 => (is => 'lazy'); sub _build_id2 { return 10; } sub _get_dbh { return $main::dbh; } package test2; use Moo; with 'PGObject::Simple::Role'; has id => (is => 'ro'); has foo => (is => 'ro'); has bar => (is => 'ro'); has baz => (is => 'ro'); sub _get_dbh { return $main::dbh; } sub _get_prefix { return 'foo'; }; package main; use Test::More; use Test::Exception; use DBI; use PGObject::Simple; plan skip_all => 'DB_TESTING not set' unless $ENV{DB_TESTING}; # Initial setup my $dbh1 = DBI->connect('dbi:Pg:', 'postgres'); plan skip_all => 'Needs superuser connection for this test script' unless $dbh1; $dbh1->do('CREATE DATABASE pgobject_test_db'); our $dbh = DBI->connect('dbi:Pg:dbname=pgobject_test_db', 'postgres'); plan skip_all => 'No db connection' unless $dbh; plan tests => 17; $dbh->do(' CREATE FUNCTION public.foobar (in_foo text, in_bar text, in_baz int, in_id int) RETURNS int language sql as $$ SELECT char_length($1) + char_length($2) + $3 * $4; $$; ') ; $dbh->do('CREATE SCHEMA TEST'); $dbh->do(' CREATE FUNCTION test.foobar (in_foo text, in_bar text, in_baz int, in_id int) RETURNS int language sql as $$ SELECT 2*(char_length($1) + char_length($2) + $3 * $4); $$; ') ; $dbh->do(' CREATE FUNCTION public.lazy_foobar (in_foo text, in_bar text, in_baz int, in_id2 int) RETURNS int language sql as $$ SELECT char_length($1) + char_length($2) + $3 * $4; $$; ') ; my ($result) = test->call_dbmethod( funcname => 'foobar', args => {id => 3, foo => 'test1', bar => 'test2', baz => 33}, ); is($result->{foobar}, 109, 'Correct Result, direct package call to call_dbmethod'); my $obj = test->new(id => 3, foo => 'test1', bar => 'test2', baz => 33); ($result) = $obj->call_dbmethod(funcname => 'foobar'); is($result->{foobar}, 109, 'Correct Result, no argument overrides'); $result = $obj->call_dbmethod(funcname => 'lazy_foobar'); is($result->{lazy_foobar}, 340, 'Correct handling of lazy attributes'); ($result) = $obj->call_procedure(funcname => 'foobar', args => ['test1', 'testing', '3', '33']); is($result->{foobar}, 111, 'Correct result, call_procedure'); ($result) = $obj->call_procedure(funcname => 'foobar', funcschema => 'test', args => ['test1', 'testing', '3', '33']); is($result->{foobar}, 222, 'Correct result, call_procedure'); ($result) = test->call_procedure(funcname => 'foobar', args => ['test1', 'testing', '3', '33']); is($result->{foobar}, 111, 'Correct result, direct package call to call_procedure'); $result = $obj->call_dbmethod(funcname => 'foobar'); is(ref $result, ref {}, 'Correct result type, scalar return, no arg overrides'); is($result->{foobar}, 109, 'Correct Result, no argument overrides, scalar return'); $result = test->call_procedure(funcname => 'foobar', args => ['test1', 'testing', '3', '33']); is($result->{foobar}, 111, 'Correct result, direct package call to call_procedure, scalar return'); ($result) = $obj->call_dbmethod(funcname => 'foobar', args=> {baz => 1}); is($result->{foobar}, 13, 'Correct result, argument overrides'); throws_ok{$obj->call_dbmethod(funcname => 'foobar', dbh => $dbh1)} qr/No such function/, 'No such function thrown using wrong db'; $obj = test2->new(id => 3, foo => 'test1', bar => 'test2', baz => 33); ($result) = $obj->call_dbmethod(funcname => 'bar'); is($result->{foobar}, 109, 'Correct Result, no argument overrides'); ($result) = $obj->call_procedure(funcname => 'bar', args => ['test1', 'testing', '3', '33']); is($result->{foobar}, 111, 'Correct result, call_procedure'); ($result) = $obj->call_dbmethod(funcname => 'bar', args=> {baz => 1}); is($result->{foobar}, 13, 'Correct result, argument overrides'); $obj->{_funcschema} = 'test'; ($result) = $obj->call_procedure(funcname => 'bar', args => ['test1', 'testing', '3', '33']); is($result->{foobar}, 222, 'Correct result, call_procedure, set schema'); ($result) = $obj->call_dbmethod(funcname => 'bar', args=> {baz => 1}); is($result->{foobar}, 26, 'Correct result, argument overrides'); throws_ok{$obj->call_dbmethod(funcname => 'bar', dbh => $dbh1)} qr/No such function/, 'No such function thrown using wrong db'; # Teardown connections $dbh->disconnect; $dbh1->do('DROP DATABASE pgobject_test_db'); $dbh1->disconnect; PGObject-Simple-Role-1.12.0/t/boilerplate.t0000644000175000017500000000236712657430251017327 0ustar chrischris#!perl -T use 5.006; use strict; use warnings; use Test::More tests => 3; 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]/, ); } 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/PGObject/Simple/Role.pm'); PGObject-Simple-Role-1.12.0/t/00-load.t0000644000175000017500000000031212657430251016145 0ustar chrischris#!perl -T use Test::More tests => 1; BEGIN { use_ok( 'PGObject::Simple::Role' ) || print "Bail out!\n"; } diag( "Testing PGObject::Simple::Role $PGObject::Simple::Role::VERSION, Perl $], $^X" ); PGObject-Simple-Role-1.12.0/t/pod.t0000644000175000017500000000035012657430251015575 0ustar chrischris#!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(); PGObject-Simple-Role-1.12.0/META.yml0000664000175000017500000000110212657432232015633 0ustar chrischris--- abstract: 'Moo/Moose mappers for minimalist PGObject framework' author: - 'Chris Travers, ' build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150001' license: bsd meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: PGObject-Simple-Role no_index: directory: - t - inc requires: Moo::Role: '0' PGObject::Simple: '0' Test::More: '0' version: v1.12.0 PGObject-Simple-Role-1.12.0/MANIFEST.SKIP0000644000175000017500000000124512657430251016265 0ustar chrischris #!start included /usr/lib/perl5/5.10/ExtUtils/MANIFEST.SKIP # Avoid version control files. \B\.svn\b \B\.hg\b \B\.git\b \B\.gitignore\b # Avoid Makemaker generated and utility files. \bMANIFEST\.bak \bMakefile$ \bblib/ \bMakeMaker-\d \bpm_to_blib\.ts$ \bpm_to_blib$ \bblibdirs\.ts$ # 6.18 through 6.25 generated this # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ # Avoid Devel::Cover files. \bcover_db\b #!end included /usr/lib/perl5/5.10/ExtUtils/MANIFEST.SKIP ^extlib ^Su-.+\.tar\.gz$ ^work ^tmp \bTAGS$ ^MYMETA.yml$ \bSu-[\d\.\_]+ \bt_util/ Debian_CPANTS.txt \blib/Su/Procs/ PGObject-Simple-Role-1.12.0/LICENSE0000644000175000017500000000241712657430251015376 0ustar chrischrisCopyright (c) 2013, Chris Travers All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.PGObject-Simple-Role-1.12.0/ignore.txt0000755000175000017500000000020212657430251016406 0ustar chrischrisblib* Makefile Makefile.old Build Build.bat _build* pm_to_blib* *.tar.gz .lwpcookies cover_db pod2htm*.tmp PGObject-Simple-Role-*