Class: RemoteRuby::CachingAdapter
- Inherits:
-
ConnectionAdapter
- Object
- ConnectionAdapter
- RemoteRuby::CachingAdapter
- Defined in:
- lib/remote_ruby/connection_adapter/caching_adapter.rb
Overview
An adapter decorator which extends the adapter passed in to its initializer to cache stdout and stderr to local filesystem
Instance Method Summary collapse
- #connection_name ⇒ Object
-
#initialize(cache_path:, adapter:) ⇒ CachingAdapter
constructor
A new instance of CachingAdapter.
- #open(code) ⇒ Object
Constructor Details
#initialize(cache_path:, adapter:) ⇒ CachingAdapter
Returns a new instance of CachingAdapter.
9 10 11 12 13 |
# File 'lib/remote_ruby/connection_adapter/caching_adapter.rb', line 9 def initialize(cache_path:, adapter:) super @cache_path = cache_path @adapter = adapter end |
Instance Method Details
#connection_name ⇒ Object
15 16 17 |
# File 'lib/remote_ruby/connection_adapter/caching_adapter.rb', line 15 def connection_name adapter.connection_name end |
#open(code) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/remote_ruby/connection_adapter/caching_adapter.rb', line 19 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 |