module VCR::Cassette::Serializers::Compressed
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.
@see YAML
Public Instance Methods
deserialize(string)
click to toggle source
Deserializes the given compressed cassette data.
@param [String] string the compressed YAML
cassette data @return [Hash] the deserialized object
# 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()
click to toggle source
The file extension to use for this serializer.
@return [String] “gz”
# File lib/vcr/cassette/serializers/compressed.rb, line 21 def file_extension 'gz' end
serialize(hash)
click to toggle source
Serializes the given hash using YAML
and Zlib.
@param [Hash] hash the object to serialize @return [String] the compressed cassette data
# File lib/vcr/cassette/serializers/compressed.rb, line 29 def serialize(hash) string = VCR::Cassette::Serializers::YAML.serialize(hash) Zlib::Deflate.deflate(string) end