Quiq/Chrome.pm

filter: Statementstmt 55.1% 16 / 29 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 100% 1 / 1 totaltotal 55.0% 22 / 40 CC 3 SCAR 16.3
CC
3
Cov
48%
renameHtmlDownload
12.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.1
« Quiq/ChartJs/TimeSeries.pm ↑ Summary Quiq/File/Audio.pm »
1 # -----------------------------------------------------------------------------
2  
3 =encoding utf8
4  
5 =head1 NAME
6  
7 Quiq::Chrome - Operationen im Zusammenhang mit dem Chrome Browser
8  
9 =head1 BASE CLASS
10  
11 L<Quiq::Object>
12  
13 =cut
14  
15 # -----------------------------------------------------------------------------
16  
17 package Quiq::Chrome;
18 1 ▶use base qw/Quiq::Object/;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 our $VERSION = '1.240';
25  
26 1 ▶use Quiq::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 # -----------------------------------------------------------------------------
29  
30 =head1 METHODS
31  
32 =head2 Methoden
33  
34 =head3 renameHtmlDownload() - Benenne heruntergeladene HTML-Seite um
35  
36 =head4 Synopsis
37  
38 $this->renameHtmlDownload($oldName,$newName);
39  
40 =head4 Arguments
41  
42 =over 4
43  
44 =item $oldName
45  
46 Aktueller Name der HTML-Datei, die heruntergeladen wurde.
47  
48 =item $newName
49  
50 Aktueller Name der HTML-Datei, die heruntergeladen wurde.
51  
52 =back
53  
54 =head4 Description
55  
56 Wird eine HTML-Seite mit Chrome heruntergeladen
57 (C<Rechte Maustaste / Save as...>), wird diese unter dem im Download-Dialog
58 vergebenen Namen I<NAME>C<.html> abgespeichert. Zusätzlich wird ein
59 Verzeichnis I<NAME>C<_files> für die von der Seite inkludierten
60 Bestandteile angelegt.
61  
62 WICHTIG: Die Umbennung muss im aktuellen Verzeichnis stattfinden.
63  
64 =head4 Example
65  
66 $ perl -MQuiq::Chrome -E 'Quiq::Chrome->renameHtmlDownload("fehler.html","01-172667217700-zugferd-2.3.html")'
67  
68 =cut
69  
70 # -----------------------------------------------------------------------------
71  
72 0 ▶sub renameHtmlDownload {
Subroutine renameHtmlDownload: not called CC=3 SCAR=24.8
Pod documented
73 0 my ($class,$oldName,$newName) = @_;
74  
75 0 my $p = Quiq::Path->new;
76  
77 0 my $oldDir = sprintf '%s_files',$p->basename($oldName);
78 0 my $newDir = sprintf '%s_files',$p->basename($newName);
79  
80 0 ▶ if (!$p->exists($oldName)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($p->exists($oldName)) 0 0 0
81 0 $class->throw(
82 'CHROME-00099: File does not exist',
83 File => $oldName,
84 );
85 }
86  
87 0 ▶ if (!$p->exists($oldDir)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($p->exists($oldDir)) 0 0 0
88 0 $class->throw(
89 'CHROME-00099: Directory does not exist',
90 Dir => $oldDir,
91 );
92 }
93  
94 0 my $html = $p->read($oldName);
95 0 $html =~ s/$oldDir/$newDir/g;
96 0 $p->write($newName,$html);
97  
98 0 $p->rename($oldDir,$newDir);
99  
100 0 return;
101 };
102  
103 # -----------------------------------------------------------------------------
104  
105 =head1 VERSION
106  
107 1.240
108  
109 =head1 AUTHOR
110  
111 Frank Seitz, L<http://fseitz.de/>
112  
113 =head1 COPYRIGHT
114  
115 Copyright (C) 2026 Frank Seitz
116  
117 =head1 LICENSE
118  
119 This code is free software; you can redistribute it and/or modify
120 it under the same terms as Perl itself.
121  
122 =cut
123  
124 # -----------------------------------------------------------------------------
125  
126 1 1;
127  
128 # eof
« Quiq/ChartJs/TimeSeries.pm ↑ Summary Quiq/File/Audio.pm »