Class: ChupaText::Decomposers::Zip
Instance Method Summary
collapse
#initialize, registry
Instance Method Details
#decompose(data) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/chupa-text/decomposers/zip.rb', line 34
def decompose(data)
Archive::Zip.open(StringIO.new(data.body)) do |zip|
zip.each do |entry|
next unless entry.file?
case entry.encryption_codec
when Archive::Zip::Codec::NullEncryption
else
raise EncryptedError.new(data)
end
entry_uri = data.uri.dup
base_path = entry_uri.path.gsub(/\.zip\z/i, "")
entry_uri.path = "#{base_path}/#{entry.zip_path}"
entry_data = VirtualFileData.new(entry_uri,
entry.file_data,
source_data: data)
yield(entry_data)
end
end
end
|
#target?(data) ⇒ Boolean
27
28
29
30
31
32
|
# File 'lib/chupa-text/decomposers/zip.rb', line 27
def target?(data)
return true if data.extension == "zip"
return true if data.mime_type == "application/zip"
false
end
|