Sha256: 99527429a52867c433cbe8abc21a6efcd6207edd76d85cc452f177cefff09566

Contents?: true

Size: 878 Bytes

Versions: 1

Compression:

Stored size: 878 Bytes

Contents

require 'logi/logger'

require 'fileutils'

class Logi; end
class Logi::Compiler
  include Logi::Logger

  attr_reader :options
  def initialize options={}
    @options = options
  end

  def compile command, path, layout
    log_compile(command, path, layout)
    wiki = IO.popen("logi-wiki #{path}", 'r')
    out  = IO.popen("logi-#{command} #{path} #{layout}", 'r+')
    IO.copy_stream(wiki, out)
    out.close_write
    out
  end

  def write output, out
    log_write(output)
    FileUtils.mkdir_p(File.dirname(output))
    IO.copy_stream(out, output)
  ensure
    out.close
  end

  private
  def log_compile command, path, layout
    w = red('logi-wiki')
    c = red("logi-#{command}")
    p = magenta(strip_path(path))
    l = yellow(strip_path(layout))
    log "#{w} #{p} |\n#{c} #{p} #{l}"
  end

  def log_write path
    log "> #{green(strip_path(path))}"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logi-0.1.0 lib/logi/compiler.rb