| 1 | package Locale::TextDomain::OO::Lexicon::Role::StoreFile; ## no critic (TidyCode) | ||||||||||||
| 2 | |||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 2 | ▶ | use Carp qw(confess); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 2 | ▶ | use English qw(-no_match_vars $OS_ERROR); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 2 | ▶ | use Moo::Role; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 2 | ▶ | use MooX::Types::MooseLike::Base qw(Str); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 2 | ▶ | use namespace::autoclean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 2 | our $VERSION = '1.017'; | |||||||||||
| 12 | |||||||||||||
| 13 | 2 | has filename => ( | |||||||||||
| 14 | is => 'ro', | ||||||||||||
| 15 | isa => Str, | ||||||||||||
| 16 | ); | ||||||||||||
| 17 | |||||||||||||
| 18 | 2 | has file_handle => ( | |||||||||||
| 19 | is => 'ro', | ||||||||||||
| 20 | ducktype => 'print', | ||||||||||||
| 21 | ); | ||||||||||||
| 22 | |||||||||||||
| 23 | 26 | ▶ | sub store_content { | ||||||||||
|
Subroutine
store_content: called CC=8 SCAR=36.4
Pod
documented
| |||||||||||||
| 24 | 26 | my ($self, $content) = @_; | |||||||||||
| 25 | |||||||||||||
| 26 | 26 | ▶ | if ( $self->file_handle ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 27 | 0 | my $quoted_filename = $self->filename; | |||||||||||
| 28 | 0 | ▶ | $quoted_filename &&= qq{"$quoted_filename"}; | ||||||||||
|
Condition0%0/2
$quoted_filename &&= qq["$quoted_filename"]
MC/DC0%0/1
$quoted_filename &&= qq["$quoted_filename"]
$quoted_filename
Truth table0%0/2
A
A= $quoted_filename
| |||||||||||||
| 29 | 0 | ▶ | $self->file_handle->print( $self->file_handle, $content ) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 30 | or confess qq{Unable to print file$quoted_filename $OS_ERROR}; | ||||||||||||
| 31 | 0 | return; | |||||||||||
| 32 | } | ||||||||||||
| 33 | 26 | ▶ | if ( $self->filename ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 34 | 0 | my $filename = $self->filename; | |||||||||||
| 35 | 0 | ▶ | open my $file_handle, q{> :raw}, $self->filename | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 36 | or confess qq{Unable to open file "$filename" $OS_ERROR}; | ||||||||||||
| 37 | 0 | ▶ | $file_handle->print($content) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 38 | or confess qq{Unable to print file "$filename" $OS_ERROR}; | ||||||||||||
| 39 | 0 | ▶ | $file_handle->close | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 40 | or confess qq{Unable to close file "$filename" $OS_ERROR}; | ||||||||||||
| 41 | 0 | return; | |||||||||||
| 42 | } | ||||||||||||
| 43 | |||||||||||||
| 44 | 26 | return $content; | |||||||||||
| 45 | } | ||||||||||||
| 46 | |||||||||||||
| 47 | 2 | 1; | |||||||||||
| 48 | |||||||||||||
| 49 | __END__ | ||||||||||||