Module: VCR::Cassette::Persisters::FileSystem
- Extended by:
- FileSystem
- Included in:
- FileSystem
- Defined in:
- lib/vcr/cassette/persisters/file_system.rb
Overview
The only built-in cassette persister. Persists cassettes to the file system.
Instance Method Summary collapse
-
#[](file_name) ⇒ String
Gets the cassette for the given storage key (file name).
-
#[]=(file_name, content) ⇒ Object
Sets the cassette for the given storage key (file name).
Instance Method Details
#[](file_name) ⇒ String
Gets the cassette for the given storage key (file name).
23 24 25 26 27 |
# File 'lib/vcr/cassette/persisters/file_system.rb', line 23 def [](file_name) path = absolute_path_to_file(file_name) return nil unless File.exist?(path) File.binread(path) end |
#[]=(file_name, content) ⇒ Object
Sets the cassette for the given storage key (file name).
33 34 35 36 37 38 |
# File 'lib/vcr/cassette/persisters/file_system.rb', line 33 def []=(file_name, content) path = absolute_path_to_file(file_name) directory = File.dirname(path) FileUtils.mkdir_p(directory) unless File.exist?(directory) File.binwrite(path, content) end |