Sha256: 5cc03fdecfad156a071cb7b8a1e5f97310bf54bed4af9aa2c4d6412c81cb5c28

Contents?: true

Size: 678 Bytes

Versions: 13

Compression:

Stored size: 678 Bytes

Contents

require 'listen'
class Maid::Watch
  include Maid::RuleContainer

  attr_reader :path, :listener, :logger

  def initialize(maid, path, options = {}, &rules)
    @maid = maid
    @options = options
    @logger = maid.logger # TODO: Maybe it's better to create seperate loggers?
    @path = File.expand_path(path)
    initialize_rules(&rules)
  end

  def run
    unless rules.empty?
      @listener = Listen.to(path, @options) do |modified, added, removed|
        follow_rules(modified, added, removed)
      end
      @listener.start
    end
  end

  def stop
    @listener.stop
  end

  def join
    @listener.thread.join unless @listener.nil? || @listener.paused?
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
maid-0.8.0.alpha.1 lib/maid/watch.rb
maid-0.7.0 lib/maid/watch.rb
maid-0.7.0.beta.1 lib/maid/watch.rb
maid-0.7.0.alpha.4 lib/maid/watch.rb
maid-0.7.0.alpha.2 lib/maid/watch.rb
maid-0.7.0.alpha.1 lib/maid/watch.rb
maid-0.6.1 lib/maid/watch.rb
maid-0.6.1.alpha.1 lib/maid/watch.rb
maid-0.6.0 lib/maid/watch.rb
maid-0.6.0.beta.2 lib/maid/watch.rb
maid-0.6.0.beta.1 lib/maid/watch.rb
maid-0.6.0.alpha.6 lib/maid/watch.rb
maid-0.6.0.alpha.5 lib/maid/watch.rb