| 1 | package App::QuoteCC::Role::Output; | ||
| 2 | 4 | ▶ | BEGIN { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 4 | $App::QuoteCC::Role::Output::AUTHORITY = 'cpan:AVAR'; | |
| 4 | } | ||
| 5 | 4 | ▶ | BEGIN { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 4 | $App::QuoteCC::Role::Output::VERSION = '0.10'; | |
| 7 | } | ||
| 8 | |||
| 9 | 4 | ▶ | use 5.010; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 4 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 4 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 4 | ▶ | use Moose::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | 4 | ▶ | use namespace::clean -except => 'meta'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | |||
| 15 | 4 | has file => ( | |
| 16 | isa => 'Str', | ||
| 17 | is => 'ro', | ||
| 18 | documentation => 'The output file to compile to. - for STDOUT', | ||
| 19 | ); | ||
| 20 | |||
| 21 | 4 | has quotes => ( | |
| 22 | isa => 'ArrayRef[Str]', | ||
| 23 | is => 'ro', | ||
| 24 | documentation => 'The quotes to compile to', | ||
| 25 | ); | ||
| 26 | |||
| 27 | 0 | ▶ | sub file_handle { |
|
Subroutine
file_handle: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 28 | 0 | my ($self) = @_; | |
| 29 | 0 | my $file = $self->file; | |
| 30 | |||
| 31 | 0 | given ($file) { | |
| 32 | 0 | when ('-') { | |
| 33 | 0 | binmode STDOUT, ":encoding(UTF-8)"; | |
| 34 | 0 | return *STDOUT; | |
| 35 | } | ||
| 36 | 0 | default { | |
| 37 | 0 | open my $fh, '>:encoding(UTF-8)', $file; | |
| 38 | 0 | return $fh; | |
| 39 | } | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | 4 | requires 'output'; | |
| 44 | |||
| 45 | 0 | ▶ | sub spew_output { |
|
Subroutine
spew_output: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 46 | 0 | my ($self, $out) = @_; | |
| 47 | |||
| 48 | 0 | given ($self->file) { | |
| 49 | 0 | when ('-') { | |
| 50 | 0 | binmode STDOUT; | |
| 51 | 0 | print $out; | |
| 52 | } | ||
| 53 | 0 | default { | |
| 54 | 0 | open my $fh, ">", $_; | |
| 55 | 0 | binmode $fh; | |
| 56 | 0 | print $fh $out; | |
| 57 | } | ||
| 58 | } | ||
| 59 | |||
| 60 | 0 | return; | |
| 61 | } | ||
| 62 | |||
| 63 | 4 | 1; | |
| 64 | |||
| 65 | =encoding utf8 | ||
| 66 | |||
| 67 | =head1 NAME | ||
| 68 | |||
| 69 | App::QuoteCC::Role::Output - A role representing a L<App::QuoteCC> output format | ||
| 70 | |||
| 71 | =head1 AUTHOR | ||
| 72 | |||
| 73 | E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org> | ||
| 74 | |||
| 75 | =head1 LICENSE AND COPYRIGHT | ||
| 76 | |||
| 77 | Copyright 2010 E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason. | ||
| 78 | |||
| 79 | This program is free software, you can redistribute it and/or modify | ||
| 80 | it under the same terms as Perl itself. | ||
| 81 | |||
| 82 | =cut | ||
| 83 | |||