Skip to content

Instantly share code, notes, and snippets.

@tricknotes
Created October 16, 2011 13:32

Revisions

  1. tricknotes revised this gist Dec 29, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion compile-haml.watchr.rb
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@

    error_message = ''
    unless stderr.eof?
    error_message << stderr.gets
    error_message << stderr.to_a.join
    end

    unless error_message.empty?
  2. tricknotes revised this gist Dec 25, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion compile-haml.watchr.rb
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@
    end

    File.open("./dist/#{md[1]}.html", 'w') do |html|
    html << stdout.stdout.to_a.join
    html << stdout.to_a.join
    end
    system "growlnotify", "-t", md[0], "-m", "Compiled successfully."
    end
  3. tricknotes revised this gist Dec 25, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion compile-haml.watchr.rb
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@
    end

    File.open("./dist/#{md[1]}.html", 'w') do |html|
    html << stdout.gets unless stdout.eof?
    html << stdout.stdout.to_a.join
    end
    system "growlnotify", "-t", md[0], "-m", "Compiled successfully."
    end
  4. tricknotes revised this gist Dec 25, 2011. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions compile-haml.watchr.rb
    Original file line number Diff line number Diff line change
    @@ -6,15 +6,15 @@
    error_message = ''
    unless stderr.eof?
    error_message << stderr.gets
    end
    end

    unless error_message.empty?
    system "growlnotify", "-t", md[0], "-m", error_message
    next
    end
    end

    File.open("./dist/#{md[1]}.html", 'w') do |html|
    html << stdout.gets unless stdout.eof?
    end
    end
    system "growlnotify", "-t", md[0], "-m", "Compiled successfully."
    end
  5. tricknotes created this gist Oct 16, 2011.
    20 changes: 20 additions & 0 deletions compile-haml.watchr.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    require "open3"

    watch('(.*)\.haml') do |md|
    stdin, stdout, stderr = Open3.popen3("haml #{md[0]}")

    error_message = ''
    unless stderr.eof?
    error_message << stderr.gets
    end

    unless error_message.empty?
    system "growlnotify", "-t", md[0], "-m", error_message
    next
    end

    File.open("./dist/#{md[1]}.html", 'w') do |html|
    html << stdout.gets unless stdout.eof?
    end
    system "growlnotify", "-t", md[0], "-m", "Compiled successfully."
    end