Module: VCR::Cassette::Serializers::Psych
- Extended by:
- EncodingErrorHandling, Psych
- Included in:
- Psych
- Defined in:
- lib/vcr/cassette/serializers/psych.rb
Overview
The Psych serializer. Psych is the new YAML engine in ruby 1.9.
Constant Summary collapse
- ENCODING_ERRORS =
[ArgumentError]
Instance Method Summary collapse
-
#deserialize(string) ⇒ Hash
Deserializes the given string using Psych.
-
#file_extension ⇒ String
The file extension to use for this serializer.
-
#serialize(hash) ⇒ String
Serializes the given hash using Psych.
Methods included from EncodingErrorHandling
Instance Method Details
#deserialize(string) ⇒ Hash
Deserializes the given string using Psych.
41 42 43 44 45 |
# File 'lib/vcr/cassette/serializers/psych.rb', line 41 def deserialize(string) handle_encoding_errors do ::Psych.load(string) end end |
#file_extension ⇒ String
The file extension to use for this serializer.
21 22 23 |
# File 'lib/vcr/cassette/serializers/psych.rb', line 21 def file_extension "yml" end |
#serialize(hash) ⇒ String
Serializes the given hash using Psych.
29 30 31 32 33 34 35 |
# File 'lib/vcr/cassette/serializers/psych.rb', line 29 def serialize(hash) handle_encoding_errors do result = ::Psych.dump(hash) result.gsub!(": \n", ": null\n") # set canonical null value in order to avoid trailing whitespaces result end end |