6 |
use base qw/WebPAC::Common Class::Accessor/; |
use base qw/WebPAC::Common Class::Accessor/; |
7 |
__PACKAGE__->mk_accessors(qw(path)); |
__PACKAGE__->mk_accessors(qw(path)); |
8 |
|
|
9 |
use Encode qw/from_to/; |
#use Encode qw/from_to/; |
10 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
11 |
|
use JSON; |
12 |
|
use File::Slurp; |
13 |
|
|
14 |
=head1 NAME |
=head1 NAME |
15 |
|
|
57 |
|
|
58 |
$log->debug('init'); |
$log->debug('init'); |
59 |
|
|
60 |
|
$self->{_data} = []; |
61 |
|
|
62 |
return 1; |
return 1; |
63 |
} |
} |
64 |
|
|
82 |
|
|
83 |
$log->debug("id: $id ds = ",dump($ds)); |
$log->debug("id: $id ds = ",dump($ds)); |
84 |
|
|
85 |
|
my $item; |
86 |
|
|
87 |
|
foreach my $t ( keys %$ds ) { |
88 |
|
my $name = lc($t); |
89 |
|
$name =~ s/\W+/_/g; |
90 |
|
|
91 |
|
# FIXME get rid of non hash values in data_structure for consistency? |
92 |
|
next unless ref($ds->{$t}) eq 'HASH'; |
93 |
|
|
94 |
|
if ( defined( $ds->{$t}->{display} ) ) { |
95 |
|
$item->{$name} = $ds->{$t}->{display}; |
96 |
|
} |
97 |
|
} |
98 |
|
|
99 |
|
push @{ $self->{_data} }, $item; |
100 |
|
|
101 |
return 1; |
return 1; |
102 |
} |
} |
103 |
|
|
112 |
|
|
113 |
my $log = $self->_get_logger(); |
my $log = $self->_get_logger(); |
114 |
|
|
115 |
$log->info("finish"); |
$log->info("writing JSON output to ", $self->path); |
116 |
|
write_file( $self->path, objToJson( { items => $self->{_data} } ) ); |
117 |
|
|
118 |
} |
} |
119 |
|
|