Class: RemoteRuby::CacheAdapter

Inherits:
ConnectionAdapter show all
Defined in:
lib/remote_ruby/cache_adapter.rb

Overview

An adapter which takes stdout, stderr and result streams from files and ignores all stdin. Only used to read from cache.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cache_path:, connection_name:) ⇒ CacheAdapter

Returns a new instance of CacheAdapter.



9
10
11
12
13
# File 'lib/remote_ruby/cache_adapter.rb', line 9

def initialize(cache_path:, connection_name:)
  super
  @cache_path = cache_path
  @connection_name = connection_name
end

Instance Attribute Details

#connection_nameObject (readonly)

Returns the value of attribute connection_name.



7
8
9
# File 'lib/remote_ruby/cache_adapter.rb', line 7

def connection_name
  @connection_name
end

Instance Method Details

#open(_code, _stdin, stdout, stderr) ⇒ Object



15
16
17
18
19
20
# File 'lib/remote_ruby/cache_adapter.rb', line 15

def open(_code, _stdin, stdout, stderr)
  IO.copy_stream(stdout_file_path, stdout)
  IO.copy_stream(stderr_file_path, stderr)

  File.binread(result_file_path) if result_file_path
end