Package-New-0.10/ 0000755 0001750 0001750 00000000000 14736621625 013060 5 ustar mdavis mdavis Package-New-0.10/t/ 0000755 0001750 0001750 00000000000 14736621625 013323 5 ustar mdavis mdavis Package-New-0.10/t/004_dump.t 0000644 0001750 0001750 00000000652 14051753674 015043 0 ustar mdavis mdavis # -*- perl -*-
use strict;
use warnings;
use Test::More tests => 5;
use Devel::Hide qw(Data::Dumper);
BEGIN { use_ok( 'Package::New::Dump' ); }
my $object = Package::New::Dump->new(one=>{two=>{three=>{four=>{}}}});
isa_ok($object, 'Package::New::Dump');
isa_ok($object, 'Package::New');
my $value = $object->dump;
is($value, '', 'dump empty string');
my @value = $object->dump;
is(scalar(@value), 0, 'dump empty array');
Package-New-0.10/t/002_base.t 0000644 0001750 0001750 00000001677 14051753674 015016 0 ustar mdavis mdavis # -*- perl -*-
use strict;
use warnings;
use Test::More tests => 16;
BEGIN { use_ok( 'Package::New' ); }
{
my $object = My::Package->new(x=>1, y=>"a");
isa_ok($object, 'Package::New');
isa_ok($object, 'My::Package');
can_ok($object, qw{new initialize x y});
is($object->x, "1", "args work");
is($object->y, "a", "args work");
}
{
my $object = My::Package->new(x=>undef)->new(x=>1, y=>"a");
isa_ok($object, 'Package::New');
isa_ok($object, 'My::Package');
can_ok($object, qw{new initialize x y});
is($object->x, "1", "args work");
is($object->y, "a", "args work");
}
{
my $object = new My::Package x=>1, y=>"a";
isa_ok($object, 'Package::New');
isa_ok($object, 'My::Package');
can_ok($object, qw{new initialize x y});
is($object->x, "1", "args work");
is($object->y, "a", "args work");
}
{
package #Hide from CPAN
My::Package;
use base qw{Package::New};
sub x {shift->{"x"}};
sub y {shift->{"y"}};
1;
}
Package-New-0.10/t/001_load.t 0000644 0001750 0001750 00000001205 14051753674 015005 0 ustar mdavis mdavis # -*- perl -*-
use strict;
use warnings;
use Test::More tests => 13;
BEGIN { use_ok( 'Package::New' ); }
BEGIN { use_ok( 'Package::New::Dump' ); }
my $obj1 = Package::New->new(x=>1, y=>"a");
isa_ok ($obj1, 'Package::New');
isa_ok($obj1->new, 'Package::New');
can_ok($obj1, qw{new initialize});
is($obj1->{"x"}, "1", "args work");
is($obj1->{"y"}, "a", "args work");
my $obj2 = Package::New::Dump->new(x=>2, y=>"b");
isa_ok($obj2, 'Package::New::Dump');
isa_ok($obj2, 'Package::New');
isa_ok($obj2->new, 'Package::New::Dump');
can_ok($obj2, qw{new initialize dump});
is($obj2->{"x"}, "2", "args work");
is($obj2->{"y"}, "b", "args work");
Package-New-0.10/t/003_dump.t 0000644 0001750 0001750 00000003155 14051753674 015043 0 ustar mdavis mdavis # -*- perl -*-
use strict;
use warnings;
use Test::More tests => 17;
BEGIN { use_ok( 'Package::New::Dump' ); }
my $object = Bar->new(one=>{two=>{three=>{four=>{}}}});
isa_ok($object, 'Bar');
isa_ok($object, 'Foo');
isa_ok($object, 'Package::New::Dump');
isa_ok($object, 'Package::New');
can_ok($object, qw{new initialize dump});
can_ok($object, qw{bar});
can_ok($object, qw{baz});
is($object->bar, "baz", "object method");
is(Bar->bar, "baz", "class method");
is($object->baz, "buz", "object method");
is(Bar->baz, "buz", "class method");
{
my $dump = $object->dump(1);
diag($dump);
$dump =~ s/\s+//g; #white space compress
$dump =~ s/0x[0-9a-f]+/XXX/;
is($dump, q{$VAR1=bless({'one'=>'HASH(XXX)'},'Bar');});
}
{
my $dump = $object->dump();
diag($dump);
$dump =~ s/\s+//g; #white space compress
$dump =~ s/0x[0-9a-f]+/XXX/;
is($dump, q{$VAR1=bless({'one'=>{'two'=>'HASH(XXX)'}},'Bar');});
}
{
my $dump = $object->dump(undef);
diag($dump);
$dump =~ s/\s+//g; #white space compress
$dump =~ s/0x[0-9a-f]+/XXX/;
is($dump, q{$VAR1=bless({'one'=>{'two'=>'HASH(XXX)'}},'Bar');});
}
{
my $dump = $object->dump(2);
diag($dump);
$dump =~ s/\s+//g; #white space compress
$dump =~ s/0x[0-9a-f]+/XXX/;
is($dump, q{$VAR1=bless({'one'=>{'two'=>'HASH(XXX)'}},'Bar');});
}
{
my $dump = $object->dump(0);
diag($dump);
$dump =~ s/\s+//g; #white space compress
is($dump, q{$VAR1=bless({'one'=>{'two'=>{'three'=>{'four'=>{}}}}},'Bar');});
}
{
package #hide
Foo;
use base qw{Package::New::Dump};
sub bar {"baz"};
1;
}
{
package #hide
Bar;
use base qw{Foo};
sub baz {"buz"};
1;
}
Package-New-0.10/perl-Package-New.spec 0000644 0001750 0001750 00000003736 14736620321 016757 0 ustar mdavis mdavis Name: perl-Package-New
Version: 0.10
Release: 1%{?dist}
Summary: Simple base package from which to inherit
License: BSD
Group: Development/Libraries
URL: http://search.cpan.org/dist/Package-New/
Source0: http://search.cpan.org/CPAN/authors/id/M/MR/MRDVT/Package-New-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
BuildRequires: perl(ExtUtils::MakeMaker)
BuildRequires: perl(Devel::Hide)
BuildRequires: perl(Test::Simple) >= 0.44
Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
%description
The Package::New object provides a consistent object constructor for
objects.
%prep
%setup -q -n Package-New-%{version}
%build
%{__perl} Makefile.PL INSTALLDIRS=vendor
make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
make pure_install PERL_INSTALL_ROOT=$RPM_BUILD_ROOT
find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} \;
find $RPM_BUILD_ROOT -depth -type d -exec rmdir {} 2>/dev/null \;
%{_fixperms} $RPM_BUILD_ROOT/*
%check
make test
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
%doc Changes LICENSE README.md
%{perl_vendorlib}/*
%{_mandir}/man3/*
%changelog
*Sun Jan 05 2025 Michael R. Davis (mrdvt92@yahoo.com) 0.10-1
-Updated to 0.10
*Fri Dec 03 2011 Michael R. Davis (mrdvt92@yahoo.com) 0.07-2
-CPAN did not symlink the package into the by_module tree.
*Thu Dec 02 2011 Michael R. Davis (mrdvt92@yahoo.com) 0.07-1
-Updated for version 0.07
*Wed Feb 23 2011 Michael R. Davis (mrdvt92@yahoo.com) 0.05-1
-Updated for version 0.05
*Wed Feb 23 2011 Michael R. Davis (mrdvt92@yahoo.com) 0.04-1
-Updated for version 0.04
*Sat Feb 05 2011 Michael R. Davis (mrdvt92@yahoo.com) 0.03-1
-Updated for version 0.03
*Fri Feb 04 2011 Michael R. Davis (mrdvt92@yahoo.com) 0.02-1
-Updated for version 0.02
*Fri Feb 04 2011 Michael R. Davis (mrdvt92@yahoo.com) 0.01-1
-Specfile autogenerated by cpanspec 1.78.
Package-New-0.10/Changes 0000644 0001750 0001750 00000001736 14736615775 014373 0 ustar mdavis mdavis Revision history for Perl module Package::New
0.10 2025-01-01
- Moving from private repo to GitHub
0.09 2020-02-17
- Updated lib/Package/New.pm - fixed testing coverage issue
- Updated t/002_base.t and t/003_dump.t - added testing coverage
0.08 2019-12-14
- Updated t/001_load.t - Added test cases from cpancover.com
- Added t/004_dump.t - Added test cases from cpancover.com
- Updated lib/Package/New/Dump.pm - Slightly refactored dump method
0.07 2011-12-01
- Cleaned up for Fedora 16
0.06 2011-08-01
- Abandoned Fork
0.05_2 2011-02-24
- Documentation
0.05 2011-02-23
- Fixed issue with pod NAME which messed up CPAN indexer
0.04 2011-02-23
- Updated Documentation
- Added dump tests
- Disabled Data::Dumper export of Dumper
- Updated tests to use can_ok instead of $obj->can
0.03 2011-02-05
- Added package with dump method for testing
0.02 2011-02-04
- Documentation
0.01 2011-02-04
- original version; created by ExtUtils::ModuleMaker 0.51
Package-New-0.10/lib/ 0000755 0001750 0001750 00000000000 14736621625 013626 5 ustar mdavis mdavis Package-New-0.10/lib/Package/ 0000755 0001750 0001750 00000000000 14736621625 015161 5 ustar mdavis mdavis Package-New-0.10/lib/Package/New.pm 0000644 0001750 0001750 00000005126 14736615435 016256 0 ustar mdavis mdavis package Package::New;
use strict;
use warnings;
our $VERSION='0.10';
=head1 NAME
Package::New - Simple base package from which to inherit
=head1 SYNOPSIS
package My::Package;
use base qw{Package::New}; #provides new and initialize
=head1 DESCRIPTION
The Package::New object provides a consistent constructor for objects.
I find that I always need these two methods in every package that I build. I plan to use this package as the base for all of my CPAN packages.
=head1 RECOMMENDATIONS
=head2 Sane defaults
I recommend that you have sane default for all of your object properties. I recommend using code like this.
sub myproperty {
my $self=shift;
$self->{"myproperty"}=shift if @_;
$self->{"myproperty"}="Default Value" unless defined $self->{"myproperty"};
return $self->{"myproperty"};
}
=head2 use strict and warnings
I recommend to always use strict, warnings and our version.
package My::Package;
use base qw{Package::New};
use strict;
use warnings;
our $VERSION='0.01';
=head2 Lazy Load where you can
I recommend Lazy Loading where you can.
sub mymethod {
my $self=shift;
$self->load unless $self->loaded;
return $self->{"mymethod"};
}
=head1 USAGE
=head1 CONSTRUCTOR
=head2 new
my $obj = Package::New->new(key=>$value, ...);
=cut
sub new {
my $this = shift;
my $class = ref($this) ? ref($this) : $this;
my $self = {};
bless $self, $class;
$self->initialize(@_);
return $self;
}
=head2 initialize
You can override this method in your package if you need to do something after construction. But, lazy loading may be a better option.
=cut
sub initialize {
my $self=shift;
%$self=@_;
}
=head1 BUGS
Log on RT and contact the author.
=head1 SUPPORT
DavisNetworks.com provides support services for all Perl applications including this package.
=head1 AUTHOR
Michael R. Davis
CPAN ID: MRDVT
DavisNetworks.com
http://www.DavisNetworks.com/
=head1 COPYRIGHT
This program is free software licensed under the...
The BSD License
The full text of the license can be found in the LICENSE file included with this module.
=head1 SEE ALSO
=head2 Building Blocks
L, L
=head2 Other Light Weight Base Objects Similar to Package::New
L, L, L, L, L
=head2 Heavy Base Objects - Drink the Kool-Aid
L, L, L, L, (as well as Moose-alikes L, L), L, L
=head2 Even more
L, L, L, L, L, L
=cut
1;
Package-New-0.10/lib/Package/New/ 0000755 0001750 0001750 00000000000 14736621625 015712 5 ustar mdavis mdavis Package-New-0.10/lib/Package/New/Dump.pm 0000644 0001750 0001750 00000002321 14736617344 017156 0 ustar mdavis mdavis package Package::New::Dump;
use base qw{Package::New};
use strict;
use warnings;
our $VERSION='0.10';
=head1 NAME
Package::New::Dump - Simple base package from which to inherit
=head1 SYNOPSIS
package My::Package;
use base qw{Package::New::Dump}; #provides new, initialize and dump
=head1 DESCRIPTION
The Package::New::Dump object provides a consistent object constructor for objects.
=head1 RECOMMENDATIONS
I recommend using this package only during development and reverting back to L when in full production
=head1 USAGE
=head1 CONSTRUCTOR
See L
=cut
=head1 METHODS
=head2 dump
Returns the object serialized by L
=cut
sub dump {
my $self = shift;
my $depth = shift;
$depth = 2 unless defined $depth;
local $@;
eval 'use Data::Dumper qw{}';
my $error = $@;
if ($error) {
return wantarray ? () : '';
} else {
my $d = Data::Dumper->new([$self]);
$d->Maxdepth($depth);
return $d->Dump;
}
}
=head1 AUTHOR
Michael R. Davis
=head1 COPYRIGHT
This program is free software licensed under the...
The BSD License
The full text of the license can be found in the LICENSE file included with this module.
=head1 SEE ALSO
=cut
1;
Package-New-0.10/MANIFEST 0000644 0001750 0001750 00000000514 14736621625 014211 0 ustar mdavis mdavis MANIFEST
README.md
LICENSE
Changes
Makefile.PL
lib/Package/New.pm
lib/Package/New/Dump.pm
t/001_load.t
t/002_base.t
t/003_dump.t
t/004_dump.t
perl-Package-New.spec
META.yml Module YAML meta-data (added by MakeMaker)
META.json Module JSON meta-data (added by MakeMaker)
Package-New-0.10/README.md 0000644 0001750 0001750 00000005740 14736614764 014353 0 ustar mdavis mdavis # NAME
Package::New - Simple base package from which to inherit
# SYNOPSIS
package My::Package;
use base qw{Package::New}; #provides new and initialize
# DESCRIPTION
The Package::New object provides a consistent constructor for objects.
I find that I always need these two methods in every package that I build. I plan to use this package as the base for all of my CPAN packages.
# RECOMMENDATIONS
## Sane defaults
I recommend that you have sane default for all of your object properties. I recommend using code like this.
sub myproperty {
my $self=shift;
$self->{"myproperty"}=shift if @_;
$self->{"myproperty"}="Default Value" unless defined $self->{"myproperty"};
return $self->{"myproperty"};
}
## use strict and warnings
I recommend to always use strict, warnings and our version.
package My::Package;
use base qw{Package::New};
use strict;
use warnings;
our $VERSION='0.01';
## Lazy Load where you can
I recommend Lazy Loading where you can.
sub mymethod {
my $self=shift;
$self->load unless $self->loaded;
return $self->{"mymethod"};
}
# USAGE
# CONSTRUCTOR
## new
my $obj = Package::New->new(key=>$value, ...);
## initialize
You can override this method in your package if you need to do something after construction. But, lazy loading may be a better option.
# BUGS
Log on RT and contact the author.
# SUPPORT
DavisNetworks.com provides support services for all Perl applications including this package.
# AUTHOR
Michael R. Davis
CPAN ID: MRDVT
DavisNetworks.com
http://www.DavisNetworks.com/
# COPYRIGHT
This program is free software licensed under the...
The BSD License
The full text of the license can be found in the LICENSE file included with this module.
# SEE ALSO
## Building Blocks
[base](https://metacpan.org/pod/base), [parent](https://metacpan.org/pod/parent)
## Other Light Weight Base Objects Similar to Package::New
[Package::Base](https://metacpan.org/pod/Package::Base), [Class::Base](https://metacpan.org/pod/Class::Base), [Class::Easy](https://metacpan.org/pod/Class::Easy), [Object::Tiny](https://metacpan.org/pod/Object::Tiny), [Badger::Base](https://metacpan.org/pod/Badger::Base)
## Heavy Base Objects - Drink the Kool-Aid
[VSO](https://metacpan.org/pod/VSO), [Class::Accessor::Fast](https://metacpan.org/pod/Class::Accessor::Fast), [Class::Accessor](https://metacpan.org/pod/Class::Accessor), [Moose](https://metacpan.org/pod/Moose), (as well as Moose-alikes [Moo](https://metacpan.org/pod/Moo), [Mouse](https://metacpan.org/pod/Mouse)), [Class::MethodMaker](https://metacpan.org/pod/Class::MethodMaker), [Class::Meta](https://metacpan.org/pod/Class::Meta)
## Even more
[Spiffy](https://metacpan.org/pod/Spiffy), [mixin](https://metacpan.org/pod/mixin), [SUPER](https://metacpan.org/pod/SUPER), [Class::Trait](https://metacpan.org/pod/Class::Trait), [Class::C3](https://metacpan.org/pod/Class::C3), [Moose::Role](https://metacpan.org/pod/Moose::Role)
Package-New-0.10/LICENSE 0000644 0001750 0001750 00000003011 14736614645 014064 0 ustar mdavis mdavis The BSD License
Copyright (c) 2011, Michael R. Davis
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.
Neither the name of the Satellite Tracking of People, LLC nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
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 REGENTS 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.
Package-New-0.10/Makefile.PL 0000644 0001750 0001750 00000001476 14736615654 015047 0 ustar mdavis mdavis use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'Package::New',
VERSION_FROM => 'lib/Package/New.pm',
AUTHOR => 'Michael R. Davis',
LICENSE => 'bsd',
ABSTRACT_FROM => 'lib/Package/New.pm',
PREREQ_PM => {
'Test::Simple' => 0.44,
'Devel::Hide' => 0,
},
'META_MERGE' => {
'resources' => {
'repository' => {
'web' => 'https://github.com/mrdvt92/perl-Package-New.git',
'url' => 'git@github.com:mrdvt92/perl-Package-New.git',
'type' => 'git'
},
'homepage' => 'https://github.com/mrdvt92/perl-Package-New',
'bugtracker' => {
'web' => 'https://github.com/mrdvt92/perl-Package-New/issues'
}
},
'meta-spec' => {
'version' => 2
}
},
);
Package-New-0.10/META.yml 0000664 0001750 0001750 00000001307 14736621625 014334 0 ustar mdavis mdavis ---
abstract: 'Simple base package from which to inherit'
author:
- 'Michael R. Davis'
build_requires:
ExtUtils::MakeMaker: '0'
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.52, 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: Package-New
no_index:
directory:
- t
- inc
requires:
Devel::Hide: '0'
Test::Simple: '0.44'
resources:
bugtracker: https://github.com/mrdvt92/perl-Package-New/issues
homepage: https://github.com/mrdvt92/perl-Package-New
repository: https://github.com/mrdvt92/perl-Package-New.git
version: '0.10'
Package-New-0.10/META.json 0000664 0001750 0001750 00000002307 14736621625 014505 0 ustar mdavis mdavis {
"abstract" : "Simple base package from which to inherit",
"author" : [
"Michael R. Davis"
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 7.52, CPAN::Meta::Converter version 2.150001",
"license" : [
"bsd"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : "2"
},
"name" : "Package-New",
"no_index" : {
"directory" : [
"t",
"inc"
]
},
"prereqs" : {
"build" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"runtime" : {
"requires" : {
"Devel::Hide" : "0",
"Test::Simple" : "0.44"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/mrdvt92/perl-Package-New/issues"
},
"homepage" : "https://github.com/mrdvt92/perl-Package-New",
"repository" : {
"type" : "git",
"web" : "https://github.com/mrdvt92/perl-Package-New.git"
}
},
"version" : "0.10"
}