Module: Raml

Defined in:
lib/raml.rb,
lib/raml/node.rb,
lib/raml/parser.rb,
lib/raml/version.rb,
lib/raml/node/body.rb,
lib/raml/node/root.rb,
lib/raml/exceptions.rb,
lib/raml/node/trait.rb,
lib/raml/mixin/merge.rb,
lib/raml/node/header.rb,
lib/raml/node/method.rb,
lib/raml/node/schema.rb,
lib/raml/mixin/parent.rb,
lib/raml/mixin/global.rb,
lib/raml/mixin/bodies.rb,
lib/raml/mixin/headers.rb,
lib/raml/node/resource.rb,
lib/raml/node/template.rb,
lib/raml/node/response.rb,
lib/raml/node/reference.rb,
lib/raml/mixin/validation.rb,
lib/raml/node/resource_type.rb,
lib/raml/mixin/documentable.rb,
lib/raml/node/documentation.rb,
lib/raml/node/abstract_method.rb,
lib/raml/node/trait_reference.rb,
lib/raml/node/schema_reference.rb,
lib/raml/node/abstract_resource.rb,
lib/raml/node/parametized_reference.rb,
lib/raml/node/parameter/uri_parameter.rb,
lib/raml/node/resource_type_reference.rb,
lib/raml/node/parameter/form_parameter.rb,
lib/raml/node/parameter/query_parameter.rb,
lib/raml/node/parameter/base_uri_parameter.rb,
lib/raml/node/parameter/abstract_parameter.rb

Defined Under Namespace

Modules: Bodies, Documentable, Global, Headers, Merge, Parameter, Parent, Validation Classes: AbstractMethod, AbstractResource, Body, CantIncludeFile, Documentation, Header, InapplicableParameterAttribute, InvalidMediaType, InvalidMethod, InvalidParameterAttribute, InvalidParameterType, InvalidParent, InvalidProperty, InvalidSchema, MergeError, Method, Node, ParametizedReference, Parser, PropertiesNode, RamlError, Reference, RequiredPropertyMissing, Resource, ResourceType, ResourceTypeReference, Response, Root, Schema, SchemaReference, Template, Trait, TraitReference, UnknownProperty, UnknownResourceTypeReference, UnknownTraitReference, UnknownTypeOrTraitParamFunction, UnknownTypeOrTraitParameter, UnsupportedRamlVersion, ValueNode

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.parse(raml) ⇒ Raml::Root

Parses RAML from a string.

Raises:


60
61
62
# File 'lib/raml.rb', line 60

def self.parse(raml)
  Raml::Parser.parse raml
end

.parse_file(filepath) ⇒ Raml::Root

Parses RAML from a file.

Raises:

  • (Errno::ENOENT)

    if the file can't be found.

  • (Errno::EACCES)

    if the file can't be read.

  • (RamlError)

    if the RAML is invalid.


71
72
73
74
75
76
77
78
79
# File 'lib/raml.rb', line 71

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