diff --git a/Changes b/Changes index 04e049d..9b431fe 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,4 @@ + - Remove reliance on MooseX::Aliases (issue #35) - Use Class::Load to replace deprecated Class::Mop method (issue #35) - Add missing dependency: LWP::Protocol::https (issue #25) - Fix OAuth failure for UTF8 params (issue #21) diff --git a/lib/Net/Twitter/Core.pm b/lib/Net/Twitter/Core.pm index 645822a..1b8e8cd 100644 --- a/lib/Net/Twitter/Core.pm +++ b/lib/Net/Twitter/Core.pm @@ -6,7 +6,6 @@ our $VERSION = '4.00007'; use 5.008001; use Moose; -use MooseX::Aliases; use Carp::Clan qw/^Net::Twitter/; use JSON; use URI::Escape; @@ -24,10 +23,8 @@ use namespace::autoclean; has useragent_class => ( isa => 'Str', is => 'ro', default => 'LWP::UserAgent' ); has useragent_args => ( isa => 'HashRef', is => 'ro', default => sub { {} } ); -has username => ( isa => 'Str', is => 'rw', predicate => 'has_username', - alias => 'user' ); -has password => ( isa => 'Str', is => 'rw', predicate => 'has_password', - alias => 'pass' ); +has username => ( isa => 'Str', is => 'rw', predicate => 'has_username' ); +has password => ( isa => 'Str', is => 'rw', predicate => 'has_password' ); has ssl => ( isa => 'Bool', is => 'ro', default => 0 ); has netrc => ( isa => 'Str', is => 'ro', predicate => 'has_netrc' ); has netrc_machine => ( isa => 'Str', is => 'ro', default => 'api.twitter.com' ); @@ -65,6 +62,19 @@ around BUILDARGS => sub { my %options = @_ == 1 ? %{$_[0]} : @_; + # aliases + for ( [ user => 'username' ], [ pass => 'password' ] ) { + my ( $alias, $base ) = @$_; + if ( exists $options{$alias} ) { + if ( !defined $options{$base} ) { + $options{$base} = delete $options{$alias}; + } + else { + cluck "Both $base and $alias provided. Ignoring $alias"; + } + } + } + if ( delete $options{identica} ) { %options = ( apiurl => 'http://identi.ca/api', diff --git a/t/aliases.t b/t/aliases.t new file mode 100644 index 0000000..98dc5f3 --- /dev/null +++ b/t/aliases.t @@ -0,0 +1,15 @@ +#!perl +use warnings; +use strict; +use Net::Twitter; +use Test::More; + +my $nt = Net::Twitter->new( + user => 'foo', + pass => 'bar', +); + +is $nt->username, 'foo'; +is $nt->password, 'bar'; + +done_testing;