method

to_yaml

Importance_0
v2_1_10 - Show latest stable - 0 notes - Class: Specification
to_yaml(opts = {}) public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/rubygems/specification.rb, line 2360
  def to_yaml(opts = {}) # :nodoc:
    if YAML.const_defined?(:ENGINE) && !YAML::ENGINE.syck? then
      # Because the user can switch the YAML engine behind our
      # back, we have to check again here to make sure that our
      # psych code was properly loaded, and load it if not.
      unless Gem.const_defined?(:NoAliasYAMLTree)
        require 'rubygems/psych_tree'
      end

      builder = Gem::NoAliasYAMLTree.create
      builder << self
      ast = builder.tree

      io = Gem::StringSink.new
      io.set_encoding Encoding::UTF_8 if Object.const_defined? :Encoding

      Psych::Visitors::Emitter.new(io).accept(ast)

      io.string.gsub(/ !!null \n/, " \n")
    else
      YAML.quick_emit object_id, opts do |out|
        out.map taguri, to_yaml_style do |map|
          encode_with map
        end
      end
    end
  end
Register or log in to add new notes.