]>
Dogcows Code - chaz/homebank2ledger/blob - Formatter.pm
3113ecb8781a0e6f9e7375c78d2e303060da26cc
1 package App
::HomeBank2Ledger
::Formatter
;
2 # ABSTRACT: Abstract class for formatting a ledger
9 use Module
::Pluggable search_path
=> [__PACKAGE__
],
10 sub_name
=> 'available_formatters';
12 our $VERSION = '0.001'; # VERSION
14 sub _croak
{ require Carp
; Carp
::croak
(@_) }
21 my $package = __PACKAGE__
;
23 if ($class eq $package and my $type = $args{type
}) {
25 for my $formatter ($class->available_formatters) {
26 next if lc($formatter) ne lc("${package}::${type}");
31 _croak
('Invalid formatter type') if $class eq $package;
34 return bless {%args}, $class;
43 sub type
{ shift-
>{type
} }
44 sub name
{ shift-
>{name
} }
45 sub file
{ shift-
>{file
} }
46 sub account_width
{ shift-
>{account_width
} || 40 }
58 App::HomeBank2Ledger::Formatter - Abstract class for formatting a ledger
66 my $formatter = App::HomeBank2Ledger::Formatter->new(
69 print $formatter->format($ledger);
73 This class formats L<ledger data|App::HomeBank2Ledger::Ledger> as for a file.
79 Get the type of formatter.
83 Get the name or title of the ledger.
87 Get the filepath where the ledger data came from.
91 Get the number of characters to use for the account column.
97 $formatter = App::HomeBank2Ledger::Formatter->new(type => $format);
99 Construct a new formatter object.
103 $str = $formatter->format($ledger);
105 Do the actual formatting of ledger data into a serialized form.
107 This must be overridden by subclasses.
115 L<App::HomeBank2Ledger::Formatter::Beancount>
119 L<App::HomeBank2Ledger::Formatter::Ledger>
125 Please report any bugs or feature requests on the bugtracker website
126 L<https://github.com/chazmcgarvey/homebank2ledger/issues>
128 When submitting a bug or request, please include a test-file or a
129 patch to an existing test-file that illustrates the bug or desired
134 Charles McGarvey <chazmcgarvey@brokenzipper.com>
136 =head1 COPYRIGHT AND LICENSE
138 This software is Copyright (c) 2019 by Charles McGarvey.
140 This is free software, licensed under:
142 The MIT (X11) License
This page took 0.036554 seconds and 3 git commands to generate.