Parent

Mizuho::Generator

Public Class Methods

new(input, options = {}) click to toggle source
# File lib/mizuho/generator.rb, line 33
def initialize(input, options = {})
        @options     = options
        @input_file  = input
        @output_file = options[:output] || default_output_filename(input)
        @id_map_file = options[:id_map] || default_id_map_filename(input)
        @icons_dir   = options[:icons_dir]
        @conf_file   = options[:conf_file]
        @attributes  = options[:attributes] || []
        @enable_topbar     = options[:topbar]
        @no_run            = options[:no_run]
        @commenting_system = options[:commenting_system]
        @index             = options[:index]
        @index_filename    = options[:index_filename] || default_index_filename(input)
        if @commenting_system == 'juvia'
                require_options(options, :juvia_url, :juvia_site_key)
        end
end
run_asciidoc(input, output, icons_dir = nil, conf_file = nil, attributes = []) click to toggle source
# File lib/mizuho/generator.rb, line 77
def self.run_asciidoc(input, output, icons_dir = nil, conf_file = nil, attributes = [])
        args = [
                ASCIIDOC,
                "-b", "html5",
                "-a", "theme=flask",
                "-a", "icons",
                "-n"
        ].flatten
        if icons_dir
                args << "-a"
                args << "iconsdir=#{icons_dir}"
        end
        attributes.each do |attribute|
                args << "-a"
                args << attribute
        end
        if conf_file
                # With the splat operator we support a string and an array of strings.
                [*conf_file].each do |cf|
                        args << "-f"
                        args << cf
                end
        end
        args += ["-o", output, input]
        if !system(*args)
                raise GenerationError, "Asciidoc failed."
        end
end

Public Instance Methods

start() click to toggle source
# File lib/mizuho/generator.rb, line 51
def start
        if @commenting_system
                @id_map = IdMap.new
                if File.exist?(@id_map_file)
                        @id_map.load(@id_map_file)
                else
                        warn "No ID map file, generating one (#{@id_map_file})..."
                end
        end
        if !@no_run
                self.class.run_asciidoc(@input_file, @output_file, @icons_dir,
                        @conf_file, @attributes)
        end
        transform(@output_file)
        if @commenting_system
                @id_map.save(@id_map_file)
                stats = @id_map.stats
                if stats[:fuzzy] > 0
                        warn "Warning: #{stats[:fuzzy]} fuzzy ID(s)"
                end
                if stats[:orphaned] > 0
                        warn "Warning: #{stats[:orphaned]} unused ID(s)"
                end
        end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.