Changeset c5b427c in lab.git for Dev


Ignore:
Timestamp:
Aug 21, 2013 10:47:41 AM (11 years ago)
Author:
Ken-ichi Mito <mitty@…>
Branches:
master
Children:
f38b66d
Parents:
d51047d
Message:

change GitHubBackup::Repository data structure

  • keep original structure from api
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/github/GitHubBackup.pm

    rd51047d rc5b427c  
    107107     
    108108    my $account = $self->account or croak "account is not set"; 
     109    my $result; 
    109110    if (my $repository = $self->repository) { 
    110         $self->{repos} = [ 
    111             GitHubBackup::Repository->new({ 
    112                 directory => sub {$self->directory}, 
    113                 full_name => "$account/$repository", 
    114             }) 
    115         ]; 
    116          
    117         return $self->{repos}; 
    118     } 
    119      
    120     my $result = utils::get("/users/$account/repos"); 
     111        $result = [ utils::json_api("/repos/$account/$repository") ]; 
     112    } 
     113    else { 
     114        $result = utils::get("/users/$account/repos"); 
     115    } 
     116     
    121117    foreach my $repos (@$result) { 
    122118        push @{$self->{repos}}, 
    123119            GitHubBackup::Repository->new({ 
    124120                directory => sub {$self->directory}, 
    125                 full_name => $repos->{full_name}, 
    126                 clone_url => $repos->{clone_url}, 
     121                repos     => $repos, 
    127122            }) 
    128123        ; 
     
    161156    my $args  = shift; 
    162157     
    163     if (! exists $args->{clone_url}) { 
    164         my $result = utils::json_api('/repos/' . $args->{full_name}); 
    165         $args->{clone_url} = $result->{clone_url}; 
    166     } 
    167      
    168158    return bless $args, $class; 
    169159} 
    170160 
     161sub clone_url { 
     162    return (shift)->{repos}{clone_url}; 
     163} 
     164 
     165sub full_name { 
     166    return (shift)->{repos}{full_name}; 
     167} 
     168 
    171169sub directory { 
    172170    my $self = shift; 
    173171     
    174     my $path = $self->{full_name}; 
     172    my $path = $self->full_name; 
    175173    if (my $base = $self->{directory}->()) { 
    176174        $path = File::Spec->catfile($base, $path); 
     
    203201     
    204202    my $dir = $self->directory . '.git'; 
    205     my $url = $self->{clone_url}; 
     203    my $url = $self->clone_url; 
    206204     
    207205    $self->sync($url => $dir); 
     
    214212    return $self->{forks} if ($self->{forks}); 
    215213     
    216     $self->{forks} = utils::get("/repos/" . $self->{full_name} . "/forks"); 
     214    $self->{forks} = utils::get("/repos/" . $self->full_name . "/forks"); 
    217215     
    218216    return $self->{forks}; 
     
    249247     
    250248    my $dir = $self->directory . '.wiki.git'; 
    251     my $url = 'https://github.com/' . $self->{full_name} . '.wiki.git'; 
     249    my $url = 'https://github.com/' . $self->full_name . '.wiki.git'; 
    252250     
    253251    $self->sync($url => $dir); 
     
    260258    return $self->{issues} if ($self->{issues}); 
    261259     
    262     my $open   = utils::get("/repos/" . $self->{full_name} . "/issues"); 
    263     my $closed = utils::get("/repos/" . $self->{full_name} . "/issues", state => 'closed'); 
     260    my $open   = utils::get("/repos/" . $self->full_name . "/issues"); 
     261    my $closed = utils::get("/repos/" . $self->full_name . "/issues", state => 'closed'); 
    264262     
    265263    if ($open)   { push @{$self->{issues}}, @$open } 
Note: See TracChangeset for help on using the changeset viewer.