line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GitHub::Jobs; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
28047
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
34
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
GitHub::Jobs - This module is a wrapper around the GitHub Jobs API. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 0.05 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
62188
|
use Moose; |
|
1
|
|
|
|
|
751663
|
|
|
1
|
|
|
|
|
10
|
|
18
|
1
|
|
|
1
|
|
9637
|
use MooseX::Params::Validate; |
|
1
|
|
|
|
|
33425
|
|
|
1
|
|
|
|
|
10
|
|
19
|
1
|
|
|
1
|
|
636
|
use Moose::Util::TypeConstraints; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
20
|
1
|
|
|
1
|
|
2619
|
use namespace::clean; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
11
|
|
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
538
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
71
|
|
23
|
1
|
|
|
1
|
|
1231
|
use Data::Dumper; |
|
1
|
|
|
|
|
9355
|
|
|
1
|
|
|
|
|
83
|
|
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
1265
|
use JSON; |
|
1
|
|
|
|
|
16704
|
|
|
1
|
|
|
|
|
7
|
|
26
|
1
|
|
|
1
|
|
1045
|
use Readonly; |
|
1
|
|
|
|
|
3527
|
|
|
1
|
|
|
|
|
204
|
|
27
|
1
|
|
|
1
|
|
886
|
use HTTP::Request; |
|
1
|
|
|
|
|
43710
|
|
|
1
|
|
|
|
|
46
|
|
28
|
1
|
|
|
1
|
|
66349
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
178701
|
|
|
1
|
|
|
|
|
822
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Readonly my $BASE_URL => "http://jobs.github.com/positions.json"; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
type 'TrueFalse' => where { /\btrue\b|\bfalse\b/i }; |
35
|
|
|
|
|
|
|
has 'description' => ( is => 'ro', isa => 'Str', required => 1 ); |
36
|
|
|
|
|
|
|
has 'full_time' => ( is => 'rw', isa => 'TrueFalse' ); |
37
|
|
|
|
|
|
|
has 'location' => ( is => 'ro', isa => 'Str' ); |
38
|
|
|
|
|
|
|
has 'page' => ( is => 'ro', isa => 'Str' ); |
39
|
|
|
|
|
|
|
has 'lat' => ( is => 'ro', isa => 'Str' ); |
40
|
|
|
|
|
|
|
has 'long' => ( is => 'ro', isa => 'Str' ); |
41
|
|
|
|
|
|
|
has 'browser' => ( |
42
|
|
|
|
|
|
|
is => 'rw', |
43
|
|
|
|
|
|
|
isa => 'LWP::UserAgent', |
44
|
|
|
|
|
|
|
default => sub { return LWP::UserAgent->new(); } |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
around BUILDARGS => sub { |
48
|
|
|
|
|
|
|
my $orig = shift; |
49
|
|
|
|
|
|
|
my $class = shift; |
50
|
|
|
|
|
|
|
if ( @_ == 1 && !ref $_[0] ) { |
51
|
|
|
|
|
|
|
return $class->$orig( description => $_[1] ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
else { |
54
|
|
|
|
|
|
|
return $class->$orig(@_); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 BUILD |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Check if description parameter is empty! |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub BUILD { |
67
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
68
|
0
|
0
|
|
|
|
|
croak("ERROR: description must be specified.\n") |
69
|
|
|
|
|
|
|
unless ( $self->description ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 search |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Generate URL with parameters values and send HTTP Request! |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub search { |
79
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
80
|
0
|
|
|
|
|
|
my ( $browser, $url, $request, $response, $content ); |
81
|
0
|
|
|
|
|
|
$browser = $self->browser; |
82
|
0
|
|
|
|
|
|
$url = sprintf( "%s?description=%s", $BASE_URL, $self->description ); |
83
|
0
|
0
|
|
|
|
|
$url .= sprintf( "&full_time=%s", $self->full_time ) if $self->full_time; |
84
|
0
|
0
|
|
|
|
|
$url .= sprintf( "&location=%s", $self->location ) if $self->location; |
85
|
0
|
0
|
|
|
|
|
$url .= sprintf( "&lat=%s", $self->lat ) if $self->lat; |
86
|
0
|
0
|
|
|
|
|
$url .= sprintf( "&long=%s", $self->long ) if $self->long; |
87
|
0
|
0
|
|
|
|
|
$url .= sprintf( "&page=%s", $self->page ) if $self->page; |
88
|
0
|
|
|
|
|
|
$request = HTTP::Request->new( GET => $url ); |
89
|
0
|
|
|
|
|
|
$response = $browser->request($request); |
90
|
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
|
croak( |
92
|
|
|
|
|
|
|
"ERROR: Couldn't fetch data [$url]:[" . $response->status_line . "]\n" ) |
93
|
|
|
|
|
|
|
unless $response->is_success; |
94
|
0
|
|
|
|
|
|
$content = $response->content; |
95
|
0
|
0
|
|
|
|
|
croak("ERROR: No data found.\n") unless defined $content; |
96
|
0
|
|
|
|
|
|
return $content; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
100
|
1
|
|
|
1
|
|
34
|
no Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
13
|
|
101
|
1
|
|
|
1
|
|
239
|
no Moose::Util::TypeConstraints; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 SYNOPSIS |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This module is the implementation of a interface to the GitHub Jobs API (as available on https://jobs.github.com/api) |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
use strict; |
108
|
|
|
|
|
|
|
use warnings; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
use GitHub::Jobs; |
111
|
|
|
|
|
|
|
use JSON::XS; |
112
|
|
|
|
|
|
|
use POSIX; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
$|++; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
my $query = 'software'; |
117
|
|
|
|
|
|
|
my $count = 0; |
118
|
|
|
|
|
|
|
my $pagination = 0; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub initial { |
121
|
|
|
|
|
|
|
my $page = shift; |
122
|
|
|
|
|
|
|
my $str = GitHub::Jobs->new( description => $query, page => $page ); |
123
|
|
|
|
|
|
|
return JSON::XS::decode_json( $str->search() ); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub decode { |
127
|
|
|
|
|
|
|
foreach my $items ( @{ initial($pagination) } ) { |
128
|
|
|
|
|
|
|
print $items->{title} . " ---- "; |
129
|
|
|
|
|
|
|
print $items->{company} . "\n"; |
130
|
|
|
|
|
|
|
$count++; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
my $page_count = ceil( ( $count / 50 ) ); |
133
|
|
|
|
|
|
|
if ( ($page_count) && ( $page_count != $pagination ) ) { |
134
|
|
|
|
|
|
|
$pagination = $page_count; |
135
|
|
|
|
|
|
|
&decode; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
decode; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 AUTHOR |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Ovidiu Nita Tatar, C<< <ovn.tatar at gmail.com> >> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 BUGS |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-github-jobs at rt.cpan.org>, or through |
148
|
|
|
|
|
|
|
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=GitHub-Jobs>. I will be notified, and then you'll |
149
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
or https://github.com/ovntatar/GitHub-Jobs/issues |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 SUPPORT |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
perldoc GitHub::Jobs |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
https://github.com/ovntatar/GitHub-Jobs |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
You can also look for information at: |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=over 4 |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=GitHub-Jobs> |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
L<http://annocpan.org/dist/GitHub-Jobs> |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item * CPAN Ratings |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/GitHub-Jobs> |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=item * Search CPAN |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/GitHub-Jobs/> |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=back |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Copyright 2013 Ovidiu Nita Tatar. |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
191
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
192
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=cut |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
1; # End of GitHub::Jobs |