module Wrapture
Classes and functions for generating language wrappers
Constants
- EQUIVALENT_POINTER_KEYWORD
A string denoting a pointer to an equivalent struct type or value.
- EQUIVALENT_STRUCT_KEYWORD
A string denoting an equivalent struct type or value.
- KEYWORDS
A list of all keywords.
- RETURN_VALUE_KEYWORD
A string denoting the return value of a wrapped function call.
- SELF_REFERENCE_KEYWORD
A string denoting a reference to the object a method is called on.
- TEMPLATE_USE_KEYWORD
A string denoting a reference to a template.
- VERSION
the current version of
Wrapture
Public Class Methods
Normalizes a spec key to be boolean, raising an error if it is not. Keys that are not present are defaulted to false.
# File lib/wrapture/normalize.rb, line 24 def self.normalize_boolean(spec, key) is_boolean = [true, false].include?(spec[key]) error_msg = "'#{key}' key may only be true or false" raise(InvalidSpecKey, error_msg) unless !spec.key?(key) || is_boolean spec.key?(key) && spec[key] end
Normalizes an include list for an element. A single string will be converted into an array containing the single string, and a nil will be converted to an empty array.
# File lib/wrapture/normalize.rb, line 35 def self.normalize_includes(includes) if includes.nil? [] elsif includes.is_a? String [includes] else includes.uniq end end
Returns the spec version for the provided spec. If the version is not provided in the spec, the newest version that the spec is compliant with will be returned instead.
If this spec uses a version unsupported by this version of Wrapture
or the spec is otherwise invalid, an exception is raised.
# File lib/wrapture/normalize.rb, line 51 def self.spec_version(spec) if spec.key?('version') && !Wrapture.supports_version?(spec['version']) raise UnsupportedSpecVersion end if spec.key?('version') spec['version'] else Wrapture::VERSION end end
Returns true if the version of the spec is supported by this version of Wrapture
. Otherwise returns false.
# File lib/wrapture/version.rb, line 27 def self.supports_version?(version) wrapture_version = Gem::Version.new(Wrapture::VERSION) spec_version = Gem::Version.new(version) spec_version <= wrapture_version end