Package-New-0.07/ 0000755 0001750 0001750 00000000000 11666331357 013065 5 ustar mdavis mdavis Package-New-0.07/Changes 0000644 0001750 0001750 00000001035 11666323746 014362 0 ustar mdavis mdavis Revision history for Perl module Package::New
0.07 2011-12-01
- Cleaned up for Fedora 16
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.07/LICENSE 0000644 0001750 0001750 00000003011 11656405451 014061 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.07/Makefile.PL 0000644 0001750 0001750 00000000472 11656405451 015036 0 ustar mdavis mdavis use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'Package::New',
VERSION_FROM => 'lib/Package/New.pm',
AUTHOR => 'Michael R. Davis (mdavis@stopllc.com)',
ABSTRACT_FROM=> 'lib/Package/New.pm',
PREREQ_PM => {
'Test::Simple' => 0.44,
},
);
Package-New-0.07/MANIFEST 0000644 0001750 0001750 00000000350 11666331357 014214 0 ustar mdavis mdavis MANIFEST
README
LICENSE
Todo
Changes
Makefile.PL
lib/Package/New.pm
lib/Package/New/Dump.pm
t/001_load.t
t/002_base.t
t/003_dump.t
perl-Package-New.spec
META.yml Module meta-data (added by MakeMaker)
Package-New-0.07/t/ 0000755 0001750 0001750 00000000000 11666331357 013330 5 ustar mdavis mdavis Package-New-0.07/t/002_base.t 0000644 0001750 0001750 00000000667 11666327652 015024 0 ustar mdavis mdavis # -*- perl -*-
use strict;
use warnings;
use Test::More tests => 6;
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");
package #Hide from CPAN
My::Package;
use base qw{Package::New};
sub x {shift->{"x"}};
sub y {shift->{"y"}};
1;
Package-New-0.07/t/001_load.t 0000644 0001750 0001750 00000001070 11666327663 015017 0 ustar mdavis mdavis # -*- perl -*-
use strict;
use warnings;
use Test::More tests => 11;
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');
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');
can_ok($obj2, qw{new initialize dump});
is($obj2->{"x"}, "2", "args work");
is($obj2->{"y"}, "b", "args work");
Package-New-0.07/t/003_dump.t 0000644 0001750 0001750 00000001766 11666330610 015045 0 ustar mdavis mdavis # -*- perl -*-
use strict;
use warnings;
use Test::More tests => 12;
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");
if ($ENV{"DEVELOPER"}) {
diag("Dump Level 1");
diag($object->dump(1));
diag("Dump Level default");
diag($object->dump);
diag("Dump Level 2");
diag($object->dump(2));
diag("Dump Level 3");
diag($object->dump(3));
diag("Dump Level 4");
diag($object->dump(4));
diag("Dump Level 0");
diag($object->dump(0));
}
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.07/META.yml 0000664 0001750 0001750 00000001074 11666331357 014342 0 ustar mdavis mdavis --- #YAML:1.0
name: Package-New
version: 0.07
abstract: Simple base package from which to inherit
author:
- Michael R. Davis (mdavis@stopllc.com)
license: unknown
distribution_type: module
configure_requires:
ExtUtils::MakeMaker: 0
build_requires:
ExtUtils::MakeMaker: 0
requires:
Test::Simple: 0.44
no_index:
directory:
- t
- inc
generated_by: ExtUtils::MakeMaker version 6.57_05
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
Package-New-0.07/lib/ 0000755 0001750 0001750 00000000000 11666331357 013633 5 ustar mdavis mdavis Package-New-0.07/lib/Package/ 0000755 0001750 0001750 00000000000 11666331357 015166 5 ustar mdavis mdavis Package-New-0.07/lib/Package/New.pm 0000644 0001750 0001750 00000005051 11666331133 016246 0 ustar mdavis mdavis package Package::New;
use strict;
use warnings;
our $VERSION='0.07';
=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) || $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
=head2 Heavy Base Objects - Drink the Kool-Aid
L, (as well as Moose-alikes L, L), L, L, L, L
=head2 Even more
L, L, L, L, L, L
=cut
1;
Package-New-0.07/lib/Package/New/ 0000755 0001750 0001750 00000000000 11666331357 015717 5 ustar mdavis mdavis Package-New-0.07/lib/Package/New/Dump.pm 0000644 0001750 0001750 00000002611 11656405451 017156 0 ustar mdavis mdavis package Package::New::Dump;
use base qw{Package::New};
use strict;
use warnings;
our $VERSION='0.06';
=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();
eval 'use Data::Dumper qw{}';
if ($@) {
return wantarray ? () : '';
} else {
my $depth=shift; $depth=2 unless defined $depth;
my $d=Data::Dumper->new([$self]);
$d->Maxdepth($depth);
return $d->Dump;
}
}
=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
=cut
1;
Package-New-0.07/Todo 0000644 0001750 0001750 00000000070 11656405451 013706 0 ustar mdavis mdavis TODO list for Perl module Package::New
- Nothing yet
Package-New-0.07/perl-Package-New.spec 0000644 0001750 0001750 00000003367 11666324047 016772 0 ustar mdavis mdavis Name: perl-Package-New
Version: 0.07
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://www.cpan.org/modules/by-module/Package/Package-New-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
BuildRequires: perl(ExtUtils::MakeMaker)
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 Todo
%{perl_vendorlib}/*
%{_mandir}/man3/*
%changelog
*Thu Dec 02 2011 Michael R. Davis (mdavis@stopllc.com) 0.07-1
-Updated for version 0.07
*Wed Feb 23 2011 Michael R. Davis (mdavis@stopllc.com) 0.05-1
-Updated for version 0.05
*Wed Feb 23 2011 Michael R. Davis (mdavis@stopllc.com) 0.04-1
-Updated for version 0.04
*Sat Feb 05 2011 Michael R. Davis (mdavis@stopllc.com) 0.03-1
-Updated for version 0.03
*Fri Feb 04 2011 Michael R. Davis (mdavis@stopllc.com) 0.02-1
-Updated for version 0.02
*Fri Feb 04 2011 Michael R. Davis (mdavis@stopllc.com) 0.01-1
-Specfile autogenerated by cpanspec 1.78.
Package-New-0.07/README 0000644 0001750 0001750 00000000276 11656405451 013746 0 ustar mdavis mdavis to install the module...
rpmbuild -ta tarball.tar.gz
rpm -Uhv file.rpm
perl Makefile.PL
make
make test
make install
If you are on a windows box you should use 'nmake' rather than 'make'.