Changeset 55d0513 in lab.git for Dev/github


Ignore:
Timestamp:
Aug 19, 2013 10:21:00 AM (11 years ago)
Author:
Ken-ichi Mito <mitty@…>
Branches:
master
Children:
49aca65
Parents:
fc647d5
Message:

utils::get with %parameters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/github/GitHubBackup.pm

    rfc647d5 r55d0513  
    2424sub get { 
    2525    my $url = shift; 
     26    my %parameters = @_; 
     27     
     28    my $parameters = ''; 
     29    while (my($key, $value) = each %parameters) { 
     30        $parameters .= "&$key=$value"; 
     31    } 
    2632     
    2733    my $page = 1; 
    2834    my $data; 
    2935    while(1) { 
    30         my $result = json_api("$url?per_page=100&page=$page"); 
     36        my $result = json_api("$url?per_page=100&page=$page$parameters"); 
    3137        if (ref($result) eq 'ARRAY' && scalar @$result > 0) { 
    3238            push @$data, @$result; 
     
    198204} 
    199205 
    200 sub get_forks { 
     206sub forks { 
    201207    my $self = shift; 
    202208    return $self->{forks} if ($self->{forks}); 
     
    204210    $self->{forks} = utils::get("/repos/" . $self->{full_name} . "/forks"); 
    205211     
    206     return $self; 
     212    return $self->{forks}; 
    207213} 
    208214 
    209215sub set_forks { 
    210216    my $self = shift; 
    211      
    212     $self->get_forks; 
    213217     
    214218    my $dir = $self->directory . '.git'; 
     
    217221    my $remotes = Git::Repository->run(branch => '--remotes'); 
    218222    my @fetch; 
    219     foreach my $fork (@{$self->{forks}}) { 
     223    foreach my $fork (@{$self->forks}) { 
    220224        if ($remotes =~ /$fork->{full_name}/) { 
    221225            print "skip ", $fork->{full_name}, "\n"; 
     
    246250} 
    247251 
     252sub issues { 
     253    my $self = shift; 
     254    return $self->{issues} if ($self->{issues}); 
     255     
     256    my $open   = utils::get("/repos/" . $self->{full_name} . "/issues"); 
     257    my $closed = utils::get("/repos/" . $self->{full_name} . "/issues", state => 'closed'); 
     258     
     259    if ($open)   { push @{$self->{issues}}, @$open } 
     260    if ($closed) { push @{$self->{issues}}, @$closed } 
     261     
     262    return $self->{issues}; 
     263} 
     264 
    248265sub save_issues { 
    249266    my $self = shift; 
     267     
     268    $self->issues; 
    250269} 
    251270 
Note: See TracChangeset for help on using the changeset viewer.