summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-07-07 15:30:48 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-07-07 15:30:48 -0700
commitd614c02ebb946fdc9de81b5e053b2343685d279f (patch)
treeaf4e41d13ae971430596c4d2bc32a43560f68e0b /lib
parente2f8e49de26b5473d679adb9d8f91ed824a51fa9 (diff)
downloadpsych-d614c02ebb946fdc9de81b5e053b2343685d279f.zip
dump options can include header and version
Diffstat (limited to 'lib')
-rw-r--r--lib/psych/visitors/yaml_tree.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb
index 5f757e9..8a12086 100644
--- a/lib/psych/visitors/yaml_tree.rb
+++ b/lib/psych/visitors/yaml_tree.rb
@@ -13,6 +13,7 @@ module Psych
@emitter = emitter
@st = {}
@ss = ScalarScanner.new
+ @options = options
@dispatch_cache = Hash.new do |h,klass|
method = "visit_#{(klass.name || '').split('::').join('_')}"
@@ -43,7 +44,19 @@ module Psych
def push object
start unless started?
- @emitter.start_document [], [], false
+ version = []
+ version = [1,1] if @options[:header]
+
+ case @options[:version]
+ when Array
+ version = @options[:version]
+ when String
+ version = @options[:version].split('.').map { |x| x.to_i }
+ else
+ version = [1,1]
+ end if @options[:version]
+
+ @emitter.start_document version, [], false
accept object
@emitter.end_document
end