Imported File#ftype spec from rubyspecs.
[rbx.git] / lib / rbyaml / dumper.rb
blob7b464258f0c6a34d593c872add41a43fcf4e1c76
1 require 'rbyaml/constants'
2 require 'rbyaml/emitter'
3 require 'rbyaml/serializer'
4 require 'rbyaml/representer'
5 require 'rbyaml/resolver'
7 module RbYAML
8   class CommonDumper
9     attr_accessor :emitter, :serializer, :representer, :resolver
10     def initialize(stream,opts={})
11       super()
12       opts = DEFAULTS.merge(opts)
13       @emitter = opts[:Emitter].new(stream,opts)
14       @resolver = opts[:Resolver].new
15       @serializer = opts[:Serializer].new(@emitter,@resolver,opts)
16       @representer = opts[:Representer].new(@serializer,opts)
17     end
18   end
19   
20   class BaseDumper < CommonDumper
21     attr_accessor 
22     def initialize(stream,opts={})
23       super(stream,DEFAULTS.merge({:Representer=>RbYAML::BaseRepresenter, :Resolver=>RbYAML::BaseResolver}).merge(opts))
24     end
25   end
26   
27   class SafeDumper < CommonDumper
28     def initialize(stream,opts={})
29       super(stream,DEFAULTS.merge({:Representer=>RbYAML::SafeRepresenter}).merge(opts))
30       super
31     end
32   end
33   
34   class Dumper < CommonDumper
35     def initialize(stream,opts={})
36       super
37     end
38   end
39 end