| 1 | package App::Github::Email; | ||||||||||||||||||||||||||||
| 2 | 1 | $App::Github::Email::VERSION = '0.3.3'; | |||||||||||||||||||||||||||
| 3 | # ABSTRACT: Search and print particular Github user emails. | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Carp qw(confess); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use JSON; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use List::MoreUtils qw(uniq); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub get_user { | ||||||||||||||||||||||||||
|
Subroutine
get_user: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 15 | 0 | my $username = shift; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 0 | my $ua = LWP::UserAgent->new; | |||||||||||||||||||||||||||
| 18 | 0 | my $get_json = | |||||||||||||||||||||||||||
| 19 | $ua->get("https://api.github.com/users/$username/events/public"); | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 0 | ▶ | if ( $get_json->is_success ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 0 | my $raw_json = $get_json->decoded_content; | |||||||||||||||||||||||||||
| 23 | 0 | my $dec_json = decode_json $raw_json; | |||||||||||||||||||||||||||
| 24 | 0 | my @push_events = grep { $_->{type} eq 'PushEvent' } @{$dec_json}; | |||||||||||||||||||||||||||
| 25 | 0 | my @commits = map { @{$_->{payload}->{commits}} } @push_events; | |||||||||||||||||||||||||||
| 26 | 0 | my @addresses = map { $_->{author}->{email} } @commits; | |||||||||||||||||||||||||||
| 27 | 0 | my @unique_addr = uniq @addresses; | |||||||||||||||||||||||||||
| 28 | 0 | my @retrieved_addrs; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | for my $address (@unique_addr) { | |||||||||||||||||||||||||||
| 31 | 0 | ▶ | if ( $address ne 'git@github.com' and not $address =~ /^":"/g ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$address ne "git\@github.com" and not $address =~ /^":"/g
MC/DC0%0/2
$address ne "git\@github.com" and not $address =~ /^":"/g
$address ne "git\@github.com"
not $address =~ /^":"/g
Truth table0%0/3
A and not(B)
A= $address ne "git\@github.com"B= not $address =~ /^":"/g
| |||||||||||||||||||||||||||||
| 32 | 0 | push( @retrieved_addrs, $address ); | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | return @retrieved_addrs; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | else { | ||||||||||||||||||||||||||||
| 40 | 0 | confess("User is not exist."); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 1 | 1; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | __END__ | ||||||||||||||||||||||||||||