1 |
package WebPAC::Output::JSON; |
2 |
|
3 |
use warnings; |
4 |
use strict; |
5 |
|
6 |
use base qw/WebPAC::Common Class::Accessor/; |
7 |
__PACKAGE__->mk_accessors(qw(path)); |
8 |
|
9 |
use Encode qw/from_to/; |
10 |
use Data::Dump qw/dump/; |
11 |
|
12 |
=head1 NAME |
13 |
|
14 |
WebPAC::Output::JSON - Create JSON output |
15 |
|
16 |
=head1 VERSION |
17 |
|
18 |
Version 0.00 |
19 |
|
20 |
=cut |
21 |
|
22 |
our $VERSION = '0.00'; |
23 |
|
24 |
=head1 SYNOPSIS |
25 |
|
26 |
Create JSON output for export into other sistems |
27 |
|
28 |
=head1 FUNCTIONS |
29 |
|
30 |
=head2 new |
31 |
|
32 |
my $output = new WebPAC::Output::JSON({ |
33 |
path => '/path/to/file.js', |
34 |
}); |
35 |
|
36 |
Options are: |
37 |
|
38 |
=over 4 |
39 |
|
40 |
=item path |
41 |
|
42 |
path to JSON file |
43 |
|
44 |
=back |
45 |
|
46 |
=head2 init |
47 |
|
48 |
$output->init; |
49 |
|
50 |
=cut |
51 |
|
52 |
sub init { |
53 |
my $self = shift; |
54 |
my $log = $self->_get_logger; |
55 |
|
56 |
$log->debug('init'); |
57 |
|
58 |
return 1; |
59 |
} |
60 |
|
61 |
|
62 |
=head2 add |
63 |
|
64 |
Adds one entry to database. |
65 |
|
66 |
$est->add( 42, $ds ); |
67 |
|
68 |
=cut |
69 |
|
70 |
sub add { |
71 |
my $self = shift; |
72 |
|
73 |
my ( $id, $ds ) = @_; |
74 |
|
75 |
my $log = $self->_get_logger; |
76 |
$log->logdie("need id") unless defined $id; |
77 |
$log->logdie("need ds") unless $ds; |
78 |
|
79 |
$log->debug("id: $id ds = ",dump($ds)); |
80 |
|
81 |
return 1; |
82 |
} |
83 |
|
84 |
=head2 finish |
85 |
|
86 |
$output->finish; |
87 |
|
88 |
=cut |
89 |
|
90 |
sub finish { |
91 |
my $self = shift; |
92 |
|
93 |
my $log = $self->_get_logger(); |
94 |
|
95 |
$log->info("finish"); |
96 |
|
97 |
} |
98 |
|
99 |
=head1 AUTHOR |
100 |
|
101 |
Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >> |
102 |
|
103 |
=head1 COPYRIGHT & LICENSE |
104 |
|
105 |
Copyright 2007 Dobrica Pavlinusic, All Rights Reserved. |
106 |
|
107 |
This program is free software; you can redistribute it and/or modify it |
108 |
under the same terms as Perl itself. |
109 |
|
110 |
=cut |
111 |
|
112 |
1; # End of WebPAC::Output::JSON |