Sha256: 550e48fb054f366310adf7bb875e5d8c5e063153b722dc532d4fd3d9b289e6fe
Contents?: true
Size: 903 Bytes
Versions: 8
Compression:
Stored size: 903 Bytes
Contents
require 'yaml' module YAML # Specify one or more directory patterns and pass each YAML file in the matching directories to a block. # # See [Dir#glob](http://www.ruby-doc.org/core/classes/Dir.html#M002347) for pattern details. # # ==Example # YAML.load_dir('/tmp/*.yaml'){|yaml_document| # #...whatever you want to do with each yaml document # } # # ==Example to load documents in files ending in ".yaml" and ".yml" # YAML.load_dir('/tmp/*.yaml','/tmp/*.yml','){|yaml_document| # #...whatever you want to do with the yaml document # } def YAML.load_dir(*dirpaths) dirpaths=[*dirpaths.flatten] dirpaths.each do |dirpath| Dir[dirpath].each do |filename| File.open(filename) do |file| YAML.load_documents(file) do |doc| yield doc end #load end #file end #dir end #each end #def end
Version data entries
8 entries across 8 versions & 1 rubygems