| 1 | package WWW::Ohloh::API; | ||||||||||||||||||||
| 2 | 28 | our $AUTHORITY = 'cpan:YANICK'; | |||||||||||||||||||
| 3 | # ABSTRACT: Ohloh API implementation (DEPRECATED) | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 28 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 28 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 28 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 28 | ▶ | use Object::InsideOut; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 28 | ▶ | use LWP::UserAgent; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 28 | ▶ | use Readonly; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 28 | ▶ | use XML::LibXML; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 28 | ▶ | use Params::Validate qw(:all); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 28 | ▶ | use WWW::Ohloh::API::Account; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | 28 | ▶ | use WWW::Ohloh::API::Analysis; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | 28 | ▶ | use WWW::Ohloh::API::Project; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 28 | ▶ | use WWW::Ohloh::API::Projects; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | 28 | ▶ | use WWW::Ohloh::API::Languages; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 21 | 28 | ▶ | use WWW::Ohloh::API::ActivityFact; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | 28 | ▶ | use WWW::Ohloh::API::ActivityFacts; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 23 | 28 | ▶ | use WWW::Ohloh::API::Kudos; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 24 | 28 | ▶ | use WWW::Ohloh::API::ContributorLanguageFact; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 25 | 28 | ▶ | use WWW::Ohloh::API::Enlistments; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 26 | 28 | ▶ | use WWW::Ohloh::API::Factoid; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 27 | 28 | ▶ | use WWW::Ohloh::API::SizeFact; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 28 | ▶ | use Digest::MD5 qw/ md5_hex /; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 28 | our $VERSION = '1.0_1'; | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 28 | Readonly our $OHLOH_URL => 'http://www.ohloh.net/'; | |||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 28 | our $useragent_signature = "WWW-Ohloh-API/$VERSION"; | |||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 28 | my @api_key_of : Field : Std(api_key) : Arg(api_key); | |||||||||||||||||||
| 38 | 28 | my @api_version_of : Field : Default(1) : Std(api_version) | |||||||||||||||||||
| 39 | ; # for now, there's only v1 | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 28 | my @user_agent_of : Field; | |||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 28 | my @debugging : Field : Arg(debug) : Default(0) : Std(debug); | |||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 28 | my @parser_of : Field; | |||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 1 | ▶ | sub fetch_messages { | ||||||||||||||||||
|
Subroutine
fetch_messages: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 50 | 1 | my $self = shift; | |||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 1 | require WWW::Ohloh::API::Messages; | |||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 1 | return WWW::Ohloh::API::Messages->new( ohloh => $self, @_ ); | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 1 | ▶ | sub fetch_account_stack { | ||||||||||||||||||
|
Subroutine
fetch_account_stack: called CC=2 SCAR=9.9
Pod
documented
| |||||||||||||||||||||
| 60 | 1 | my $self = shift; | |||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 1 | my $id = shift; | |||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 1 | require WWW::Ohloh::API::Stack; | |||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 1 | return WWW::Ohloh::API::Stack->fetch( | |||||||||||||||||||
| 67 | ohloh => $self, | ||||||||||||||||||||
| 68 | id => $id | ||||||||||||||||||||
| 69 | ); | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 0 | ▶ | $id = md5_hex($id) if -1 < index $id, '@'; # it's an email | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | 0 | my ( $url, $xml ) = | |||||||||||||||||||
| 74 | $self->_query_server("accounts/$id/stacks/default.xml"); | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 0 | return WWW::Ohloh::API::Stack->new( | |||||||||||||||||||
| 77 | ohloh => $self, | ||||||||||||||||||||
| 78 | request_url => $url, | ||||||||||||||||||||
| 79 | xml => $xml->findnodes('stack[1]'), | ||||||||||||||||||||
| 80 | ); | ||||||||||||||||||||
| 81 | } | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 1 | ▶ | sub fetch_project_stacks { | ||||||||||||||||||
|
Subroutine
fetch_project_stacks: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 86 | 1 | my $self = shift; | |||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | 1 | my $project = shift; | |||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | 1 | my ( $url, $xml ) = $self->_query_server("projects/$project/stacks.xml"); | |||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | 1 | require WWW::Ohloh::API::Stack; | |||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | return map { | ||||||||||||||||||||
| 95 | 1 | WWW::Ohloh::API::Stack->new( | |||||||||||||||||||
| 96 | ohloh => $self, | ||||||||||||||||||||
| 97 | request_url => $url, | ||||||||||||||||||||
| 98 | xml => $_, | ||||||||||||||||||||
| 99 | ) | ||||||||||||||||||||
| 100 | } $xml->findnodes('//result/stack'); | ||||||||||||||||||||
| 101 | } | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | 1 | ▶ | sub fetch_size_facts { | ||||||||||||||||||
|
Subroutine
fetch_size_facts: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 106 | 1 | my $self = shift; | |||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | 1 | my ( $project_id, $analysis_id ) = | |||||||||||||||||||
| 109 | validate_pos( @_, 1, { default => 'latest' }, ); | ||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | 1 | my ( $url, $xml ) = $self->_query_server( | |||||||||||||||||||
| 112 | "projects/$project_id/analyses/$analysis_id/size_facts.xml"); | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | return map { | ||||||||||||||||||||
| 115 | 1 | WWW::Ohloh::API::SizeFact->new( | |||||||||||||||||||
| 116 | ohloh => $self, | ||||||||||||||||||||
| 117 | request_url => $url, | ||||||||||||||||||||
| 118 | xml => $_ | ||||||||||||||||||||
| 119 | ) | ||||||||||||||||||||
| 120 | } $xml->findnodes('//size_fact'); | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | } | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | 5 | ▶ | sub fetch_account { | ||||||||||||||||||
|
Subroutine
fetch_account: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 127 | 5 | my ( $self, $id ) = @_; | |||||||||||||||||||
| 128 | |||||||||||||||||||||
| 129 | 5 | require WWW::Ohloh::API::Account; | |||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | 5 | return WWW::Ohloh::API::Account->fetch( | |||||||||||||||||||
| 132 | ohloh => $self, | ||||||||||||||||||||
| 133 | id => $id, | ||||||||||||||||||||
| 134 | ); | ||||||||||||||||||||
| 135 | } | ||||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 138 | |||||||||||||||||||||
| 139 | 1 | ▶ | sub fetch_enlistments { | ||||||||||||||||||
|
Subroutine
fetch_enlistments: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 140 | 1 | my $self = shift; | |||||||||||||||||||
| 141 | 1 | my %arg = @_; | |||||||||||||||||||
| 142 | |||||||||||||||||||||
| 143 | return WWW::Ohloh::API::Enlistments->new( | ||||||||||||||||||||
| 144 | ohloh => $self, | ||||||||||||||||||||
| 145 | project_id => $arg{project_id}, | ||||||||||||||||||||
| 146 | ( sort => $arg{sort} ) x !!$arg{sort}, | ||||||||||||||||||||
| 147 | 1 | ); | |||||||||||||||||||
| 148 | } | ||||||||||||||||||||
| 149 | |||||||||||||||||||||
| 150 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 151 | |||||||||||||||||||||
| 152 | 2 | ▶ | sub fetch_factoids { | ||||||||||||||||||
|
Subroutine
fetch_factoids: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 153 | 2 | my $self = shift; | |||||||||||||||||||
| 154 | |||||||||||||||||||||
| 155 | 2 | my $project_id = shift; | |||||||||||||||||||
| 156 | |||||||||||||||||||||
| 157 | 2 | my ( $url, $xml ) = | |||||||||||||||||||
| 158 | $self->_query_server("projects/$project_id/factoids.xml"); | ||||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | return map { | ||||||||||||||||||||
| 161 | 2 | WWW::Ohloh::API::Factoid->new( | |||||||||||||||||||
| 162 | ohloh => $self, | ||||||||||||||||||||
| 163 | request_url => $url, | ||||||||||||||||||||
| 164 | xml => $_ | ||||||||||||||||||||
| 165 | ) | ||||||||||||||||||||
| 166 | } $xml->findnodes('//factoid'); | ||||||||||||||||||||
| 167 | } | ||||||||||||||||||||
| 168 | |||||||||||||||||||||
| 169 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 170 | |||||||||||||||||||||
| 171 | 1 | ▶ | sub fetch_contributor_language_facts { | ||||||||||||||||||
|
Subroutine
fetch_contributor_language_facts: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 172 | 1 | my $self = shift; | |||||||||||||||||||
| 173 | |||||||||||||||||||||
| 174 | 1 | my %param = validate( | |||||||||||||||||||
| 175 | @_, | ||||||||||||||||||||
| 176 | { project_id => 1, | ||||||||||||||||||||
| 177 | contributor_id => 1, | ||||||||||||||||||||
| 178 | } ); | ||||||||||||||||||||
| 179 | |||||||||||||||||||||
| 180 | 1 | my ( $url, $xml ) = $self->_query_server( | |||||||||||||||||||
| 181 | "projects/$param{project_id}/contributors/$param{contributor_id}.xml" | ||||||||||||||||||||
| 182 | ); | ||||||||||||||||||||
| 183 | |||||||||||||||||||||
| 184 | return map { | ||||||||||||||||||||
| 185 | 1 | WWW::Ohloh::API::ContributorLanguageFact->new( | |||||||||||||||||||
| 186 | ohloh => $self, | ||||||||||||||||||||
| 187 | request_url => $url, | ||||||||||||||||||||
| 188 | xml => $_ | ||||||||||||||||||||
| 189 | ) | ||||||||||||||||||||
| 190 | } $xml->findnodes('//contributor_language_fact'); | ||||||||||||||||||||
| 191 | |||||||||||||||||||||
| 192 | } | ||||||||||||||||||||
| 193 | |||||||||||||||||||||
| 194 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 195 | |||||||||||||||||||||
| 196 | 2 | ▶ | sub fetch_kudos { | ||||||||||||||||||
|
Subroutine
fetch_kudos: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||
| 197 | 2 | my $self = shift; | |||||||||||||||||||
| 198 | 2 | my ($id) = @_; | |||||||||||||||||||
| 199 | |||||||||||||||||||||
| 200 | 2 | ▶ | $id = md5_hex($id) if -1 < index $id, '@'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 201 | |||||||||||||||||||||
| 202 | 2 | return WWW::Ohloh::API::Kudos->new( | |||||||||||||||||||
| 203 | ohloh => $self, | ||||||||||||||||||||
| 204 | id => $id, | ||||||||||||||||||||
| 205 | ); | ||||||||||||||||||||
| 206 | } | ||||||||||||||||||||
| 207 | |||||||||||||||||||||
| 208 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 209 | |||||||||||||||||||||
| 210 | 2 | ▶ | sub fetch_project { | ||||||||||||||||||
|
Subroutine
fetch_project: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 211 | 2 | my $self = shift; | |||||||||||||||||||
| 212 | 2 | my $id = shift; | |||||||||||||||||||
| 213 | |||||||||||||||||||||
| 214 | 2 | my ( $url, $xml ) = $self->_query_server("projects/$id.xml"); | |||||||||||||||||||
| 215 | |||||||||||||||||||||
| 216 | 2 | return WWW::Ohloh::API::Project->new( | |||||||||||||||||||
| 217 | ohloh => $self, | ||||||||||||||||||||
| 218 | request_url => $url, | ||||||||||||||||||||
| 219 | xml => $xml->findnodes('project[1]'), | ||||||||||||||||||||
| 220 | ); | ||||||||||||||||||||
| 221 | } | ||||||||||||||||||||
| 222 | |||||||||||||||||||||
| 223 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 224 | |||||||||||||||||||||
| 225 | 1 | ▶ | sub fetch_projects { | ||||||||||||||||||
|
Subroutine
fetch_projects: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 226 | 1 | my $self = shift; | |||||||||||||||||||
| 227 | 1 | my %arg = validate( @_, { query => 0, sort => 0, max => 0 } ); | |||||||||||||||||||
| 228 | |||||||||||||||||||||
| 229 | return WWW::Ohloh::API::Projects->new( | ||||||||||||||||||||
| 230 | ohloh => $self, | ||||||||||||||||||||
| 231 | query => $arg{query}, | ||||||||||||||||||||
| 232 | sort => $arg{sort}, | ||||||||||||||||||||
| 233 | max => $arg{max}, | ||||||||||||||||||||
| 234 | 1 | ); | |||||||||||||||||||
| 235 | } | ||||||||||||||||||||
| 236 | |||||||||||||||||||||
| 237 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 238 | |||||||||||||||||||||
| 239 | 0 | ▶ | sub fetch_analysis { | ||||||||||||||||||
|
Subroutine
fetch_analysis: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 240 | 0 | my $self = shift; | |||||||||||||||||||
| 241 | 0 | my $project = shift; | |||||||||||||||||||
| 242 | |||||||||||||||||||||
| 243 | 0 | ▶ | $_[0] ||= 'latest'; | ||||||||||||||||||
|
Condition0%0/2
$_[0] ||= "latest"
MC/DC0%0/1
$_[0] ||= "latest"
$_[0]
Truth table0%0/2
A
A= $_[0]
| |||||||||||||||||||||
| 244 | |||||||||||||||||||||
| 245 | 0 | my ( $url, $xml ) = | |||||||||||||||||||
| 246 | $self->_query_server("projects/$project/analyses/$_[0].xml"); | ||||||||||||||||||||
| 247 | |||||||||||||||||||||
| 248 | 0 | my $analysis = WWW::Ohloh::API::Analysis->new( | |||||||||||||||||||
| 249 | request_url => $url, | ||||||||||||||||||||
| 250 | xml => $xml->findnodes('analysis[1]'), | ||||||||||||||||||||
| 251 | ); | ||||||||||||||||||||
| 252 | |||||||||||||||||||||
| 253 | 0 | ▶ | unless ( $analysis->project_id == $project ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 254 | 0 | croak "analysis $_[0] doesn't apply to project $project"; | |||||||||||||||||||
| 255 | } | ||||||||||||||||||||
| 256 | |||||||||||||||||||||
| 257 | 0 | return $analysis; | |||||||||||||||||||
| 258 | } | ||||||||||||||||||||
| 259 | |||||||||||||||||||||
| 260 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 261 | |||||||||||||||||||||
| 262 | 1 | ▶ | sub fetch_languages { | ||||||||||||||||||
|
Subroutine
fetch_languages: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 263 | 1 | my $self = shift; | |||||||||||||||||||
| 264 | 1 | my %arg = @_; | |||||||||||||||||||
| 265 | |||||||||||||||||||||
| 266 | return WWW::Ohloh::API::Languages->new( | ||||||||||||||||||||
| 267 | ohloh => $self, | ||||||||||||||||||||
| 268 | ( sort => $arg{sort} ) x !!$arg{sort}, | ||||||||||||||||||||
| 269 | 1 | ); | |||||||||||||||||||
| 270 | } | ||||||||||||||||||||
| 271 | |||||||||||||||||||||
| 272 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 273 | |||||||||||||||||||||
| 274 | 0 | ▶ | sub fetch_language { | ||||||||||||||||||
|
Subroutine
fetch_language: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 275 | 0 | my $self = shift; | |||||||||||||||||||
| 276 | 0 | my $id = shift; | |||||||||||||||||||
| 277 | |||||||||||||||||||||
| 278 | 0 | my ( $url, $xml ) = $self->_query_server("languages/$id.xml"); | |||||||||||||||||||
| 279 | |||||||||||||||||||||
| 280 | 0 | return WWW::Ohloh::API::Language->new( | |||||||||||||||||||
| 281 | request_url => $url, | ||||||||||||||||||||
| 282 | xml => $xml->findnodes('language[1]'), | ||||||||||||||||||||
| 283 | ); | ||||||||||||||||||||
| 284 | |||||||||||||||||||||
| 285 | } | ||||||||||||||||||||
| 286 | |||||||||||||||||||||
| 287 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 288 | |||||||||||||||||||||
| 289 | 1 | ▶ | sub fetch_activity_facts { | ||||||||||||||||||
|
Subroutine
fetch_activity_facts: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 290 | 1 | my $self = shift; | |||||||||||||||||||
| 291 | 1 | my ( $project, $analysis ) = | |||||||||||||||||||
| 292 | validate_pos( @_, 1, { default => 'latest' }, ); | ||||||||||||||||||||
| 293 | |||||||||||||||||||||
| 294 | 1 | return WWW::Ohloh::API::ActivityFacts->new( | |||||||||||||||||||
| 295 | ohloh => $self, | ||||||||||||||||||||
| 296 | project => $project, | ||||||||||||||||||||
| 297 | analysis => $analysis, | ||||||||||||||||||||
| 298 | ); | ||||||||||||||||||||
| 299 | } | ||||||||||||||||||||
| 300 | |||||||||||||||||||||
| 301 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 302 | |||||||||||||||||||||
| 303 | 0 | ▶ | sub _ua { | ||||||||||||||||||
|
Subroutine
_ua: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 304 | 0 | my $self = shift; | |||||||||||||||||||
| 305 | 0 | my $ua; | |||||||||||||||||||
| 306 | 0 | ▶ | unless ( $ua = $user_agent_of[$$self] ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 307 | 0 | $ua = $user_agent_of[$$self] = LWP::UserAgent->new; | |||||||||||||||||||
| 308 | 0 | $ua->agent($useragent_signature); | |||||||||||||||||||
| 309 | } | ||||||||||||||||||||
| 310 | 0 | return $ua; | |||||||||||||||||||
| 311 | } | ||||||||||||||||||||
| 312 | |||||||||||||||||||||
| 313 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 314 | |||||||||||||||||||||
| 315 | 0 | ▶ | sub _parser { | ||||||||||||||||||
|
Subroutine
_parser: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 316 | 0 | my $self = shift; | |||||||||||||||||||
| 317 | 0 | ▶ | return $parser_of[$$self] ||= XML::LibXML->new; | ||||||||||||||||||
|
Condition0%0/3
$parser_of[$$self] ||= "XML::LibXML"->new
MC/DC0%0/2
$parser_of[$$self] ||= "XML::LibXML"->new
$parser_of[$$self]
"XML::LibXML"->new
Truth table0%0/3
A ||= B
A= $parser_of[$$self]B= "XML::LibXML"->new
| |||||||||||||||||||||
| 318 | } | ||||||||||||||||||||
| 319 | |||||||||||||||||||||
| 320 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 321 | |||||||||||||||||||||
| 322 | 0 | ▶ | sub _query_server { | ||||||||||||||||||
|
Subroutine
_query_server: not called CC=8 SCAR=42.8
| |||||||||||||||||||||
| 323 | 0 | my $self = shift; | |||||||||||||||||||
| 324 | 0 | my $url = shift; | |||||||||||||||||||
| 325 | 0 | ▶ | my %param = $_[0] ? %{ $_[0] } : (); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 326 | |||||||||||||||||||||
| 327 | 0 | ▶ | if ( $url !~ /^http/ ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 328 | 0 | ▶ | $param{api_key} = $self->get_api_key | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 329 | or croak "api key not configured"; | ||||||||||||||||||||
| 330 | |||||||||||||||||||||
| 331 | 0 | $param{v} = $api_version_of[$$self]; | |||||||||||||||||||
| 332 | |||||||||||||||||||||
| 333 | 0 | $url = $OHLOH_URL . $url; | |||||||||||||||||||
| 334 | |||||||||||||||||||||
| 335 | 0 | $url .= '?' . join '&', map { "$_=$param{$_}" } keys %param; | |||||||||||||||||||
| 336 | } | ||||||||||||||||||||
| 337 | |||||||||||||||||||||
| 338 | 0 | ▶ | warn "querying ohloh server with $url" if $debugging[$$self]; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 339 | |||||||||||||||||||||
| 340 | # TODO: beef up here for failures | ||||||||||||||||||||
| 341 | 0 | my $request = HTTP::Request->new( GET => $url ); | |||||||||||||||||||
| 342 | 0 | my $response = $self->_ua->request($request); | |||||||||||||||||||
| 343 | |||||||||||||||||||||
| 344 | 0 | ▶ | unless ( $response->is_success ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 345 | 0 | croak "http query to Ohloh server failed: " . $response->status_line; | |||||||||||||||||||
| 346 | } | ||||||||||||||||||||
| 347 | |||||||||||||||||||||
| 348 | 0 | my $result = $response->content; | |||||||||||||||||||
| 349 | |||||||||||||||||||||
| 350 | 0 | ▶ | my $dom = eval { $self->_parser->parse_string($result) } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 351 | or croak "server didn't feed back valid xml: $@"; | ||||||||||||||||||||
| 352 | |||||||||||||||||||||
| 353 | 0 | ▶ | if ( $dom->findvalue('/response/status/text()') ne 'success' ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 354 | 0 | croak "query to Ohloh server failed: ", | |||||||||||||||||||
| 355 | $dom->findvalue('/response/status/text()'); | ||||||||||||||||||||
| 356 | } | ||||||||||||||||||||
| 357 | |||||||||||||||||||||
| 358 | 0 | return $url, $dom->findnodes('/response/result[1]'); | |||||||||||||||||||
| 359 | } | ||||||||||||||||||||
| 360 | |||||||||||||||||||||
| 361 | 28 | 1; # Magic true value required at end of module | |||||||||||||||||||
| 362 | |||||||||||||||||||||
| 363 | __END__ | ||||||||||||||||||||