module Psych

def self.load_stream yaml, filename: nil, fallback: [], **kwargs


list # => ['foo', 'bar']
end
list << ruby
Psych.load_stream("--- foo\n...\n--- bar\n...") do |ruby|
list = []

Psych.load_stream("--- foo\n...\n--- bar\n...") # => ['foo', 'bar']

Example:

and passed to the block during parsing
as a list. If a block is given, each document will be converted to Ruby
Load multiple documents given in +yaml+. Returns the parsed documents
##
def self.load_stream yaml, filename: nil, fallback: [], **kwargs
  result = if block_given?
             parse_stream(yaml, filename: filename) do |node|
               yield node.to_ruby(**kwargs)
             end
           else
             parse_stream(yaml, filename: filename).children.map { |node| node.to_ruby(**kwargs) }
           end
  return fallback if result.is_a?(Array) && result.empty?
  result
end