| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Modern::OpenAPI::Generator::Writer; |
|
2
|
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
109041
|
use v5.26; |
|
|
7
|
|
|
|
|
18
|
|
|
4
|
7
|
|
|
7
|
|
25
|
use strict; |
|
|
7
|
|
|
|
|
11
|
|
|
|
7
|
|
|
|
|
142
|
|
|
5
|
7
|
|
|
7
|
|
22
|
use warnings; |
|
|
7
|
|
|
|
|
18
|
|
|
|
7
|
|
|
|
|
326
|
|
|
6
|
7
|
|
|
7
|
|
26
|
use Carp qw(croak); |
|
|
7
|
|
|
|
|
15
|
|
|
|
7
|
|
|
|
|
366
|
|
|
7
|
7
|
|
|
7
|
|
33
|
use File::Path qw(make_path); |
|
|
7
|
|
|
|
|
9
|
|
|
|
7
|
|
|
|
|
329
|
|
|
8
|
7
|
|
|
7
|
|
26
|
use File::Spec (); |
|
|
7
|
|
|
|
|
1532
|
|
|
|
7
|
|
|
|
|
125
|
|
|
9
|
7
|
|
|
7
|
|
749
|
use Path::Tiny qw(path); |
|
|
7
|
|
|
|
|
11407
|
|
|
|
7
|
|
|
|
|
1704
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
|
12
|
9
|
|
|
9
|
1
|
139928
|
my ( $class, %arg ) = @_; |
|
13
|
|
|
|
|
|
|
bless { |
|
14
|
|
|
|
|
|
|
root => path( $arg{root} )->stringify, |
|
15
|
|
|
|
|
|
|
force => $arg{force} // 0, |
|
16
|
9
|
|
100
|
|
|
89
|
merge => $arg{merge} // 0, |
|
|
|
|
100
|
|
|
|
|
|
17
|
|
|
|
|
|
|
}, $class; |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub write { |
|
21
|
70
|
|
|
70
|
1
|
417
|
my ( $self, $rel, $content ) = @_; |
|
22
|
70
|
100
|
66
|
|
|
356
|
croak "Writer: empty rel" unless defined $rel && length $rel; |
|
23
|
69
|
|
|
|
|
203
|
my $full = path( $self->{root} )->child($rel); |
|
24
|
69
|
|
|
|
|
4265
|
$full->parent->mkpath( { mode => 0755 } ); |
|
25
|
|
|
|
|
|
|
|
|
26
|
69
|
100
|
100
|
|
|
14247
|
if ( -e $full && $self->{merge} && !$self->{force} ) { |
|
|
|
|
100
|
|
|
|
|
|
27
|
1
|
|
|
|
|
19
|
return; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
68
|
100
|
100
|
|
|
3188
|
if ( -e $full && !$self->{force} && !$self->{merge} ) { |
|
|
|
|
66
|
|
|
|
|
|
30
|
1
|
|
|
|
|
15
|
croak "Refusing to overwrite $full (use --force)"; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
67
|
|
|
|
|
798
|
$full->spew_utf8($content); |
|
34
|
67
|
|
|
|
|
53415
|
return $full; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |