Class: ChupaText::Decomposers::OpenDocument

Inherits:
ChupaText::Decomposer show all
Includes:
Loggable, Unzippable
Defined in:
lib/chupa-text/decomposers/opendocument.rb

Defined Under Namespace

Classes: AttributesListener

Instance Method Summary collapse

Methods inherited from ChupaText::Decomposer

#initialize, registry

Constructor Details

This class inherits a constructor from ChupaText::Decomposer

Instance Method Details

#decompose(data, &block) ⇒ Object


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/chupa-text/decomposers/opendocument.rb', line 38

def decompose(data, &block)
  unzip(data) do |zip|
    context = {
      data: data,
      attributes: {},
    }
    zip.each do |entry|
      next unless entry.file?
      case entry.zip_path
      when "content.xml"
        process_content(entry, context, &block)
      when "meta.xml"
        process_meta(entry, context, &block)
      end
    end
    finish_decompose(context, &block)
  end
end

#target?(data) ⇒ Boolean


25
26
27
28
# File 'lib/chupa-text/decomposers/opendocument.rb', line 25

def target?(data)
  data.extension == @extension or
    data.mime_type == @mime_type
end

#target_score(data) ⇒ Object


30
31
32
33
34
35
36
# File 'lib/chupa-text/decomposers/opendocument.rb', line 30

def target_score(data)
  if target?(data)
    -1
  else
    nil
  end
end