Class: Gollum::Export::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/gollum/export/processor.rb

Class Method Summary collapse

Class Method Details

.convert_file(source_filename, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/gollum/export/processor.rb', line 6

def self.convert_file(source_filename, options={})
  return unless source_filename =~ /\.md$/

  output_directory = options.fetch(:output_directory, nil)
  repository = options.fetch(:repository, nil)

  File.open(source_filename, 'r') do |source_file|
    File.open(target_filename(source_filename, output_directory), 'w') do |target_file|
      md_filter = HTML::Pipeline::MarkdownFilter.new(source_file.read)
      link_filter = Gollum::Export::LinkFilter.new(md_filter.call, repository)
      target_file.write(link_filter.call)
    end
  end
end