App-SD
view release on metacpan or search on metacpan
lib/App/SD/Replica/gcode.pm view on Meta::CPAN
package App::SD::Replica::gcode;
use Any::Moose;
extends qw/App::SD::ForeignReplica/;
use Params::Validate qw(:all);
use File::Temp 'tempdir';
use Memoize;
use Try::Tiny;
use constant scheme => 'gcode';
use constant pull_encoder => 'App::SD::Replica::gcode::PullEncoder';
use constant push_encoder => 'App::SD::Replica::gcode::PushEncoder';
use Prophet::ChangeSet;
our %PROP_MAP = (
summary => 'summary',
status => 'status',
owner => 'owner',
reporter => 'reporter',
cc => 'cc',
closed => 'completed',
reported => 'created',
labels => 'tags',
priority => 'priority',
mergedinto => 'merged_into',
blockedon => 'blocked_on',
);
has query => ( isa => 'Str', is => 'rw');
has gcode => ( isa => 'Net::Google::Code', is => 'rw');
has project => ( isa => 'Str', is => 'rw');
has foreign_username => ( isa => 'Str', is => 'rw' );
sub remote_url { return "http://code.google.com/p/".shift->project}
sub BUILD {
my $self = shift;
# Require rather than use to defer load
try {
require Net::Google::Code;
require Net::Google::Code::Issue;
} catch {
die "SD requires Net::Google::Code to sync with Google Code.\n".
"'cpan Net::Google::Code' may sort this out for you.\n";
};
$Net::Google::Code::Issue::USE_HYBRID = 1
if $Net::Google::Code::VERSION ge '0.15';
my ( $userinfo, $project, $query ) =
$self->{url} =~ m!^gcode:(?:(.*)@)?(.*?)(?:/(.*))?$!
or die
"Can't parse Google::Code server spec. Expected gcode:k9mail or gcode:user:password\@k9mail or gcode:user:password\@k9mail/q=string&can=all";
$self->project($project);
$self->url($project); # url should be raw url minus scheme and auth info
$self->query($query) if defined $query;
# Since we don't need a username / password to clone or pull, we don't save
# the username and password here, if specified-- we only want to save
# username/password combinations after they've been verified to work. (So
# we save later if we end up trying to auth.) We do still want to parse any
# username/password specified in the url.
my ( $email, $password );
if ( $userinfo ) {
( $email, $password ) = split /:/, $userinfo, 2;
( run in 1.061 second using v1.01-cache-2.11-cpan-39bf76dae61 )