Dezi::Utils - utility variables and methods
use Dezi::Utils; my $ext = Dezi::Utils->get_file_ext( $filename ); my $mime = Dezi::Utils->get_mime( $filename ); if (Dezi::Utils->looks_like_gz( $filename )) { $mime = Dezi::Utils->get_real_mime( $filename ); } my $parser = Dezi::Utils->get_parser_for_mime( $mime );
This class provides commonly used variables and methods shared by many classes in the Dezi project.
Regular expression of common file type extensions.
Hash of MIME types to their equivalent parser. This hash is used to cache lookups in get_parser_for_mime(). You really don't want to mess with this, but documented in case you're brave or foolish.
Defaults to html.
html
Defaults to text/html.
text/html
Returns MIME type for url, using optional swish3 instance to look it up. If swish3 is missing, will use the SWISH::3 default mapping.
Backcompat for SWISH::Prog::Utils. Use get_mime() instead, which is what this does internally.
Returns the SWISH::3 parser type for mime. This can be configured via the %ParserTypes class variable.
%ParserTypes
Backcompat for SWISH::Prog::Utils. Use get_parser_for_mime() instead, which is what this does internally.
Returns array of path, file and extension using the File::Basename module. If regex is missing or false, uses $ExtRE.
The SWISH::3 class currently does not allow for modification of the internal C structs from Perl space. Instead, the SWISH::3::Config->merge method can be used to parse XML strings. Since hand-crafting XML is tedious, this method eases the pain.
key should be a SWISH::3::Config reserved word. Use the SWISH::3::Constants for safety.
value is passed through perl_to_xml(). If value is a hashref, it should be a simple key/value set with strings. You may use arrayref values, where items in the array are strings.
The optional swish3 object is modified, or the internal singleton SWISH::3 object will be modified if swish3 is missing.
Example:
use SWISH::3 qw( :constants ); $utils->merge_swish3_config( SWISH_PARSERS() => { 'XML' => [ 'application/x-bar', 'application/x-foo' ], 'HTML' => [ 'application/x-blue', 'application/x-red' ] } ); $utils->merge_swish3_config( 'foo' => 'bar' ); $utils->get_parser_for_mime( 'application/x-foo' ); # returns 'XML'
Returns the class singleton.
Similar to the XML::Simple XMLout() feature, perl_to_xml() will take a Perl data structure ref and convert it to XML, using root_element as the top-level element.
As of version 0.38 this method is now part of Search::Tools and included here simply as a backcompat feature.
Logging method. By default writes to stderr via warn().
args is a key/value pair hash, with keys uri and msg.
Writes char x width to stderr, to provide some visual separation when viewing logs. char defaults to - and width to 80.
-
80
Peter Karman, <karpet@dezi.org>
Please report any bugs or feature requests to bug-dezi-app at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dezi-App. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-dezi-app at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Dezi::Utils
You can also look for information at:
Website
http://dezi.org/
IRC
#dezisearch at freenode
Mailing list
https://groups.google.com/forum/#!forum/dezi-search
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dezi-App
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Dezi-App
CPAN Ratings
http://cpanratings.perl.org/d/Dezi-App
Search CPAN
https://metacpan.org/dist/Dezi-App/
Copyright 2018 by Peter Karman
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
http://dezi.org/, http://swish-e.org/, http://lucy.apache.org/
To install Dezi::App, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dezi::App
CPAN shell
perl -MCPAN -e shell install Dezi::App
For more information on module installation, please visit the detailed CPAN module installation guide.