Sha256: e5d26edb1f9c99add3c8afba4305a0b28362098da0eaff9514b666eb47027918

Contents?: true

Size: 1.4 KB

Versions: 80

Compression:

Stored size: 1.4 KB

Contents

require 'yaml'

module VCR
  class Cassette
    class Serializers
      # The Syck serializer. Syck is the legacy YAML engine in ruby 1.8 and 1.9.
      #
      # @see JSON
      # @see Psych
      # @see YAML
      module Syck
        extend self
        extend EncodingErrorHandling

        # @private
        ENCODING_ERRORS = [ArgumentError]

        # The file extension to use for this serializer.
        #
        # @return [String] "yml"
        def file_extension
          "yml"
        end

        # Serializes the given hash using Syck.
        #
        # @param [Hash] hash the object to serialize
        # @return [String] the YAML string
        def serialize(hash)
          handle_encoding_errors do
            using_syck { ::YAML.dump(hash) }
          end
        end

        # Deserializes the given string using Syck.
        #
        # @param [String] string the YAML string
        # @return [Hash] the deserialized object
        def deserialize(string)
          handle_encoding_errors do
            using_syck { ::YAML.load(string) }
          end
        end

      private

        def using_syck
          return yield unless defined?(::YAML::ENGINE)
          original_engine = ::YAML::ENGINE.yamler
          ::YAML::ENGINE.yamler = 'syck'

          begin
            yield
          ensure
            ::YAML::ENGINE.yamler = original_engine
          end
        end
      end
    end
  end
end

Version data entries

80 entries across 80 versions & 9 rubygems

Version Path
cloudsmith-api-0.49.118 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/serializers/syck.rb
cloudsmith-api-0.49.98 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/serializers/syck.rb
cloudsmith-api-0.49.94 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/serializers/syck.rb
cloudsmith-api-0.49.21 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/serializers/syck.rb
cloudsmith-api-0.49.15 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/serializers/syck.rb
cloudsmith-api-0.49.13 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/serializers/syck.rb
cloudsmith-api-0.49.9 vendor/bundle/ruby/2.3.0/gems/vcr-3.0.3/lib/vcr/cassette/serializers/syck.rb
vcr-5.1.0 lib/vcr/cassette/serializers/syck.rb
cloudsmith-api-0.44.4 vendor/bundle/ruby/2.3.0/gems/vcr-3.0.3/lib/vcr/cassette/serializers/syck.rb
dadapush_client-1.0.1 vendor/bundle/ruby/2.3.0/gems/vcr-3.0.3/lib/vcr/cassette/serializers/syck.rb
vcr-5.0.0 lib/vcr/cassette/serializers/syck.rb
cloudsmith-api-0.30.7 vendor/bundle/ruby/2.3.0/gems/vcr-3.0.3/lib/vcr/cassette/serializers/syck.rb
color_me_shop-1.0.0 vendor/bundle/ruby/2.5.0/gems/vcr-3.0.3/lib/vcr/cassette/serializers/syck.rb
cloudsmith-api-0.21.4 vendor/bundle/ruby/2.3.0/gems/vcr-3.0.3/lib/vcr/cassette/serializers/syck.rb
vcr-4.0.0 lib/vcr/cassette/serializers/syck.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/vcr-3.0.3/lib/vcr/cassette/serializers/syck.rb
logstash-input-salesforce-3.0.0 vendor/jruby/1.9/gems/vcr-3.0.3/lib/vcr/cassette/serializers/syck.rb
vcr-3.0.3 lib/vcr/cassette/serializers/syck.rb
vcr-3.0.2 lib/vcr/cassette/serializers/syck.rb
dwolla_swagger-1.0.6 vendor/bundle/ruby/2.2.0/gems/vcr-2.9.3/lib/vcr/cassette/serializers/syck.rb