File Coverage

lib/App/gh/Command/Search.pm
Criterion Covered Total %
statement 24 35 68.5
branch n/a
condition 0 2 0.0
subroutine 8 9 88.8
pod 0 1 0.0
total 32 47 68.0


line stmt bran cond sub pod time code
1             package App::gh::Command::Search;
2 1     1   1370 use warnings;
  1         2  
  1         34  
3 1     1   7 use strict;
  1         2  
  1         40  
4 1     1   6 use base qw(App::gh::Command);
  1         3  
  1         82  
5 1     1   6 use App::gh::Utils;
  1         2  
  1         78  
6 1     1   6 use App::gh;
  1         10  
  1         19  
7 1     1   6 use Term::ANSIColor;
  1         2  
  1         58  
8 1     1   9325 use Text::Wrap;
  1         6450  
  1         155  
9 1     1   21 use v5.10;
  1         4  
  1         280  
10              
11             =head1 NAME
12              
13             App::gh::Command::Search - search repositories
14              
15             =head1 USAGE
16              
17             $ gh search perl6
18              
19             =cut
20              
21             sub run {
22 0     0 0   my ($self,$keyword) = @_;
23 0           local $|;
24 0           info "Fetching list...";
25              
26 0           my $data = App::gh->github->query( 'GET' , '/legacy/repos/search/' . $keyword );
27              
28 0           my @ary = ();
29 0           for my $repo ( @{ $data->{repositories} } ) {
  0            
30 0           my $name = sprintf "%s/%s", $repo->{username} , $repo->{name};
31 0           my $desc = $repo->{description};
32 0   0       push @ary, [ $name , $desc || '' ];
33             }
34 0           print_list @ary;
35              
36             # my $result = App::gh->api->search($keyword);
37             # if( $self->{long} ) {
38             # for my $entry ( @{ $result->{repositories} } ) {
39             # print color 'white bold';
40             # say "* $entry->{owner}/$entry->{name}";
41             # print color 'reset';
42             # say " W/F: $entry->{watchers}/$entry->{forks}";
43             # say " Url: " . $entry->{url} if $entry->{url};
44             # say " Homepage: " . $entry->{homepage} if $entry->{homepage};
45             # say "\n" . wrap( ' ', ' ', $entry->{description} ) . "\n";
46             # }
47             # } else {
48             # my @ary = ();
49             # for my $repo ( @{ $result->{repositories} } ) {
50             # }
51             # # print short list
52             # }
53              
54             }
55              
56             1;
57             __END__