17 |
|
|
18 |
=head1 VERSION |
=head1 VERSION |
19 |
|
|
20 |
Version 0.07 |
Version 0.08 |
21 |
|
|
22 |
=cut |
=cut |
23 |
|
|
24 |
our $VERSION = '0.07'; |
our $VERSION = '0.08'; |
25 |
|
|
26 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
27 |
|
|
169 |
} |
} |
170 |
|
|
171 |
|
|
172 |
=head2 generate_marc |
=head2 have_rules |
173 |
|
|
174 |
my $do_marc = $parser->generate_marc($database, $input); |
my $do_marc = $parser->have_rules('marc', $database, $input); |
175 |
|
my $do_index = $parser->have_rules('search', $database); |
176 |
|
|
177 |
This function will return hash containing count of all found C<marc_*> directives. |
This function will return hash containing count of all found C<marc_*> or |
178 |
|
C<search> directives. Input name is optional. |
179 |
|
|
180 |
=cut |
=cut |
181 |
|
|
182 |
sub generate_marc { |
sub have_rules { |
183 |
my $self = shift; |
my $self = shift; |
184 |
my ($database,$input) = @_; |
|
185 |
|
my $log = $self->_get_logger(); |
186 |
|
my $type = shift @_ || $log->logconfess("need at least type"); |
187 |
|
my $database = shift @_ || $log->logconfess("database is required"); |
188 |
|
my $input = shift @_; |
189 |
|
|
190 |
$input = _input_name($input); |
$input = _input_name($input); |
191 |
return unless ( |
|
192 |
defined( $self->{_generate_marc}->{ _q($database) } ) && |
|
193 |
defined( $self->{_generate_marc}->{ _q($database) }->{ _q($input) } ) |
return unless defined( $self->{_have_rules}->{ _q($database) } ); |
194 |
); |
|
195 |
return $self->{_generate_marc}->{ _q($database) }->{ _q($input) }; |
my $database_rules = $self->{_have_rules}->{ _q($database ) }; |
196 |
|
|
197 |
|
if (defined($input)) { |
198 |
|
|
199 |
|
return unless ( |
200 |
|
defined( $database_rules->{ _q($input) } ) && |
201 |
|
defined( $database_rules->{ _q($input) }->{ $type } ) |
202 |
|
); |
203 |
|
|
204 |
|
return $database_rules->{ _q($input) }->{ $type }; |
205 |
|
} |
206 |
|
|
207 |
|
my $usage; |
208 |
|
|
209 |
|
foreach my $i (keys %{ $database_rules }) { |
210 |
|
next unless defined( $database_rules->{$i}->{$type} ); |
211 |
|
|
212 |
|
foreach my $t (keys %{ $database_rules->{ $i }->{$type} }) { |
213 |
|
$usage->{ $t } += $database_rules->{ $i }->{ $t }; |
214 |
|
} |
215 |
|
} |
216 |
|
|
217 |
|
return $usage; |
218 |
|
|
219 |
} |
} |
220 |
|
|
221 |
|
|
420 |
my ($Document,$Element) = @_; |
my ($Document,$Element) = @_; |
421 |
|
|
422 |
$Element->isa('PPI::Token::Word') or return ''; |
$Element->isa('PPI::Token::Word') or return ''; |
423 |
$Element->content =~ m/^marc/ or return ''; |
if ($Element->content =~ m/^(marc|search)/) { |
424 |
|
my $what = $1; |
425 |
$log->debug("found marc output generation for $database/$input"); |
$log->debug("found $what rules in $database/$input"); |
426 |
$self->{_generate_marc}->{ $database }->{ $input }->{ $Element->content }++; |
$self->{_have_rules}->{ $database }->{ $input }->{ $what }->{ $Element->content }++; |
427 |
|
} else { |
428 |
|
return ''; |
429 |
|
} |
430 |
}); |
}); |
431 |
|
|
432 |
return 1; |
return 1; |