class RemoteRuby::CacheAdapter

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

Attributes

cache_path[R]

Public Class Methods

new(connection_name:, cache_path:) click to toggle source
# File lib/remote_ruby/connection_adapter/cache_adapter.rb, line 5
def initialize(connection_name:, cache_path:)
  @cache_path = cache_path
  @connection_name = connection_name
end

Public Instance Methods

connection_name() click to toggle source
# File lib/remote_ruby/connection_adapter/cache_adapter.rb, line 10
def connection_name
  "[CACHE] #{@connection_name}"
end
open(_code) { |stdout, stderr| ... } click to toggle source
# File lib/remote_ruby/connection_adapter/cache_adapter.rb, line 14
def open(_code)
  stdout = File.open(stdout_file_path, 'r')
  stderr = File.open(stderr_file_path, 'r')

  yield stdout, stderr
ensure
  stderr.close unless stderr.closed?
  stdout.close unless stdout.closed?
end

Private Instance Methods

stderr_file_path() click to toggle source
# File lib/remote_ruby/connection_adapter/cache_adapter.rb, line 33
def stderr_file_path
  fp = "#{cache_path}.stderr"
  File.exist?(fp) ? fp : File::NULL
end
stdout_file_path() click to toggle source
# File lib/remote_ruby/connection_adapter/cache_adapter.rb, line 28
def stdout_file_path
  fp = "#{cache_path}.stdout"
  File.exist?(fp) ? fp : File::NULL
end