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

Version Path
webget_ramp-1.7.1.8 lib/webget_ramp/yaml.rb
webget_ramp-1.7.1.7 lib/webget_ramp/yaml.rb
webget_ramp-1.7.1.6 lib/webget_ramp/yaml.rb
webget_ramp-1.7.1.5 lib/webget_ramp/yaml.rb
webget_ramp-1.7.1.4 lib/webget_ramp/yaml.rb
webget_ramp-1.7.1.3 lib/webget_ramp/yaml.rb
webget_ramp-1.7.1.2 lib/webget_ramp/yaml.rb
webget_ramp-1.7.1.1 lib/webget_ramp/yaml.rb