| 1 | package WWW::Ohloh::API; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 16 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 16 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 16 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 16 | ▶ | use Object::InsideOut; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 16 | ▶ | use LWP::UserAgent; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 16 | ▶ | use Readonly; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 16 | ▶ | use XML::LibXML; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 16 | ▶ | use Params::Validate qw(:all); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 16 | ▶ | use WWW::Ohloh::API::Account; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | 16 | ▶ | use WWW::Ohloh::API::Analysis; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | 16 | ▶ | use WWW::Ohloh::API::Project; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | 16 | ▶ | use WWW::Ohloh::API::Projects; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | 16 | ▶ | use WWW::Ohloh::API::Languages; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 16 | ▶ | use WWW::Ohloh::API::ActivityFact; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | 16 | ▶ | use WWW::Ohloh::API::ActivityFacts; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 21 | 16 | ▶ | use WWW::Ohloh::API::Kudos; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | 16 | ▶ | use WWW::Ohloh::API::ContributorLanguageFact; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 23 | 16 | ▶ | use WWW::Ohloh::API::Enlistments; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 24 | 16 | ▶ | use WWW::Ohloh::API::Factoid; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 25 | 16 | ▶ | use WWW::Ohloh::API::SizeFact; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 16 | ▶ | use Digest::MD5 qw/ md5_hex /; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 16 | our $VERSION = '1.0_1'; | |||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 16 | Readonly our $OHLOH_URL => 'http://www.ohloh.net/'; | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 16 | our $useragent_signature = "WWW-Ohloh-API/$VERSION"; | |||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 16 | my @api_key_of : Field : Std(api_key) : Arg(api_key); | |||||||||||||||||||
| 36 | 16 | my @api_version_of : Field : Default(1) : Std(api_version) | |||||||||||||||||||
| 37 | ; # for now, there's only v1 | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 16 | my @user_agent_of : Field; | |||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 16 | my @debugging : Field : Arg(debug) : Default(0) : Std(debug); | |||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 16 | my @parser_of : Field; | |||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | sub fetch_messages { | ||||||||||||||||||||
| 48 | 1 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
fetch_messages: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 1 | require WWW::Ohloh::API::Messages; | |||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 1 | return WWW::Ohloh::API::Messages->new( ohloh => $self, @_ ); | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | sub fetch_account_stack { | ||||||||||||||||||||
| 58 | 2 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
fetch_account_stack: called CC=2 SCAR=9.9
Pod
documented
| |||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 2 | my $id = shift; | |||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 2 | require WWW::Ohloh::API::Stack; | |||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 2 | return WWW::Ohloh::API::Stack->fetch( | |||||||||||||||||||
| 65 | ohloh => $self, | ||||||||||||||||||||
| 66 | id => $id | ||||||||||||||||||||
| 67 | ); | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 0 | ▶ | $id = md5_hex($id) if -1 < index $id, '@'; # it's an email | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 0 | my ( $url, $xml ) = | |||||||||||||||||||
| 72 | $self->_query_server("accounts/$id/stacks/default.xml"); | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 0 | return WWW::Ohloh::API::Stack->new( | |||||||||||||||||||
| 75 | ohloh => $self, | ||||||||||||||||||||
| 76 | request_url => $url, | ||||||||||||||||||||
| 77 | xml => $xml->findnodes('stack[1]'), | ||||||||||||||||||||
| 78 | ); | ||||||||||||||||||||
| 79 | } | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | sub fetch_project_stacks { | ||||||||||||||||||||
| 84 | 1 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
fetch_project_stacks: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | 1 | my $project = shift; | |||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | 1 | my ( $url, $xml ) = $self->_query_server("projects/$project/stacks.xml"); | |||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | 1 | require WWW::Ohloh::API::Stack; | |||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | return map { | ||||||||||||||||||||
| 93 | 1 | WWW::Ohloh::API::Stack->new( | |||||||||||||||||||
| 94 | ohloh => $self, | ||||||||||||||||||||
| 95 | request_url => $url, | ||||||||||||||||||||
| 96 | xml => $_, | ||||||||||||||||||||
| 97 | ) | ||||||||||||||||||||
| 98 | } $xml->findnodes('//result/stack'); | ||||||||||||||||||||
| 99 | } | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | sub fetch_size_facts { | ||||||||||||||||||||
| 104 | 1 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
fetch_size_facts: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | 1 | my ( $project_id, $analysis_id ) = | |||||||||||||||||||
| 107 | validate_pos( @_, 1, { default => 'latest' }, ); | ||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | 1 | my ( $url, $xml ) = $self->_query_server( | |||||||||||||||||||
| 110 | "projects/$project_id/analyses/$analysis_id/size_facts.xml"); | ||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | return map { | ||||||||||||||||||||
| 113 | 1 | WWW::Ohloh::API::SizeFact->new( | |||||||||||||||||||
| 114 | ohloh => $self, | ||||||||||||||||||||
| 115 | request_url => $url, | ||||||||||||||||||||
| 116 | xml => $_ | ||||||||||||||||||||
| 117 | ) | ||||||||||||||||||||
| 118 | } $xml->findnodes('//size_fact'); | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | } | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | sub fetch_account { | ||||||||||||||||||||
| 125 | 6 | ▶ | my ( $self, $id ) = @_; | ||||||||||||||||||
|
Subroutine
fetch_account: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | 6 | require WWW::Ohloh::API::Account; | |||||||||||||||||||
| 128 | |||||||||||||||||||||
| 129 | 6 | return WWW::Ohloh::API::Account->fetch( | |||||||||||||||||||
| 130 | ohloh => $self, | ||||||||||||||||||||
| 131 | id => $id, | ||||||||||||||||||||
| 132 | ); | ||||||||||||||||||||
| 133 | } | ||||||||||||||||||||
| 134 | |||||||||||||||||||||
| 135 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | sub fetch_enlistments { | ||||||||||||||||||||
| 138 | 1 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
fetch_enlistments: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 139 | 1 | my %arg = @_; | |||||||||||||||||||
| 140 | |||||||||||||||||||||
| 141 | return WWW::Ohloh::API::Enlistments->new( | ||||||||||||||||||||
| 142 | ohloh => $self, | ||||||||||||||||||||
| 143 | project_id => $arg{project_id}, | ||||||||||||||||||||
| 144 | ( sort => $arg{sort} ) x !!$arg{sort}, | ||||||||||||||||||||
| 145 | 1 | ); | |||||||||||||||||||
| 146 | } | ||||||||||||||||||||
| 147 | |||||||||||||||||||||
| 148 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 149 | |||||||||||||||||||||
| 150 | sub fetch_factoids { | ||||||||||||||||||||
| 151 | 2 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
fetch_factoids: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 152 | |||||||||||||||||||||
| 153 | 2 | my $project_id = shift; | |||||||||||||||||||
| 154 | |||||||||||||||||||||
| 155 | 2 | my ( $url, $xml ) = | |||||||||||||||||||
| 156 | $self->_query_server("projects/$project_id/factoids.xml"); | ||||||||||||||||||||
| 157 | |||||||||||||||||||||
| 158 | return map { | ||||||||||||||||||||
| 159 | 2 | WWW::Ohloh::API::Factoid->new( | |||||||||||||||||||
| 160 | ohloh => $self, | ||||||||||||||||||||
| 161 | request_url => $url, | ||||||||||||||||||||
| 162 | xml => $_ | ||||||||||||||||||||
| 163 | ) | ||||||||||||||||||||
| 164 | } $xml->findnodes('//factoid'); | ||||||||||||||||||||
| 165 | } | ||||||||||||||||||||
| 166 | |||||||||||||||||||||
| 167 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 168 | |||||||||||||||||||||
| 169 | sub fetch_contributor_language_facts { | ||||||||||||||||||||
| 170 | 1 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
fetch_contributor_language_facts: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 171 | |||||||||||||||||||||
| 172 | 1 | my %param = validate( | |||||||||||||||||||
| 173 | @_, | ||||||||||||||||||||
| 174 | { project_id => 1, | ||||||||||||||||||||
| 175 | contributor_id => 1, | ||||||||||||||||||||
| 176 | } ); | ||||||||||||||||||||
| 177 | |||||||||||||||||||||
| 178 | 1 | my ( $url, $xml ) = $self->_query_server( | |||||||||||||||||||
| 179 | "projects/$param{project_id}/contributors/$param{contributor_id}.xml" | ||||||||||||||||||||
| 180 | ); | ||||||||||||||||||||
| 181 | |||||||||||||||||||||
| 182 | return map { | ||||||||||||||||||||
| 183 | 1 | WWW::Ohloh::API::ContributorLanguageFact->new( | |||||||||||||||||||
| 184 | ohloh => $self, | ||||||||||||||||||||
| 185 | request_url => $url, | ||||||||||||||||||||
| 186 | xml => $_ | ||||||||||||||||||||
| 187 | ) | ||||||||||||||||||||
| 188 | } $xml->findnodes('//contributor_language_fact'); | ||||||||||||||||||||
| 189 | |||||||||||||||||||||
| 190 | } | ||||||||||||||||||||
| 191 | |||||||||||||||||||||
| 192 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 193 | |||||||||||||||||||||
| 194 | sub fetch_kudos { | ||||||||||||||||||||
| 195 | 2 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
fetch_kudos: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||
| 196 | 2 | my ($id) = @_; | |||||||||||||||||||
| 197 | |||||||||||||||||||||
| 198 | 2 | ▶ | $id = md5_hex($id) if -1 < index $id, '@'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 199 | |||||||||||||||||||||
| 200 | 2 | return WWW::Ohloh::API::Kudos->new( | |||||||||||||||||||
| 201 | ohloh => $self, | ||||||||||||||||||||
| 202 | id => $id, | ||||||||||||||||||||
| 203 | ); | ||||||||||||||||||||
| 204 | } | ||||||||||||||||||||
| 205 | |||||||||||||||||||||
| 206 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 207 | |||||||||||||||||||||
| 208 | sub fetch_project { | ||||||||||||||||||||
| 209 | 2 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
fetch_project: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 210 | 2 | my $id = shift; | |||||||||||||||||||
| 211 | |||||||||||||||||||||
| 212 | 2 | my ( $url, $xml ) = $self->_query_server("projects/$id.xml"); | |||||||||||||||||||
| 213 | |||||||||||||||||||||
| 214 | 2 | return WWW::Ohloh::API::Project->new( | |||||||||||||||||||
| 215 | ohloh => $self, | ||||||||||||||||||||
| 216 | request_url => $url, | ||||||||||||||||||||
| 217 | xml => $xml->findnodes('project[1]'), | ||||||||||||||||||||
| 218 | ); | ||||||||||||||||||||
| 219 | } | ||||||||||||||||||||
| 220 | |||||||||||||||||||||
| 221 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 222 | |||||||||||||||||||||
| 223 | sub fetch_projects { | ||||||||||||||||||||
| 224 | 1 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
fetch_projects: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 225 | 1 | my %arg = validate( @_, { query => 0, sort => 0, max => 0 } ); | |||||||||||||||||||
| 226 | |||||||||||||||||||||
| 227 | return WWW::Ohloh::API::Projects->new( | ||||||||||||||||||||
| 228 | ohloh => $self, | ||||||||||||||||||||
| 229 | query => $arg{query}, | ||||||||||||||||||||
| 230 | sort => $arg{sort}, | ||||||||||||||||||||
| 231 | max => $arg{max}, | ||||||||||||||||||||
| 232 | 1 | ); | |||||||||||||||||||
| 233 | } | ||||||||||||||||||||
| 234 | |||||||||||||||||||||
| 235 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 236 | |||||||||||||||||||||
| 237 | sub fetch_analysis { | ||||||||||||||||||||
| 238 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
fetch_analysis: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 239 | 0 | my $project = shift; | |||||||||||||||||||
| 240 | |||||||||||||||||||||
| 241 | 0 | ▶ | $_[0] ||= 'latest'; | ||||||||||||||||||
|
Condition0%0/2
$_[0] ||= "latest"
MC/DC0%0/1
$_[0] ||= "latest"
$_[0]
Truth table0%0/2
A
A= $_[0]
| |||||||||||||||||||||
| 242 | |||||||||||||||||||||
| 243 | 0 | my ( $url, $xml ) = | |||||||||||||||||||
| 244 | $self->_query_server("projects/$project/analyses/$_[0].xml"); | ||||||||||||||||||||
| 245 | |||||||||||||||||||||
| 246 | 0 | my $analysis = WWW::Ohloh::API::Analysis->new( | |||||||||||||||||||
| 247 | request_url => $url, | ||||||||||||||||||||
| 248 | xml => $xml->findnodes('analysis[1]'), | ||||||||||||||||||||
| 249 | ); | ||||||||||||||||||||
| 250 | |||||||||||||||||||||
| 251 | 0 | ▶ | unless ( $analysis->project_id == $project ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 252 | 0 | croak "analysis $_[0] doesn't apply to project $project"; | |||||||||||||||||||
| 253 | } | ||||||||||||||||||||
| 254 | |||||||||||||||||||||
| 255 | 0 | return $analysis; | |||||||||||||||||||
| 256 | } | ||||||||||||||||||||
| 257 | |||||||||||||||||||||
| 258 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 259 | |||||||||||||||||||||
| 260 | sub fetch_languages { | ||||||||||||||||||||
| 261 | 1 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
fetch_languages: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 262 | 1 | my %arg = @_; | |||||||||||||||||||
| 263 | |||||||||||||||||||||
| 264 | return WWW::Ohloh::API::Languages->new( | ||||||||||||||||||||
| 265 | ohloh => $self, | ||||||||||||||||||||
| 266 | ( sort => $arg{sort} ) x !!$arg{sort}, | ||||||||||||||||||||
| 267 | 1 | ); | |||||||||||||||||||
| 268 | } | ||||||||||||||||||||
| 269 | |||||||||||||||||||||
| 270 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 271 | |||||||||||||||||||||
| 272 | sub fetch_language { | ||||||||||||||||||||
| 273 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
fetch_language: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 274 | 0 | my $id = shift; | |||||||||||||||||||
| 275 | |||||||||||||||||||||
| 276 | 0 | my ( $url, $xml ) = $self->_query_server("languages/$id.xml"); | |||||||||||||||||||
| 277 | |||||||||||||||||||||
| 278 | 0 | return WWW::Ohloh::API::Language->new( | |||||||||||||||||||
| 279 | request_url => $url, | ||||||||||||||||||||
| 280 | xml => $xml->findnodes('language[1]'), | ||||||||||||||||||||
| 281 | ); | ||||||||||||||||||||
| 282 | |||||||||||||||||||||
| 283 | } | ||||||||||||||||||||
| 284 | |||||||||||||||||||||
| 285 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 286 | |||||||||||||||||||||
| 287 | sub fetch_activity_facts { | ||||||||||||||||||||
| 288 | 1 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
fetch_activity_facts: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 289 | 1 | my ( $project, $analysis ) = | |||||||||||||||||||
| 290 | validate_pos( @_, 1, { default => 'latest' }, ); | ||||||||||||||||||||
| 291 | |||||||||||||||||||||
| 292 | 1 | return WWW::Ohloh::API::ActivityFacts->new( | |||||||||||||||||||
| 293 | ohloh => $self, | ||||||||||||||||||||
| 294 | project => $project, | ||||||||||||||||||||
| 295 | analysis => $analysis, | ||||||||||||||||||||
| 296 | ); | ||||||||||||||||||||
| 297 | } | ||||||||||||||||||||
| 298 | |||||||||||||||||||||
| 299 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 300 | |||||||||||||||||||||
| 301 | sub _ua { | ||||||||||||||||||||
| 302 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
_ua: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 303 | 0 | my $ua; | |||||||||||||||||||
| 304 | 0 | ▶ | unless ( $ua = $user_agent_of[$$self] ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 305 | 0 | $ua = $user_agent_of[$$self] = LWP::UserAgent->new; | |||||||||||||||||||
| 306 | 0 | $ua->agent($useragent_signature); | |||||||||||||||||||
| 307 | } | ||||||||||||||||||||
| 308 | 0 | return $ua; | |||||||||||||||||||
| 309 | } | ||||||||||||||||||||
| 310 | |||||||||||||||||||||
| 311 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 312 | |||||||||||||||||||||
| 313 | sub _parser { | ||||||||||||||||||||
| 314 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
_parser: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 315 | 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
| |||||||||||||||||||||
| 316 | } | ||||||||||||||||||||
| 317 | |||||||||||||||||||||
| 318 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||
| 319 | |||||||||||||||||||||
| 320 | sub _query_server { | ||||||||||||||||||||
| 321 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
_query_server: not called CC=8 SCAR=42.8
| |||||||||||||||||||||
| 322 | 0 | my $url = shift; | |||||||||||||||||||
| 323 | 0 | ▶ | my %param = $_[0] ? %{ $_[0] } : (); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 324 | |||||||||||||||||||||
| 325 | 0 | ▶ | if ( $url !~ /^http/ ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 326 | 0 | ▶ | $param{api_key} = $self->get_api_key | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 327 | or croak "api key not configured"; | ||||||||||||||||||||
| 328 | |||||||||||||||||||||
| 329 | 0 | $param{v} = $api_version_of[$$self]; | |||||||||||||||||||
| 330 | |||||||||||||||||||||
| 331 | 0 | $url = $OHLOH_URL . $url; | |||||||||||||||||||
| 332 | |||||||||||||||||||||
| 333 | 0 | $url .= '?' . join '&', map { "$_=$param{$_}" } keys %param; | |||||||||||||||||||
| 334 | } | ||||||||||||||||||||
| 335 | |||||||||||||||||||||
| 336 | 0 | ▶ | warn "querying ohloh server with $url" if $debugging[$$self]; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 337 | |||||||||||||||||||||
| 338 | # TODO: beef up here for failures | ||||||||||||||||||||
| 339 | 0 | my $request = HTTP::Request->new( GET => $url ); | |||||||||||||||||||
| 340 | 0 | my $response = $self->_ua->request($request); | |||||||||||||||||||
| 341 | |||||||||||||||||||||
| 342 | 0 | ▶ | unless ( $response->is_success ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 343 | 0 | croak "http query to Ohloh server failed: " . $response->status_line; | |||||||||||||||||||
| 344 | } | ||||||||||||||||||||
| 345 | |||||||||||||||||||||
| 346 | 0 | my $result = $response->content; | |||||||||||||||||||
| 347 | |||||||||||||||||||||
| 348 | 0 | ▶ | my $dom = eval { $self->_parser->parse_string($result) } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 349 | or croak "server didn't feed back valid xml: $@"; | ||||||||||||||||||||
| 350 | |||||||||||||||||||||
| 351 | 0 | ▶ | if ( $dom->findvalue('/response/status/text()') ne 'success' ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 352 | 0 | croak "query to Ohloh server failed: ", | |||||||||||||||||||
| 353 | $dom->findvalue('/response/status/text()'); | ||||||||||||||||||||
| 354 | } | ||||||||||||||||||||
| 355 | |||||||||||||||||||||
| 356 | 0 | return $url, $dom->findnodes('/response/result[1]'); | |||||||||||||||||||
| 357 | } | ||||||||||||||||||||
| 358 | |||||||||||||||||||||
| 359 | 16 | 1; # Magic true value required at end of module | |||||||||||||||||||
| 360 | |||||||||||||||||||||
| 361 | __END__ | ||||||||||||||||||||
| 362 | |||||||||||||||||||||
| 363 | =head1 NAME | ||||||||||||||||||||
| 364 | |||||||||||||||||||||
| 365 | WWW::Ohloh::API - Ohloh API implementation | ||||||||||||||||||||
| 366 | |||||||||||||||||||||
| 367 | =head1 SYNOPSIS | ||||||||||||||||||||
| 368 | |||||||||||||||||||||
| 369 | use WWW::Ohloh::API; | ||||||||||||||||||||
| 370 | |||||||||||||||||||||
| 371 | my $ohloh = WWW::Ohloh::API->new( api_key => $my_api_key ); | ||||||||||||||||||||
| 372 | my $account = $ohloh->fetch_account( 12933 ); | ||||||||||||||||||||
| 373 | |||||||||||||||||||||
| 374 | print $account->name; | ||||||||||||||||||||
| 375 | |||||||||||||||||||||
| 376 | =head1 DESCRIPTION | ||||||||||||||||||||
| 377 | |||||||||||||||||||||
| 378 | This module is a Perl interface to the Ohloh API as defined at | ||||||||||||||||||||
| 379 | http://www.ohloh.net/api/getting_started. | ||||||||||||||||||||
| 380 | |||||||||||||||||||||
| 381 | =head1 METHODS | ||||||||||||||||||||
| 382 | |||||||||||||||||||||
| 383 | =head2 new( [ api_key => $api_key ] ) | ||||||||||||||||||||
| 384 | |||||||||||||||||||||
| 385 | Create a new WWW::Ohloh::API object. To be able to retrieve information | ||||||||||||||||||||
| 386 | from the Ohloh server, an api key must be either passed to the constructor | ||||||||||||||||||||
| 387 | or set via the L<set_api_key> method. | ||||||||||||||||||||
| 388 | |||||||||||||||||||||
| 389 | my $ohloh = WWW::Ohloh::API->new( api_key => $your_key ); | ||||||||||||||||||||
| 390 | |||||||||||||||||||||
| 391 | =head2 fetch_account( $account_id ) | ||||||||||||||||||||
| 392 | |||||||||||||||||||||
| 393 | Return the account associated with the $account_id as a | ||||||||||||||||||||
| 394 | L<WWW::Ohloh::API::Account> | ||||||||||||||||||||
| 395 | object. If no such account exists, an error is thrown. | ||||||||||||||||||||
| 396 | The $accound_id can either be specified as the Ohloh id number, | ||||||||||||||||||||
| 397 | or the email address associated with the account. | ||||||||||||||||||||
| 398 | |||||||||||||||||||||
| 399 | my $account = $ohloh->fetch_account( 12933 ); | ||||||||||||||||||||
| 400 | my $other_accound = $ohloh->fetch_account( 'foo@bar.com' ); | ||||||||||||||||||||
| 401 | |||||||||||||||||||||
| 402 | |||||||||||||||||||||
| 403 | =head2 fetch_project( $id ) | ||||||||||||||||||||
| 404 | |||||||||||||||||||||
| 405 | Return the project having the Ohloh id I<$id> as a | ||||||||||||||||||||
| 406 | L<WWW::Ohloh::API::Project>. If no such project exists, | ||||||||||||||||||||
| 407 | an error is thrown. | ||||||||||||||||||||
| 408 | |||||||||||||||||||||
| 409 | my $project = $ohloh->fetch_project( 1234) ; | ||||||||||||||||||||
| 410 | print $project->name; | ||||||||||||||||||||
| 411 | |||||||||||||||||||||
| 412 | =head2 fetch_projects( query => $query, sort => $sorting_order, max => $nbr ) | ||||||||||||||||||||
| 413 | |||||||||||||||||||||
| 414 | Return a set of projects as a L<WWW::Ohloh::API::Projects> object. | ||||||||||||||||||||
| 415 | |||||||||||||||||||||
| 416 | =head3 Parameters | ||||||||||||||||||||
| 417 | |||||||||||||||||||||
| 418 | =over | ||||||||||||||||||||
| 419 | |||||||||||||||||||||
| 420 | =item query | ||||||||||||||||||||
| 421 | |||||||||||||||||||||
| 422 | If provided, only the projects matching the query string are returned. | ||||||||||||||||||||
| 423 | A project matches the query string is any of its name, description | ||||||||||||||||||||
| 424 | or tags does. | ||||||||||||||||||||
| 425 | |||||||||||||||||||||
| 426 | =item sort | ||||||||||||||||||||
| 427 | |||||||||||||||||||||
| 428 | If provided, the projects will be returned according to the specified | ||||||||||||||||||||
| 429 | sorting order. Valid values are | ||||||||||||||||||||
| 430 | 'created_at', 'description', 'id', 'name', 'stack_count', | ||||||||||||||||||||
| 431 | 'updated_at', 'created_at_reverse', | ||||||||||||||||||||
| 432 | 'description_reverse', 'id_reverse', 'name_reverse', | ||||||||||||||||||||
| 433 | 'stack_count_reverse' or 'updated_at_reverse'. If no sorting order | ||||||||||||||||||||
| 434 | is explicitly given, 'id' is the default. | ||||||||||||||||||||
| 435 | |||||||||||||||||||||
| 436 | =item max | ||||||||||||||||||||
| 437 | |||||||||||||||||||||
| 438 | If given, the project set will returns at most I<$nbr> projects. | ||||||||||||||||||||
| 439 | |||||||||||||||||||||
| 440 | # get top ten stacked projects | ||||||||||||||||||||
| 441 | my @top = $ohloh->fetch_projects( max => 10, sort => 'stack_count' )->all; | ||||||||||||||||||||
| 442 | |||||||||||||||||||||
| 443 | =back | ||||||||||||||||||||
| 444 | |||||||||||||||||||||
| 445 | =head2 fetch_languages( sort => $order ) | ||||||||||||||||||||
| 446 | |||||||||||||||||||||
| 447 | Return the languages known to Ohloh a set of L<WWW::Ohloh::API::Language> | ||||||||||||||||||||
| 448 | objects. | ||||||||||||||||||||
| 449 | |||||||||||||||||||||
| 450 | An optional I<sort> parameter can be passed to the method. The valid | ||||||||||||||||||||
| 451 | I<$order>s it accepts are | ||||||||||||||||||||
| 452 | C<total>, C<code>, C<projects>, C<comment_ratio>, | ||||||||||||||||||||
| 453 | C<contributors>, C<commits> and C<name>. If I<sort> is not explicitly called, | ||||||||||||||||||||
| 454 | projects are returned in alphabetical order of C<name>s. | ||||||||||||||||||||
| 455 | |||||||||||||||||||||
| 456 | =head2 fetch_activity_facts( $project_id, $analysis ) | ||||||||||||||||||||
| 457 | |||||||||||||||||||||
| 458 | Return a set of activity facts computed out of the project associated | ||||||||||||||||||||
| 459 | with the I<$project_id> as a L<WWW::Ohloh::API::ActivityFacts> object. | ||||||||||||||||||||
| 460 | |||||||||||||||||||||
| 461 | The optional argument I<$analysis> can be either an Ohloh analysis id | ||||||||||||||||||||
| 462 | (which must be an analysis associated to the project) or the keyword | ||||||||||||||||||||
| 463 | 'latest'. By default the latest analysis will be queried. | ||||||||||||||||||||
| 464 | |||||||||||||||||||||
| 465 | =head2 fetch_contributor_language_facts( project_id => $p_id, contributor_id => $c_id ) | ||||||||||||||||||||
| 466 | |||||||||||||||||||||
| 467 | my @facts = $ohloh->fetch_contributor_language_facts( | ||||||||||||||||||||
| 468 | project_id => 1234, | ||||||||||||||||||||
| 469 | contributor_id => 5678 | ||||||||||||||||||||
| 470 | ); | ||||||||||||||||||||
| 471 | |||||||||||||||||||||
| 472 | Return the list of contributor language facts associated to the | ||||||||||||||||||||
| 473 | contributor I<$c_id> for the project I<$p_id>. | ||||||||||||||||||||
| 474 | |||||||||||||||||||||
| 475 | =head2 fetch_enlistments( project_id => $id ) | ||||||||||||||||||||
| 476 | |||||||||||||||||||||
| 477 | Returns the list of enlistements pertaining to the | ||||||||||||||||||||
| 478 | given project as an L<WWW::Ohloh::API::Enlistment> object. | ||||||||||||||||||||
| 479 | |||||||||||||||||||||
| 480 | my $enlistments = $ohloh->fetch_enlistments( project_id => 1234 ); | ||||||||||||||||||||
| 481 | |||||||||||||||||||||
| 482 | while ( my $enlistment = $enlistments->next ) { | ||||||||||||||||||||
| 483 | # do stuff with $enlistment... | ||||||||||||||||||||
| 484 | } | ||||||||||||||||||||
| 485 | |||||||||||||||||||||
| 486 | =head2 fetch_size_facts( $project_id, $analysis_id ) | ||||||||||||||||||||
| 487 | |||||||||||||||||||||
| 488 | Return the list of L<WWW::Ohloh::API::SizeFact> objects pertaining to the | ||||||||||||||||||||
| 489 | given project and analysis. If I<$analysis_id> is not provided, it defaults | ||||||||||||||||||||
| 490 | to the latest analysis done on the project. | ||||||||||||||||||||
| 491 | |||||||||||||||||||||
| 492 | =head2 fetch_project_stacks( $project_id ) | ||||||||||||||||||||
| 493 | |||||||||||||||||||||
| 494 | Returns the list of stacks containing the project as | ||||||||||||||||||||
| 495 | L<WWW::Ohloh::API::Stack> | ||||||||||||||||||||
| 496 | objects. | ||||||||||||||||||||
| 497 | |||||||||||||||||||||
| 498 | =head2 fetch_account_stack( $account_id ) | ||||||||||||||||||||
| 499 | |||||||||||||||||||||
| 500 | Returns the stack associated with the account as an | ||||||||||||||||||||
| 501 | L<WWW::Ohloh::API::Stack> object. | ||||||||||||||||||||
| 502 | |||||||||||||||||||||
| 503 | =head2 fetch_kudos( $account_id ) | ||||||||||||||||||||
| 504 | |||||||||||||||||||||
| 505 | Returns the kudos associated with the given account | ||||||||||||||||||||
| 506 | (the id can be either the numerical id or the account's | ||||||||||||||||||||
| 507 | email address) as a list of L<WWW::Ohloh::API::Kudo> objects. | ||||||||||||||||||||
| 508 | |||||||||||||||||||||
| 509 | my @kudos = $ohloh->fetch_kudos( 12345 ); | ||||||||||||||||||||
| 510 | |||||||||||||||||||||
| 511 | =head2 fetch_messages( [ account | project ] => I<$id> ) | ||||||||||||||||||||
| 512 | |||||||||||||||||||||
| 513 | Returns the messages associated to the given account or project | ||||||||||||||||||||
| 514 | as a L<WWW::Ohloh::API::Messages> object. | ||||||||||||||||||||
| 515 | |||||||||||||||||||||
| 516 | =head1 SEE ALSO | ||||||||||||||||||||
| 517 | |||||||||||||||||||||
| 518 | =over | ||||||||||||||||||||
| 519 | |||||||||||||||||||||
| 520 | =item * | ||||||||||||||||||||
| 521 | |||||||||||||||||||||
| 522 | L<WWW::Ohloh::API::Project>, | ||||||||||||||||||||
| 523 | L<WWW::Ohloh::API::Projects>, | ||||||||||||||||||||
| 524 | L<WWW::Ohloh::API::Account>, | ||||||||||||||||||||
| 525 | L<WWW::Ohloh::API::KudoScore>, | ||||||||||||||||||||
| 526 | L<WWW::Ohloh::API::Languages>, | ||||||||||||||||||||
| 527 | L<WWW::Ohloh::API::Language>. | ||||||||||||||||||||
| 528 | |||||||||||||||||||||
| 529 | =item * | ||||||||||||||||||||
| 530 | |||||||||||||||||||||
| 531 | Ohloh API reference: http://www.ohloh.net/api/getting_started | ||||||||||||||||||||
| 532 | |||||||||||||||||||||
| 533 | =item * | ||||||||||||||||||||
| 534 | |||||||||||||||||||||
| 535 | How to obtain an Ohloh API key: http://www.ohloh.net/api_keys/new | ||||||||||||||||||||
| 536 | |||||||||||||||||||||
| 537 | =back | ||||||||||||||||||||
| 538 | |||||||||||||||||||||
| 539 | =head1 VERSION | ||||||||||||||||||||
| 540 | |||||||||||||||||||||
| 541 | This document describes WWW::Ohloh::API version 1.0_1 | ||||||||||||||||||||
| 542 | |||||||||||||||||||||
| 543 | =head1 BUGS AND LIMITATIONS | ||||||||||||||||||||
| 544 | |||||||||||||||||||||
| 545 | WWW::Ohloh::API is very extremely alpha quality. It'll improve, | ||||||||||||||||||||
| 546 | but till then: I<Caveat emptor>. | ||||||||||||||||||||
| 547 | |||||||||||||||||||||
| 548 | Please report any bugs or feature requests to | ||||||||||||||||||||
| 549 | C<bug-www-ohloh-api@rt.cpan.org>, or through the web interface at | ||||||||||||||||||||
| 550 | L<http://rt.cpan.org>. | ||||||||||||||||||||
| 551 | |||||||||||||||||||||
| 552 | |||||||||||||||||||||
| 553 | =head1 AUTHOR | ||||||||||||||||||||
| 554 | |||||||||||||||||||||
| 555 | Yanick Champoux C<< <yanick@cpan.org> >> | ||||||||||||||||||||
| 556 | |||||||||||||||||||||
| 557 | =head1 LICENCE AND COPYRIGHT | ||||||||||||||||||||
| 558 | |||||||||||||||||||||
| 559 | Copyright (c) 2008, Yanick Champoux C<< <yanick@cpan.org> >>. All rights reserved. | ||||||||||||||||||||
| 560 | |||||||||||||||||||||
| 561 | This module is free software; you can redistribute it and/or | ||||||||||||||||||||
| 562 | modify it under the same terms as Perl itself. See L<perlartistic>. | ||||||||||||||||||||
| 563 | |||||||||||||||||||||