]> Dogcows Code - chaz/homebank2ledger/blobdiff - lib/App/HomeBank2Ledger/Formatter/Ledger.pm
Version 0.010
[chaz/homebank2ledger] / lib / App / HomeBank2Ledger / Formatter / Ledger.pm
index 7385165ba73be40a2975b195395c973378054338..1588bc07904a6a49e0c5bbd8b2660252d0a07318 100644 (file)
@@ -10,12 +10,13 @@ use App::HomeBank2Ledger::Util qw(commify rtrim);
 
 use parent 'App::HomeBank2Ledger::Formatter';
 
-our $VERSION = '0.009'; # VERSION
+our $VERSION = '0.010'; # VERSION
 
 my %STATUS_SYMBOLS = (
     cleared => '*',
     pending => '!',
 );
+my $SYMBOL = qr![^\s\d.,;:?\!\-+*/^&|=\<\>\[\]\(\)\{\}\@]+!;
 
 sub _croak { require Carp; Carp::croak(@_) }
 
@@ -266,6 +267,13 @@ sub _quote_string {
     return "\"$str\"";
 }
 
+sub _format_symbol {
+    my $self = shift;
+    my $str  = shift;
+    return $self->_quote_string($str) if $str !~ /^${SYMBOL}$/;
+    return $str;
+}
+
 sub _format_amount {
     my $self      = shift;
     my $amount    = shift;
@@ -280,9 +288,7 @@ sub _format_amount {
         $num .= $commodity->{dchar} . $fraction;
     }
 
-    my $symbol = $commodity->{symbol};
-    $symbol = $self->_quote_string($symbol) if $symbol =~ /[0-9\s]/;
-
+    my $symbol = $self->_format_symbol($commodity->{symbol});
     $num = $commodity->{syprf} ? "$symbol $num" : "$num $symbol";
 
     return $num;
@@ -302,7 +308,7 @@ App::HomeBank2Ledger::Formatter::Ledger - Ledger formatter
 
 =head1 VERSION
 
-version 0.009
+version 0.010
 
 =head1 DESCRIPTION
 
This page took 0.0178739999999999 seconds and 4 git commands to generate.