diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-07 23:18:27 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-07 23:18:27 +0000 |
commit | 646b6995362aff14abfc08db24d091d01f5879d0 (patch) | |
tree | 43f1a48002803da9017b4de247c6fb7d23238a59 /ext | |
parent | 3a185ede69ac5845aebbde38dc8e6fbe4f64308a (diff) | |
download | ruby-646b6995362aff14abfc08db24d091d01f5879d0.tar.gz |
* ext/psych/lib/psych/visitors/yaml_tree.rb (push): adding version
and header emit options.
* test/psych/test_psych.rb: corresponding test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/psych/lib/psych/visitors/yaml_tree.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb index 5f757e9e1b..8a12086458 100644 --- a/ext/psych/lib/psych/visitors/yaml_tree.rb +++ b/ext/psych/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 |