Sha256: e4e375223c24768102841673b4451baf3611bf37ead2ded709c22511d20c6760

Contents?: true

Size: 701 Bytes

Versions: 15

Compression:

Stored size: 701 Bytes

Contents

module WatchmonkeyCli
  class LoopbackConnection
    def initialize(id, opts = {}, &initializer)
      @id = id
      @opts = {}.merge(opts)
      # @mutex = Monitor.new
      initializer.try(:call, @opts)
    end

    def to_s
      "#<WatchmonkeyCli::LoopbackConnection:#{@id}>"
    end

    def name
      "lo:#{@id}"
    end

    def sync &block
      # @mutex.synchronize(&block)
      block.try(:call)
    end

    def exec cmd, chomp = true
      _stdin, _stdouterr, _thread = Open3.popen2e(cmd)
      _thread.join
      res = _stdouterr.read
      chomp ? res.chomp : res
    ensure
      _stdin.close rescue false
      _stdouterr.close rescue false
    end

    def close!
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
watchmonkey_cli-1.10.0 lib/watchmonkey_cli/loopback_connection.rb
watchmonkey_cli-1.9.1 lib/watchmonkey_cli/loopback_connection.rb
watchmonkey_cli-1.9.0 lib/watchmonkey_cli/loopback_connection.rb
watchmonkey_cli-1.8.6 lib/watchmonkey_cli/loopback_connection.rb
watchmonkey_cli-1.8.5 lib/watchmonkey_cli/loopback_connection.rb
watchmonkey_cli-1.8.4 lib/watchmonkey_cli/loopback_connection.rb
watchmonkey_cli-1.8.3 lib/watchmonkey_cli/loopback_connection.rb
watchmonkey_cli-1.8.2 lib/watchmonkey_cli/loopback_connection.rb
watchmonkey_cli-1.8.1 lib/watchmonkey_cli/loopback_connection.rb
watchmonkey_cli-1.8 lib/watchmonkey_cli/loopback_connection.rb
watchmonkey_cli-1.7.1 lib/watchmonkey_cli/loopback_connection.rb
watchmonkey_cli-1.7 lib/watchmonkey_cli/loopback_connection.rb
watchmonkey_cli-1.6 lib/watchmonkey_cli/loopback_connection.rb
watchmonkey_cli-1.5 lib/watchmonkey_cli/loopback_connection.rb
watchmonkey_cli-1.4 lib/watchmonkey_cli/loopback_connection.rb