Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Tomcat42
perl-Hash-AutoHash-Args
perl-Hash-AutoHash-Args.spec
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File perl-Hash-AutoHash-Args.spec of Package perl-Hash-AutoHash-Args
# # spec file for package perl-Hash-AutoHash-Args # # Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ # Name: perl-Hash-AutoHash-Args Version: 1.18 Release: 0 %define cpan_name Hash-AutoHash-Args Summary: Object-oriented processing of keyword-based argument lists License: Artistic-1.0 or GPL-1.0+ Group: Development/Libraries/Perl Url: http://search.cpan.org/dist/Hash-AutoHash-Args/ Source0: http://www.cpan.org/authors/id/N/NA/NATG/%{cpan_name}-%{version}.tar.gz Source1: cpanspec.yml BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl BuildRequires: perl-macros BuildRequires: perl(Carp) >= 1.2 BuildRequires: perl(Cwd) >= 3.4 BuildRequires: perl(Exporter) >= 5.68 BuildRequires: perl(File::Basename) >= 2.82 BuildRequires: perl(File::Spec) >= 3.4 BuildRequires: perl(Hash::AutoHash) >= 1.17 BuildRequires: perl(List::MoreUtils) >= 0.33 BuildRequires: perl(List::Util) >= 1.32 BuildRequires: perl(Module::Build) >= 0.400700 BuildRequires: perl(Test::Deep) >= 0.11 BuildRequires: perl(Test::More) >= 0.98 BuildRequires: perl(Test::Pod) >= 1.48 BuildRequires: perl(Test::Pod::Content) >= 0.0.6 BuildRequires: perl(Tie::Hash) >= 1.04 BuildRequires: perl(Tie::ToObject) >= 0.03 BuildRequires: perl(XSLoader) >= 0.16 Requires: perl(Carp) >= 1.2 Requires: perl(Cwd) >= 3.4 Requires: perl(Exporter) >= 5.68 Requires: perl(Hash::AutoHash) >= 1.17 Requires: perl(List::MoreUtils) >= 0.33 Requires: perl(List::Util) >= 1.32 Requires: perl(Tie::Hash) >= 1.04 Requires: perl(Tie::ToObject) >= 0.03 Requires: perl(XSLoader) >= 0.16 %{perl_requires} %description This class simplifies the handling of keyword argument lists. It replaces the Class::AutoClass::Args manpage. See the DIFFERENCES FROM Class::AutoClass::Args manpage for a discussion of what's new. See the Hash::AutoHash::Args::V0 manpage for a subclass which is more compatible with the original. The 'new' method accepts a list, ARRAY, or HASH of keyword=>value pairs, another Hash::AutoHash::Args object, or any object that can be coerced into a HASH . It normalizes the keywords to ignore case and leading dashes ('-'). The following keywords are all equivalent: name, -name, -NAME, --NAME, Name, -Name Arguments can be accessed using HASH or method notation; the following are equivalent (assuming the keyword 'name' exists in $args). my $name=$args->{name}; my $name=$args->name; Arguments values can also be changed using either notation: $args->{name}='Jonathan'; $args->name('Jonathan'); Keywords are normalized automatically; the following are all equivalent. my $name=$args->{name}; # lower case HASH key my $name=$args->{Name}; # capitalized HASH key my $name=$args->{NAME}; # upper case HASH key my $name=$args->{NaMe}; # mixed case HASH key my $name=$args->{-name}; # leading - in HASH key The following are also all equivalent, and are equivalent to the ones above assuming the keyword 'name' exists in $args. my $name=$args->name; # lower case method my $name=$args->Name; # capitalized method my $name=$args->NAME; # upper case method my $name=$args->NaMe; # mixed case method One caution is that when using method notation, keywords must be syntactically legal method names and cannot include leading dashes. The following is NOT legal. my $name=$args->-name; # leading dash in method - ILLEGAL Repeated keyword arguments are converted into an ARRAY of the values. new Hash::AutoHash::Args(hobbies=>'hiking', hobbies=>'cooking') is equivalent to new Hash::AutoHash::Args(hobbies=>['hiking', 'cooking']) Caution: when setting values using HASH or method notation, the grouping of repeated arguments does NOT occur. Thus, @$args{qw(hobbies hobbies)}=qw(running rowing); leaves 'hobbies' set to the last value presented, namely 'rowing', as does $args->hobbies('running'); $args->hobbies('rowing'); New keywords can be added using either notation. For example, $args->{first_name}='Joe'; $args->last_name('Plumber'); If a keyword does not exist, the method notation returns nothing, while the HASH notation returns undef. This difference matters in array context (including when passing the result as a parameter). my @list=$args->non_existent; # @list will contain 0 elements my @list=$args->{non_existent}; # @list will contain 1 element We find the method behavior (returning nothing) to be more natural and is the behavior in Class::AutoClass::Args. Unfortunately, Perl does not support this behavior with HASH notation; if the tied hash code returns nothing, Perl converts this into undef before passing the result to the caller. Too bad. You can alias the object to a regular hash for more concise hash notation. use Hash::AutoHash::Args qw(autoargs_alias); autoargs_alias($args,%args); my($name,$hobbies)=@args{qw(name hobbies)}; $args{name}='Joseph'; By aliasing $args to %args, you avoid the need to dereference the variable when using hash notation. Admittedly, this is a minor convenience, but then again, this entire class is about convenience. %prep %setup -q -n %{cpan_name}-%{version} %build %{__perl} Build.PL installdirs=vendor ./Build build flags=%{?_smp_mflags} %check ./Build test %install ./Build install destdir=%{buildroot} create_packlist=0 %perl_gen_filelist %files -f %{name}.files %defattr(-,root,root,755) %doc Changes README %changelog
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor