Sha256: 6eac85968b6dd68dcd7783098786010e76057fbc70827f4d5f1ce2d482fc2dd5

Contents?: true

Size: 1.15 KB

Versions: 14

Compression:

Stored size: 1.15 KB

Contents

LEXT = ".lt3"

  def stale?(src, dst, force = false)
    log!(enter: __method__, args: [src, dst])
    raise "Source #{src} not found in #{Dir.pwd}" unless File.exist?(src)
    return true if force
    return true unless File.exist?(dst)
    return true if File.mtime(src) > File.mtime(dst)
    return false
  end

  def xlate(cwd: Dir.pwd, src:, 
            dst: (strip = true; src.sub(/.lt3$/,"")), 
            copy: nil, debug: false, force: false)
    src += LEXT unless src.end_with?(LEXT)
    dst += ".html" unless dst.end_with?(".html") || strip
    indent = " "*12
    Dir.chdir(cwd) do
      if debug
        STDERR.puts "#{indent} -- xlate #{src} >#{dst}"
        STDERR.puts "#{indent}      in:   #{Dir.pwd}"
        STDERR.puts "#{indent}      from: #{caller[0]}"
        STDERR.puts "#{indent}      copy: #{copy}" if copy
      end
      if stale?(src, dst, force)
        # do nothing
      else
        STDERR.puts "#{indent} -- ^ Already up to date!" if debug
        return
      end
      rc = system!("livetext #{src} >#{dst}")
      STDERR.puts "...completed (shell returned #{rc})" if debug
      system!("cp #{dst} #{copy}") if copy
    end
  end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
runeblog-0.2.38 lib/xlate.rb
runeblog-0.2.37 lib/xlate.rb
runeblog-0.2.36 lib/xlate.rb
runeblog-0.2.35 lib/xlate.rb
runeblog-0.2.34 lib/xlate.rb
runeblog-0.2.33 lib/xlate.rb
runeblog-0.2.32 lib/xlate.rb
runeblog-0.2.31 lib/xlate.rb
runeblog-0.2.30 lib/xlate.rb
runeblog-0.2.29 lib/xlate.rb
runeblog-0.2.28 lib/xlate.rb
runeblog-0.2.27 lib/xlate.rb
runeblog-0.2.26 lib/xlate.rb
runeblog-0.2.25 lib/xlate.rb