diff options
100 files changed, 258 insertions, 298 deletions
diff --git a/.autotest b/.autotest deleted file mode 100644 index ac7a24c..0000000 --- a/.autotest +++ /dev/null @@ -1,18 +0,0 @@ -require "autotest/restart" -require 'rbconfig' - -Autotest.add_hook :initialize do |at| - at.find_directories = ARGV unless ARGV.empty? - at.testlib = "minitest/autorun" -end - -Autotest.add_hook :run_command do |at| - at.unit_diff = 'cat' - system "ruby -S rake compile" -end - -Autotest.add_hook :ran_command do |at| - File.open('/tmp/autotest.txt', 'wb') { |f| - f.write(at.results.join) - } -end @@ -3,5 +3,12 @@ *.jar *.class .mvn -/pkg -/tmp +/.bundle/ +/.yardoc +/Gemfile.lock +/_yardoc/ +/coverage/ +/doc/ +/pkg/ +/spec/reports/ +/tmp/ diff --git a/.travis.yml b/.travis.yml index 102f109..4758c96 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,13 +4,4 @@ rvm: - 2.2 - 2.3.0 - ruby-head - - rbx-2 -before_script: - - gem install hoe - - gem install rake-compiler - - gem install minitest -v '~> 5.0' -script: rake test -matrix: - allow_failures: - - rvm: ruby-head - - rvm: rbx-2 +before_install: gem install bundler --no-document @@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gemspec diff --git a/Manifest.txt b/Manifest.txt deleted file mode 100644 index 5803f6d..0000000 --- a/Manifest.txt +++ /dev/null @@ -1,114 +0,0 @@ -.autotest -.travis.yml -CHANGELOG.rdoc -Manifest.txt -README.rdoc -Rakefile -ext/psych/depend -ext/psych/extconf.rb -ext/psych/psych.c -ext/psych/psych.h -ext/psych/psych_emitter.c -ext/psych/psych_emitter.h -ext/psych/psych_parser.c -ext/psych/psych_parser.h -ext/psych/psych_to_ruby.c -ext/psych/psych_to_ruby.h -ext/psych/psych_yaml_tree.c -ext/psych/psych_yaml_tree.h -ext/psych/yaml/LICENSE -ext/psych/yaml/api.c -ext/psych/yaml/config.h -ext/psych/yaml/dumper.c -ext/psych/yaml/emitter.c -ext/psych/yaml/loader.c -ext/psych/yaml/parser.c -ext/psych/yaml/reader.c -ext/psych/yaml/scanner.c -ext/psych/yaml/writer.c -ext/psych/yaml/yaml.h -ext/psych/yaml/yaml_private.h -lib/psych.rb -lib/psych/class_loader.rb -lib/psych/coder.rb -lib/psych/core_ext.rb -lib/psych/deprecated.rb -lib/psych/exception.rb -lib/psych/handler.rb -lib/psych/handlers/document_stream.rb -lib/psych/handlers/recorder.rb -lib/psych/json/ruby_events.rb -lib/psych/json/stream.rb -lib/psych/json/tree_builder.rb -lib/psych/json/yaml_events.rb -lib/psych/nodes.rb -lib/psych/nodes/alias.rb -lib/psych/nodes/document.rb -lib/psych/nodes/mapping.rb -lib/psych/nodes/node.rb -lib/psych/nodes/scalar.rb -lib/psych/nodes/sequence.rb -lib/psych/nodes/stream.rb -lib/psych/omap.rb -lib/psych/parser.rb -lib/psych/scalar_scanner.rb -lib/psych/set.rb -lib/psych/stream.rb -lib/psych/streaming.rb -lib/psych/syntax_error.rb -lib/psych/tree_builder.rb -lib/psych/versions.rb -lib/psych/visitors.rb -lib/psych/visitors/depth_first.rb -lib/psych/visitors/emitter.rb -lib/psych/visitors/json_tree.rb -lib/psych/visitors/to_ruby.rb -lib/psych/visitors/visitor.rb -lib/psych/visitors/yaml_tree.rb -lib/psych/y.rb -lib/psych_jars.rb -test/psych/handlers/test_recorder.rb -test/psych/helper.rb -test/psych/json/test_stream.rb -test/psych/nodes/test_enumerable.rb -test/psych/test_alias_and_anchor.rb -test/psych/test_array.rb -test/psych/test_boolean.rb -test/psych/test_class.rb -test/psych/test_coder.rb -test/psych/test_date_time.rb -test/psych/test_deprecated.rb -test/psych/test_document.rb -test/psych/test_emitter.rb -test/psych/test_encoding.rb -test/psych/test_exception.rb -test/psych/test_hash.rb -test/psych/test_json_tree.rb -test/psych/test_merge_keys.rb -test/psych/test_nil.rb -test/psych/test_null.rb -test/psych/test_numeric.rb -test/psych/test_object.rb -test/psych/test_object_references.rb -test/psych/test_omap.rb -test/psych/test_parser.rb -test/psych/test_psych.rb -test/psych/test_safe_load.rb -test/psych/test_scalar.rb -test/psych/test_scalar_scanner.rb -test/psych/test_serialize_subclasses.rb -test/psych/test_set.rb -test/psych/test_stream.rb -test/psych/test_string.rb -test/psych/test_struct.rb -test/psych/test_symbol.rb -test/psych/test_tainted.rb -test/psych/test_to_yaml_properties.rb -test/psych/test_tree_builder.rb -test/psych/test_yaml.rb -test/psych/test_yamldbm.rb -test/psych/test_yamlstore.rb -test/psych/visitors/test_depth_first.rb -test/psych/visitors/test_emitter.rb -test/psych/visitors/test_to_ruby.rb -test/psych/visitors/test_yaml_tree.rb diff --git a/README.rdoc b/README.rdoc index 47ff958..445d3f7 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,6 +1,6 @@ = Psych -* http://github.com/tenderlove/psych +* https://github.com/ruby/psych == Description @@ -1,123 +1,31 @@ -# -*- ruby -*- - -require 'psych' -require 'rubygems' -require 'hoe' - -def java? - RUBY_PLATFORM =~ /java/ -end - -class Hoe - remove_const :RUBY_FLAGS - flags = "-I#{%w(lib ext bin test).join(File::PATH_SEPARATOR)}" - flags = "--1.9 " + flags if java? - RUBY_FLAGS = flags -end - -gem 'rake-compiler', '>= 0.4.1' -gem 'minitest', '~> 5.0' -require "rake/extensiontask" - -Hoe.plugin :doofus, :git, :gemspec - -$hoe = Hoe.spec 'psych' do - license 'MIT' - developer 'Aaron Patterson', 'aaron@tenderlovemaking.com' - - self.extra_rdoc_files = Dir['*.rdoc'] - self.history_file = 'CHANGELOG.rdoc' - self.readme_file = 'README.rdoc' - self.testlib = :minitest - - extra_dev_deps << ['rake-compiler', '>= 0.4.1'] - extra_dev_deps << ['minitest', '~> 5.0'] - - self.spec_extras = { - :required_ruby_version => '>= 1.9.2' - } - - if java? - require './lib/psych/versions.rb' - extra_deps << ['jar-dependencies', '>= 0.1.7'] - - # the jar declaration for jar-dependencies - self.spec_extras[ 'requirements' ] = "jar org.yaml:snakeyaml, #{Psych::DEFAULT_SNAKEYAML_VERSION}" - self.spec_extras[ 'platform' ] = 'java' - # TODO: clean this section up. - require "rake/javaextensiontask" - Rake::JavaExtensionTask.new("psych", spec) do |ext| - require 'maven/ruby/maven' - # uses Mavenfile to write classpath into pkg/classpath - # and tell maven via system properties the snakeyaml version - # this is basically the same as running from the commandline: - # rmvn dependency:build-classpath -Dsnakeyaml.version='use version from Psych::DEFAULT_SNAKEYAML_VERSION here' - Maven::Ruby::Maven.new.exec( 'dependency:build-classpath', "-Dsnakeyaml.version=#{Psych::DEFAULT_SNAKEYAML_VERSION}", '-Dverbose=true')#, '--quiet' ) - ext.source_version = '1.7' - ext.target_version = '1.7' - ext.classpath = File.read('pkg/classpath') - ext.ext_dir = 'ext/java' - end - else - self.spec_extras[:extensions] = ["ext/psych/extconf.rb"] - Rake::ExtensionTask.new "psych", spec do |ext| - ext.lib_dir = File.join(*['lib', ENV['FAT_DIR']].compact) - end - end -end - -def gem_build_path - File.join 'pkg', $hoe.spec.full_name -end - -def add_file_to_gem relative_path - target_path = File.join gem_build_path, relative_path - target_dir = File.dirname(target_path) - mkdir_p target_dir unless File.directory?(target_dir) - rm_f target_path - safe_ln relative_path, target_path - $hoe.spec.files.concat [relative_path] -end - -if java? - task gem_build_path => [:compile] do - add_file_to_gem 'lib/psych.jar' +require "bundler/gem_tasks" +require "rake/testtask" + +Rake::TestTask.new(:test) do |t| + t.libs << "test" + t.libs << "lib" + t.test_files = FileList['test/**/test_*.rb'] +end + +if RUBY_PLATFORM =~ /java/ + require 'rake/javaextensiontask' + Rake::JavaExtensionTask.new("psych") do |ext| + require 'maven/ruby/maven' + # uses Mavenfile to write classpath into pkg/classpath + # and tell maven via system properties the snakeyaml version + # this is basically the same as running from the commandline: + # rmvn dependency:build-classpath -Dsnakeyaml.version='use version from Psych::DEFAULT_SNAKEYAML_VERSION here' + Maven::Ruby::Maven.new.exec( 'dependency:build-classpath', "-Dsnakeyaml.version=#{Psych::DEFAULT_SNAKEYAML_VERSION}", '-Dverbose=true')#, '--quiet' ) + ext.source_version = '1.7' + ext.target_version = '1.7' + ext.classpath = File.read('pkg/classpath') + ext.ext_dir = 'ext/java' end -end - -Hoe.add_include_dirs('.:lib/psych') - -task :test => :compile - -task :hack_spec do - $hoe.spec.extra_rdoc_files.clear -end -task 'core:spec' => [:hack_spec, 'gem:spec'] - -desc "merge psych in to ruby trunk" -namespace :merge do - basedir = File.expand_path File.dirname __FILE__ - rubydir = File.join ENV['HOME'], 'git', 'ruby' - mergedirs = { - # From # To - [basedir, 'ext', 'psych/'] => [rubydir, 'ext', 'psych/'], - [basedir, 'lib/'] => [rubydir, 'ext', 'psych', 'lib/'], - [basedir, 'test', 'psych/'] => [rubydir, 'test', 'psych/'], - } - - rsync = 'rsync -av --exclude lib --exclude ".*" --exclude "*.o" --exclude Makefile --exclude mkmf.log --delete' - - task :to_ruby do - mergedirs.each do |from, to| - sh "#{rsync} #{File.join(*from)} #{File.join(*to)}" - end - end - - task :from_ruby do - mergedirs.each do |from, to| - sh "#{rsync} #{File.join(*to)} #{File.join(*from)}" - end +else + require 'rake/extensiontask' + Rake::ExtensionTask.new("psych") do |ext| + ext.lib_dir = File.join(*['lib', ENV['FAT_DIR']].compact) end end -# vim: syntax=ruby +task :default => [:compile, :test] diff --git a/bin/console b/bin/console new file mode 100755 index 0000000..86c5a21 --- /dev/null +++ b/bin/console @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby + +require "bundler/setup" +require "psych" + +require "irb" +IRB.start diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000..cf4ad25 --- /dev/null +++ b/bin/setup @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' +set -vx + +bundle install diff --git a/ext/java/PsychParser.java b/ext/java/PsychParser.java index c8f25a0..b6868f9 100644 --- a/ext/java/PsychParser.java +++ b/ext/java/PsychParser.java @@ -77,7 +77,7 @@ import org.jruby.util.ByteList; public class PsychParser extends RubyObject { - private static final Logger LOG = LoggerFactory.getLogger("PsychParser"); + private static final Logger LOG = LoggerFactory.getLogger(PsychParser.class); public static void initPsychParser(Ruby runtime, RubyModule psych) { RubyClass psychParser = runtime.defineClassUnder("Parser", runtime.getObject(), new ObjectAllocator() { diff --git a/ext/java/PsychToRuby.java b/ext/java/PsychToRuby.java index 39f7c42..8286837 100644 --- a/ext/java/PsychToRuby.java +++ b/ext/java/PsychToRuby.java @@ -55,7 +55,7 @@ public class PsychToRuby { public static IRubyObject build_exception(ThreadContext context, IRubyObject self, IRubyObject klass, IRubyObject message) { if (klass instanceof RubyClass) { IRubyObject exception = ((RubyClass)klass).allocate(); - ((RubyException)exception).message = message; + ((RubyException)exception).setMessage(message); return exception; } else { throw context.runtime.newTypeError(klass, context.runtime.getClassClass()); diff --git a/ext/psych/extconf.rb b/ext/psych/extconf.rb index 65e83a3..be33d35 100644 --- a/ext/psych/extconf.rb +++ b/ext/psych/extconf.rb @@ -1,4 +1,5 @@ # -*- coding: us-ascii -*- +# frozen_string_literal: false require 'mkmf' require 'fileutils' diff --git a/ext/psych/yaml/loader.c b/ext/psych/yaml/loader.c index cb3ea93..def6793 100644 --- a/ext/psych/yaml/loader.c +++ b/ext/psych/yaml/loader.c @@ -239,8 +239,8 @@ yaml_parser_register_anchor(yaml_parser_t *parser, if (strcmp((char *)alias_data->anchor, (char *)anchor) == 0) { yaml_free(anchor); return yaml_parser_set_composer_error_context(parser, - "found duplicate anchor; first occurence", - alias_data->mark, "second occurence", data.mark); + "found duplicate anchor; first occurrence", + alias_data->mark, "second occurrence", data.mark); } } diff --git a/ext/psych/yaml/scanner.c b/ext/psych/yaml/scanner.c index c8627e2..5e4875d 100644 --- a/ext/psych/yaml/scanner.c +++ b/ext/psych/yaml/scanner.c @@ -1251,7 +1251,7 @@ yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column, /* * Pop indentation levels from the indents stack until the current level - * becomes less or equal to the column. For each intendation level, append + * becomes less or equal to the column. For each indentation level, append * the BLOCK-END token. */ @@ -1266,7 +1266,7 @@ yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column) if (parser->flow_level) return 1; - /* Loop through the intendation levels in the stack. */ + /* Loop through the indentation levels in the stack. */ while (parser->indent > column) { @@ -2775,15 +2775,15 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token, if (IS_DIGIT(parser->buffer)) { - /* Check that the intendation is greater than 0. */ + /* Check that the indentation is greater than 0. */ if (CHECK(parser->buffer, '0')) { yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "found an intendation indicator equal to 0"); + start_mark, "found an indentation indicator equal to 0"); goto error; } - /* Get the intendation level and eat the indicator. */ + /* Get the indentation level and eat the indicator. */ increment = AS_DIGIT(parser->buffer); @@ -2797,7 +2797,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token, { if (CHECK(parser->buffer, '0')) { yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "found an intendation indicator equal to 0"); + start_mark, "found an indentation indicator equal to 0"); goto error; } @@ -2847,7 +2847,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token, end_mark = parser->mark; - /* Set the intendation level if it was specified. */ + /* Set the indentation level if it was specified. */ if (increment) { indent = parser->indent >= 0 ? parser->indent+increment : increment; @@ -2913,7 +2913,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token, if (!READ_LINE(parser, leading_break)) goto error; - /* Eat the following intendation spaces and line breaks. */ + /* Eat the following indentation spaces and line breaks. */ if (!yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark)) goto error; @@ -2948,8 +2948,8 @@ error: } /* - * Scan intendation spaces and line breaks for a block scalar. Determine the - * intendation level if needed. + * Scan indentation spaces and line breaks for a block scalar. Determine the + * indentation level if needed. */ static int @@ -2961,11 +2961,11 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser, *end_mark = parser->mark; - /* Eat the intendation spaces and line breaks. */ + /* Eat the indentation spaces and line breaks. */ while (1) { - /* Eat the intendation spaces. */ + /* Eat the indentation spaces. */ if (!CACHE(parser, 1)) return 0; @@ -2978,12 +2978,12 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser, if ((int)parser->mark.column > max_indent) max_indent = (int)parser->mark.column; - /* Check for a tab character messing the intendation. */ + /* Check for a tab character messing the indentation. */ if ((!*indent || (int)parser->mark.column < *indent) && IS_TAB(parser->buffer)) { return yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "found a tab character where an intendation space is expected"); + start_mark, "found a tab character where an indentation space is expected"); } /* Have we found a non-empty line? */ @@ -3504,12 +3504,12 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token) { if (IS_BLANK(parser->buffer)) { - /* Check for tab character that abuse intendation. */ + /* Check for tab character that abuse indentation. */ if (leading_blanks && (int)parser->mark.column < indent && IS_TAB(parser->buffer)) { yaml_parser_set_scanner_error(parser, "while scanning a plain scalar", - start_mark, "found a tab character that violate intendation"); + start_mark, "found a tab character that violate indentation"); goto error; } @@ -3542,7 +3542,7 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token) if (!CACHE(parser, 1)) goto error; } - /* Check intendation level. */ + /* Check indentation level. */ if (!parser->flow_level && (int)parser->mark.column < indent) break; diff --git a/lib/psych.rb b/lib/psych.rb index 1006998..ecef46c 100644 --- a/lib/psych.rb +++ b/lib/psych.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false case RUBY_ENGINE when 'jruby' require 'psych_jars' @@ -223,11 +224,13 @@ require 'psych/class_loader' module Psych # The version is Psych you're using - VERSION = '2.0.17' + VERSION = '2.1.1' # The version of libyaml Psych is using LIBYAML_VERSION = Psych.libyaml_version.join '.' + FALLBACK = Struct.new :to_ruby # :nodoc: + ### # Load +yaml+ in to a Ruby data structure. If multiple documents are # provided, the object contained in the first document will be returned. @@ -247,8 +250,8 @@ module Psych # ex.file # => 'file.txt' # ex.message # => "(file.txt): found character that cannot start any token" # end - def self.load yaml, filename = nil - result = parse(yaml, filename) + def self.load yaml, filename = nil, fallback = false + result = parse(yaml, filename, fallback) result ? result.to_ruby : result end @@ -320,11 +323,11 @@ module Psych # end # # See Psych::Nodes for more information about YAML AST. - def self.parse yaml, filename = nil + def self.parse yaml, filename = nil, fallback = false parse_stream(yaml, filename) do |node| return node end - false + fallback end ### @@ -465,9 +468,12 @@ module Psych ### # Load the document contained in +filename+. Returns the yaml contained in - # +filename+ as a Ruby object - def self.load_file filename - File.open(filename, 'r:bom|utf-8') { |f| self.load f, filename } + # +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 + File.open(filename, 'r:bom|utf-8') { |f| + self.load f, filename, FALLBACK.new(fallback) + } end # :stopdoc: diff --git a/lib/psych/class_loader.rb b/lib/psych/class_loader.rb index 46c6b93..ba756f7 100644 --- a/lib/psych/class_loader.rb +++ b/lib/psych/class_loader.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/omap' require 'psych/set' diff --git a/lib/psych/coder.rb b/lib/psych/coder.rb index 2b830d2..26005f5 100644 --- a/lib/psych/coder.rb +++ b/lib/psych/coder.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych ### # If an object defines +encode_with+, then an instance of Psych::Coder will diff --git a/lib/psych/core_ext.rb b/lib/psych/core_ext.rb index 9c8134d..1a98279 100644 --- a/lib/psych/core_ext.rb +++ b/lib/psych/core_ext.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false class Object def self.yaml_tag url Psych.add_tag(url, self) diff --git a/lib/psych/deprecated.rb b/lib/psych/deprecated.rb index 8c310b3..165d210 100644 --- a/lib/psych/deprecated.rb +++ b/lib/psych/deprecated.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'date' module Psych diff --git a/lib/psych/exception.rb b/lib/psych/exception.rb index ce9d2ca..83c3d7f 100644 --- a/lib/psych/exception.rb +++ b/lib/psych/exception.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych class Exception < RuntimeError end diff --git a/lib/psych/handler.rb b/lib/psych/handler.rb index c55afe7..1ab5f73 100644 --- a/lib/psych/handler.rb +++ b/lib/psych/handler.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych ### # Psych::Handler is an abstract base class that defines the events used diff --git a/lib/psych/handlers/document_stream.rb b/lib/psych/handlers/document_stream.rb index e429993..c43b39e 100644 --- a/lib/psych/handlers/document_stream.rb +++ b/lib/psych/handlers/document_stream.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/tree_builder' module Psych diff --git a/lib/psych/handlers/recorder.rb b/lib/psych/handlers/recorder.rb index 4eae62e..341b81d 100644 --- a/lib/psych/handlers/recorder.rb +++ b/lib/psych/handlers/recorder.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/handler' module Psych diff --git a/lib/psych/json/ruby_events.rb b/lib/psych/json/ruby_events.rb index 6b73249..478eb66 100644 --- a/lib/psych/json/ruby_events.rb +++ b/lib/psych/json/ruby_events.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych module JSON module RubyEvents # :nodoc: diff --git a/lib/psych/json/stream.rb b/lib/psych/json/stream.rb index fe2a6e9..83b7e13 100644 --- a/lib/psych/json/stream.rb +++ b/lib/psych/json/stream.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/json/ruby_events' require 'psych/json/yaml_events' diff --git a/lib/psych/json/tree_builder.rb b/lib/psych/json/tree_builder.rb index b799c93..2f94b8c 100644 --- a/lib/psych/json/tree_builder.rb +++ b/lib/psych/json/tree_builder.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/json/yaml_events' module Psych diff --git a/lib/psych/json/yaml_events.rb b/lib/psych/json/yaml_events.rb index d054d9b..07f6473 100644 --- a/lib/psych/json/yaml_events.rb +++ b/lib/psych/json/yaml_events.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych module JSON module YAMLEvents # :nodoc: diff --git a/lib/psych/nodes.rb b/lib/psych/nodes.rb index f3b33fe..01573b5 100644 --- a/lib/psych/nodes.rb +++ b/lib/psych/nodes.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/nodes/node' require 'psych/nodes/stream' require 'psych/nodes/document' diff --git a/lib/psych/nodes/alias.rb b/lib/psych/nodes/alias.rb index 5bd4df1..716a00d 100644 --- a/lib/psych/nodes/alias.rb +++ b/lib/psych/nodes/alias.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych module Nodes ### diff --git a/lib/psych/nodes/document.rb b/lib/psych/nodes/document.rb index 32014d6..7234fef 100644 --- a/lib/psych/nodes/document.rb +++ b/lib/psych/nodes/document.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych module Nodes ### diff --git a/lib/psych/nodes/mapping.rb b/lib/psych/nodes/mapping.rb index 5ba95ce..4c11df8 100644 --- a/lib/psych/nodes/mapping.rb +++ b/lib/psych/nodes/mapping.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych module Nodes ### diff --git a/lib/psych/nodes/node.rb b/lib/psych/nodes/node.rb index 83233a6..e3621dc 100644 --- a/lib/psych/nodes/node.rb +++ b/lib/psych/nodes/node.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'stringio' require 'psych/class_loader' require 'psych/scalar_scanner' diff --git a/lib/psych/nodes/scalar.rb b/lib/psych/nodes/scalar.rb index 1b1b25b..ee55705 100644 --- a/lib/psych/nodes/scalar.rb +++ b/lib/psych/nodes/scalar.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych module Nodes ### diff --git a/lib/psych/nodes/sequence.rb b/lib/psych/nodes/sequence.rb index 7e907fe..1096469 100644 --- a/lib/psych/nodes/sequence.rb +++ b/lib/psych/nodes/sequence.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych module Nodes ### diff --git a/lib/psych/nodes/stream.rb b/lib/psych/nodes/stream.rb index 7cf5e03..559b084 100644 --- a/lib/psych/nodes/stream.rb +++ b/lib/psych/nodes/stream.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych module Nodes ### diff --git a/lib/psych/omap.rb b/lib/psych/omap.rb index 6286270..233b945 100644 --- a/lib/psych/omap.rb +++ b/lib/psych/omap.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych class Omap < ::Hash end diff --git a/lib/psych/parser.rb b/lib/psych/parser.rb index 84085f1..242512f 100644 --- a/lib/psych/parser.rb +++ b/lib/psych/parser.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych ### # YAML event parser class. This class parses a YAML document and calls diff --git a/lib/psych/scalar_scanner.rb b/lib/psych/scalar_scanner.rb index 9300790..a849359 100644 --- a/lib/psych/scalar_scanner.rb +++ b/lib/psych/scalar_scanner.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'strscan' module Psych @@ -99,7 +100,7 @@ module Psych @string_cache[string] = true string else - Float(string.gsub(/[,_]|\.$/, '')) + Float(string.gsub(/[,_]|\.([Ee]|$)/, '\1')) end else int = parse_int string.gsub(/[,_]/, '') diff --git a/lib/psych/set.rb b/lib/psych/set.rb index 6793a8e..f35be15 100644 --- a/lib/psych/set.rb +++ b/lib/psych/set.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych class Set < ::Hash end diff --git a/lib/psych/stream.rb b/lib/psych/stream.rb index 88c4c4c..2f63d7d 100644 --- a/lib/psych/stream.rb +++ b/lib/psych/stream.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych ### # Psych::Stream is a streaming YAML emitter. It will not buffer your YAML, diff --git a/lib/psych/streaming.rb b/lib/psych/streaming.rb index 9d94eb5..260f8a8 100644 --- a/lib/psych/streaming.rb +++ b/lib/psych/streaming.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych module Streaming module ClassMethods diff --git a/lib/psych/syntax_error.rb b/lib/psych/syntax_error.rb index e200ef0..db293b9 100644 --- a/lib/psych/syntax_error.rb +++ b/lib/psych/syntax_error.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/exception' module Psych diff --git a/lib/psych/tree_builder.rb b/lib/psych/tree_builder.rb index c8f3447..d359c93 100644 --- a/lib/psych/tree_builder.rb +++ b/lib/psych/tree_builder.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/handler' module Psych diff --git a/lib/psych/versions.rb b/lib/psych/versions.rb index 530d310..5f7652b 100644 --- a/lib/psych/versions.rb +++ b/lib/psych/versions.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych DEFAULT_SNAKEYAML_VERSION = '1.14'.freeze end diff --git a/lib/psych/visitors.rb b/lib/psych/visitors.rb index cc98b10..5dee4eb 100644 --- a/lib/psych/visitors.rb +++ b/lib/psych/visitors.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/visitors/visitor' require 'psych/visitors/to_ruby' require 'psych/visitors/emitter' diff --git a/lib/psych/visitors/depth_first.rb b/lib/psych/visitors/depth_first.rb index c6eb814..2d74a21 100644 --- a/lib/psych/visitors/depth_first.rb +++ b/lib/psych/visitors/depth_first.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych module Visitors class DepthFirst < Psych::Visitors::Visitor diff --git a/lib/psych/visitors/emitter.rb b/lib/psych/visitors/emitter.rb index c886e50..f2ff9fd 100644 --- a/lib/psych/visitors/emitter.rb +++ b/lib/psych/visitors/emitter.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych module Visitors class Emitter < Psych::Visitors::Visitor diff --git a/lib/psych/visitors/json_tree.rb b/lib/psych/visitors/json_tree.rb index 0127ac8..f2f0215 100644 --- a/lib/psych/visitors/json_tree.rb +++ b/lib/psych/visitors/json_tree.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/json/ruby_events' module Psych diff --git a/lib/psych/visitors/to_ruby.rb b/lib/psych/visitors/to_ruby.rb index 4c3591b..fd1c8e6 100644 --- a/lib/psych/visitors/to_ruby.rb +++ b/lib/psych/visitors/to_ruby.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/scalar_scanner' require 'psych/class_loader' require 'psych/exception' @@ -69,11 +70,11 @@ module Psych o.value end when '!ruby/object:BigDecimal' - require 'bigdecimal' + require 'bigdecimal' unless defined? BigDecimal class_loader.big_decimal._load o.value when "!ruby/object:DateTime" class_loader.date_time - require 'date' + require 'date' unless defined? DateTime @ss.parse_time(o.value).to_datetime when '!ruby/encoding' ::Encoding.find o.value diff --git a/lib/psych/visitors/visitor.rb b/lib/psych/visitors/visitor.rb index 4d7772f..d97bf55 100644 --- a/lib/psych/visitors/visitor.rb +++ b/lib/psych/visitors/visitor.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Psych module Visitors class Visitor diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb index 6ad30d2..11214ec 100644 --- a/lib/psych/visitors/yaml_tree.rb +++ b/lib/psych/visitors/yaml_tree.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/tree_builder' require 'psych/scalar_scanner' require 'psych/class_loader' @@ -313,7 +314,7 @@ module Psych tag = nil if binary?(o) - o = [o].pack('m').chomp + o = [o].pack('m0') tag = '!binary' # FIXME: change to below when syck is removed #tag = 'tag:yaml.org,2002:binary' style = Nodes::Scalar::LITERAL @@ -330,7 +331,7 @@ module Psych style = Nodes::Scalar::FOLDED elsif o =~ /^[^[:word:]][^"]*$/ style = Nodes::Scalar::DOUBLE_QUOTED - elsif not String === @ss.tokenize(o) + elsif not String === @ss.tokenize(o) or /\A0[0-7]*[89]/ =~ o style = Nodes::Scalar::SINGLE_QUOTED end diff --git a/lib/psych/y.rb b/lib/psych/y.rb index d0e049d..82e05a7 100644 --- a/lib/psych/y.rb +++ b/lib/psych/y.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false module Kernel ### # An alias for Psych.dump_stream meant to be used with IRB. diff --git a/lib/psych_jars.rb b/lib/psych_jars.rb index 795c7ea..bd7ea04 100644 --- a/lib/psych_jars.rb +++ b/lib/psych_jars.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/versions' require 'psych.jar' diff --git a/psych.gemspec b/psych.gemspec new file mode 100644 index 0000000..e0302e4 --- /dev/null +++ b/psych.gemspec @@ -0,0 +1,41 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = "psych" + s.version = "2.1.1" + s.authors = ["Aaron Patterson", "SHIBATA Hiroshi"] + s.email = ["aaron@tenderlovemaking.com", "hsbt@ruby-lang.org"] + s.date = "2016-09-07" + 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] +for its YAML parsing and emitting capabilities. In addition to wrapping libyaml, +Psych also knows how to serialize and de-serialize most Ruby objects to and from the YAML format. +DESCRIPTION + s.homepage = "https://github.com/ruby/psych" + s.licenses = ["MIT"] + s.require_paths = ["lib"] + + # for ruby core repository. It was generated by `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } + s.files = [".gitignore", ".travis.yml", "CHANGELOG.rdoc", "Gemfile", "Mavenfile", "README.rdoc", "Rakefile", "bin/console", "bin/setup", "ext/java/PsychEmitter.java", "ext/java/PsychLibrary.java", "ext/java/PsychParser.java", "ext/java/PsychToRuby.java", "ext/java/PsychYamlTree.java", "ext/psych/.gitignore", "ext/psych/depend", "ext/psych/extconf.rb", "ext/psych/psych.c", "ext/psych/psych.h", "ext/psych/psych_emitter.c", "ext/psych/psych_emitter.h", "ext/psych/psych_parser.c", "ext/psych/psych_parser.h", "ext/psych/psych_to_ruby.c", "ext/psych/psych_to_ruby.h", "ext/psych/psych_yaml_tree.c", "ext/psych/psych_yaml_tree.h", "ext/psych/yaml/LICENSE", "ext/psych/yaml/api.c", "ext/psych/yaml/config.h", "ext/psych/yaml/dumper.c", "ext/psych/yaml/emitter.c", "ext/psych/yaml/loader.c", "ext/psych/yaml/parser.c", "ext/psych/yaml/reader.c", "ext/psych/yaml/scanner.c", "ext/psych/yaml/writer.c", "ext/psych/yaml/yaml.h", "ext/psych/yaml/yaml_private.h", "lib/psych.rb", "lib/psych/class_loader.rb", "lib/psych/coder.rb", "lib/psych/core_ext.rb", "lib/psych/deprecated.rb", "lib/psych/exception.rb", "lib/psych/handler.rb", "lib/psych/handlers/document_stream.rb", "lib/psych/handlers/recorder.rb", "lib/psych/json/ruby_events.rb", "lib/psych/json/stream.rb", "lib/psych/json/tree_builder.rb", "lib/psych/json/yaml_events.rb", "lib/psych/nodes.rb", "lib/psych/nodes/alias.rb", "lib/psych/nodes/document.rb", "lib/psych/nodes/mapping.rb", "lib/psych/nodes/node.rb", "lib/psych/nodes/scalar.rb", "lib/psych/nodes/sequence.rb", "lib/psych/nodes/stream.rb", "lib/psych/omap.rb", "lib/psych/parser.rb", "lib/psych/scalar_scanner.rb", "lib/psych/set.rb", "lib/psych/stream.rb", "lib/psych/streaming.rb", "lib/psych/syntax_error.rb", "lib/psych/tree_builder.rb", "lib/psych/versions.rb", "lib/psych/visitors.rb","lib/psych/visitors/depth_first.rb", "lib/psych/visitors/emitter.rb", "lib/psych/visitors/json_tree.rb", "lib/psych/visitors/to_ruby.rb", "lib/psych/visitors/visitor.rb", "lib/psych/visitors/yaml_tree.rb", "lib/psych/y.rb", "lib/psych_jars.rb", "psych.gemspec"] + + s.rdoc_options = ["--main", "README.rdoc"] + s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.rdoc", "CHANGELOG.rdoc", "README.rdoc"] + + s.required_ruby_version = Gem::Requirement.new(">= 1.9.2") + s.rubygems_version = "2.5.1" + s.required_rubygems_version = Gem::Requirement.new(">= 0") + + s.add_development_dependency(%q<rake-compiler>, [">= 0.4.1"]) + s.add_development_dependency(%q<minitest>, ["~> 5.0"]) + + if RUBY_PLATFORM =~ /java/ + require 'psych/versions' + s.platform = 'java' + s.requirements = "jar org.yaml:snakeyaml, #{Psych::DEFAULT_SNAKEYAML_VERSION}" + s.add_dependency 'jar-dependencies', '>= 0.1.7' + s.add_development_dependency 'ruby-maven' + else + s.extensions = ["ext/psych/extconf.rb"] + end +end diff --git a/test/psych/handlers/test_recorder.rb b/test/psych/handlers/test_recorder.rb index 96b8eac..17c7c6d 100644 --- a/test/psych/handlers/test_recorder.rb +++ b/test/psych/handlers/test_recorder.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/helper' require 'psych/handlers/recorder' diff --git a/test/psych/helper.rb b/test/psych/helper.rb index 3bbb459..498cdf8 100644 --- a/test/psych/helper.rb +++ b/test/psych/helper.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'minitest/autorun' require 'stringio' require 'tempfile' diff --git a/test/psych/json/test_stream.rb b/test/psych/json/test_stream.rb index b0c33e6..519c114 100644 --- a/test/psych/json/test_stream.rb +++ b/test/psych/json/test_stream.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/helper' module Psych diff --git a/test/psych/nodes/test_enumerable.rb b/test/psych/nodes/test_enumerable.rb index 19cf94b..2f4e1f3 100644 --- a/test/psych/nodes/test_enumerable.rb +++ b/test/psych/nodes/test_enumerable.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/helper' module Psych diff --git a/test/psych/test_alias_and_anchor.rb b/test/psych/test_alias_and_anchor.rb index 9e2c240..ed00960 100644 --- a/test/psych/test_alias_and_anchor.rb +++ b/test/psych/test_alias_and_anchor.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' class ObjectWithInstanceVariables diff --git a/test/psych/test_array.rb b/test/psych/test_array.rb index 960ffd7..f1e71fb 100644 --- a/test/psych/test_array.rb +++ b/test/psych/test_array.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_boolean.rb b/test/psych/test_boolean.rb index b656f4f..b2803a6 100644 --- a/test/psych/test_boolean.rb +++ b/test/psych/test_boolean.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_class.rb b/test/psych/test_class.rb index c7f964c..4e1fd4a 100644 --- a/test/psych/test_class.rb +++ b/test/psych/test_class.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_coder.rb b/test/psych/test_coder.rb index e3213e2..e578d55 100644 --- a/test/psych/test_coder.rb +++ b/test/psych/test_coder.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_date_time.rb b/test/psych/test_date_time.rb index 72150ad..433fbf3 100644 --- a/test/psych/test_date_time.rb +++ b/test/psych/test_date_time.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' require 'date' diff --git a/test/psych/test_deprecated.rb b/test/psych/test_deprecated.rb index fd2d329..a806f6b 100644 --- a/test/psych/test_deprecated.rb +++ b/test/psych/test_deprecated.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_document.rb b/test/psych/test_document.rb index bd77d60..97de2e1 100644 --- a/test/psych/test_document.rb +++ b/test/psych/test_document.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_emitter.rb b/test/psych/test_emitter.rb index 1c96c12..23e68b3 100644 --- a/test/psych/test_emitter.rb +++ b/test/psych/test_emitter.rb @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +# frozen_string_literal: false require_relative 'helper' @@ -53,6 +54,7 @@ module Psych [[], 'foo', false], [[], ['foo'], false], [[], [nil,nil], false], + [[1,1], [[nil, "tag:TALOS"]], 0], ].each do |args| assert_raises(TypeError) do @emitter.start_document(*args) @@ -89,5 +91,22 @@ module Psych @emitter.start_sequence(nil, nil, true, :foo) end end + + def test_resizing_tags + @emitter.start_stream Psych::Nodes::Stream::UTF8 + + tags = [] + version = [1,1] + obj = Object.new + obj.instance_variable_set(:@tags, tags) + def obj.to_str + (1..10).map{|x| @tags.push(["AAAA","BBBB"])} + return "x" + end + + tags.push([obj, "tag:TALOS"]) + @emitter.start_document(version, tags, 0) + assert(true) + end end end diff --git a/test/psych/test_encoding.rb b/test/psych/test_encoding.rb index 544337d..13ca5db 100644 --- a/test/psych/test_encoding.rb +++ b/test/psych/test_encoding.rb @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +# frozen_string_literal: false require_relative 'helper' diff --git a/test/psych/test_exception.rb b/test/psych/test_exception.rb index 30dfb24..85fa78f 100644 --- a/test/psych/test_exception.rb +++ b/test/psych/test_exception.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_hash.rb b/test/psych/test_hash.rb index e2a3129..b449ce4 100644 --- a/test/psych/test_hash.rb +++ b/test/psych/test_hash.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_json_tree.rb b/test/psych/test_json_tree.rb index a23fc1a..8bb850b 100644 --- a/test/psych/test_json_tree.rb +++ b/test/psych/test_json_tree.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_marshalable.rb b/test/psych/test_marshalable.rb index 7df74ee..544947a 100644 --- a/test/psych/test_marshalable.rb +++ b/test/psych/test_marshalable.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' require 'delegate' diff --git a/test/psych/test_merge_keys.rb b/test/psych/test_merge_keys.rb index 1620a6a..76245ca 100644 --- a/test/psych/test_merge_keys.rb +++ b/test/psych/test_merge_keys.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_nil.rb b/test/psych/test_nil.rb index 3dbf562..3d4fa88 100644 --- a/test/psych/test_nil.rb +++ b/test/psych/test_nil.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_null.rb b/test/psych/test_null.rb index 1725550..d8ccb70 100644 --- a/test/psych/test_null.rb +++ b/test/psych/test_null.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_numeric.rb b/test/psych/test_numeric.rb index 5378b4a..9d8b74f 100644 --- a/test/psych/test_numeric.rb +++ b/test/psych/test_numeric.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' require 'bigdecimal' diff --git a/test/psych/test_object.rb b/test/psych/test_object.rb index 5e3ce82..ed1ccd9 100644 --- a/test/psych/test_object.rb +++ b/test/psych/test_object.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_object_references.rb b/test/psych/test_object_references.rb index 273b466..1300bfc 100644 --- a/test/psych/test_object_references.rb +++ b/test/psych/test_object_references.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_omap.rb b/test/psych/test_omap.rb index 36edc26..80791aa 100644 --- a/test/psych/test_omap.rb +++ b/test/psych/test_omap.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_parser.rb b/test/psych/test_parser.rb index 0abe0dd..26aba05 100644 --- a/test/psych/test_parser.rb +++ b/test/psych/test_parser.rb @@ -1,4 +1,5 @@ # coding: utf-8 +# frozen_string_literal: false require_relative 'helper' diff --git a/test/psych/test_psych.rb b/test/psych/test_psych.rb index 05a9343..0e76927 100644 --- a/test/psych/test_psych.rb +++ b/test/psych/test_psych.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' require 'stringio' @@ -143,6 +144,12 @@ class TestPsych < Psych::TestCase } end + def test_load_file_with_fallback + Tempfile.create(['empty', 'yml']) {|t| + assert_equal Hash.new, Psych.load_file(t.path, Hash.new) + } + end + def test_parse_file Tempfile.create(['yikes', 'yml']) {|t| t.binmode diff --git a/test/psych/test_safe_load.rb b/test/psych/test_safe_load.rb index dd299c0..b69c54c 100644 --- a/test/psych/test_safe_load.rb +++ b/test/psych/test_safe_load.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/helper' module Psych diff --git a/test/psych/test_scalar.rb b/test/psych/test_scalar.rb index e6b7697..4353ec3 100644 --- a/test/psych/test_scalar.rb +++ b/test/psych/test_scalar.rb @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +# frozen_string_literal: false require_relative 'helper' diff --git a/test/psych/test_scalar_scanner.rb b/test/psych/test_scalar_scanner.rb index e8e423c..2599989 100644 --- a/test/psych/test_scalar_scanner.rb +++ b/test/psych/test_scalar_scanner.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' require 'date' @@ -73,6 +74,10 @@ module Psych assert ss.tokenize('.nan').nan? end + def test_scan_float_with_exponent_but_no_fraction + assert_equal(0.0, ss.tokenize('0.E+0')) + end + def test_scan_null assert_equal nil, ss.tokenize('null') assert_equal nil, ss.tokenize('~') diff --git a/test/psych/test_serialize_subclasses.rb b/test/psych/test_serialize_subclasses.rb index f597b7a..be209ed 100644 --- a/test/psych/test_serialize_subclasses.rb +++ b/test/psych/test_serialize_subclasses.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_set.rb b/test/psych/test_set.rb index 921fe22..0eb999c 100644 --- a/test/psych/test_set.rb +++ b/test/psych/test_set.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_stream.rb b/test/psych/test_stream.rb index 7e41178..1b05428 100644 --- a/test/psych/test_stream.rb +++ b/test/psych/test_stream.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb index a8ae55c..25c6353 100644 --- a/test/psych/test_string.rb +++ b/test/psych/test_string.rb @@ -1,4 +1,5 @@ # encoding: UTF-8 +# frozen_string_literal: false require_relative 'helper' module Psych @@ -98,6 +99,10 @@ module Psych assert_cycle '+.' end + def test_float_with_no_fractional_before_exponent + assert_cycle '0.E+0' + end + def test_string_subclass_with_anchor y = Psych.load <<-eoyml --- diff --git a/test/psych/test_struct.rb b/test/psych/test_struct.rb index 8c7f251..b7968d3 100644 --- a/test/psych/test_struct.rb +++ b/test/psych/test_struct.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' class PsychStructWithIvar < Struct.new(:foo) diff --git a/test/psych/test_symbol.rb b/test/psych/test_symbol.rb index 558a672..a98881c 100644 --- a/test/psych/test_symbol.rb +++ b/test/psych/test_symbol.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_tainted.rb b/test/psych/test_tainted.rb index 37fc5b2..8705833 100644 --- a/test/psych/test_tainted.rb +++ b/test/psych/test_tainted.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_to_yaml_properties.rb b/test/psych/test_to_yaml_properties.rb index 724aab4..8a29b6a 100644 --- a/test/psych/test_to_yaml_properties.rb +++ b/test/psych/test_to_yaml_properties.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_tree_builder.rb b/test/psych/test_tree_builder.rb index 7ad3ddd..09f1ee3 100644 --- a/test/psych/test_tree_builder.rb +++ b/test/psych/test_tree_builder.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' module Psych diff --git a/test/psych/test_yaml.rb b/test/psych/test_yaml.rb index e628175..f8e9e2f 100644 --- a/test/psych/test_yaml.rb +++ b/test/psych/test_yaml.rb @@ -1,4 +1,5 @@ # -*- coding: us-ascii; mode: ruby; ruby-indent-level: 4; tab-width: 4 -*- +# frozen_string_literal: false # vim:sw=4:ts=4 # $Id$ # diff --git a/test/psych/test_yamldbm.rb b/test/psych/test_yamldbm.rb index 62c88b7..71ee04f 100644 --- a/test/psych/test_yamldbm.rb +++ b/test/psych/test_yamldbm.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' require 'tmpdir' diff --git a/test/psych/test_yamlstore.rb b/test/psych/test_yamlstore.rb index 94f1330..a9ce652 100644 --- a/test/psych/test_yamlstore.rb +++ b/test/psych/test_yamlstore.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative 'helper' require 'yaml/store' require 'tmpdir' diff --git a/test/psych/visitors/test_depth_first.rb b/test/psych/visitors/test_depth_first.rb index 837c8e8..8072c26 100644 --- a/test/psych/visitors/test_depth_first.rb +++ b/test/psych/visitors/test_depth_first.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/helper' module Psych diff --git a/test/psych/visitors/test_emitter.rb b/test/psych/visitors/test_emitter.rb index 780c953..9317855 100644 --- a/test/psych/visitors/test_emitter.rb +++ b/test/psych/visitors/test_emitter.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/helper' module Psych diff --git a/test/psych/visitors/test_to_ruby.rb b/test/psych/visitors/test_to_ruby.rb index 19e5365..8878ea2 100644 --- a/test/psych/visitors/test_to_ruby.rb +++ b/test/psych/visitors/test_to_ruby.rb @@ -1,4 +1,5 @@ # coding: US-ASCII +# frozen_string_literal: false require 'psych/helper' module Psych diff --git a/test/psych/visitors/test_yaml_tree.rb b/test/psych/visitors/test_yaml_tree.rb index 40702bc..5755f58 100644 --- a/test/psych/visitors/test_yaml_tree.rb +++ b/test/psych/visitors/test_yaml_tree.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'psych/helper' module Psych @@ -155,6 +156,12 @@ module Psych assert_equal(-1, Psych.load(Psych.dump(-1 / 0.0)).infinite?) end + def test_string + assert_match(/'017'/, Psych.dump({'a' => '017'})) + assert_match(/'019'/, Psych.dump({'a' => '019'})) + assert_match(/'01818'/, Psych.dump({'a' => '01818'})) + end + # http://yaml.org/type/null.html def test_nil assert_cycle nil |