Sha256: 4096ac09402df5a66bb8cce5cbbdb23467fdbc9560d12cf1c2c91b5af3652926

Contents?: true

Size: 644 Bytes

Versions: 1

Compression:

Stored size: 644 Bytes

Contents

module Pieces
  class Listener
    attr_reader :path
    attr_reader :build_method
    attr_reader :force_polling

    def initialize(config = {})
      @path = config[:path] || Dir.pwd
      @build_method = config[:build_method] || :build
      @force_polling = config[:force_polling] || false
      build_pieces
    end

    def listen
      Listen.to("#{path}/config/", "#{path}/app/", force_polling: force_polling) do
        print "Rebuilding #{path}... "
        build_pieces
        puts 'done.'
      end.tap(&:start)
    end

    private

    def build_pieces
      Pieces::Builder.new(path: path).send(build_method)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pieces-0.4.2 lib/pieces/listener.rb