| 1 | package Shodo; | ||||||||||
| 2 | 5 | ▶ | use 5.008005; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 5 | ▶ | use Shodo::Suzuri; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 5 | ▶ | use Shodo::Hanshi; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 5 | ▶ | use Path::Tiny qw/path/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 5 | our $VERSION = "0.08"; | |||||||||
| 10 | |||||||||||
| 11 | 5 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 12 | 5 | my ($class, %args) = @_; | |||||||||
| 13 | my $self = bless { | ||||||||||
| 14 | template => $args{template}, | ||||||||||
| 15 | 5 | ▶ | document_root => $args{document_root} ? path($args{document_root}) : path('.'), | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | }, $class; | ||||||||||
| 17 | 5 | $self->{stock} = ''; | |||||||||
| 18 | 5 | $self; | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | 5 | ▶ | sub template { | ||||||||
|
Subroutine
template: called CC=2 SCAR=9.2
Pod
documented
| |||||||||||
| 22 | 5 | my ($self, $tmpl) = @_; | |||||||||
| 23 | 5 | ▶ | return $self->{template} unless $tmpl; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 0 | $self->{template} = $tmpl; | |||||||||
| 25 | 0 | return $self->{template}; | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 10 | ▶ | sub document_root { | ||||||||
|
Subroutine
document_root: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 29 | 10 | my ($self, $path) = @_; | |||||||||
| 30 | 10 | ▶ | return $self->{document_root} unless $path; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 1 | $self->{document_root} = path($path); | |||||||||
| 32 | 1 | return $self->{document_root}; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 5 | ▶ | sub new_suzuri { | ||||||||
|
Subroutine
new_suzuri: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 36 | 5 | my ($self, $description) = @_; | |||||||||
| 37 | 5 | my $hanshi = Shodo::Hanshi->new( | |||||||||
| 38 | template => $self->template, | ||||||||||
| 39 | ); | ||||||||||
| 40 | 5 | return Shodo::Suzuri->new( | |||||||||
| 41 | hanshi => $hanshi, | ||||||||||
| 42 | description => $description, | ||||||||||
| 43 | document_root => $self->document_root | ||||||||||
| 44 | ); | ||||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 5 | ▶ | sub stock { | ||||||||
|
Subroutine
stock: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 48 | 5 | my ($self, $doc) = @_; | |||||||||
| 49 | 5 | ▶ | return $self->{stock} unless $doc; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 2 | $self->{stock} .= $doc; | |||||||||
| 51 | 2 | return $self->{stock}; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 2 | ▶ | sub write { | ||||||||
|
Subroutine
write: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 55 | 2 | my ($self, $filename) = @_; | |||||||||
| 56 | 2 | ▶ | Carp::croak "Document root is not direcotry: " . $self->document_root unless( -d $self->document_root ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 2 | my $file = $self->document_root->child($filename); | |||||||||
| 58 | 2 | $file->spew_utf8( $self->stock ); | |||||||||
| 59 | 2 | $self->{stock} = ''; | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 5 | 1; | |||||||||
| 63 | __END__ | ||||||||||