use LWP::UserAgent;
use JSON;
-my $ua = LWP::UserAgent->new;
-my $json = JSON->new->utf8->indent;
sub json_api {
my $url = shift;
+ my $ua = LWP::UserAgent->new;
+ my $json = JSON->new->utf8->indent;
+
my $res = $ua->get(
"https://api.github.com$url"
);
use File::chdir;
use File::Spec;
use File::Path qw(mkpath);
+use LWP::UserAgent;
+use JSON;
+
sub new {
my $class = shift;
sub save_issues {
my $self = shift;
- $self->issues;
+ my $ua = LWP::UserAgent->new;
+ my $json = JSON->new->utf8->indent;
+
+ my $dir = $self->directory . '.issues';
+ mkpath $dir unless (-d $dir);
+ local $CWD = $dir;
+ foreach my $issue (@{$self->issues}) {
+ my $number = $issue->{number};
+ print "save issue/$number\n";
+
+ open my $fh, ">$number.json";
+ print $fh $json->encode($issue);
+ close $fh;
+
+ if (exists $issue->{pull_request}{patch_url}) {
+ $ua->mirror($issue->{pull_request}{patch_url} => "$number.patch");
+ }
+ }
+
+ return $self;
}
sub backup {