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/bodies.rb,
lib/raml/mixin/global.rb,
lib/raml/mixin/parent.rb,
lib/raml/mixin/headers.rb,
lib/raml/node/resource.rb,
lib/raml/node/response.rb,
lib/raml/node/template.rb,
lib/raml/node/reference.rb,
lib/raml/mixin/secured_by.rb,
lib/raml/mixin/validation.rb,
lib/raml/mixin/documentable.rb,
lib/raml/node/documentation.rb,
lib/raml/node/resource_type.rb,
lib/raml/node/abstract_method.rb,
lib/raml/node/security_scheme.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/security_scheme_reference.rb,
lib/raml/node/parameter/abstract_parameter.rb,
lib/raml/node/parameter/base_uri_parameter.rb

Defined Under Namespace

Modules: Bodies, Documentable, Global, Headers, Merge, Parameter, Parent, SecuredBy, 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, SecurityScheme, SecuritySchemeReference, Template, Trait, TraitReference, UnknownProperty, UnknownResourceTypeReference, UnknownSecuritySchemeReference, UnknownTraitReference, UnknownTypeOrTraitParamFunction, UnknownTypeOrTraitParameter, UnsupportedRamlVersion, ValueNode

Constant Summary collapse

VERSION =
"0.1.2"

Class Method Summary collapse

Class Method Details

.parse(raml) ⇒ Raml::Root

Parses RAML from a string.

Parameters:

  • raml (String)

    the string containing RAML.

Returns:

Raises:



64
65
66
# File 'lib/raml.rb', line 64

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

.parse_file(filepath) ⇒ Raml::Root

Parses RAML from a file.

Parameters:

  • filepath (String)

    the file path of the file containing RAML.

Returns:

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.



75
76
77
78
79
80
81
82
83
# 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