PGObject-Type-ByteString-1.2.0/0000755000175000017500000000000013110327415015155 5ustar chrischrisPGObject-Type-ByteString-1.2.0/META.yml0000664000175000017500000000127613110327415016436 0ustar chrischris--- abstract: 'Wrapper for raw strings mapping to BYTEA columns' author: - 'Erik Huelsmann ' build_requires: File::Slurp: '0' 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-ByteString no_index: directory: - t - inc requires: DBD::Pg: '1.20' PGObject: v1.403.2 resources: repository: https://github.com/ledgersmb/PGObject-Type-ByteString.git version: v1.2.0 x_serialization_backend: 'CPAN::Meta::YAML version 0.018' PGObject-Type-ByteString-1.2.0/Changes0000644000175000017500000000057113104703135016453 0ustar chrischrisRevision history for PGObject-Type-ByteString 1.2.0 2017-05-16 Adds support for PGObject 2.x 1.1.2 2016-12-04 Fix copyright attribution in LICENSE (consistency) 1.1.1 2016-11-21 Fix NAME section in the PGObject::Type::ByteString module 1.1.0 2016-11-20 Switch from hashref to scalarref, while we can 1.0.0 2016-11-19 First version. PGObject-Type-ByteString-1.2.0/META.json0000664000175000017500000000235413110327415016604 0ustar chrischris{ "abstract" : "Wrapper for raw strings mapping to BYTEA columns", "author" : [ "Erik Huelsmann " ], "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-ByteString", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "File::Slurp" : "0", "Test::More" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "DBD::Pg" : "1.20", "PGObject" : "v1.403.2" } } }, "release_status" : "stable", "resources" : { "repository" : { "type" : "git", "url" : "https://github.com/ledgersmb/PGObject-Type-ByteString.git", "web" : "https://github.com/ledgersmb/PGObject-Type-ByteString" } }, "version" : "v1.2.0", "x_serialization_backend" : "JSON::PP version 2.27400" } PGObject-Type-ByteString-1.2.0/Makefile.PL0000644000175000017500000000212613104703020017121 0ustar chrischrisuse 5.006; use strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'PGObject::Type::ByteString', AUTHOR => q{Erik Huelsmann }, VERSION_FROM => 'lib/PGObject/Type/ByteString.pm', ABSTRACT_FROM => 'lib/PGObject/Type/ByteString.pm', ($ExtUtils::MakeMaker::VERSION >= 6.3002 ? ('LICENSE'=> 'BSD') : ()), PL_FILES => {}, PREREQ_PM => { 'PGObject' => '1.403.2', 'DBD::Pg' => '1.20', }, BUILD_REQUIRES => { 'Test::More' => 0, 'File::Slurp' => 0, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'PGObject-Type-ByteString-*' }, META_MERGE => { 'meta-spec' => { version => 2 }, resources => { repository => { type => 'git', url => 'https://github.com/ledgersmb/PGObject-Type-ByteString.git', web => 'https://github.com/ledgersmb/PGObject-Type-ByteString', }, }, }, ); PGObject-Type-ByteString-1.2.0/t/0000755000175000017500000000000013110327415015420 5ustar chrischrisPGObject-Type-ByteString-1.2.0/t/02-registration.t0000644000175000017500000000272513104702101020534 0ustar chrischris use Test::More; use PGObject; use PGObject::Type::ByteString; use DBD::Pg qw(:pg_types); 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::ByteString->register(), 'default registration'); ok(PGObject::Type::ByteString->register(types => ['mybytes']), 'mybytes registration'); ok(PGObject::Type::ByteString->register(registry => 'test', types => ['mybytes']), 'custom registry, mybytes registration'), ok(PGObject::Type::ByteString->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 (PG_BYTEA, 'mybytes') { is($registry->{$reg}->{$type}, 'PGObject::Type::ByteString', "registry $reg, type $type correctly registered"); } } done_testing; PGObject-Type-ByteString-1.2.0/t/data/0000755000175000017500000000000013110327415016331 5ustar chrischrisPGObject-Type-ByteString-1.2.0/t/data/non-ascii-non-utf80000644000175000017500000000000613104700475021610 0ustar chrischrisÊþº¾Õ PGObject-Type-ByteString-1.2.0/t/03-dbtests.t0000644000175000017500000000241613104700475017504 0ustar chrischrisuse Test::More; use File::Slurp; use DBI; use PGObject; use PGObject::Type::ByteString; PGObject::Type::ByteString->register(); plan skip_all => 'Not set up for dbtests' unless $ENV{DB_TESTING}; # DB Setup my $predbh = DBI->connect('dbi:Pg:', 'postgres', undef, { PrintError => 0 }); plan skip_all => "Could not get superuser access to db. skipping" unless $predbh; $predbh->do('CREATE DATABASE test_pgobject_type_bytestring'); my $dbh = DBI->connect('dbi:Pg:dbname=test_pgobject_type_bytestring'); # Planning plan skipall => "No database connection, or connection failed" unless $dbh; $dbh->do(qq| CREATE or REPLACE FUNCTION test__roundtrip(in_col bytea) RETURNS bytea LANGUAGE SQL AS \$\$ SELECT \$1; \$\$; |); # Test cases my $non_utf8 = read_file( 't/data/non-ascii-non-utf8', { binmode => ':raw' }); my $obj = PGObject::Type::ByteString->new(non_utf8); my ($ref) = PGObject->call_procedure( funcname => 'roundtrip', funcprefix => 'test__', args => [$obj], dbh => $dbh, ); my ($val) = values %$ref; ok($val->isa('PGObject::Type::ByteString'), 'Roundtrip returns correct type'); is($$val, $$obj, 'Roundtrip returns same value'); # DB Cleanup $dbh->disconnect; $predbh->do('DROP DATABASE test_pgobject_type_datetime'); done_testing; PGObject-Type-ByteString-1.2.0/t/manifest.t0000644000175000017500000000042013104700475017413 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-ByteString-1.2.0/t/01-constructor.t0000644000175000017500000000045113104700475020414 0ustar chrischrisuse PGObject::Type::ByteString; use Test::More; my $test; $test = PGObject::Type::ByteString->from_db("\xCA\xFE\xBA\xBE"); isa_ok $test, 'PGObject::Type::ByteString', 'non-UTF characters in string; expected class'; is $test->to_db->{value}, "\xCA\xFE\xBA\xBE", 'expected db out'; done_testing; PGObject-Type-ByteString-1.2.0/t/00-load.t0000644000175000017500000000014713104700475016747 0ustar chrischris#!perl -T use Test::More tests => 1; use_ok( 'PGObject::Type::ByteString' ) || print "Bail out!\n"; PGObject-Type-ByteString-1.2.0/lib/0000755000175000017500000000000013110327415015723 5ustar chrischrisPGObject-Type-ByteString-1.2.0/lib/PGObject/0000755000175000017500000000000013110327415017360 5ustar chrischrisPGObject-Type-ByteString-1.2.0/lib/PGObject/Type/0000755000175000017500000000000013110327415020301 5ustar chrischrisPGObject-Type-ByteString-1.2.0/lib/PGObject/Type/ByteString.pm0000644000175000017500000000624113104703100022724 0ustar chrischrispackage PGObject::Type::ByteString; use strict; use warnings; use 5.008; use Carp; use DBD::Pg qw(:pg_types); =head1 NAME PGObject::Type::ByteString - Wrapper for raw strings mapping to BYTEA columns =head1 VERSION Version 1.1.2 =cut our $VERSION = '1.2.0'; =head1 SYNOPSIS PGObject::Type::ByteString->register(); Now all BYTEA columns will be returned as ByteString objects. =head1 DESCRIPTION This module provides a basic wrapper around Perl strings, mapping them to =head1 SUBROUTINES/METHODS =head2 register By default registers PG_BYTEA =cut sub register { my $self = shift @_; croak "Can't pass reference to register \n". "Hint: use the class instead of the object" if ref $self; my %args = @_; my $registry = $args{registry}; $registry ||= 'default'; my $types = $args{types}; $types = [ DBD::Pg::PG_BYTEA, 'bytea' ] 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 new =cut sub new { my ($class, $value) = @_; my $self; croak 'Must pass scalar or scalar ref' if defined ref $value and ref $value !~ /SCALAR/; if (ref $value ) { $self = $value; } else { $self = \$value; } return bless $self, $class; } =head2 from_db Parses a date from YYYY-MM-DD format and generates the new object based on it. =cut sub from_db { my ($class, $value) = @_; return $class->new($value); } =head2 to_db Returns the date in YYYY-MM-DD format. =cut sub to_db { my ($self) = @_; # hashref with value and type allows us to tell DBD::Pg to bind to binary return { value => $$self, type => PG_BYTEA }; } =head1 AUTHOR Erik Huelsmann, 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::ByteString 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 2016 Erik Huelsmann This program is released under the following license: BSD =cut 1; # End of PGObject::Type::DateTime PGObject-Type-ByteString-1.2.0/README0000644000175000017500000000163313104700475016044 0ustar chrischrisPGObject-Type-ByteString This module maps Perl strings into a BYTEA field. 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::ByteString 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-ByteString AnnoCPAN, Annotated CPAN documentation http://annocpan.org/dist/PGObject-Type-ByteString CPAN Ratings http://cpanratings.perl.org/d/PGObject-Type-ByteString Search CPAN http://search.cpan.org/dist/PGObject-Type-ByteString/ LICENSE AND COPYRIGHT Copyright (C) 2016 Erik Huelsmann This program is released under the following license: BSD PGObject-Type-ByteString-1.2.0/MANIFEST0000664000175000017500000000064213110327415016312 0ustar chrischrisChanges lib/PGObject/Type/ByteString.pm LICENSE Makefile.PL MANIFEST This list of files README t/00-load.t t/01-constructor.t t/02-registration.t t/03-dbtests.t t/manifest.t xt/pod-coverage.t xt/pod.t t/data/non-ascii-non-utf8 META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) PGObject-Type-ByteString-1.2.0/xt/0000755000175000017500000000000013110327415015610 5ustar chrischrisPGObject-Type-ByteString-1.2.0/xt/pod-coverage.t0000644000175000017500000000104713104700475020356 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-ByteString-1.2.0/xt/pod.t0000644000175000017500000000035013104700475016561 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-ByteString-1.2.0/LICENSE0000644000175000017500000000244713104703020016162 0ustar chrischrisBSD 2-Clause License Copyright (c) 2016, Erik Huelsmann 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.