PGObject-Type-BigFloat-2/0000755000175000017500000000000013110060235014247 5ustar chrischrisPGObject-Type-BigFloat-2/META.yml0000664000175000017500000000124313110060235015522 0ustar chrischris--- abstract: 'Math::BigFloat wrappers for PGObject classes' author: - 'Chris Travers ' build_requires: Test::More: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150005' license: bsd meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: PGObject-Type-BigFloat no_index: directory: - t - inc requires: Math::BigFloat: '0' PGObject: '0' resources: repository: https://github.com/ledgersmb/PGObject-Type-BigFloat.git version: 2 x_serialization_backend: 'CPAN::Meta::YAML version 0.018' PGObject-Type-BigFloat-2/Changes0000644000175000017500000000072513104435734015563 0ustar chrischrisRevision history for PGObject-Type-BigFloat 2.0.0 TBD PGObject 2.x support Registry may throw errors if type has been defined before. Perl 5.8 support removed. 1.0.1 2014-09-11 Minor documentation changes 1.00 2014-02-20 Fixing Makefile Innacuracies 0.03 2013-11-13 Added proper null handling for undef values. 0.02 2013-11-12 Fixed test cases in routine installation. 0.01 2013-11-11 First version, released on an unsuspecting world. PGObject-Type-BigFloat-2/META.json0000664000175000017500000000227513110060235015700 0ustar chrischris{ "abstract" : "Math::BigFloat wrappers for PGObject classes", "author" : [ "Chris Travers " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150005", "license" : [ "bsd" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "PGObject-Type-BigFloat", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "Test::More" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Math::BigFloat" : "0", "PGObject" : "0" } } }, "release_status" : "stable", "resources" : { "repository" : { "type" : "git", "url" : "https://github.com/ledgersmb/PGObject-Type-BigFloat.git", "web" : "https://github.com/ledgersmb/PGObject-Type-BigFloat" } }, "version" : 2, "x_serialization_backend" : "JSON::PP version 2.27400" } PGObject-Type-BigFloat-2/Makefile.PL0000644000175000017500000000214513104454106016232 0ustar chrischrisuse 5.010; use strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'PGObject::Type::BigFloat', AUTHOR => q{Chris Travers }, VERSION_FROM => 'lib/PGObject/Type/BigFloat.pm', ABSTRACT_FROM => 'lib/PGObject/Type/BigFloat.pm', ($ExtUtils::MakeMaker::VERSION >= 6.3002 ? ('LICENSE'=> 'BSD') : ()), PL_FILES => {}, PREREQ_PM => { 'PGObject' => 0, 'Math::BigFloat' => 0, }, BUILD_REQUIRES => { 'Test::More' => 0, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'PGObject-*' }, META_MERGE => { 'meta-spec' => { version => 2 }, resources => { repository => { type => 'git', url => 'https://github.com/ledgersmb/PGObject-Type-BigFloat.git', web => 'https://github.com/ledgersmb/PGObject-Type-BigFloat', }, }, }, ); PGObject-Type-BigFloat-2/t/0000755000175000017500000000000013110060235014512 5ustar chrischrisPGObject-Type-BigFloat-2/t/pod-coverage.t0000644000175000017500000000104713104435270017264 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-Type-BigFloat-2/t/03-dbtests.t0000644000175000017500000000575413104454770016620 0ustar chrischrisuse Test::More; use DBI; use PGObject; use PGObject::Type::BigFloat; PGObject::Type::BigFloat->register(); my $functions = { float4 => ' create or replace function test__float4() returns float4 language sql as $$SELECT 1.345::float4;$$', float8 => ' create or replace function test__float8() returns float language sql as $$SELECT 1.345::double precision;$$', numeric => ' create or replace function test__numeric() returns numeric language sql as $$SELECT 1.345::numeric;$$', round_trip => ' create or replace function test__roundtrip(numeric) returns numeric language sql as $$SELECT $1;$$', null => ' CREATE OR REPLACE FUNCTION test__null() RETURNS numeric LANGUAGE SQL AS $$ SELECT null::numeric; $$ ', }; plan skip_all => 'Not set up for dbtests' unless $ENV{DB_TESTING}; # DB Setup my $predbh = DBI->connect('dbi:Pg:', 'postgres'); plan skip_all => "Could not get superuser access to db. skipping" unless $predbh; $predbh->do('CREATE DATABASE test_pgobject_type_bigfloat'); my $dbh = DBI->connect('dbi:Pg:dbname=test_pgobject_type_bigfloat'); for my $fnc (keys %$functions){ $dbh->do($functions->{$fnc}); } # Planning if ($dbh) { plan tests => 12; } else { plan skipall => "No database connection, or connection failed"; } # Test cases for my $type (qw(float4 float8 numeric)){ my ($ref) = PGObject->call_procedure( funcname => $type, funcprefix => 'test__', args => [], dbh => $dbh, ); my ($val) = values %$ref; ok(eval {$val->isa('Math::BigFloat')}, "Type $type returns BigFloat object"); ok(eval {$val->isa('PGObject::Type::BigFloat')}, "Type $type returns PGObject::Type::BigFloat object"); } my ($ref) = PGObject->call_procedure( funcname => 'null', funcprefix => 'test__', args => [], dbh => $dbh, ); my ($val) = values %$ref; ok(eval {$val->isa('Math::BigFloat')}, "Type null returns BigFloat object"); ok(eval {$val->isa('PGObject::Type::BigFloat')}, "Type null returns PGObject::Type::BigFloat object"); ok(! defined $val->to_db, 'null returns undef to db'); $val = PGObject::Type::BigFloat->new(1.222); ($ref) = PGObject->call_procedure( funcname => 'roundtrip', funcprefix => 'test__', args => [$val], dbh => $dbh, ); ($val) = values %$ref; ok(eval {$val->isa('Math::BigFloat')}, "Roundtrip returns BigFloat object"); ok(eval {$val->isa('PGObject::Type::BigFloat')}, "Roundtrip returns PGObject::Type::BigFloat object"); is(eval {$val->to_db}, '1.222', 'Round Trip returns same value sent'); # DB Cleanup $dbh->disconnect; $predbh->do('DROP DATABASE test_pgobject_type_bigfloat'); PGObject-Type-BigFloat-2/t/manifest.t0000644000175000017500000000042013104435270016511 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-Type-BigFloat-2/t/02-dbinterface.t0000644000175000017500000000117113104452205017371 0ustar chrischrisuse Test::More tests => 39; use PGObject::Type::BigFloat; my @values = (1.234, 1000, 1234.34, -12333.23, 12143234523, 4233143455, 43324324, undef); for my $val (@values){ my $testvar = PGObject::Type::BigFloat->from_db($val); ok($testvar, "Object creation, value $val") if defined $val; ok($testvar->isa('Math::BigFloat'), "Object isa Math::BigFloat, value $val"); ok($testvar->isa('PGObject::Type::BigFloat'), "Object isa PGObject::Type::BigFloat, value $val"); my $out = $testvar->to_db; is(ref $out, '', "Output is not an object"); is($out, $val, "Value matches on output"); } PGObject-Type-BigFloat-2/t/boilerplate.t0000644000175000017500000000235713104435270017220 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/Type/BigFloat.pm'); PGObject-Type-BigFloat-2/t/01-registration.t0000644000175000017500000000245713104451406017646 0ustar chrischris use Test::More tests => 13; use PGObject; use PGObject::Type::BigFloat; use strict; use warnings; # Theoretically we could grab ints as well, and this makes a nice test case. # The tests here are: # 1. Registration with the default registry, default types # 2. Registration with the default registry, int8 type # 3. Registration with custom registry 'test', int8 type # 4. Registration with custom registry 'test', default types # 5. Registry properly lists all appropriate types. ok(PGObject->new_registry('test'), 'creating test registry'); ok(PGObject::Type::BigFloat->register(), 'default registration'); ok(PGObject::Type::BigFloat->register(types => ['int8']), 'int8 registration'); ok(PGObject::Type::BigFloat->register(registry => 'test', types => ['int8']), 'custom registry, int8 registration'), ok(PGObject::Type::BigFloat->register(registry => 'test'), 'default types, custom registry'); my $registry; if ($PGObject::VERSION =~ /^1\./){ $registry = PGObject::get_type_registry(); } else { $registry = {map {$_ => PGObject::Type::Registry->inspect($_)} qw(default test) }; } for my $reg(qw(default test)){ for my $type (qw(int8 float8 float4 numeric)) { is($registry->{$reg}->{$type}, 'PGObject::Type::BigFloat'); } } PGObject-Type-BigFloat-2/t/pod.t0000644000175000017500000000035013104435270015467 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-Type-BigFloat-2/t/00-load.t0000644000175000017500000000032013104435270016036 0ustar chrischris#!perl -T use Test::More tests => 1; BEGIN { use_ok( 'PGObject::Type::BigFloat' ) || print "Bail out!\n"; } diag( "Testing PGObject::Type::BigFloat $PGObject::Type::BigFloat::VERSION, Perl $], $^X" ); PGObject-Type-BigFloat-2/lib/0000755000175000017500000000000013110060235015015 5ustar chrischrisPGObject-Type-BigFloat-2/lib/PGObject/0000755000175000017500000000000013110060235016452 5ustar chrischrisPGObject-Type-BigFloat-2/lib/PGObject/Type/0000755000175000017500000000000013110060235017373 5ustar chrischrisPGObject-Type-BigFloat-2/lib/PGObject/Type/BigFloat.pm0000644000175000017500000000630713104453143021435 0ustar chrischrispackage PGObject::Type::BigFloat; use 5.010; use strict; use warnings; use base qw(Math::BigFloat); use PGObject; use Carp; =head1 NAME PGObject::Type::BigFloat - Math::BigFloat wrappers for PGObject classes =head1 VERSION Version 2 =cut our $VERSION = 2.000000; =head1 SYNOPSIS use PGObject::Type::BigFloat; PGObject::Type::BigFloat->register(); # Get all numeric and float types my $self->{foo} = PGObject::Type::BigFloat->new(0); $self->call_dbmethod(funcname => 'bar'); # will use this as a numeric =head1 SUBROUTINES/METHODS =head2 register(registry => 'default', types => ['float4', 'float8', 'numeric']) =cut sub register{ my $self = shift @_; my %args = @_; croak "Can't pass reference to register \n". "Hint: use the class instead of the object" if ref $self; my $registry = $args{registry}; $registry ||= 'default'; my $types = $args{types}; $types = ['float4', 'float8', 'numeric'] unless defined $types and @$types; for my $type (@$types){ if ($PGObject::VERSION =~ /^1\./){ my $ret = PGObject->register_type(registry => $registry, pg_type => $type, perl_class => $self); return $ret unless $ret; } else { PGObject::Type::Registry->register_type( registry => $registry, dbtype => $type, apptype => $self ); } } return 1; } =head2 to_db This serializes this into a simple db-friendly form. =cut sub to_db { my $self = shift @_; return undef if $self->is_undef; return $self->bstr; } =head2 from_db take simple normalized db floats and turn them into numeric representations. =cut sub from_db { my ($self, $value) = @_; my $obj = "$self"->new($value); $obj->is_undef(1) if ! defined $value; return $obj; } =head2 is_undef(optionally $set); Return undef to the db or user interface. Can be set through apps. =cut sub is_undef { my ($self, $set) = @_; $self->{_pgobject_undef} = $set if defined $set; return $self->{_pgobject_undef}; } =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::Type::BigFloat 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. This program is released under the following license: BSD =cut 1; # End of PGObject::Type::BigFloat PGObject-Type-BigFloat-2/README0000644000175000017500000000225513104435270015143 0ustar chrischrisPGObject-Type-BigFloat The PGObject::Module::BigFloat module provides a PGObject-aware wrapper around Math::BigFloat. This can then be the basis of "double-facing" classes sitting between user interfaces and the database. Once registered (optionally in a registry, which must already exist), it grabs all NUMERIC and FLOAT types and returns these as Math::BigFloat-compatible objects. 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::Type::BigFloat You can also look for information at: RT, CPAN's request tracker (report bugs here) http://rt.cpan.org/NoAuth/Bugs.html?Dist=PGObject-Type-BigFloat AnnoCPAN, Annotated CPAN documentation http://annocpan.org/dist/PGObject-Type-BigFloat CPAN Ratings http://cpanratings.perl.org/d/PGObject-Type-BigFloat Search CPAN http://search.cpan.org/dist/PGObject-Type-BigFloat/ LICENSE AND COPYRIGHT Copyright (C) 2013 Chris Travers This program is released under the following license: BSD PGObject-Type-BigFloat-2/README.md0000644000175000017500000000225513104435270015542 0ustar chrischrisPGObject-Type-BigFloat The PGObject::Module::BigFloat module provides a PGObject-aware wrapper around Math::BigFloat. This can then be the basis of "double-facing" classes sitting between user interfaces and the database. Once registered (optionally in a registry, which must already exist), it grabs all NUMERIC and FLOAT types and returns these as Math::BigFloat-compatible objects. 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::Type::BigFloat You can also look for information at: RT, CPAN's request tracker (report bugs here) http://rt.cpan.org/NoAuth/Bugs.html?Dist=PGObject-Type-BigFloat AnnoCPAN, Annotated CPAN documentation http://annocpan.org/dist/PGObject-Type-BigFloat CPAN Ratings http://cpanratings.perl.org/d/PGObject-Type-BigFloat Search CPAN http://search.cpan.org/dist/PGObject-Type-BigFloat/ LICENSE AND COPYRIGHT Copyright (C) 2013 Chris Travers This program is released under the following license: BSD PGObject-Type-BigFloat-2/ignore.txt0000644000175000017500000000020413104435270016277 0ustar chrischrisblib* Makefile Makefile.old Build Build.bat _build* pm_to_blib* *.tar.gz .lwpcookies cover_db pod2htm*.tmp PGObject-Type-BigFloat-* PGObject-Type-BigFloat-2/MANIFEST0000644000175000017500000000062413110060235015402 0ustar chrischrisChanges ignore.txt lib/PGObject/Type/BigFloat.pm LICENSE Makefile.PL MANIFEST This list of files README README.md t/00-load.t t/01-registration.t t/02-dbinterface.t t/03-dbtests.t t/boilerplate.t t/manifest.t t/pod-coverage.t t/pod.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) PGObject-Type-BigFloat-2/LICENSE0000644000175000017500000000241713104435270015270 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.