commit a45f142b845aa5ec15a023254f7a48dbe37608f5 Author: Paul Howarth <paul@xxxxxxxxxxxx> Date: Sun Apr 24 22:10:41 2011 +0100 Initial import of perl-Devel-EnforceEncapsulation-0.50-3 Encapsulation is the practice of creating subroutines to access the properties of a class instead of accessing those properties directly. The advantage of good encapsulation is that the author is permitted to change the internal implementation of a class without breaking its usage. Object-oriented programming in Perl is most commonly implemented via blessed hashes. This practice makes it easy for users of a class to violate encapsulation by simply accessing the hash values directly. Although less common, the same applies to classes implemented via blessed arrays, scalars, filehandles, etc. This module is a hack to block those direct accesses. If you try to access a hash value of an object from its own class, or a superclass or subclass, all goes well. If you try to access a hash value from any other package, an exception is thrown. The same applies to the scalar value of a blessed scalar, entry in a blessed array, etc. To be clear: this class is NOT intended for strict enforcement of encapsulation. If you want bullet-proof encapsulation, use inside-out objects or the like. Instead, this module is intended to be a development or debugging aid in catching places where direct access is used against classes implemented as blessed hashes. To repeat: the encapsulation enforced here is a hack and is easily circumvented. Please use this module for good (finding bugs), not evil (making life harder for downstream developers). .gitignore | 1 + perl-Devel-EnforceEncapsulation.spec | 74 ++++++++++++++++++++++++++++++++++ sources | 1 + 3 files changed, 76 insertions(+), 0 deletions(-) --- diff --git a/.gitignore b/.gitignore index e69de29..28302f8 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/Devel-EnforceEncapsulation-0.50.tgz diff --git a/perl-Devel-EnforceEncapsulation.spec b/perl-Devel-EnforceEncapsulation.spec new file mode 100644 index 0000000..679735c --- /dev/null +++ b/perl-Devel-EnforceEncapsulation.spec @@ -0,0 +1,74 @@ +Name: perl-Devel-EnforceEncapsulation +Version: 0.50 +Release: 3%{?dist} +Summary: Find access violations to blessed objects +Group: Development/Libraries +License: GPL+ or Artistic +URL: http://search.cpan.org/dist/Devel-EnforceEncapsulation/ +Source0: http://search.cpan.org/CPAN/authors/id/C/CL/CLOTHO/Devel-EnforceEncapsulation-%{version}.tgz +BuildArch: noarch +BuildRequires: perl(ExtUtils::MakeMaker) +BuildRequires: perl(Test::More) +BuildRequires: perl(Test::Pod) +BuildRequires: perl(Test::Pod::Coverage) +Requires: perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version)) + +%description +Encapsulation is the practice of creating subroutines to access the properties +of a class instead of accessing those properties directly. The advantage of +good encapsulation is that the author is permitted to change the internal +implementation of a class without breaking its usage. + +Object-oriented programming in Perl is most commonly implemented via blessed +hashes. This practice makes it easy for users of a class to violate +encapsulation by simply accessing the hash values directly. Although less +common, the same applies to classes implemented via blessed arrays, scalars, +filehandles, etc. + +This module is a hack to block those direct accesses. If you try to access a +hash value of an object from its own class, or a superclass or subclass, all +goes well. If you try to access a hash value from any other package, an +exception is thrown. The same applies to the scalar value of a blessed scalar, +entry in a blessed array, etc. + +To be clear: this class is NOT intended for strict enforcement of +encapsulation. If you want bullet-proof encapsulation, use inside-out objects +or the like. Instead, this module is intended to be a development or debugging +aid in catching places where direct access is used against classes implemented +as blessed hashes. + +To repeat: the encapsulation enforced here is a hack and is easily +circumvented. Please use this module for good (finding bugs), not evil (making +life harder for downstream developers). + +%prep +%setup -q -n Devel-EnforceEncapsulation-%{version} + +%build +perl Makefile.PL INSTALLDIRS=vendor +make %{?_smp_mflags} + +%install +make pure_install DESTDIR=%{buildroot} +find %{buildroot} -type f -name .packlist -exec rm -f {} \; +find %{buildroot} -depth -type d -exec rmdir {} \; 2>/dev/null +%{_fixperms} %{buildroot} + +%check +make test AUTHOR_TEST=1 AUTHOR_TEST_CDOLAN=1 + +%files +%defattr(-,root,root,-) +%doc CHANGES LICENSE README index.html +%{perl_vendorlib}/Devel/ +%{_mandir}/man3/Devel::EnforceEncapsulation.3pm* + +%changelog +* Mon Apr 11 2011 Paul Howarth <paul@xxxxxxxxxxxx> - 0.50-3 +- Clean up for modern rpmbuild + +* Mon Apr 11 2011 Paul Howarth <paul@xxxxxxxxxxxx> - 0.50-2 +- Nobody else likes macros for commands + +* Fri Mar 18 2011 Paul Howarth <paul@xxxxxxxxxxxx> - 0.50-1 +- Initial RPM version diff --git a/sources b/sources index e69de29..345d376 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +434b5a9e99e1153282076680c9de29c5 Devel-EnforceEncapsulation-0.50.tgz -- Fedora Extras Perl SIG http://www.fedoraproject.org/wiki/Extras/SIGs/Perl perl-devel mailing list perl-devel@xxxxxxxxxxxxxxxxxxxxxxx https://admin.fedoraproject.org/mailman/listinfo/perl-devel