Class: YDoc::HtmlBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/appcom-ydoc-ruby/html/html_builder.rb

Instance Method Summary collapse

Constructor Details

#initializeHtmlBuilder

Returns a new instance of HtmlBuilder.



8
9
# File 'lib/appcom-ydoc-ruby/html/html_builder.rb', line 8

def initialize
end

Instance Method Details

#to_html(file_or_directory, output_directory, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/appcom-ydoc-ruby/html/html_builder.rb', line 11

def to_html file_or_directory, output_directory, options = {}
  abort 'Pandoc command is not available. Make sure it is installed and added to the path' unless find_executable('pandoc')
  is_file = File.file?(file_or_directory) && File.exists?(file_or_directory)
  is_directory = File.directory?(file_or_directory) && File.exists?(file_or_directory)

  options = load_config(options[:config]) || options

  if is_file
    file_to_html file_or_directory, output_directory, options
  elsif is_directory
    Dir["#{file_or_directory}/*.md"].each { |file| file_to_html file, output_directory, options }
  end
end