blib/lib/URI/jar.pm

filter: Statementstmt 87.5% 28 / 32 Branchbran 66.6% 8 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 84.6% 44 / 52 CC 7 SCAR 12.6
CC
7
Cov
82%
jar_file_uri
5.8
jar_entry_name
3.1
BEGIN
1.0
CRAP 3.5
↑ Summary
1 package URI::jar;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use base qw(URI::_generic);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 =head1 NAME
10  
11 URI::jar - Java ARchive URI
12  
13 =head1 VERSION
14  
15 version 0.02
16  
17 =cut
18  
19 4 our $VERSION = '0.02';
20  
21 =head1 SYNOPSIS
22  
23 use URI;
24 use URI::jar;
25  
26 my $jar_uri = URI->jar("jar:http://www.art-code.org/foo/bar.jar!/content/baz/zigorou.js");
27 local $\ = "\n";
28 print $jar_uri->jar_entry_name; # will print "/content/baz/zigorou.js"
29 print $jar_uri->jar_file_uri; # will print "http://www.art-code.org/foo/bar.jar"
30  
31 =head1 METHOD
32  
33 =head2 jar_entry_name()
34  
35 Return entry name in jar file.
36  
37 =cut
38  
39 6 ▶sub jar_entry_name {
Subroutine jar_entry_name: called CC=3 SCAR=11.2
Pod documented
40 6 my ($self, $jar_entry_name) = @_;
41 6 my @leaf = split(/!/, $$self);
42  
43 6 ▶ if (@leaf == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@leaf == 2) { } 6 0 6
44 6 ▶ if ($jar_entry_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($jar_entry_name) { } 2 4 6
45 2 $self->path(join("!", $leaf[0], $jar_entry_name));
46 }
47 else {
48 4 return $leaf[1];
49 }
50 }
51 else {
52 0 return;
53 }
54 }
55  
56 =head2 jar_file_uri()
57  
58 Return jar file's uri as L<URI> object.
59  
60 =cut
61  
62 8 ▶sub jar_file_uri {
Subroutine jar_file_uri: called CC=5 SCAR=17.6
Pod documented
63 8 my ($self, $jar_file_uri) = @_;
64  
65 8 my @leaf = split(/!/, $self->path);
66  
67 8 ▶ if (@leaf == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@leaf == 2) { } 8 0 8
68 8 ▶ if ($jar_file_uri) {
Branch: 1 branch
BranchTrueFalseTotal
if ($jar_file_uri) { } 2 6 8
69 2 ▶ if (UNIVERSAL::isa($jar_file_uri, "URI")) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($jar_file_uri, "URI")) 0 2 2
70 0 $jar_file_uri = $jar_file_uri->as_string;
71 }
72  
73 2 $self->path(join("!", $jar_file_uri, $leaf[1]));
74 }
75 else {
76 6 ▶ if ($leaf[0] =~ /^([^:]+)\:/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($leaf[0] =~ /^([^:]+)\:/) { } 6 0 6
77 6 return URI->new($leaf[0]);
78 }
79 else {
80 0 return URI->new($leaf[0], "file");
81 }
82 }
83 }
84 else {
85 0 return;
86 }
87 }
88  
89 =head1 AUTHOR
90  
91 Toru Yamaguchi, C<< <zigorou@cpan.org> >>
92  
93 =head1 BUGS
94  
95 Please report any bugs or feature requests to
96 C<bug-uri-jar@rt.cpan.org>, or through the web interface at
97 L<http://rt.cpan.org>. I will be notified, and then you'll automatically be
98 notified of progress on your bug as I make changes.
99  
100 =head1 COPYRIGHT & LICENSE
101  
102 Copyright 2007 Toru Yamaguchi, All Rights Reserved.
103  
104 This program is free software; you can redistribute it and/or modify it
105 under the same terms as Perl itself.
106  
107 =cut
108  
109 4 1; # End of URI::jar
↑ Summary