Class | File |
In: |
lib/more/facets/yaml.rb
|
Parent: | Object |
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.
# File lib/more/facets/yaml.rb, line 65 65: def self.yaml?(file) 66: File.open(file) do |f| 67: until f.eof? 68: line = f.gets 69: break true if line =~ /^---/ 70: break false unless line =~ /^(\s*#.*?|\s*)$/ 71: end 72: end 73: end