File Coverage

blib/lib/WWW/Ohloh/API/Language.pm
Criterion Covered Total %
statement 21 47 44.6
branch 0 2 0.0
condition n/a
subroutine 7 12 58.3
pod 3 3 100.0
total 31 64 48.4


line stmt bran cond sub pod time code
1             package WWW::Ohloh::API::Language;
2             our $AUTHORITY = 'cpan:YANICK';
3              
4 30     30   254492 use strict;
  30         66  
  30         1115  
5 30     30   139 use warnings;
  30         53  
  30         1627  
6              
7 30     30   151 use Carp;
  30         93  
  30         1980  
8 30     30   1345 use Object::InsideOut;
  30         70142  
  30         236  
9 30     30   4080 use XML::LibXML;
  30         58038  
  30         260  
10              
11             our $VERSION = '1.0_1';
12              
13 30     30   8312 use overload '""' => sub { $_[0]->nice_name };
  30     0   81  
  30         354  
  0         0  
14              
15             my @request_url_of : Field : Arg(request_url) : Get( request_url );
16             my @xml_of : Field : Arg(xml);
17             my @ohloh_of : Field : Arg(ohloh);
18              
19             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             my @id_of : Field : Set(_set_id) : Get(id);
34             my @name_of : Field : Set(_set_name) : Get(name);
35             my @nice_name_of : Field : Set(_set_nice_name) : Get(nice_name);
36             my @category_of : Field : Set(_set_category) : Get(category);
37             my @lines_of_code_of : Field : Set(_set_code) : Get(code);
38             my @comments_of : Field : Set(_set_comments) : Get(comments);
39             my @comment_ratio_of : Field : Set(_set_comment_ratio) : Get(comment_ratio);
40             my @blanks_of : Field : Set(_set_blanks) : Get(blanks);
41             my @projects_of : Field : Set(_set_projects) : Get(projects);
42             my @contributors_of : Field : Set(_set_contributors) : Get(contributors);
43             my @commits_of : Field : Set(_set_commits) : Get(commits);
44              
45             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
46              
47             sub _init : Init {
48 0     0     my $self = shift;
49              
50 0 0         my $dom = $xml_of[$$self] or return;
51              
52 0           $self->_set_id( $dom->findvalue("id/text()") );
53 0           $self->_set_name( $dom->findvalue("name/text()") );
54 0           $self->_set_nice_name( $dom->findvalue("nice_name/text()") );
55 0           $self->_set_category( $dom->findvalue("category/text()") );
56 0           $self->_set_code( $dom->findvalue("code/text()") );
57 0           $self->_set_comments( $dom->findvalue("comments/text()") );
58 0           $self->_set_blanks( $dom->findvalue("blanks/text()") );
59 0           $self->_set_comment_ratio( $dom->findvalue("comment_ratio/text()") );
60 0           $self->_set_projects( $dom->findvalue("projects/text()") );
61 0           $self->_set_contributors( $dom->findvalue("contributors/text()") );
62 0           $self->_set_commits( $dom->findvalue("commits/text()") );
63 30     30   14091 }
  30         61  
  30         213  
64              
65             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66              
67             sub as_xml {
68 0     0 1   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             sub is_code {
86 0     0 1   my $self = shift;
87              
88 0           return $self->category eq 'code';
89             }
90              
91             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
92              
93             sub is_markup {
94 0     0 1   my $self = shift;
95              
96 0           return $self->category eq 'markup';
97             }
98              
99             'end of WWW::Ohloh::API::Language';
100              
101             __END__