File Coverage

blib/lib/Lemonldap/Federation/SplitURI.pm
Criterion Covered Total %
statement 3 40 7.5
branch 0 8 0.0
condition 0 3 0.0
subroutine 1 8 12.5
pod 0 7 0.0
total 4 66 6.0


line stmt bran cond sub pod time code
1             package Lemonldap::Federation::SplitURI ;
2 1     1   963 use URI;
  1         8989  
  1         525  
3             sub new {
4 0     0 0   my $class =shift;
5 0           my %args = @_;
6 0           my $self;
7 0           $self=\%args;
8 0           my $_uri = URI->new($self->{uri} );
9 0           $self->{scheme} = $_uri->scheme;
10 0           $self->{path} = $_uri->path;
11 0           $self->{port} = $_uri->port;
12 0           $self->{host} = $_uri->host;
13 0           bless $self,$class;
14 0           $self->splitPathURI($self);
15 0           return $self;
16             }
17              
18              
19              
20             sub splitPathURI {
21 0     0 0   my $self= shift;
22              
23 0           my $string_of_path = $self->{path};
24              
25 0           my @paths;
26             my $may_rep;
27 0 0         $may_page= 1 if $string_of_path !~ /\/$/ ;
28 0           my @tmp_paths = split /\// , $string_of_path ;
29 0           shift @tmp_paths ;# the first it is root directory
30 0 0 0       if (($tmp_paths[-1]=~/\./) and ($may_page)) {
    0          
31 0           pop @tmp_paths ;
32             }
33             elsif ($may_page) { # must be tested ahead
34 0           pop @tmp_paths;
35             }
36              
37              
38 0           for my $a_path (@tmp_paths) {
39 0           push @paths , $a_path ;
40             }
41              
42 0           $self->{ref_paths} = \@paths ;
43 0           return 1;
44              
45             }
46              
47             sub get_host
48             {
49 0     0 0   my $self = shift;
50 0           return $self->{host};
51             }
52             sub get_port
53             {
54 0     0 0   my $self = shift;
55 0           return $self->{port};
56             }
57             sub get_scheme
58             {
59 0     0 0   my $self = shift;
60 0           return $self->{scheme};
61             }
62             sub get_path
63             {
64 0     0 0   my $self = shift;
65 0           return $self->{path};
66             }
67              
68             sub get_ref_array_of_path
69             {
70 0     0 0   my $self = shift;
71 0 0         if ($self->{ref_paths}) {
72 0           return $self->{ref_paths} }
73 0           else { return 0 ;
74             }
75             }
76              
77             1;
78