Sha256: fd01da14ce872ce1be2a67a08fa0c75820e004357aa7c84d5d47f2517e1937ab

Contents?: true

Size: 542 Bytes

Versions: 2

Compression:

Stored size: 542 Bytes

Contents

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

2 entries across 2 versions & 1 rubygems

Version Path
mado-0.2.1 lib/mado/file_handler.rb
mado-0.2.0 lib/mado/file_handler.rb