line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Github::Email; |
2
|
|
|
|
|
|
|
$Github::Email::VERSION = '1.1.0'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Search and print particular Github user emails. |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
202663
|
use strict; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
34
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use Carp qw(confess); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
60
|
|
9
|
1
|
|
|
1
|
|
5
|
use JSON; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
10
|
1
|
|
|
1
|
|
127
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
11
|
1
|
|
|
1
|
|
7
|
use List::MoreUtils qw(uniq); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
12
|
1
|
|
|
1
|
|
624
|
use Email::Valid; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
263
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub get_emails { |
16
|
0
|
|
|
0
|
1
|
|
my $username = shift; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my $user_agent = LWP::UserAgent->new; |
19
|
0
|
|
|
|
|
|
my $get_json = |
20
|
|
|
|
|
|
|
$user_agent->get("https://api.github.com/users/$username/events/public"); |
21
|
|
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
|
if ( $get_json->is_success ) { |
23
|
0
|
|
|
|
|
|
my $raw_json = $get_json->decoded_content; |
24
|
0
|
|
|
|
|
|
my $decoded_json = decode_json $raw_json; |
25
|
0
|
|
|
|
|
|
my @push_events = grep { $_->{type} eq 'PushEvent' } @{$decoded_json}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my @commits = map { @{$_->{payload}->{commits}} } @push_events; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my @addresses = map { $_->{author}->{email} } @commits; |
|
0
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my @unique_addresses = uniq @addresses; |
29
|
0
|
|
|
|
|
|
my @retrieved_addresses; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
for my $address (@unique_addresses) { |
32
|
0
|
0
|
0
|
|
|
|
if ( $address ne 'git@github.com' && Email::Valid->address($address) ) { |
33
|
0
|
|
|
|
|
|
push( @retrieved_addresses, $address ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
return @retrieved_addresses; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
else { |
41
|
0
|
|
|
|
|
|
confess("User doesn't exist"); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |