Module: VCR::Cassette::Serializers::Psych
- Extended by:
- EncodingErrorHandling, Psych, VCR::Cassette::SyntaxErrorHandling
- 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]
- SYNTAX_ERRORS =
[::Psych::SyntaxError]
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
Methods included from VCR::Cassette::SyntaxErrorHandling
Instance Method Details
#deserialize(string) ⇒ Hash
Deserializes the given string using Psych.
45 46 47 48 49 50 51 |
# File 'lib/vcr/cassette/serializers/psych.rb', line 45 def deserialize(string) handle_encoding_errors do handle_syntax_errors do ::Psych.load(string) end end end |
#file_extension ⇒ String
The file extension to use for this serializer.
25 26 27 |
# File 'lib/vcr/cassette/serializers/psych.rb', line 25 def file_extension "yml" end |
#serialize(hash) ⇒ String
Serializes the given hash using Psych.
33 34 35 36 37 38 39 |
# File 'lib/vcr/cassette/serializers/psych.rb', line 33 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 |