Module: RedSnow
- Includes:
- Binding
- Defined in:
- lib/redsnow/object.rb,
lib/redsnow.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, 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.3.1"
Instance Attribute Summary collapse
-
#options ⇒ Object
Parse options.
Class Method Summary collapse
-
.parse(rawBlueprint, options = 0) ⇒ ParseResult
parse parsing API Blueprint into Ruby objects.
- .parse_options(options) ⇒ Object
Instance Attribute Details
Class Method Details
.parse(rawBlueprint, options = 0) ⇒ ParseResult
parse
parsing API Blueprint into Ruby objects
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/redsnow.rb', line 45 def self.parse(rawBlueprint, = 0) raise ArgumentError.new("Expected string value") unless rawBlueprint.is_a?(String) blueprintOptions = self.() blueprint = FFI::MemoryPointer.new :pointer sourcemap = FFI::MemoryPointer.new :pointer report = FFI::MemoryPointer.new :pointer RedSnow::Binding.sc_c_parse(rawBlueprint, blueprintOptions, report, blueprint, sourcemap) blueprint = blueprint.get_pointer(0) sourcemap = sourcemap.get_pointer(0) report = report.get_pointer(0) parseResult = ParseResult.new(report, blueprint, sourcemap) return parseResult ensure RedSnow::Binding.sc_sm_blueprint_free(sourcemap) RedSnow::Binding.sc_blueprint_free(blueprint) RedSnow::Binding.sc_report_free(report) end |
.parse_options(options) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/redsnow.rb', line 17 def self.() # Parse Options unless .is_a?(Numeric) opt = 0 if .has_key?(REQUIRE_BLUEPRINT_NAME_OPTION_KEY) if [REQUIRE_BLUEPRINT_NAME_OPTION_KEY] === true opt = opt | (1 << 1) end end if .has_key?(EXPORT_SOURCEMAP_OPTION_KEY) if [EXPORT_SOURCEMAP_OPTION_KEY] === true opt = opt | (1 << 2) end end return opt else return end end |