module VCR::Cassette::Serializers::YAML
The YAML
serializer. This will use either Psych
or Syck
, which ever your ruby interpreter defaults to. You can also force VCR
to use Psych
or Syck
by using one of those serializers.
Constants
- ENCODING_ERRORS
@private
- SYNTAX_ERRORS
@private
Public Instance Methods
deserialize(string)
click to toggle source
Deserializes the given string using YAML
.
@param [String] string the YAML
string @return [Hash] the deserialized object
# File lib/vcr/cassette/serializers/yaml.rb, line 47 def deserialize(string) handle_encoding_errors do handle_syntax_errors do if ::YAML.respond_to?(:unsafe_load) ::YAML.unsafe_load(string) else ::YAML.load(string) end end end end
file_extension()
click to toggle source
The file extension to use for this serializer.
@return [String] “yml”
# File lib/vcr/cassette/serializers/yaml.rb, line 27 def file_extension "yml" end
serialize(hash)
click to toggle source
Serializes the given hash using YAML
.
@param [Hash] hash the object to serialize @return [String] the YAML
string
# File lib/vcr/cassette/serializers/yaml.rb, line 35 def serialize(hash) handle_encoding_errors do result = ::YAML.dump(hash) result.gsub!(": \n", ": null\n") # set canonical null value in order to avoid trailing whitespaces result end end