Sha256: d94eff1408d433f8a7af86f40dc41a34b86a661c0a6b8a6f6dac742364d44e98

Contents?: true

Size: 964 Bytes

Versions: 1

Compression:

Stored size: 964 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'fileutils'

module Genit

  # Web site "compiler".
  class Compiler
  
    # Public: Constructor.
    #
    # working_dir - The String working directory, where live the project.
    def initialize working_dir
      @working_dir = working_dir
    end
  
    # Public: Compile the web site.
    def compile
      compile_pages
      FileUtils.cp_r File.join(@working_dir, 'styles'), File.join(@working_dir, 'www')
    end
    
    private
    
    def compile_pages
      Dir.foreach(File.join(@working_dir, 'pages')) do |file|
        next if (file == ".") or (file == "..")
        @filename = file
        compile_page
      end
    end
    
    def compile_page
      pc = PageCompiler.new @working_dir, @filename
      @page = pc.compile
      save_file_as_html
    end
    
    def save_file_as_html
      doc_writer = DocumentWriter.new @working_dir
      doc_writer.save_as_html @page, @filename
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
genit-0.3 lib/genit/compiler.rb