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 SCAR 13.9
CC
4
Cov
100%
getService
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
↑ 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.03
15  
16 =cut
17  
18 2 our $VERSION = '1.03';
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  
39 # IDevelop
40 'bill2myprint' => 'https://ofrf.epfl.ch',
41 'elements' => 'https://epfl-idevelop.github.io/elements',
42 'epfl-news' => 'https://actu.epfl.ch',
43 'epfl-theme-elements' => 'https://web2018.epfl.ch',
44 'homepage' => 'https://homepage.epfl.ch',
45 'homepage-archiveweb.epfl.ch' => 'https://archiveweb.epfl.ch',
46 'kis-mobile' => 'http://m.epfl.ch',
47 'kis-bootstrap' => 'https://static.epfl.ch',
48 'memento' => 'https://memento.epfl.ch',
49 'polyblog' => 'https://blogs.epfl.ch',
50 'polywiki' => 'https://wiki.epfl.ch',
51 'press-release' => 'https://rdp.epfl.ch',
52 'science-cruise-data-management' => 'https://scdm.epfl.ch',
53 'site-diffusion-mediatheque' => 'https://mediatheque.epfl.ch',
54 'web2010' => 'https://www.epfl.ch',
55 );
56  
57 2 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
58 2 our @EXPORT_OK = qw( getService );
59  
60 =head1 SUBROUTINES/METHODS
61  
62 =head2 getService( $repository )
63  
64 Return the EPFL website (service) associated with the Git repository or undef.
65  
66 =cut
67  
68 sub getService {
69 4 ▶ my $repository = shift;
Subroutine getService: called CC=4 SCAR=13.9
Pod documented
70 4 ▶ return if not defined $repository;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $repository 1 3 4
71  
72 3 my @parts = split /\//xms, $repository;
73 3 my $gitName = $parts[-1];
74 3 ▶ return if not defined $gitName;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $gitName 1 2 3
75  
76 2 @parts = split /[.]/xms, $gitName;
77 2 pop @parts;
78 2 my $projectName = join q{.}, @parts;
79  
80 2 ▶ if ( $REPOSITORY_LIST{$projectName} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($REPOSITORY_LIST{$projectName}) 1 1 2
81 1 return $REPOSITORY_LIST{$projectName};
82 }
83 1 return;
84 }
85  
86 =head1 AUTHOR
87  
88 William Belle, C<< <william.belle at gmail.com> >>
89  
90 =head1 BUGS AND LIMITATIONS
91  
92 Please report any bugs or feature requests here L<https://github.com/epfl-devrun/epfl-service-open/issues>.
93 I will be notified, and then you'll automatically be notified of progress on
94 your bug as I make changes.
95  
96 =head1 SUPPORT
97  
98 You can find documentation for this module with the perldoc command.
99  
100 perldoc EPFL::Service::Open
101  
102 You can also look for information at:
103  
104 =over 4
105  
106 =item * AnnoCPAN: Annotated CPAN documentation
107  
108 L<http://annocpan.org/dist/EPFL-Service-Open>
109  
110 =item * CPAN Ratings
111  
112 L<http://cpanratings.perl.org/d/EPFL-Service-Open>
113  
114 =item * Search CPAN
115  
116 L<http://search.cpan.org/dist/EPFL-Service-Open/>
117  
118 =back
119  
120 =head1 LICENSE AND COPYRIGHT
121  
122 Original work Copyright ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE,
123 Switzerland, VPSI, 2018.
124  
125 Modified work Copyright William Belle, 2018.
126  
127 Licensed under the Apache License, Version 2.0 (the "License");
128 you may not use this file except in compliance with the License.
129 You may obtain a copy of the License at
130  
131 L<http://www.apache.org/licenses/LICENSE-2.0>
132  
133 Unless required by applicable law or agreed to in writing, software
134 distributed under the License is distributed on an "AS IS" BASIS,
135 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
136 See the License for the specific language governing permissions and
137 limitations under the License.
138  
139 =cut
140  
141 2 1;
↑ Summary