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   69062 use 5.006;
  2         14  
4 2     2   11 use strict;
  2         4  
  2         40  
5 2     2   9 use warnings;
  2         4  
  2         190  
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             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             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     2   14 use base 'Exporter';
  2         3  
  2         667  
58             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     4 1 94 my $repository = shift;
70 4 100       15 return if not defined $repository;
71              
72 3         10 my @parts = split /\//xms, $repository;
73 3         8 my $gitName = $parts[-1];
74 3 100       10 return if not defined $gitName;
75              
76 2         5 @parts = split /[.]/xms, $gitName;
77 2         4 pop @parts;
78 2         7 my $projectName = join q{.}, @parts;
79              
80 2 100       8 if ( $REPOSITORY_LIST{$projectName} ) {
81 1         7 return $REPOSITORY_LIST{$projectName};
82             }
83 1         4 return;
84             }
85              
86             =head1 AUTHOR
87              
88             William Belle, C<< >>
89              
90             =head1 BUGS AND LIMITATIONS
91              
92             Please report any bugs or feature requests here L.
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
109              
110             =item * CPAN Ratings
111              
112             L
113              
114             =item * Search CPAN
115              
116             L
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
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             1;