module Raml

Constants

VERSION

Public Class Methods

parse(raml) click to toggle source

Parses RAML from a string.

@param raml [String] the string containing RAML. @return [Raml::Root] the RAML root node. @raise [RamlError] if the RAML is invalid.

# File lib/raml.rb, line 64
def self.parse(raml)
  Raml::Parser.parse raml
end
parse_file(filepath) click to toggle source

Parses RAML from a file.

@param filepath [String] the file path of the file containing RAML. @return [Raml::Root] the RAML root node. @raise [Errno::ENOENT] if the file can’t be found. @raise [Errno::EACCES] if the file can’t be read. @raise [RamlError] if the RAML is invalid.

# File lib/raml.rb, line 75
def self.parse_file(filepath)
  file = File.new filepath
  raise UnsupportedRamlVersion unless file.readline =~ /\A#%RAML 0.8\s*\z/

  path = File.dirname filepath
  path = nil if path == ''

  Raml::Parser.parse file.read, path
end