| 1 | package WWW::Ohloh::API::Language; | ||||||||||
| 2 | 30 | our $AUTHORITY = 'cpan:YANICK'; | |||||||||
| 3 | |||||||||||
| 4 | 30 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 30 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 30 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 30 | ▶ | use Object::InsideOut; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 30 | ▶ | use XML::LibXML; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 30 | our $VERSION = '1.0_1'; | |||||||||
| 12 | |||||||||||
| 13 | 0 | ▶ | use overload '""' => sub { $_[0]->nice_name }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
__ANON__: not called CC=1 SCAR=0.2
| |||||||||||
| 14 | |||||||||||
| 15 | 30 | my @request_url_of : Field : Arg(request_url) : Get( request_url ); | |||||||||
| 16 | 30 | my @xml_of : Field : Arg(xml); | |||||||||
| 17 | 30 | my @ohloh_of : Field : Arg(ohloh); | |||||||||
| 18 | |||||||||||
| 19 | 30 | my @api_fields = qw/ | |||||||||
| 20 | id | ||||||||||
| 21 | name | ||||||||||
| 22 | nice_name | ||||||||||
| 23 | category | ||||||||||
| 24 | code | ||||||||||
| 25 | comments | ||||||||||
| 26 | blanks | ||||||||||
| 27 | comment_ratio | ||||||||||
| 28 | projects | ||||||||||
| 29 | contributors | ||||||||||
| 30 | commits | ||||||||||
| 31 | /; | ||||||||||
| 32 | |||||||||||
| 33 | 30 | my @id_of : Field : Set(_set_id) : Get(id); | |||||||||
| 34 | 30 | my @name_of : Field : Set(_set_name) : Get(name); | |||||||||
| 35 | 30 | my @nice_name_of : Field : Set(_set_nice_name) : Get(nice_name); | |||||||||
| 36 | 30 | my @category_of : Field : Set(_set_category) : Get(category); | |||||||||
| 37 | 30 | my @lines_of_code_of : Field : Set(_set_code) : Get(code); | |||||||||
| 38 | 30 | my @comments_of : Field : Set(_set_comments) : Get(comments); | |||||||||
| 39 | 30 | my @comment_ratio_of : Field : Set(_set_comment_ratio) : Get(comment_ratio); | |||||||||
| 40 | 30 | my @blanks_of : Field : Set(_set_blanks) : Get(blanks); | |||||||||
| 41 | 30 | my @projects_of : Field : Set(_set_projects) : Get(projects); | |||||||||
| 42 | 30 | my @contributors_of : Field : Set(_set_contributors) : Get(contributors); | |||||||||
| 43 | 30 | my @commits_of : Field : Set(_set_commits) : Get(commits); | |||||||||
| 44 | |||||||||||
| 45 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 46 | |||||||||||
| 47 | 32 | ▶ | sub _init : Init { | ||||||||
|
Subroutine
_init: called CC=2 SCAR=6.9
| |||||||||||
| 48 | 32 | my $self = shift; | |||||||||
| 49 | |||||||||||
| 50 | 32 | ▶ | my $dom = $xml_of[$$self] or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | |||||||||||
| 52 | 32 | $self->_set_id( $dom->findvalue("id/text()") ); | |||||||||
| 53 | 32 | $self->_set_name( $dom->findvalue("name/text()") ); | |||||||||
| 54 | 32 | $self->_set_nice_name( $dom->findvalue("nice_name/text()") ); | |||||||||
| 55 | 32 | $self->_set_category( $dom->findvalue("category/text()") ); | |||||||||
| 56 | 32 | $self->_set_code( $dom->findvalue("code/text()") ); | |||||||||
| 57 | 32 | $self->_set_comments( $dom->findvalue("comments/text()") ); | |||||||||
| 58 | 32 | $self->_set_blanks( $dom->findvalue("blanks/text()") ); | |||||||||
| 59 | 32 | $self->_set_comment_ratio( $dom->findvalue("comment_ratio/text()") ); | |||||||||
| 60 | 32 | $self->_set_projects( $dom->findvalue("projects/text()") ); | |||||||||
| 61 | 32 | $self->_set_contributors( $dom->findvalue("contributors/text()") ); | |||||||||
| 62 | 32 | $self->_set_commits( $dom->findvalue("commits/text()") ); | |||||||||
| 63 | 30 | ▶ | } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 64 | |||||||||||
| 65 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 66 | |||||||||||
| 67 | 0 | ▶ | sub as_xml { | ||||||||
|
Subroutine
as_xml: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 68 | 0 | my $self = shift; | |||||||||
| 69 | 0 | my $xml; | |||||||||
| 70 | 0 | my $w = XML::Writer->new( OUTPUT => \$xml ); | |||||||||
| 71 | |||||||||||
| 72 | 0 | $w->startTag('language'); | |||||||||
| 73 | |||||||||||
| 74 | 0 | for my $e (@api_fields) { | |||||||||
| 75 | 0 | $w->dataElement( $e => $self->$e ); | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | 0 | $w->endTag; | |||||||||
| 79 | |||||||||||
| 80 | 0 | return $xml; | |||||||||
| 81 | } | ||||||||||
| 82 | |||||||||||
| 83 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 84 | |||||||||||
| 85 | 0 | ▶ | sub is_code { | ||||||||
|
Subroutine
is_code: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 86 | 0 | my $self = shift; | |||||||||
| 87 | |||||||||||
| 88 | 0 | return $self->category eq 'code'; | |||||||||
| 89 | } | ||||||||||
| 90 | |||||||||||
| 91 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 92 | |||||||||||
| 93 | 0 | ▶ | sub is_markup { | ||||||||
|
Subroutine
is_markup: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 94 | 0 | my $self = shift; | |||||||||
| 95 | |||||||||||
| 96 | 0 | return $self->category eq 'markup'; | |||||||||
| 97 | } | ||||||||||
| 98 | |||||||||||
| 99 | 30 | 'end of WWW::Ohloh::API::Language'; | |||||||||
| 100 | |||||||||||
| 101 | __END__ | ||||||||||