class RemoteRuby::CachingAdapter

An adapter decorator which extends the adapter passed in to its initializer to cache stdout and stderr to local filesystem

Attributes

adapter[R]
cache_path[R]

Public Class Methods

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

Public Instance Methods

connection_name() click to toggle source
# File lib/remote_ruby/connection_adapter/caching_adapter.rb, line 12
def connection_name
  adapter.connection_name
end
open(code) { |stream_cacher, stream_cacher| ... } click to toggle source
# File lib/remote_ruby/connection_adapter/caching_adapter.rb, line 16
def open(code)
  with_cache do |stdout_cache, stderr_cache|
    adapter.open(code) do |stdout, stderr|
      yield ::RemoteRuby::StreamCacher.new(stdout, stdout_cache),
      ::RemoteRuby::StreamCacher.new(stderr, stderr_cache)
    end
  end
end

Private Instance Methods

stderr_file_path() click to toggle source
# File lib/remote_ruby/connection_adapter/caching_adapter.rb, line 43
def stderr_file_path
  "#{cache_path}.stderr"
end
stdout_file_path() click to toggle source
# File lib/remote_ruby/connection_adapter/caching_adapter.rb, line 39
def stdout_file_path
  "#{cache_path}.stdout"
end
with_cache() { |stdout_cache, stderr_cache| ... } click to toggle source
# File lib/remote_ruby/connection_adapter/caching_adapter.rb, line 29
def with_cache
  stderr_cache = File.open(stderr_file_path, 'w')
  stdout_cache = File.open(stdout_file_path, 'w')

  yield stdout_cache, stderr_cache
ensure
  stdout_cache.close
  stderr_cache.close
end