I assume that most of the types under YAML::Syck are supposed to be impleme=
ntation details, right?

Assuming this is correct, some of those types are actually used by existing=
 Ruby code, mainly with YAML.quick_emit. In the real-world Ruby snippet bel=
ow, the Ruby code uses YAML::Syck in two ways:

1.       It passes an instance of YAML::Syck::Emitter as an argument to YAM=
L.quick_parse

2.       It calls YAML::Syck::Out#map.

require "yaml"

class B
  def to_yaml emitter
    YAML.quick_emit(object_id, emitter) do |out|
      out.map("tag:ruby.yaml.org,2002:object:B", to_yaml_style) do |map|
        map.add("b_attr", "some value")
      end
    end
  end
end

If you look at the extended version of the code at the end (also at http://=
gist.github.com/79760# with color coding), you will see the details of the =
types of the values used in the snippet. Given that existing Ruby code deal=
s with some parts of YAML::Syck, its not clear what is left as an implement=
ation detail, and what is required by the spec.

It seems like YAML::Syck::Emitter and YAML::Syck::Out should both include (=
new) modules like YAML::BaseEmitter and YAML::BaseOutputter which will have=
 the formal API that all Ruby implementations need to support. The pattern =
would be the same as YAML::Syck::Map including YAML::BaseNode today. Does t=
his sound right, and if so, should I open a bug to track this issue for Rub=
y 1.9?

Also, YAML::Syck::Emitter and YAML::Syck::Out have a number of methods. I h=
ave not seen any uses of these methods, but I havent really used yaml much =
either. Does anyone know if any of these other methods are actually used by=
 Ruby code?

Thanks,
Shri


require "yaml"

class A
  def initialize
    @b =3D B.new
  end
end

class B
  def to_yaml emitter
    puts emitter.class # YAML::Syck::Emitter
    puts emitter.class.ancestors.inspect # [YAML::Syck::Emitter, Object, Ke=
rnel]
    puts (emitter.methods - Object.new.methods).sort.inspect # ["emit", "le=
vel", "level=3D", "node_export", "reset", "set_resolver"]

    YAML.quick_emit(object_id, emitter) do |out|
      puts out.class # YAML::Syck::Out
      puts out.class.ancestors.inspect # [YAML::Syck::Out, Object, Kernel]
      puts (out.methods - Object.new.methods).sort.inspect # ["emitter", "e=
mitter=3D", "map", "scalar", "seq"]

      out.map("tag:ruby.yaml.org,2002:object:B", to_yaml_style) do |map|
        puts map.class # YAML::Syck::Map
        puts map.class.ancestors.inspect # [YAML::Syck::Map, YAML::Syck::No=
de, YAML::BaseNode, Object, Kernel]
        puts (map.methods - Object.new.methods).sort.inspect # ...

        map.add("b_attr", "some value")
      end
    end
  end
end

a =3D A.new
a.to_yaml