EBook-Tools

 view release on metacpan or  search on metacpan

lib/EBook/Tools/Unpack.pm  view on Meta::CPAN

determines the filename to use for the generated OPF file.  If not
specified, and the object attribute C<opffile> has somehow been
cleared (the attribute is set during L</new()>), it will be generated
by looking at the C<textfile> argument.  If no value can be found, the
method croaks.  If a value was found somewhere other than the object
attribute C<opffile>, then the object attribute is updated to match.

=item * C<textfile> (optional)

The file containing the main text of the document.  If specified, the
method will attempt to split metadata out of the file and add whatever
remains to the manifest of the OPF.

=item * C<mediatype> (optional)

The media type (mime type) of the document specified via C<textfile>.
If C<textfile> is not specified, this argument is ignored.  If C<textfile> is specified, but

=back

=cut

scripts/ebook.pl  view on Meta::CPAN

    {
        print {*STDERR} "No metadata block was found in '",$infile,"'\n";
        exit(EXIT_BADINPUT);
    }

    $ebook = EBook::Tools->new($opffile);
    $ebook->fix_oeb12 if($opt{oeb12});
    $ebook->fix_opf20 if($opt{opf20});
    $ebook->fix_mobi if($opt{mobi});

    # The split metadata never includes manifest/spine info, so add in the
    # HTML file now
    $ebook->add_document($infile,'item-maintext');
    $ebook->fix_misc;
    $ebook->save;

    if($ebook->errors)
    {
        $ebook->print_errors;
        $ebook->print_warnings if($ebook->warnings);
        exit(EXIT_TOOLSERROR);

t/50-user_scripts.t  view on Meta::CPAN


# ebook splitmeta
unlink('containsmetadata.opf');
$exitval = system('perl','-I../lib',
                  '../scripts/ebook.pl','splitmeta','containsmetadata.html');
$exitval >>= 8;
is($exitval,0,'ebook splitmeta generates right return value');
ok(-f 'containsmetadata.opf','ebook splitmeta created containsmetadata.opf');

ok($ebook = EBook::Tools->new('containsmetadata.opf'),
   'split metadata parsed successfully');
is($ebook->title,'A Noncompliant OPF Test Sample',
   'split metadata has correct title');
is(@rights = $ebook->rights,1,'split metadata contains dc:rights');
is($rights[0],"Copyright \x{00A9} 2008 by Zed Pobre",
   'split metadata has correct rights (HTML entity handled)');

########## CLEANUP ##########

unlink('containsmetadata.html');
unlink('containsmetadata.opf');
unlink('containsmetadata.opf.backup');
unlink('emptyuid.opf');
unlink('emptyuid.opf.backup');
unlink('mimetype');
unlink('missingfwid.opf');



( run in 1.235 second using v1.01-cache-2.11-cpan-71847e10f99 )