Sha256: dff4e3df55d075963ad48b92e43953aade6990f04a5bef750c5d5eb88d1ca5f1

Contents?: true

Size: 741 Bytes

Versions: 13

Compression:

Stored size: 741 Bytes

Contents

# TITLE:
#
#   YAML Extensions
#
# SUMMARY:
#
#   Extenstion related to YAML.
#
# AUTHORS:
#
#   - Thomas Sawyer

require 'yaml'

module Kernel
  # Convenience method for loading YAML.
  #
  def yaml(*args,&blk)
    YAML.load(*args,&blk)
  end
end

class File
  # Is a file a YAML file?
  #
  # Note this isn't perfect. At present it depends on the use
  # use of an initial document separator (eg. '---'). With
  # YAML 1.1 the %YAML delaration will be manditory, so in the
  # future this can be adapted to fit that standard.
  #
  def self.yaml?(file)
    File.open(file) do |f|
      until f.eof?
        line = f.gets
        break true if line =~ /^---/
        break false unless line =~ /^(\s*#.*?|\s*)$/
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
facets-2.0.1 lib/more/facets/yaml.rb
facets-2.0.0 lib/more/facets/yaml.rb
facets-2.0.2 lib/more/facets/yaml.rb
facets-2.0.4 lib/more/facets/yaml.rb
facets-2.0.5 lib/more/facets/yaml.rb
facets-2.1.0 lib/more/facets/yaml.rb
facets-2.1.1 lib/more/facets/yaml.rb
facets-2.1.2 lib/more/facets/yaml.rb
facets-2.0.3 lib/more/facets/yaml.rb
facets-2.2.1 lib/more/facets/yaml.rb
facets-2.2.0 lib/more/facets/yaml.rb
facets-2.3.0 lib/more/facets/yaml.rb
facets-2.1.3 lib/more/facets/yaml.rb