Module: FFI::Extractor

Extended by:
Library
Defined in:
lib/ffi/extractor/types.rb,
lib/ffi/extractor/library.rb,
lib/ffi/extractor/version.rb,
lib/ffi/extractor/extractor.rb,
lib/ffi/extractor/plugin_list.rb,
lib/ffi/extractor/metadata_processor.rb

Defined Under Namespace

Classes: MetadataProcessor, PluginList

Constant Summary collapse

VERSION =

ffi-extractor version

"0.1.1"

Class Method Summary collapse

Class Method Details

.abort!Object

Aborts metadata extraction.



40
41
42
# File 'lib/ffi/extractor/extractor.rb', line 40

def self.abort!
  throw :return, 1
end

.extract(data, plugins = Extractor.plugins) {|plugin_name, type, format, mime_type, data| ... } ⇒ Object

Extracts metadata.

Parameters:

  • data (String)

    The data to extract from.

  • plugins (PluginList) (defaults to: Extractor.plugins)

    The extraction plugins to use.

Yields:

  • (plugin_name, type, format, mime_type, data)

    The given block will be passed the extracted metadata.

Yield Parameters:

  • plugin_name (Symbol)

    The name of the plugin.

  • type (Symbol)

    The type of metadata.

  • format (:unknown, :utf8, :binary, :c_string)

    The format of the metadata.

  • mime_type (String)

    The MIME-type of the data.

  • data (String)

    The extracted metadata.



71
72
73
74
75
# File 'lib/ffi/extractor/extractor.rb', line 71

def self.extract(data,plugins=Extractor.plugins,&block)
  processor = MetadataProcessor.new(&block)

  Extractor.EXTRACTOR_extract(plugins,nil,data,data.length,processor,nil)
end

.extract_from(path, plugins = Extractor.plugins) {|plugin_name, type, format, mime_type, data| ... } ⇒ Object

Extracts metadata from a file.

Parameters:

  • path (String)

    The path to the file.

  • plugins (PluginList) (defaults to: Extractor.plugins)

    The extraction plugins to use.

Yields:

  • (plugin_name, type, format, mime_type, data)

    The given block will be passed the extracted metadata.

Yield Parameters:

  • plugin_name (Symbol)

    The name of the plugin.

  • type (Symbol)

    The type of metadata.

  • format (:unknown, :utf8, :binary, :c_string)

    The format of the metadata.

  • mime_type (String)

    The MIME-type of the data.

  • data (String)

    The extracted metadata.



104
105
106
107
108
# File 'lib/ffi/extractor/extractor.rb', line 104

def self.extract_from(path,plugins=Extractor.plugins,&block)
  processor = MetadataProcessor.new(&block)

  Extractor.EXTRACTOR_extract(plugins,path,nil,0,processor,nil)
end

.pluginsPluginList

The default list of plugins.

Returns:



33
34
35
# File 'lib/ffi/extractor/extractor.rb', line 33

def self.plugins
  @plugins ||= PluginList.default
end