File Coverage

blib/lib/EPFL/Service/Open.pm
Criterion Covered Total %
statement 22 22 100.0
branch 6 6 100.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 34 34 100.0


line stmt bran cond sub pod time code
1             package EPFL::Service::Open;
2              
3 2     2   69856 use 5.006;
  2         13  
4 2     2   13 use strict;
  2         5  
  2         40  
5 2     2   9 use warnings;
  2         4  
  2         182  
6              
7             =head1 NAME
8              
9             EPFL::Service::Open - Open the EPFL website (service) associated with the
10             Git repository.
11              
12             =head1 VERSION
13              
14             Version 1.05
15              
16             =cut
17              
18             our $VERSION = '1.05';
19              
20             =head1 SYNOPSIS
21              
22             Retrieve the EPFL website (service) associated with the Git repository.
23              
24             use EPFL::Service::Open qw( getService );
25              
26             my $serviceUrl = getService('git@github.com:epfl-idevelop/epfl-theme-elements.git');
27              
28             =head1 DESCRIPTION
29              
30             A simple module to retrieve the EPFL website (service) associated with the
31             Git repository.
32              
33             =cut
34              
35             my %REPOSITORY_LIST = (
36             'bill2myprint' => 'https://ofrf.epfl.ch',
37             'elements' => 'https://epfl-idevelop.github.io/elements',
38             'epfl-news' => 'https://actu.epfl.ch',
39             'epfl-theme-elements' => 'https://web2018.epfl.ch',
40             'homepage-archiveweb.epfl.ch' => 'https://archiveweb.epfl.ch',
41             'kis-bootstrap' => 'https://static.epfl.ch',
42             'memento' => 'https://memento.epfl.ch',
43             'polyblog' => 'https://blogs.epfl.ch',
44             'polywiki' => 'https://wiki.epfl.ch',
45             'press-release' => 'https://rdp.epfl.ch',
46             'science-cruise-data-management' => 'https://scdm.epfl.ch',
47             'site-diffusion-mediatheque' => 'https://mediatheque.epfl.ch',
48             'web2010' => 'https://www.epfl.ch/templates/',
49             );
50              
51 2     2   14 use base 'Exporter';
  2         4  
  2         718  
52             our @EXPORT_OK = qw( getService );
53              
54             =head1 SUBROUTINES/METHODS
55              
56             =head2 getService( $repository )
57              
58             Return the EPFL website (service) associated with the Git repository or undef.
59              
60             =cut
61              
62             sub getService {
63 4     4 1 89 my $repository = shift;
64 4 100       14 return if not defined $repository;
65              
66 3         10 my @parts = split /\//xms, $repository;
67 3         6 my $gitName = $parts[-1];
68 3 100       10 return if not defined $gitName;
69              
70 2         5 @parts = split /[.]/xms, $gitName;
71 2         4 pop @parts;
72 2         6 my $projectName = join q{.}, @parts;
73              
74 2 100       9 if ( $REPOSITORY_LIST{$projectName} ) {
75 1         6 return $REPOSITORY_LIST{$projectName};
76             }
77 1         4 return;
78             }
79              
80             =head1 AUTHOR
81              
82             William Belle, C<< >>
83              
84             =head1 SEE ALSO
85              
86             See L for the command line.
87              
88             =head1 BUGS AND LIMITATIONS
89              
90             Please report any bugs or feature requests here
91             L.
92             I will be notified, and then you'll automatically be notified of progress on
93             your bug as I make changes.
94              
95             =head1 SUPPORT
96              
97             You can find documentation for this module with the perldoc command.
98              
99             perldoc EPFL::Service::Open
100              
101             You can also look for information at:
102              
103             =over 4
104              
105             =item * AnnoCPAN: Annotated CPAN documentation
106              
107             L
108              
109             =item * CPAN Ratings
110              
111             L
112              
113             =item * Search CPAN
114              
115             L
116              
117             =back
118              
119             =head1 LICENSE AND COPYRIGHT
120              
121             Original work Copyright ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE,
122             Switzerland, VPSI, 2018.
123              
124             Modified work Copyright William Belle, 2018-2019.
125              
126             Licensed under the Apache License, Version 2.0 (the "License");
127             you may not use this file except in compliance with the License.
128             You may obtain a copy of the License at
129              
130             L
131              
132             Unless required by applicable law or agreed to in writing, software
133             distributed under the License is distributed on an "AS IS" BASIS,
134             WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
135             See the License for the specific language governing permissions and
136             limitations under the License.
137              
138             =cut
139              
140             1;