commit 0d83bd386f96e82a136afc952373af0f761d5c77
Author: intrigeri <intrigeri@boum.org>
Date: Tue Dec 24 11:56:47 2013 +0000
Convert to Moo.
... using MooX::late to ease the transition.
Notes:
* __PACKAGE__->meta->make_immutable is now useless: Moo does it automatically
the first time ->new is called on a class.
* auto_deref is not supported by Moo, so we explicitly dereference things in the
few places where they were automatically dereferenced before.
* Instead of __PACKAGE__->meta->add_method (that would trigger the load of
Moose, and require a dependency on it), use MooX::HandlesVia NativeTrait-like
behaviour to generate push_$list methods.
* The test suite still passes successfully.
diff --git a/META.yml b/META.yml
index 1beaef2..fc4ebb6 100644
--- a/META.yml
+++ b/META.yml
@@ -20,7 +20,9 @@ no_index:
- t
- test
requires:
- Any::Moose: 0.04
+ Moo: 0.091011
+ MooX::HandlesVia: 0.001004
+ MooX::late: 0.014
Math::BigInt: 1.78
resources:
license:
http://dev.perl.org/licenses/
diff --git a/Makefile.PL b/Makefile.PL
index 8156e7f..1be9418 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -16,7 +16,9 @@ author 'Frank J. Tobin';
abstract 'supply object methods for interacting with GnuPG';
name 'GnuPG-Interface';
version_from 'lib/GnuPG/Interface.pm';
-requires 'Any::Moose' => '0.04';
+requires 'Moo' => '0.091011';
+requires 'MooX::HandlesVia' => '0.001004';
+requires 'MooX::late' => '0.014';
requires 'Math::BigInt' => '1.78';
license 'perl';
diff --git a/lib/GnuPG/Fingerprint.pm b/lib/GnuPG/Fingerprint.pm
index 871e02a..fcb1028 100644
--- a/lib/GnuPG/Fingerprint.pm
+++ b/lib/GnuPG/Fingerprint.pm
@@ -14,7 +14,8 @@
#
package GnuPG::Fingerprint;
-use Any::Moose;
+use Moo;
+use MooX::late;
with qw(GnuPG::HashInit);
has as_hex_string => (
@@ -36,8 +37,6 @@ sub hex_data
return $self->as_hex_string();
}
-__PACKAGE__->meta->make_immutable;
-
1;
__END__
diff --git a/lib/GnuPG/Handles.pm b/lib/GnuPG/Handles.pm
index fabf31c..b30ca57 100644
--- a/lib/GnuPG/Handles.pm
+++ b/lib/GnuPG/Handles.pm
@@ -14,7 +14,8 @@
#
package GnuPG::Handles;
-use Any::Moose;
+use Moo;
+use MooX::late;
with qw(GnuPG::HashInit);
use constant HANDLES => qw(
@@ -57,8 +58,6 @@ sub BUILD {
$self->hash_init(%$args);
}
-__PACKAGE__->meta->make_immutable;
-
1;
=head1 NAME
diff --git a/lib/GnuPG/HashInit.pm b/lib/GnuPG/HashInit.pm
index 9daa6a9..a278b09 100644
--- a/lib/GnuPG/HashInit.pm
+++ b/lib/GnuPG/HashInit.pm
@@ -1,5 +1,5 @@
package GnuPG::HashInit;
-use Any::Moose 'Role';
+use Moo::Role;
sub hash_init {
my ($self, %args) = @_;
diff --git a/lib/GnuPG/Interface.pm b/lib/GnuPG/Interface.pm
index 5d80eeb..93cb051 100644
--- a/lib/GnuPG/Interface.pm
+++ b/lib/GnuPG/Interface.pm
@@ -12,7 +12,8 @@
#
package GnuPG::Interface;
-use Any::Moose;
+use Moo;
+use MooX::late;
with qw(GnuPG::HashInit);
use English qw( -no_match_vars );
@@ -867,7 +868,7 @@ decryption, verification, and key-listing parsing.
=head2 How Data Member Accessor Methods are Created
Each module in the GnuPG::Interface bundle relies
-on Any::Moose to generate the get/set methods
+on Moo to generate the get/set methods
used to set the object's data members.
I<This is very important to realize.> This means that
any data member which is a list has special
@@ -1351,8 +1352,5 @@ Frank J. Tobin, ftobin@cpan.org was the original author of the package.
=cut
-
-__PACKAGE__->meta->make_immutable;
-
1;
diff --git a/lib/GnuPG/Key.pm b/lib/GnuPG/Key.pm
index fbdda52..ea14a6a 100644
--- a/lib/GnuPG/Key.pm
+++ b/lib/GnuPG/Key.pm
@@ -14,7 +14,8 @@
#
package GnuPG::Key;
-use Any::Moose;
+use Moo;
+use MooX::late;
with qw(GnuPG::HashInit);
has [
@@ -124,8 +125,6 @@ sub compare {
return 1;
}
-__PACKAGE__->meta->make_immutable;
-
1;
__END__
diff --git a/lib/GnuPG/Options.pm b/lib/GnuPG/Options.pm
index bbfd67a..c81f60e 100644
--- a/lib/GnuPG/Options.pm
+++ b/lib/GnuPG/Options.pm
@@ -14,7 +14,9 @@
#
package GnuPG::Options;
-use Any::Moose;
+use Moo;
+use MooX::late;
+use MooX::HandlesVia;
with qw(GnuPG::HashInit);
use constant BOOLEANS => qw(
@@ -71,17 +73,15 @@ has $_ => (
for my $list (LISTS) {
has $list => (
- isa => 'ArrayRef',
- is => 'rw',
- lazy => 1,
- clearer => "clear_$list",
- default => sub { [] },
- auto_deref => 1,
+ handles_via => 'Array',
+ is => 'rw',
+ lazy => 1,
+ clearer => "clear_$list",
+ default => sub { [] },
+ handles => {
+ "push_$list" => 'push',
+ },
);
- __PACKAGE__->meta->add_method("push_$list" => sub {
- my $self = shift;
- push @{ $self->$list }, @_;
- });
}
sub BUILD {
@@ -110,7 +110,7 @@ sub get_args {
return (
$self->get_meta_args(),
$self->get_option_args(),
- $self->extra_args(),
+ @{$self->extra_args()},
);
}
@@ -147,8 +147,8 @@ sub get_option_args {
push @args, '--command-fd', $self->command_fd()
if defined $self->command_fd();
- push @args, map { ( '--recipient', $_ ) } $self->recipients();
- push @args, map { ( '--encrypt-to', $_ ) } $self->encrypt_to();
+ push @args, map { ( '--recipient', $_ ) } @{$self->recipients};
+ push @args, map { ( '--encrypt-to', $_ ) } @{$self->encrypt_to};
return @args;
}
@@ -172,15 +172,14 @@ sub get_meta_args {
if $self->meta_signing_key();
push @args,
- map { ( '--recipient', $_ ) } $self->meta_recipients_key_ids();
+ map { ( '--recipient', $_ ) } @{$self->meta_recipients_key_ids};
+ use Data::Dumper::Concise;
push @args,
- map { ( '--recipient', $_->hex_id() ) } $self->meta_recipients_keys();
+ map { ( '--recipient', $_->hex_id() ) } @{$self->meta_recipients_keys};
return @args;
}
-__PACKAGE__->meta->make_immutable;
-
1;
__END__
diff --git a/lib/GnuPG/PrimaryKey.pm b/lib/GnuPG/PrimaryKey.pm
index d36d0b9..d3c745e 100644
--- a/lib/GnuPG/PrimaryKey.pm
+++ b/lib/GnuPG/PrimaryKey.pm
@@ -14,22 +14,21 @@
#
package GnuPG::PrimaryKey;
-use Any::Moose;
+use Moo;
+use MooX::late;
+use MooX::HandlesVia;
BEGIN { extends qw( GnuPG::Key ) }
for my $list (qw(user_ids subkeys user_attributes)) {
has $list => (
- isa => 'ArrayRef',
- is => 'rw',
- default => sub { [] },
- auto_deref => 1,
+ handles_via => 'Array',
+ is => 'rw',
+ default => sub { [] },
+ handles => {
+ "push_$list" => 'push',
+ },
);
-
- __PACKAGE__->meta->add_method("push_$list" => sub {
- my $self = shift;
- push @{ $self->$list }, @_;
- });
}
has $_ => (
@@ -71,9 +70,6 @@ sub compare {
return $self->SUPER::compare($other, $deep);
}
-
-__PACKAGE__->meta->make_immutable;
-
1;
__END__
diff --git a/lib/GnuPG/PublicKey.pm b/lib/GnuPG/PublicKey.pm
index 69609b3..62a7963 100644
--- a/lib/GnuPG/PublicKey.pm
+++ b/lib/GnuPG/PublicKey.pm
@@ -14,12 +14,10 @@
#
package GnuPG::PublicKey;
-use Any::Moose;
+use Moo;
BEGIN { extends qw( GnuPG::PrimaryKey ) }
-__PACKAGE__->meta->make_immutable;
-
1;
__END__
diff --git a/lib/GnuPG/Revoker.pm b/lib/GnuPG/Revoker.pm
index 151a2f5..0bd79dd 100644
--- a/lib/GnuPG/Revoker.pm
+++ b/lib/GnuPG/Revoker.pm
@@ -15,7 +15,8 @@
#
package GnuPG::Revoker;
-use Any::Moose;
+use Moo;
+use MooX::late;
has [qw(
algo_num
@@ -70,8 +71,6 @@ sub compare {
return 1;
}
-__PACKAGE__->meta->make_immutable;
-
1;
__END__
diff --git a/lib/GnuPG/SecretKey.pm b/lib/GnuPG/SecretKey.pm
index 18cc161..eead427 100644
--- a/lib/GnuPG/SecretKey.pm
+++ b/lib/GnuPG/SecretKey.pm
@@ -14,12 +14,10 @@
#
package GnuPG::SecretKey;
-use Any::Moose;
+use Moo;
BEGIN { extends qw( GnuPG::PrimaryKey ) }
-__PACKAGE__->meta->make_immutable;
-
1;
__END__
diff --git a/lib/GnuPG/Signature.pm b/lib/GnuPG/Signature.pm
index c2ba189..5020bb7 100644
--- a/lib/GnuPG/Signature.pm
+++ b/lib/GnuPG/Signature.pm
@@ -14,7 +14,8 @@
#
package GnuPG::Signature;
-use Any::Moose;
+use Moo;
+use MooX::late;
has [qw(
validity
@@ -62,8 +63,6 @@ sub compare {
return 1;
}
-__PACKAGE__->meta->make_immutable;
-
1;
__END__
diff --git a/lib/GnuPG/SubKey.pm b/lib/GnuPG/SubKey.pm
index 1e5f606..f5d7872 100644
--- a/lib/GnuPG/SubKey.pm
+++ b/lib/GnuPG/SubKey.pm
@@ -14,8 +14,9 @@
#
package GnuPG::SubKey;
-use Any::Moose;
use Carp;
+use Moo;
+use MooX::late;
BEGIN { extends qw( GnuPG::Key ) }
has [qw( validity owner_trust local_id )] => (
@@ -43,8 +44,6 @@ sub signature {
}
}
-__PACKAGE__->meta->make_immutable;
-
1;
__END__
diff --git a/lib/GnuPG/UserAttribute.pm b/lib/GnuPG/UserAttribute.pm
index 22ffbd1..ddc7ead 100644
--- a/lib/GnuPG/UserAttribute.pm
+++ b/lib/GnuPG/UserAttribute.pm
@@ -15,7 +15,8 @@
#
package GnuPG::UserAttribute;
-use Any::Moose;
+use Moo;
+use MooX::late;
has [qw( validity subpacket_count subpacket_total_size )] => (
isa => 'Any',
@@ -42,8 +43,6 @@ sub push_revocations {
push @{ $self->revocations }, @_;
}
-__PACKAGE__->meta->make_immutable;
-
1;
__END__
diff --git a/lib/GnuPG/UserId.pm b/lib/GnuPG/UserId.pm
index eef2da1..8c4124f 100644
--- a/lib/GnuPG/UserId.pm
+++ b/lib/GnuPG/UserId.pm
@@ -14,7 +14,8 @@
#
package GnuPG::UserId;
-use Any::Moose;
+use Moo;
+use MooX::late;
has [qw( validity as_string )] => (
isa => 'Any',
@@ -77,8 +78,6 @@ sub user_id_string {
return $self->as_string();
}
-__PACKAGE__->meta->make_immutable;
-
1;
__END__