Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
36 changes: 36 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 6 additions & 2 deletions lib/yaml/safe_load_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down