Class: DaggerRuby::Progress::Relay

Inherits:
Object
  • Object
show all
Defined in:
lib/dagger_ruby/progress.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Relay

Returns a new instance of Relay.



16
17
18
# File 'lib/dagger_ruby/progress.rb', line 16

def initialize(path)
  @socket = UNIXSocket.new(path)
end

Class Method Details

.from_environment(environment) ⇒ Object



11
12
13
14
# File 'lib/dagger_ruby/progress.rb', line 11

def self.from_environment(environment)
  path = environment[SOCKET_ENV]
  new(path) if path
end

Instance Method Details

#closeObject



26
27
28
# File 'lib/dagger_ruby/progress.rb', line 26

def close
  @socket.close unless @socket.closed?
end

#emit(event) ⇒ Object

Raises:

  • (IOError)


20
21
22
23
24
# File 'lib/dagger_ruby/progress.rb', line 20

def emit(event)
  @socket.puts(JSON.generate(event))
  @socket.flush
  raise IOError, "Dagger Ruby progress relay disconnected" unless @socket.gets
end