Class: ChupaText::Decomposers::Tar

Inherits:
ChupaText::Decomposer show all
Defined in:
lib/chupa-text/decomposers/tar.rb

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) ⇒ Object



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

def decompose(data)
  Gem::Package::TarReader.new(StringIO.new(data.body)) do |reader|
    reader.each do |entry|
      next unless entry.file?
      extracted = VirtualFileData.new(entry.full_name, entry)
      extracted.source = data
      yield(extracted)
    end
  end
end

#target?(data) ⇒ Boolean

Returns:

  • (Boolean)


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

def target?(data)
  data.extension == "tar" or
    data.mime_type == "application/x-tar"
end