return $json->decode($res->content);
}
+sub get {
+ my $url = shift;
+
+ my $page = 1;
+ my $data;
+ while(1) {
+ my $result = json_api("$url?per_page=100&page=$page");
+ if (ref($result) eq 'ARRAY' && scalar @$result > 0) {
+ push @$data, @$result;
+ $page++;
+
+ next;
+ }
+ last;
+ }
+
+ return $data;
+}
package GitHubBackup;
return $self->{repos};
}
- my $page = 1;
- my @repos;
- while (1) {
- my $result = utils::json_api("/users/$account/repos?per_page=100&page=$page");
- if (ref($result) eq 'ARRAY' && scalar @$result > 0) {
- push @repos, @$result;
- $page++;
-
- next;
- }
- last;
- }
-
- foreach my $repos (@repos) {
+ my $result = utils::get("/users/$account/repos");
+ foreach my $repos (@$result) {
push @{$self->{repos}},
GitHubBackup::Repository->new({
directory => sub {$self->directory},
my $self = shift;
return $self->{forks} if ($self->{forks});
- my $page = 1;
- while (1) {
- my $result = utils::json_api("/repos/" . $self->{full_name} . "/forks?per_page=100&page=$page");
- if (ref($result) eq 'ARRAY' && scalar @$result > 0) {
- push @{$self->{forks}}, @$result;
- $page++;
-
- next;
- }
- last;
- }
+ $self->{forks} = utils::get("/repos/" . $self->{full_name} . "/forks");
return $self;
}