diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..417620e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +ARG BASE_IMAGE=ruby:2.7 +FROM ${BASE_IMAGE} + +WORKDIR /app + +COPY gems.rb *.gemspec ./ +COPY lib/yaml/safe_load_stream/version.rb ./lib/yaml/safe_load_stream/ + +RUN gem install bundler:2.3.5 +RUN bundle install +RUN bundle update --bundler + +COPY . . + +ENTRYPOINT ["bundle", "exec"] diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..7bbbf80 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,36 @@ +services: + rspec-2.6: + build: + context: . + args: + BASE_IMAGE: ruby:2.6 + volumes: + - .:/app + entrypoint: bundle exec rspec + + rspec-2.7: + build: + context: . + args: + BASE_IMAGE: ruby:2.7 + volumes: + - .:/app + entrypoint: bundle exec rspec + + rspec-3.0: + build: + context: . + args: + BASE_IMAGE: ruby:3.0 + volumes: + - .:/app + entrypoint: bundle exec rspec + + rspec-3.1: + build: + context: . + args: + BASE_IMAGE: ruby:3.1 + volumes: + - .:/app + entrypoint: bundle exec rspec diff --git a/lib/yaml/safe_load_stream.rb b/lib/yaml/safe_load_stream.rb index 5b3879e..e8dc451 100644 --- a/lib/yaml/safe_load_stream.rb +++ b/lib/yaml/safe_load_stream.rb @@ -13,7 +13,7 @@ module YAMLSafeLoadStream # @return [Array] when a block is not given, returns an Array of documents module_function def safe_load_stream(yaml, filename = nil) result = [] - ::YAML.parse_stream(yaml, filename) do |stream| + ::YAML.parse_stream(yaml, filename: filename) do |stream| raise_if_tags(stream, filename) result << if block_given? yield(stream.to_ruby) @@ -38,7 +38,11 @@ module YAMLSafeLoadStream "in document #{doc_num}" end message += " in file #{filename}" if filename - raise Psych::DisallowedClass, message + if RUBY_VERSION < "3.1.0" + raise Psych::DisallowedClass, message + else + raise Psych::DisallowedClass.new(:load, message) + end end end end