| 1 | package App::QuoteCC::Output::C; | ||
| 2 | 1 | ▶ | BEGIN { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | $App::QuoteCC::Output::C::AUTHORITY = 'cpan:AVAR'; | |
| 4 | } | ||
| 5 | 1 | ▶ | BEGIN { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | $App::QuoteCC::Output::C::VERSION = '0.10'; | |
| 7 | } | ||
| 8 | |||
| 9 | 1 | ▶ | use 5.010; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | 1 | ▶ | use Template; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 1 | ▶ | use Data::Section qw/ -setup /; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 1 | ▶ | use namespace::clean -except => [ qw/ meta merged_section_data section_data / ]; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | |||
| 17 | 1 | with qw/ App::QuoteCC::Role::Output /; | |
| 18 | |||
| 19 | 1 | has template => ( | |
| 20 | isa => 'Str', | ||
| 21 | is => 'ro', | ||
| 22 | lazy_build => 1, | ||
| 23 | documentation => "The Template template to emit", | ||
| 24 | ); | ||
| 25 | |||
| 26 | 0 | ▶ | sub _build_template { |
|
Subroutine
_build_template: not called CC=1 SCAR=6.9
| |||
| 27 | 0 | my ($self) = @_; | |
| 28 | 0 | my $template = $self->section_data( 'program' ); | |
| 29 | 0 | return $$template; | |
| 30 | } | ||
| 31 | |||
| 32 | 0 | ▶ | sub output { |
|
Subroutine
output: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 33 | 0 | my ($self) = @_; | |
| 34 | 0 | my $handle = $self->file_handle; | |
| 35 | |||
| 36 | # Get output | ||
| 37 | 0 | my $out = $self->_process_template; | |
| 38 | |||
| 39 | # Spew output | ||
| 40 | 0 | $self->spew_output($out); | |
| 41 | |||
| 42 | 0 | return; | |
| 43 | } | ||
| 44 | |||
| 45 | 0 | ▶ | sub _process_template { |
|
Subroutine
_process_template: not called CC=1 SCAR=6.9
| |||
| 46 | 0 | my ($self) = @_; | |
| 47 | 0 | my $quotes = $self->quotes; | |
| 48 | 0 | my $template = $self->template; | |
| 49 | 0 | my $out; | |
| 50 | |||
| 51 | Template->new->process( | ||
| 52 | \$template, | ||
| 53 | { | ||
| 54 | quotes => $quotes, | ||
| 55 | size => scalar(@$quotes), | ||
| 56 | 0 | ▶ | escape => sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 57 | 0 | my $text = shift; | |
| 58 | 0 | $text =~ s/"/\\"/g; | |
| 59 | 0 | my $was = $text; | |
| 60 | 0 | $text =~ s/\\(\$)/\\\\$1/g; | |
| 61 | 0 | given ($text) { | |
| 62 | 0 | when (/\n/) { | |
| 63 | 0 | return join(qq[\\n"\n], map { qq["$_] } split /\n/, $text). q["]; | |
| 64 | } | ||
| 65 | 0 | default { | |
| 66 | 0 | return qq["$text"]; | |
| 67 | } | ||
| 68 | } | ||
| 69 | }, | ||
| 70 | }, | ||
| 71 | 0 | \$out | |
| 72 | ); | ||
| 73 | |||
| 74 | 0 | return $out; | |
| 75 | } | ||
| 76 | |||
| 77 | 1 | __PACKAGE__->meta->make_immutable; | |
| 78 | |||
| 79 | =encoding utf8 | ||
| 80 | |||
| 81 | =head1 NAME | ||
| 82 | |||
| 83 | App::QuoteCC::Output::C - Emit quotes in C format | ||
| 84 | |||
| 85 | =head1 AUTHOR | ||
| 86 | |||
| 87 | E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org> | ||
| 88 | |||
| 89 | =head1 LICENSE AND COPYRIGHT | ||
| 90 | |||
| 91 | Copyright 2010 E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org> | ||
| 92 | |||
| 93 | This program is free software, you can redistribute it and/or modify | ||
| 94 | it under the same terms as Perl itself. | ||
| 95 | |||
| 96 | =cut | ||
| 97 | |||
| 98 | __DATA__ | ||