module Extractor::MetadataProcessor
Defined in:
extractor/metadata_processor.crConstant Summary
-
CALLBACK =
->(cls : ::Pointer(Void), plugin : ::Pointer(Char), type : MetaType, format : MetaFormat, mime_type : ::Pointer(Char), data : ::Pointer(Char), size : SizeT) do callback = unbox(cls) plugin_name = PLUGIN_NAMES[String.new(plugin)] mime_type = String.new(mime_type) value = case format when MetaFormat::UTF8 String.new(Bytes.new(data, size - 1), "UTF-8") when MetaFormat::C_STRING String.new(Bytes.new(data, size - 1), "ASCII") else Bytes.new(data, size) end begin callback.call(plugin_name, type, format, mime_type, value) 0 rescue Abort 1 end end
-
PLUGIN_NAMES =
Hash(String, String).new do |plugin_names, plugin| libname = File.basename(plugin, File.extname(plugin)) plugin_names[plugin] = libname.sub("libextractor_", "") end
-
Mapping of plugin paths to names
Class Method Summary
-
.box(closure : Callback) : Pointer(Void)
Wraps a closure in a box.
-
.to_unsafe
Returns a proc literal for the
call
method. -
.unbox(cls : Pointer(Void)) : Callback
Unwraps a boxed closure.