Module: VCR::Cassette::Serializers::Compressed
- Extended by:
- Compressed
- Included in:
- Compressed
- Defined in:
- lib/vcr/cassette/serializers/compressed.rb
Overview
The compressed serializer. This serializer wraps the YAML serializer to write compressed cassettes to disk.
Cassettes containing responses with JSON data often compress at greater than 10:1. The tradeoff is that cassettes will not diff nicely or be easily inspectable or editable.
Instance Method Summary collapse
-
#deserialize(string) ⇒ Hash
Deserializes the given compressed cassette data.
-
#file_extension ⇒ String
The file extension to use for this serializer.
-
#serialize(hash) ⇒ String
Serializes the given hash using YAML and Zlib.
Instance Method Details
#deserialize(string) ⇒ Hash
Deserializes the given compressed cassette data.
38 39 40 41 |
# File 'lib/vcr/cassette/serializers/compressed.rb', line 38 def deserialize(string) yaml = Zlib::Inflate.inflate(string) VCR::Cassette::Serializers::YAML.deserialize(yaml) end |
#file_extension ⇒ String
The file extension to use for this serializer.
21 22 23 |
# File 'lib/vcr/cassette/serializers/compressed.rb', line 21 def file_extension 'zz' end |
#serialize(hash) ⇒ String
Serializes the given hash using YAML and Zlib.
29 30 31 32 |
# File 'lib/vcr/cassette/serializers/compressed.rb', line 29 def serialize(hash) string = VCR::Cassette::Serializers::YAML.serialize(hash) Zlib::Deflate.deflate(string) end |