File: cache.pl

package info (click to toggle)
libpithub-perl 0.01043-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,148 kB
  • sloc: perl: 9,098; makefile: 7
file content (31 lines) | stat: -rwxr-xr-x 655 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env perl

use strict;
use warnings;

use CHI                    ();
use Pithub::Repos          ();
use WWW::Mechanize::Cached ();

my $cache = CHI->new(
    driver   => 'File',
    root_dir => '/tmp/pithub-example'
);

my $mech = WWW::Mechanize::Cached->new( cache => $cache );

my $b = Pithub::Repos->new(
    auto_pagination => 1,
    per_page        => 100,
    ua              => $mech,
);
my $result = $b->branches( user => 'plu', repo => 'Pithub' );

unless ( $result->success ) {
    printf "something is fishy: %s\n", $result->response->status_line;
    exit 1;
}

while ( my $row = $result->next ) {
    printf "%s\n", $row->{name};
}