Sha256: b3ceb7257c5a4c120d389e8642b72cf1f4fac5a5148ad287a5563006023ab6a5

Contents?: true

Size: 891 Bytes

Versions: 2

Compression:

Stored size: 891 Bytes

Contents

#!/usr/bin/env watchr

require 'pathname'
require 'rdiscount'
# --------------------------------------------------
# Helpers
# --------------------------------------------------
class ::String
  def md2html
    RDiscount.new(self).to_html
  end
  def save_as(path)
    Pathname(path).open('w') {|f| f << self }
  end
end

default_action do
  md   = Pathname('README.md').expand_path
  html = Pathname('doc/README.html').expand_path

  puts "Translating #{md.basename} (file://#{html})"
  md.read.md2html.save_as(html)
end

# --------------------------------------------------
# Watchr Rules
# --------------------------------------------------
watch( '^README\.md' )

# --------------------------------------------------
# Signal Handling
# --------------------------------------------------
# Ctrl-\
Signal.trap('QUIT') { default_action.call }

# Ctrl-C
Signal.trap('INT') { abort("\n") }

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nanotest-0.9.4.1 markdown.watchr
nanotest-0.9.4 markdown.watchr