ruby-changes:49221
From: hsbt <ko1@a...>
Date: Tue, 19 Dec 2017 18:44:38 +0900 (JST)
Subject: [ruby-changes:49221] hsbt:r61336 (trunk): Merge psych-3.0.2 from ruby/psych.
hsbt 2017-12-19 18:44:33 +0900 (Tue, 19 Dec 2017) New Revision: 61336 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61336 Log: Merge psych-3.0.2 from ruby/psych. It version changed fallback option to keywoad argument on `Yaml.load` method. It break backword compatiblity. see detailed discuttion: https://github.com/ruby/psych/issues/340 From: SHIBATA Hiroshi <hsbt@r...> Modified files: trunk/ext/psych/lib/psych/versions.rb trunk/ext/psych/lib/psych.rb trunk/ext/psych/psych.gemspec trunk/test/psych/test_psych.rb Index: ext/psych/lib/psych/versions.rb =================================================================== --- ext/psych/lib/psych/versions.rb (revision 61335) +++ ext/psych/lib/psych/versions.rb (revision 61336) @@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/versions.rb#L1 # frozen_string_literal: true module Psych # The version is Psych you're using - VERSION = '3.0.0' + VERSION = '3.0.2' if RUBY_ENGINE == 'jruby' DEFAULT_SNAKEYAML_VERSION = '1.18'.freeze Index: ext/psych/lib/psych.rb =================================================================== --- ext/psych/lib/psych.rb (revision 61335) +++ ext/psych/lib/psych.rb (revision 61336) @@ -259,8 +259,8 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych.rb#L259 # Psych.load("---\n foo: bar") # => {"foo"=>"bar"} # Psych.load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"} # - def self.load yaml, filename = nil, fallback = false, symbolize_names: false - result = parse(yaml, filename, fallback) + def self.load yaml, filename = nil, fallback: false, symbolize_names: false + result = parse(yaml, filename, fallback: fallback) result = result.to_ruby if result symbolize_names!(result) if symbolize_names result @@ -300,6 +300,16 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych.rb#L300 # # A Psych::BadAlias exception will be raised if the yaml contains aliases # but the +aliases+ parameter is set to false. + # + # +filename+ will be used in the exception message if any exception is raised + # while parsing. + # + # When the optional +symbolize_names+ keyword argument is set to a + # true value, returns symbols for keys in Hash objects (default: strings). + # + # Psych.safe_load("---\n foo: bar") # => {"foo"=>"bar"} + # Psych.safe_load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"} + # def self.safe_load yaml, whitelist_classes = [], whitelist_symbols = [], aliases = false, filename = nil, symbolize_names: false result = parse(yaml, filename) return unless result @@ -336,7 +346,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych.rb#L346 # end # # See Psych::Nodes for more information about YAML AST. - def self.parse yaml, filename = nil, fallback = false + def self.parse yaml, filename = nil, fallback: false parse_stream(yaml, filename) do |node| return node end @@ -483,9 +493,9 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych.rb#L493 # Load the document contained in +filename+. Returns the yaml contained in # +filename+ as a Ruby object, or if the file is empty, it returns # the specified default return value, which defaults to an empty Hash - def self.load_file filename, fallback = false + def self.load_file filename, fallback: false File.open(filename, 'r:bom|utf-8') { |f| - self.load f, filename, FALLBACK.new(fallback) + self.load f, filename, fallback: FALLBACK.new(fallback) } end Index: ext/psych/psych.gemspec =================================================================== --- ext/psych/psych.gemspec (revision 61335) +++ ext/psych/psych.gemspec (revision 61336) @@ -3,10 +3,10 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/psych.gemspec#L3 Gem::Specification.new do |s| s.name = "psych" - s.version = "3.0.0" + s.version = "3.0.2" s.authors = ["Aaron Patterson", "SHIBATA Hiroshi", "Charles Oliver Nutter"] s.email = ["aaron@t...", "hsbt@r...", "headius@h..."] - s.date = "2017-12-01" + s.date = "2017-12-04" s.summary = "Psych is a YAML parser and emitter" s.description = <<-DESCRIPTION Psych is a YAML parser and emitter. Psych leverages libyaml[http://pyyaml.org/wiki/LibYAML] @@ -41,7 +41,7 @@ DESCRIPTION https://github.com/ruby/ruby/blob/trunk/ext/psych/psych.gemspec#L41 s.rdoc_options = ["--main", "README.md"] s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.md"] - s.required_ruby_version = Gem::Requirement.new(">= 1.9.2") + s.required_ruby_version = Gem::Requirement.new(">= 2.2.2") s.rubygems_version = "2.5.1" s.required_rubygems_version = Gem::Requirement.new(">= 0") Index: test/psych/test_psych.rb =================================================================== --- test/psych/test_psych.rb (revision 61335) +++ test/psych/test_psych.rb (revision 61336) @@ -146,7 +146,7 @@ class TestPsych < Psych::TestCase https://github.com/ruby/ruby/blob/trunk/test/psych/test_psych.rb#L146 def test_load_file_with_fallback Tempfile.create(['empty', 'yml']) {|t| - assert_equal Hash.new, Psych.load_file(t.path, Hash.new) + assert_equal Hash.new, Psych.load_file(t.path, fallback: Hash.new) } end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/