PGObject-Type-ByteString-1.2.3/0000755000175000017500000000000013311300062017226 5ustar ehuelsmannehuelsmannPGObject-Type-ByteString-1.2.3/MANIFEST0000644000175000017500000000064213311300062020361 0ustar ehuelsmannehuelsmannChanges 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.3/Makefile.PL0000644000175000017500000000216213311272615021215 0ustar ehuelsmannehuelsmannuse 5.010; 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', 'Ref::Util' => 0, }, 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.3/lib/0000755000175000017500000000000013311300062017774 5ustar ehuelsmannehuelsmannPGObject-Type-ByteString-1.2.3/lib/PGObject/0000755000175000017500000000000013311300062021431 5ustar ehuelsmannehuelsmannPGObject-Type-ByteString-1.2.3/lib/PGObject/Type/0000755000175000017500000000000013311300062022352 5ustar ehuelsmannehuelsmannPGObject-Type-ByteString-1.2.3/lib/PGObject/Type/ByteString.pm0000644000175000017500000000727713311277650025037 0ustar ehuelsmannehuelsmannpackage PGObject::Type::ByteString; use strict; use warnings; use 5.010; use Carp; use DBD::Pg qw(:pg_types); use Ref::Util qw(is_ref is_scalarref); =head1 NAME PGObject::Type::ByteString - Wrapper for raw strings mapping to BYTEA columns. =head1 VERSION Version 1.2.3 =cut our $VERSION = '1.2.3'; =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 BYTEA database columns. PGObject::Type::ByteString objects have no traditional properties, however dereferencing them will yield the raw string they contain. =head1 SUBROUTINES/METHODS =head2 register([registry => 'default',] [types => $types_arrayref]) By default registers type 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 Instantiates and returns a new object, based on the supplied scalar string, or scalar string reference. Dereferencing the returned object will yield the original raw string. =cut sub new { my ($class, $value) = @_; my $self; croak 'Must pass scalar or scalar ref' if is_ref($value) && ! is_scalarref($value); if (is_ref($value)) { $self = $value; } else { $self = \$value; } return bless $self, $class; } =head2 from_db Returns a new PGObject::Type::ByteString object based on the supplied scalar string, or scalar string reference. =cut sub from_db { my ($class, $value) = @_; return $class->new($value); } =head2 to_db Returns the object's binary string value packaged as PG_BYTEA type/value hashref suitable for passing to DBD::Pg. =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-2018 Erik Huelsmann This program is released under the following license: BSD =cut 1; # End of PGObject::Type::DateTime PGObject-Type-ByteString-1.2.3/META.yml0000644000175000017500000000123013311300062020473 0ustar ehuelsmannehuelsmann--- 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.0401, 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-Type-ByteString no_index: directory: - t - inc requires: DBD::Pg: '1.20' PGObject: v1.403.2 Ref::Util: '0' resources: repository: https://github.com/ledgersmb/PGObject-Type-ByteString.git version: v1.2.3 PGObject-Type-ByteString-1.2.3/t/0000755000175000017500000000000013311300062017471 5ustar ehuelsmannehuelsmannPGObject-Type-ByteString-1.2.3/t/01-constructor.t0000644000175000017500000000045113311272514022473 0ustar ehuelsmannehuelsmannuse 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.3/t/00-load.t0000644000175000017500000000014713311272514021026 0ustar ehuelsmannehuelsmann#!perl -T use Test::More tests => 1; use_ok( 'PGObject::Type::ByteString' ) || print "Bail out!\n"; PGObject-Type-ByteString-1.2.3/t/02-registration.t0000644000175000017500000000272513311272514022627 0ustar ehuelsmannehuelsmann 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.3/t/manifest.t0000644000175000017500000000042013311272514021472 0ustar ehuelsmannehuelsmann#!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.3/t/data/0000755000175000017500000000000013311300062020402 5ustar ehuelsmannehuelsmannPGObject-Type-ByteString-1.2.3/t/data/non-ascii-non-utf80000644000175000017500000000000613311272514023667 0ustar ehuelsmannehuelsmannÊþº¾Õ PGObject-Type-ByteString-1.2.3/t/03-dbtests.t0000644000175000017500000000241613311272514021563 0ustar ehuelsmannehuelsmannuse 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.3/README0000644000175000017500000000163313311272514020123 0ustar ehuelsmannehuelsmannPGObject-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.3/LICENSE0000644000175000017500000000244713311272514020254 0ustar ehuelsmannehuelsmannBSD 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. PGObject-Type-ByteString-1.2.3/META.json0000644000175000017500000000232313311300062020647 0ustar ehuelsmannehuelsmann{ "abstract" : "Wrapper for raw strings mapping to BYTEA columns.", "author" : [ "Erik Huelsmann " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150001", "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", "Ref::Util" : "0" } } }, "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.3" } PGObject-Type-ByteString-1.2.3/Changes0000644000175000017500000000111513311277635020542 0ustar ehuelsmannehuelsmannRevision history for PGObject-Type-ByteString 1.2.3 2018-06-16 Correct inversed condition after fixes 1.2.2 2018-06-16 Restore support for undefined values 1.2.1 2018-06-16 Address warning thrown by LedgerSMB tests 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.3/xt/0000755000175000017500000000000013311300062017661 5ustar ehuelsmannehuelsmannPGObject-Type-ByteString-1.2.3/xt/pod-coverage.t0000644000175000017500000000104713311272514022435 0ustar ehuelsmannehuelsmannuse 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.3/xt/pod.t0000644000175000017500000000035013311272514020640 0ustar ehuelsmannehuelsmann#!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();