Module: RedSnow
- Includes:
- Binding
- Defined in:
- lib/redsnow.rb,
lib/redsnow/object.rb,
lib/redsnow/binding.rb,
lib/redsnow/version.rb,
lib/redsnow/blueprint.rb,
lib/redsnow/sourcemap.rb,
lib/redsnow/parseresult.rb
Overview
The classes in this module should be 1:1 with the Snow Crash Blueprint sourcemap counterparts (github.com/apiaryio/snowcrash/blob/master/src/BlueprintSourcemap.h).
Defined Under Namespace
Modules: Binding, Memory, Sourcemap Classes: Action, Blueprint, BlueprintNode, ErrorCodes, Headers, KeyValueCollection, Location, Metadata, NamedBlueprintNode, Object, Parameter, Parameters, ParseResult, Payload, ReferenceNode, Resource, ResourceGroup, TransactionExample, WarningCodes
Constant Summary collapse
- EXPORT_SOURCEMAP_OPTION_KEY =
Options
:exportSourcemap
- REQUIRE_BLUEPRINT_NAME_OPTION_KEY =
:requireBlueprintName
- VERSION =
Gem version
'0.4.4'
Instance Attribute Summary collapse
-
#options ⇒ Object
Parse options.
Class Method Summary collapse
-
.parse(raw_blueprint, options = 0) ⇒ ParseResult
parse parsing API Blueprint into Ruby objects.
- .parse_options(options) ⇒ Object
Instance Attribute Details
Class Method Details
.parse(raw_blueprint, options = 0) ⇒ ParseResult
parse
parsing API Blueprint into Ruby objects
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/redsnow.rb', line 36 def self.parse(raw_blueprint, = 0) fail ArgumentError, 'Expected string value' unless raw_blueprint.is_a?(String) = () parse_result = FFI::MemoryPointer.new :pointer RedSnow::Binding.drafter_c_parse(raw_blueprint, , parse_result) parse_result = parse_result.get_pointer(0) ParseResult.new(parse_result.null? ? nil : parse_result.read_string) ensure RedSnow::Memory.free(parse_result) end |
.parse_options(options) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/redsnow.rb', line 18 def self.() # Parse Options if .is_a?(Numeric) return else opt = 0 opt |= (1 << 1) if [REQUIRE_BLUEPRINT_NAME_OPTION_KEY] opt |= (1 << 2) if [EXPORT_SOURCEMAP_OPTION_KEY] return opt end end |