diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-07 16:58:10 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-07 16:58:10 +0000 |
commit | a34e45fd546ac30f254237ab743120372f76935f (patch) | |
tree | 73778b242ce07f61ed0861409e473888251b056f /ext/psych/lib/psych | |
parent | 56367e25ee9ae99694a2e69f6c2de0dfa9956211 (diff) |
* ext/psych/*: update psych to 2.0.16
* test/psych/*: ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/psych/lib/psych')
-rw-r--r-- | ext/psych/lib/psych/visitors/to_ruby.rb | 3 | ||||
-rw-r--r-- | ext/psych/lib/psych/visitors/yaml_tree.rb | 34 |
2 files changed, 15 insertions, 22 deletions
diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb index ea3ab1c479..4c3591b373 100644 --- a/ext/psych/lib/psych/visitors/to_ruby.rb +++ b/ext/psych/lib/psych/visitors/to_ruby.rb @@ -330,12 +330,13 @@ module Psych list end + SHOVEL = '<<' def revive_hash hash, o o.children.each_slice(2) { |k,v| key = accept(k) val = accept(v) - if key == '<<' && k.tag != "tag:yaml.org,2002:str" + if key == SHOVEL && k.tag != "tag:yaml.org,2002:str" case v when Nodes::Alias, Nodes::Mapping begin diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb index 3087a4db1c..6ad30d2683 100644 --- a/ext/psych/lib/psych/visitors/yaml_tree.rb +++ b/ext/psych/lib/psych/visitors/yaml_tree.rb @@ -70,6 +70,14 @@ module Psych @ss = ss @options = options @line_width = options[:line_width] + if @line_width && @line_width < 0 + if @line_width == -1 + # Treat -1 as unlimited line-width, same as libyaml does. + @line_width = nil + else + fail(ArgumentError, "Invalid line_width #{@line_width}, must be non-negative or -1 for unlimited.") + end + end @coders = [] @dispatch_cache = Hash.new do |h,klass| @@ -510,27 +518,11 @@ module Psych def dump_list o end - # '%:z' was no defined until 1.9.3 - if RUBY_VERSION < '1.9.3' - def format_time time - formatted = time.strftime("%Y-%m-%d %H:%M:%S.%9N") - - if time.utc? - formatted += " Z" - else - zone = time.strftime('%z') - formatted += " #{zone[0,3]}:#{zone[3,5]}" - end - - formatted - end - else - def format_time time - if time.utc? - time.strftime("%Y-%m-%d %H:%M:%S.%9N Z") - else - time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z") - end + def format_time time + if time.utc? + time.strftime("%Y-%m-%d %H:%M:%S.%9N Z") + else + time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z") end end |