blib/lib/EPFL/Service/Open.pm

filter: Statementstmt 100% 26 / 26 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 100% 38 / 38 CC 4 SCAR 9.2
CC
4
Cov
100%
getService
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.5
↑ Summary
1 package EPFL::Service::Open;
2  
3 2 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 2 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 2 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 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
54 2 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 ▶ my $repository = shift;
Subroutine getService: called CC=4 SCAR=13.9
Pod documented
66 4 ▶ return if not defined $repository;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $repository 1 3 4
67  
68 3 my @parts = split /\//xms, $repository;
69 3 my $gitName = $parts[-1];
70 3 ▶ return if not defined $gitName;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $gitName 1 2 3
71  
72 2 @parts = split /[.]/xms, $gitName;
73 2 pop @parts;
74 2 my $projectName = join q{.}, @parts;
75  
76 2 ▶ if ( $REPOSITORY_LIST{$projectName} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($REPOSITORY_LIST{$projectName}) 1 1 2
77 1 return $REPOSITORY_LIST{$projectName};
78 }
79 1 return;
80 }
81  
82 =head1 AUTHOR
83  
84 William Belle, C<< <william.belle at gmail.com> >>
85  
86 =head1 BUGS AND LIMITATIONS
87  
88 Please report any bugs or feature requests here L<https://github.com/epfl-devrun/epfl-service-open/issues>.
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<http://annocpan.org/dist/EPFL-Service-Open>
105  
106 =item * CPAN Ratings
107  
108 L<http://cpanratings.perl.org/d/EPFL-Service-Open>
109  
110 =item * Search CPAN
111  
112 L<http://search.cpan.org/dist/EPFL-Service-Open/>
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<http://www.apache.org/licenses/LICENSE-2.0>
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 2 1;
↑ Summary