Sha256: 6ce64d607cdd252d76b9a299d0268f2669c7ca3de417a0c7a0d89d8730f9d343
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
# -*- coding: utf-8 -*- =begin rdoc Please see README =end require "yaml" module YAML # Specify file glob patterns, load each file, and yield each YAML document to a block. # # @see [Dir#glob](http://www.ruby-doc.org/core/classes/Dir.html#M002347) for pattern details. # # @example To load file names that end with ".yml" or ".yaml" # # YAML.load_glob_documents("*.yml","*.yaml"){|document| # ... # } # def YAML.load_glob_documents(*globs) globs=[*globs.flatten] globs.each do |glob| Dir[glob].each do |filename| File.open(filename) do |file| YAML.load_stream(file) do |document| yield document end #load end #file end #dir end #each end #def # Specify file glob patterns, load each file, and yield each YAML key and its values to a block. # # @see [Dir#glob](http://www.ruby-doc.org/core/classes/Dir.html#M002347) for pattern details. # # @example To load file names that end with "*.yml" or "*.yaml" # # YAML.load_glob_keys("*.yml","*.yaml"){|key, values| # ... # } # def YAML.load_glob_keys(*globs) YAML.load_glob_documents(globs){|document| document.keys.map{|key| yield key, document[key] } } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sixarm_ruby_yaml_load_glob-2.0.2 | lib/sixarm_ruby_yaml_load_glob.rb |