Package br.com.caelum.tubaina

Examples of br.com.caelum.tubaina.BookPart


                "[section test]\nchpater 3 text", 3, sectionsManager).build();
        List<BookPart> bookParts = new BookPartsBuilder(sectionsManager).addPartFrom(partOneText)
                .addChaptersToLastAddedPart(Arrays.asList(first)).addPartFrom(partTwoText)
                .addChaptersToLastAddedPart(Arrays.asList(second, third)).build();

        BookPart partOne = bookParts.get(0);
        BookPart partTwo = bookParts.get(1);

        assertEquals(2, bookParts.size());
        assertEquals("part one", partOne.getTitle());
        assertEquals("part two", partTwo.getTitle());
        assertEquals("first", partOne.getChapters().get(0).getTitle());
        assertEquals("second", partTwo.getChapters().get(0).getTitle());
        assertEquals("third", partTwo.getChapters().get(1).getTitle());
    }
View Full Code Here


                "[section test]\nchpater 3 text", 3, sectionsManager).build();
        List<BookPart> bookParts = new BookPartsBuilder(sectionsManager).addPartFrom(partOneText)
                .addChaptersToLastAddedPart(Arrays.asList(first)).addPartFrom(partTwoText)
                .addChaptersToLastAddedPart(Arrays.asList(second, third)).build();
       
        BookPart partOne = bookParts.get(0);
        BookPart partTwo = bookParts.get(1);
       
        assertEquals(2, bookParts.size());
        assertEquals("part one", partOne.getTitle());
        assertEquals("image.png", partOne.getIllustrationPath());
        assertEquals("part two", partTwo.getTitle());
        assertEquals("first", partOne.getChapters().get(0).getTitle());
        assertEquals("second", partTwo.getChapters().get(0).getTitle());
        assertEquals("third", partTwo.getChapters().get(1).getTitle());
    }
View Full Code Here

    String content = "[part \"parte um\"]\n" + "[chapter capitulo um]\n" + "introducao do capitulo um\n"
        + "[section secao um]\n" + "conteudo da secao um";
    builder.addReaderFromString(content);
    Book b = builder.build();
    module.inject(b);
    BookPart bookPart = b.getParts().get(0);
    Chapter chapter = bookPart.getChapters().get(0);
    assertEquals("capitulo um", chapter.getTitle());
    assertEquals("secao um", chapter.getSections().get(0).getTitle());

    assertEquals("parte um", bookPart.getTitle());
    assertEquals(true, bookPart.isPrintable());
  }
View Full Code Here

    String chapter1 = "[part \"parte um\"]\n" + "[chapter capitulo um]\n" + "introducao do capitulo um\n"
        + "[section secao um]\n" + "conteudo da secao um";
    builder.addReaderFromStrings(Arrays.asList(chapter0, chapter1));
    Book b = builder.build();
    module.inject(b);
    BookPart bookPart = b.getParts().get(1);
    Chapter chapter = bookPart.getChapters().get(0);
    assertEquals("capitulo um", chapter.getTitle());
    assertEquals("secao um", chapter.getSections().get(0).getTitle());

    assertEquals("parte um", bookPart.getTitle());
    assertEquals(true, bookPart.isPrintable());

    assertEquals(false, b.getParts().get(0).isPrintable());
  }
View Full Code Here

    String content = "[part \"parte um\" illustration=resources/image.png]\n" + "[chapter capitulo um]\n"
        + "introducao do capitulo um\n" + "[section secao um]\n" + "conteudo da secao um";
    builder.addReaderFromString(content);
    Book b = builder.build();
    module.inject(b);
    BookPart bookPart = b.getParts().get(0);
    Chapter chapter = bookPart.getChapters().get(0);
    assertEquals("capitulo um", chapter.getTitle());
    assertEquals("secao um", chapter.getSections().get(0).getTitle());

    assertEquals("parte um", bookPart.getTitle());
    assertEquals(true, bookPart.isPrintable());
  }
View Full Code Here

    String content = "[chapter capitulo um label=\"label of this chapter\"]\n" + "introducao do capitulo um\n"
        + "[section secao um]\n" + "conteudo da secao um";
    builder.addReaderFromString(content);
    Book b = builder.build();
    module.inject(b);
    BookPart bookPart = b.getParts().get(0);
    Chapter chapter = bookPart.getChapters().get(0);
    assertEquals("capitulo um", chapter.getTitle());
    assertEquals("label of this chapter", chapter.getLabel());
  }
View Full Code Here

    public void testGeneratePartWithChapters() {
        Chapter chapter = createChapter("chapter title", "introduction",
                "[section section one] section content");
        List<BookPart> bookParts = new BookPartsBuilder(new SectionsManager()).addPartFrom("[part \"parte 1\"]")
                .addChaptersToLastAddedPart(Arrays.asList(chapter)).build();
        BookPart part = bookParts.get(0);
        new KindleModule().inject(part);
       
    String generatedContent = partToKindle.generateKindlePart(part,
                new TubainaHtmlDir(null, null, new KindleResourceManipulatorFactory()), 1)
                .toString();
View Full Code Here

    public void testGenerateANotPrintablePartWithChapters() {
        Chapter chapter = createChapter("chapter title", "introduction",
                "[section section one] section content");
        List<BookPart> bookParts = new BookPartsBuilder(new SectionsManager()).addChaptersToLastAddedPart(
                Arrays.asList(chapter)).build();
        BookPart part = bookParts.get(0);
        new KindleModule().inject(part);
    String generatedContent = partToKindle.generateKindlePart(part,
                new TubainaHtmlDir(null, null, new KindleResourceManipulatorFactory()), 1).toString();
        assertEquals(0, countOccurrences(generatedContent, "<h1>.*</h1>"));
        assertEquals(1, countOccurrences(generatedContent, "<h2.*>\\d+ - chapter title</h2>"));
View Full Code Here

            String introductionText = extractIntroduction(text);
            String illustrationPath = extractIllustrationPath(text);
            IntroductionChunk introChunk = new IntroductionChunk(new ChunkSplitter(partResources,
                    "all", sectionsManager).splitChunks(introductionText));

            bookParts.add(new BookPart(bookPartTitle, true, introductionText, introChunk,
                    illustrationPath, partResources));
            LOG.info("Parsing part: " + bookPartTitle);
        }
        return this;
    }
View Full Code Here

        return bookParts;
    }

    public BookPartsBuilder addChaptersToLastAddedPart(List<Chapter> parsedChapters) {
        if (bookParts.isEmpty()) {
            bookParts.add(new BookPart("", false, "", null, "", new ArrayList<Resource>()));
        }
        int lastPartIndex = bookParts.size() - 1;
        bookParts.get(lastPartIndex).addAllChapters(parsedChapters);
        return this;
    }
View Full Code Here

TOP

Related Classes of br.com.caelum.tubaina.BookPart

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.