Skip to content

Commit

Permalink
use 'https' for user->update, issue->comment etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
fayland committed May 19, 2009
1 parent 03de6eb commit 419bb28
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 10 deletions.
3 changes: 3 additions & 0 deletions Changes
@@ -1,5 +1,8 @@
Revision history for Net-GitHub

0.17 2009.05.19
use 'https' for user->update, issue->comment etc.

0.16 2009.05.19
fix the role (Chris Nehren)

Expand Down
2 changes: 1 addition & 1 deletion lib/Net/GitHub.pm
Expand Up @@ -2,7 +2,7 @@ package Net::GitHub;

use Moose;

our $VERSION = '0.16';
our $VERSION = '0.17';
our $AUTHORITY = 'cpan:FAYLAND';

sub new {
Expand Down
11 changes: 7 additions & 4 deletions lib/Net/GitHub/V2/Issues.pm
Expand Up @@ -2,7 +2,7 @@ package Net::GitHub::V2::Issues;

use Moose;

our $VERSION = '0.10';
our $VERSION = '0.17';
our $AUTHORITY = 'cpan:FAYLAND';

with 'Net::GitHub::V2::HasRepo';
Expand Down Expand Up @@ -85,15 +85,17 @@ sub add_label {
my $owner = $self->owner;
my $repo = $self->repo;

return $self->get_json_to_obj_authed( "issues/label/add/$owner/$repo/$label/$id", 'labels' );
my $url = $self->api_url_https . "issues/label/add/$owner/$repo/$label/$id";
return $self->get_json_to_obj_authed( $url, 'labels' );
}
sub remove_label {
my ( $self, $id, $label ) = @_;

my $owner = $self->owner;
my $repo = $self->repo;

return $self->get_json_to_obj_authed( "issues/label/remove/$owner/$repo/$label/$id", 'labels' );
my $url = $self->api_url_https . "issues/label/remove/$owner/$repo/$label/$id";
return $self->get_json_to_obj_authed( $url, 'labels' );
}

sub comment {
Expand All @@ -102,7 +104,8 @@ sub comment {
my $owner = $self->owner;
my $repo = $self->repo;

return $self->get_json_to_obj_authed( "issues/comment/$owner/$repo/$id",
my $url = $self->api_url_https . "issues/comment/$owner/$repo/$id"
return $self->get_json_to_obj_authed( $url,
comment => $text,
'comment'
);
Expand Down
8 changes: 5 additions & 3 deletions lib/Net/GitHub/V2/NoRepo.pm
Expand Up @@ -2,7 +2,7 @@ package Net::GitHub::V2::NoRepo;

use Moose::Role;

our $VERSION = '0.13';
our $VERSION = '0.17';
our $AUTHORITY = 'cpan:FAYLAND';

use JSON::Any;
Expand All @@ -18,6 +18,7 @@ has 'token' => ( is => 'ro', isa => 'Str', default => '' );

# api
has 'api_url' => ( is => 'ro', default => 'http://github.com/api/v2/json/');
has 'api_url_https' => ( is => 'ro', default => 'https://github.com/api/v2/json/');

has 'ua' => (
isa => 'WWW::Mechanize',
Expand Down Expand Up @@ -74,8 +75,9 @@ sub get_json_to_obj_authed {
croak 'login and token are required' unless ( $self->login and $self->token );

$pending_url =~ s!^/!!; # Strip leading '/'
my $url = $self->api_url . $pending_url;

my $url = ( $pending_url =~ /^https?\:/ ) ? $pending_url :
$self->api_url . $pending_url;

my $key; # return $key from json obj
if ( scalar @_ % 2 ) {
$key = pop @_;
Expand Down
5 changes: 3 additions & 2 deletions lib/Net/GitHub/V2/Users.pm
Expand Up @@ -2,7 +2,7 @@ package Net::GitHub::V2::Users;

use Moose;

our $VERSION = '0.15';
our $VERSION = '0.17';
our $AUTHORITY = 'cpan:FAYLAND';

use URI::Escape;
Expand Down Expand Up @@ -34,7 +34,8 @@ sub update {
push @values, ( "values[$key]", $up{$key} );
}

return $self->get_json_to_obj_authed( "user/show/$user", @values, 'user' );
my $url = $self->api_url_https . "user/show/$user";
return $self->get_json_to_obj_authed( $url, @values, 'user' );
}

sub followers {
Expand Down
13 changes: 13 additions & 0 deletions t/02-load-v2.t
@@ -0,0 +1,13 @@
#!perl -T

use Test::More tests => 7;

use_ok( 'Net::GitHub::V2' );
use_ok( 'Net::GitHub::V2::Repositories' );
use_ok( 'Net::GitHub::V2::Users' );
use_ok( 'Net::GitHub::V2::Commits' );
use_ok( 'Net::GitHub::V2::Issues' );
use_ok( 'Net::GitHub::V2::Object' );
use_ok( 'Net::GitHub::V2::Network' );

1;

0 comments on commit 419bb28

Please sign in to comment.