Sha256: 87be0ac05ae87a99178ca89dc9250d2c8dd9fb87a5f8c7fc3989cf1e3055f259

Contents?: true

Size: 566 Bytes

Versions: 6

Compression:

Stored size: 566 Bytes

Contents

require "eventmachine"

module Mado
  class FileHandler < EventMachine::FileWatch
    def initialize(sockets)
      @sockets = sockets
    end

    def file_modified
      @sockets.each { |socket| socket.send(convert_markdown) } if File.exist?(path)
    end

    def file_moved
      # @sockets.each { |socket| socket.send(convert_markdown) }
    end

    def file_deleted
      @sockets.each { |socket| socket.send(convert_markdown) } if File.exist?(path)
    end

    private

    def convert_markdown
      Mado::Markdown.convert_markdown(path)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mado-0.1.1 lib/mado/file_handler.rb
mado-0.1.0 lib/mado/file_handler.rb
mado-0.0.4 lib/mado/file_handler.rb
mado-0.0.3 lib/mado/file_handler.rb
mado-0.0.2 lib/mado/file_handler.rb
mado-0.0.1 lib/mado/file_handler.rb