Skip to content

Commit

Permalink
Remove reliance on MooseX::Aliases (#35)
Browse files Browse the repository at this point in the history
MooseX::Aliases is not compatible with Moose > 2.110. Close #35.
  • Loading branch information
semifor committed Nov 19, 2013
1 parent cd9c747 commit dd8285c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
1 change: 1 addition & 0 deletions 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)
Expand Down
20 changes: 15 additions & 5 deletions lib/Net/Twitter/Core.pm
Expand Up @@ -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;
Expand All @@ -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' );
Expand Down Expand Up @@ -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',
Expand Down
15 changes: 15 additions & 0 deletions 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;

0 comments on commit dd8285c

Please sign in to comment.