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