Sha256: 1e578114336d609c2545615601ae98ba1c3d3d7ab67fc298ff76b8701adf5cdf

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

module Softcover
  class Builder
    include Softcover::Utils

    attr_accessor :manifest, :built_files

    def initialize
      @manifest = Softcover::BookManifest.new(verify_paths: true,
                                               source: source)
      @built_files = []
      write_polytexnic_commands_file
    end

    def build!(options={})
      setup
      build(options)
      verify
      self
    end

    # Returns true if we should remove the generated PolyTeX.
    # This is true of Markdown books, but we can't just use `markdown?` because
    # we're re-using the PolyTeX production pipeline.
    def remove_polytex?
      @remove_tex
    end

    # Removes the generated PolyTeX.
    # The 'removal' actually just involves moving it to an ignored storage
    # directory. This gives users the ability to inspect it if desired.
    def remove_polytex!
      mkdir 'generated_polytex'
      FileUtils.mv(Dir.glob(path('chapters/*.tex')), 'generated_polytex')
    end

    def clean!; end

    private
      def setup; end
      def verify; end

      def source
        Dir.glob(path('chapters/*.md')).empty? ? :polytex : :markdown
      end

      # Writes out the PolyTeXnic commands from polytexnic.
      def write_polytexnic_commands_file
        Polytexnic.write_polytexnic_style_file(Dir.pwd)
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
softcover-0.6.1 lib/softcover/builder.rb
softcover-0.6.0 lib/softcover/builder.rb
softcover-0.5.0 lib/softcover/builder.rb