Package br.com.caelum.tubaina.builder

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


  private static void generate() throws IOException {

    ResourceLocator.initialize(inputDir);
    List<Reader> readers = getAfcsFrom(inputDir);
    BookBuilder builder = new BookBuilder(bookName);
    builder.addAll(readers);

    Book b = null;
    try {
      b = builder.build(showNotes);
    } catch (TubainaException e) {
      if (dontCare) {
        LOG.warn(e);
      } else {
        e.printStackTrace();
View Full Code Here


    ResourceLocator.initialize(path);
    data = new TubainaBuilderData(false, TubainaBuilder.DEFAULT_TEMPLATE_DIR, false, false, "teste");

    generator = new LatexGenerator(parser, data);

    BookBuilder builder = builder("livro");
    builder.addReaderFromString("[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");
    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

        }));
  }

  @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 LatexModule().inject(b);

    generator.generate(b, temp);

    File[] images = temp.listFiles(new FilenameFilter() {
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 LatexModule().inject(b);
    try {
      generator.generate(b, temp);
    } catch (TubainaException t) {
      Assert.fail("Should not raise an exception");
View Full Code Here

    // OK
  }

  @Test
  public void testGeneratorWithNonExistantImage() throws TubainaException, IOException {
    BookBuilder builder = builder("Com imagens");
    builder.addReaderFromString("[chapter qualquer um]\n" + "[img src/test/resources/someImage.gif]");
    try {
      Book b = builder.build();
      new LatexModule().inject(b);
      generator.generate(b, temp);
      Assert.fail("Should raise an exception");
    } catch (TubainaException t) {
      // OK
View Full Code Here

    List<RegexTag> tags = configurator.read("/regex.properties", "/html.properties");
    LatexParser parser = new LatexParser(tags);

    File path = new File("src/test/resources");
    ResourceLocator.initialize(path);
    BookBuilder builder = builder("Do Instrutor");
    builder.addReaderFromString("[chapter com notas]\n" + "Algo mais no capitulo.\n\n[note]uma nota para o instrutor[/note]");
    Book b = builder.build();
    new LatexModule(true, true).inject(b);
    new LatexGenerator(parser, data).generate(b, temp);
    File texFile = new File(temp, "teste.tex");
    Assert.assertTrue("Book file should exist", texFile.exists());
   
View Full Code Here

    Assert.assertTrue("Should display the note", containsText(texFile, "uma nota para o instrutor"));
  }

  @Test
  public void testGeneratorForStudentTextbook() throws IOException {
    BookBuilder builder = builder("Do Aluno");
    builder.addReaderFromString("[chapter com notas]\n" + "[note]uma nota para o instrutor[/note]");
    Book b = builder.build();
    new LatexModule(false, true).inject(b);
    generator.generate(b, temp);
    File texFile = new File(temp, "teste.tex");
    Assert.assertTrue("Book file should exist", texFile.exists());
    Assert.assertFalse("Should not have INSTRUCTOR TEXTBOOK on the first page",
View Full Code Here

    Assert.assertFalse("Should not display the note", containsText(texFile, "uma nota para o instrutor"));
  }

  @Test
  public void shouldCopyImagesFromIntroduction() throws IOException {
    BookBuilder builder = builder("With images in intro");
    List<AfcFile> chapterReaders = new ArrayList<AfcFile>();
    String imagePath = "introImage.jpg";
    List<AfcFile> introductionReaders = Arrays.asList(new AfcFile(new StringReader("[chapter intro]\n[img "
        + imagePath + "]"), "file from string"));
    builder.addAllReaders(chapterReaders, introductionReaders);
    Book b = builder.build();
    new LatexModule().inject(b);

    generator.generate(b, temp);
    File copied = new File(temp, imagePath);
View Full Code Here

    }
    return containsText;
  }
 
    private BookBuilder builder(String title) {
      return new BookBuilder(title, new SectionsManager());
    }
View Full Code Here

    List<AfcFile> afcFiles = getAfcsFrom(inputDir);
    File introductionChapterDirs = new File(inputDir, "introduction");
    if (introductionChapterDirs.exists()) {
      introductionAfcFiles = getAfcsFrom(introductionChapterDirs);
    }
    BookBuilder builder = new BookBuilder(bookName, sectionsManager);
    builder.addAllReaders(afcFiles, introductionAfcFiles);

    Book b = null;
    try {
      b = builder.build();
    } catch (TubainaException e) {
      if (dontCare) {
        LOG.warn(e);
      } else {
        throw e;
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.