Sha256: bbedec0634976d7ae8c1f0c3619f2ac91fa48bd301db5e2210e3b3329adf7b5c

Contents?: true

Size: 756 Bytes

Versions: 1

Compression:

Stored size: 756 Bytes

Contents

module Guard
  class Interactor

    attr_reader :locked

    def initialize
      @locked = false
    end

    def start
      return if ENV["GUARD_ENV"] == 'test'
      Thread.new do
        loop do
          if (entry = $stdin.gets) && !@locked
            entry.gsub! /\n/, ''
            case entry
            when 'stop', 'quit', 'exit', 's', 'q', 'e'
              ::Guard.stop
            when 'reload', 'r', 'z'
              ::Guard.reload
            when 'pause', 'p'
              ::Guard.pause
            else
              ::Guard.run_all
            end
          end
        end
      end
    end

    def lock
      @locked = true
    end

    def unlock
      @locked = false
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
guard-0.7.0 lib/guard/interactor.rb