Package br.com.caelum.tubaina.builder

Examples of br.com.caelum.tubaina.builder.BookBuilder


        assertTrue("should create the index.html containing the whole book", theBookItself.exists());
    }

    @Test
    public void shouldCreateADirectoryForEachChapterThatContainsImages() throws Exception {
        BookBuilder builder = builder("Com Imagens");
        builder.addReaderFromString("[chapter Um capítulo]\n"
                + "Uma introdução com imagem: \n\n" + "[img baseJpgImage.jpg]");
        builder.addReaderFromString("[chapter Outro capítulo]\n"
                + "Uma introdução com imagem: \n\n" + "[img basePngImage.png]");
        Book imageBook = builder.build();
        new KindleModule().inject(imageBook);

        generator.generate(imageBook, tempDir);

        File firstChapter = new File(tempDir, "um-capitulo/");
View Full Code Here


        assertTrue(secondChaptersImage.exists());
    }

    @Test
    public void shouldNotCreateADirectoryChapterThatDoesntContainAnyImages() throws Exception {
        BookBuilder builder = builder("Com Imagens");
        builder.addReaderFromString("[chapter Um capítulo]\n"
                + "Uma introdução com imagem:\n");
        builder.addReaderFromString("[chapter Outro capítulo]\n"
                + "Uma introdução com imagem: \n\n" + "[img basePngImage.png]");
        Book imageBook = builder.build();
        new KindleModule().inject(imageBook);

        generator.generate(imageBook, tempDir);

        File firstChapter = new File(tempDir, "um-capitulo/");
View Full Code Here

        assertFalse(firstChapter.exists());
    }

    @Test
    public void testGeneratorWithCorrectImages() throws IOException {
        BookBuilder builder = builder("Com imagens");
        builder.addReaderFromString("[chapter qualquer um]\n"
                + "[img baseJpgImage.jpg]");
        Book b = builder.build();
        new KindleModule().inject(b);

        generator.generate(b, tempDir);
        // testar se a imagem foi copiada pro diretorio images
        File chapterDir = new File(tempDir, "qualquer-um/");
View Full Code Here

        Assert.assertTrue(copied.exists());
    }

    @Test
    public void testGeneratorWithDoubledImage() throws TubainaException, IOException {
        BookBuilder builder = builder("Com imagens");
        builder.addReaderFromString("[chapter qualquer um]\n"
                + "[img baseJpgImage.jpg]\n[img baseJpgImage.jpg]");

        Book b = builder.build();
        new KindleModule().inject(b);
        try {
            generator.generate(b, tempDir);
        } catch (TubainaException e) {
            Assert.fail("Should not complain if one uses twice the same image");
View Full Code Here

        }
    }
   
    @Test
    public void shouldCopyImagesFromIntroduction() throws IOException {
        BookBuilder builder = builder("With images in intro");
        List<AfcFile> chapterReaders = new ArrayList<AfcFile>();
        String imageName = "introImage.jpg";
        List<AfcFile> introductionReaders = Arrays.asList(new AfcFile(new StringReader("[chapter intro]\n[img " + imageName + "]"), "file from string"));
        builder.addAllReaders(chapterReaders, introductionReaders);
        Book book = builder.build();
        new KindleModule().inject(book);
        generator.generate(book, tempDir);
        File introDir = new File(tempDir, IntroductionChaptersToKindle.RESOURCES_PATH);
        File copied = new File(introDir, imageName);
View Full Code Here

        Assert.assertTrue(copied.exists());
    }

    @Test(expected = TubainaException.class)
    public void testGeneratorWithUnexistantImage() throws TubainaException, IOException {
        BookBuilder builder = builder("Com imagens");
        builder.addReaderFromString("[chapter qualquer um]\n"
                + "[img src/test/resources/someImage.gif]");
        Book b = builder.build();
        generator.generate(b, tempDir);
    }
View Full Code Here

        Book b = builder.build();
        generator.generate(b, tempDir);
    }
   
    private BookBuilder builder(String title) {
      return new BookBuilder(title, new SectionsManager());
    }
View Full Code Here

        chapterIdentifier = "class=\"indexChapter\"";
        sectionIdentifier = "class=\"indexSection\"";
        introChapterIdentifier = "class=\"chapter";
        introSectionIdentifier = "class=\"section";
        builder = new BookBuilder("Title", new SectionsManager());
    }
View Full Code Here

        SingleHtmlChapterGenerator singleHtmlChapterGenerator = new SingleHtmlChapterGenerator(parser, cfg, new ArrayList<String>());
       
        Chapter c = createChapter("introducao", "[section primeira] conteudo da primeira "
                + "\n[section segunda] conteudo da segunda");
       
        Book book = new BookBuilder("some name", new SectionsManager()).build();
        new HtmlModule().inject(book);
        new HtmlModule().inject(c);
       
    String string = singleHtmlChapterGenerator.generateSingleHtmlChapter(book, c).toString();
       
View Full Code Here

        generator = new FlatHtmlGenerator(parser, data);

        String content = "[chapter     O que é java?   ]\n" + "texto da seção\n"
                + "[section Primeira seção]\n" + "texto da prim seção\n"
                + "[section Segunda seção]\n" + "texto da segunda seção\n\n";
        BookBuilder builder = builder("livro");
        builder.addAllReadersOfNonNumberedFromStrings(Arrays.asList("[chapter introduction]\n" + "texto do prefácio\n"));
    builder.addReaderFromString(content);
        builder.addReaderFromString("[chapter Introdução]\n"
                + "Algum texto de introdução\n");
        book = builder.build();
        temp = new File("tmp");
        temp.mkdir();

    }
View Full Code Here

TOP

Related Classes of br.com.caelum.tubaina.builder.BookBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.