libis-format 0.9.41 → 0.9.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +365 -0
- data/bin/droid +1 -1
- data/bin/fido +1 -1
- data/bin/pdf_copy +1 -1
- data/lib/libis/format/config.rb +1 -0
- data/lib/libis/format/converter/audio_converter.rb +1 -1
- data/lib/libis/format/converter/base.rb +2 -1
- data/lib/libis/format/converter/office_converter.rb +2 -2
- data/lib/libis/format/converter/pdf_converter.rb +6 -6
- data/lib/libis/format/converter/video_converter.rb +96 -2
- data/lib/libis/format/identifier.rb +12 -12
- data/lib/libis/format/tool/droid.rb +108 -0
- data/lib/libis/format/tool/extension_identification.rb +58 -0
- data/lib/libis/format/tool/ffmpeg.rb +43 -0
- data/lib/libis/format/tool/fido.rb +91 -0
- data/lib/libis/format/tool/file_tool.rb +78 -0
- data/lib/libis/format/tool/identification_tool.rb +175 -0
- data/lib/libis/format/tool/office_to_pdf.rb +54 -0
- data/lib/libis/format/tool/pdf_copy.rb +42 -0
- data/lib/libis/format/tool/pdf_merge.rb +43 -0
- data/lib/libis/format/tool/pdf_optimizer.rb +38 -0
- data/lib/libis/format/tool/pdf_split.rb +41 -0
- data/lib/libis/format/tool/pdf_to_pdfa.rb +78 -0
- data/lib/libis/format/tool/pdfa_validator.rb +63 -0
- data/lib/libis/format/tool.rb +23 -0
- data/lib/libis/format/version.rb +1 -1
- data/lib/libis/format.rb +1 -15
- data/libis-format.gemspec +1 -2
- data/spec/converter_audio_spec.rb +66 -0
- data/spec/converter_image_spec.rb +166 -0
- data/spec/converter_office_spec.rb +84 -0
- data/spec/converter_pdf_spec.rb +30 -0
- data/spec/converter_repository_spec.rb +91 -0
- data/spec/converter_video_spec.rb +97 -0
- data/spec/data/video/copyright.png +0 -0
- data/spec/identifier_spec.rb +3 -15
- metadata +32 -33
- data/lib/libis/format/droid.rb +0 -106
- data/lib/libis/format/extension_identification.rb +0 -55
- data/lib/libis/format/ffmpeg.rb +0 -41
- data/lib/libis/format/fido.rb +0 -89
- data/lib/libis/format/file_tool.rb +0 -76
- data/lib/libis/format/identification_tool.rb +0 -174
- data/lib/libis/format/office_to_pdf.rb +0 -52
- data/lib/libis/format/pdf_copy.rb +0 -40
- data/lib/libis/format/pdf_merge.rb +0 -41
- data/lib/libis/format/pdf_optimizer.rb +0 -36
- data/lib/libis/format/pdf_split.rb +0 -39
- data/lib/libis/format/pdf_to_pdfa.rb +0 -74
- data/lib/libis/format/pdfa_validator.rb +0 -61
- data/spec/converter_spec.rb +0 -433
@@ -0,0 +1,84 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
require 'libis/format/converter/office_converter'
|
5
|
+
|
6
|
+
describe 'Converters' do
|
7
|
+
|
8
|
+
let(:repository) {Libis::Format::Converter::Repository}
|
9
|
+
let(:file_dir) {File.dirname(__FILE__)}
|
10
|
+
|
11
|
+
before(:all) {
|
12
|
+
Libis::Tools::Config.logger.level = 'off'
|
13
|
+
}
|
14
|
+
|
15
|
+
context 'Office Converter' do
|
16
|
+
|
17
|
+
let(:converter) {Libis::Format::Converter::OfficeConverter.new}
|
18
|
+
|
19
|
+
it 'converts Word document to PDF' do
|
20
|
+
src_file = File.join(file_dir, 'data', 'test.doc')
|
21
|
+
tgt_file = File.join(file_dir, 'work', 'test_doc.pdf')
|
22
|
+
FileUtils.mkdir_p File.dirname(tgt_file)
|
23
|
+
result = converter.convert(src_file, tgt_file, :PDF)
|
24
|
+
expect(result).to eq tgt_file
|
25
|
+
FileUtils.rm tgt_file, force: true
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'converts Word 2010 document to PDF' do
|
29
|
+
src_file = File.join(file_dir, 'data', 'test.docx')
|
30
|
+
tgt_file = File.join(file_dir, 'work', 'test_docx.pdf')
|
31
|
+
FileUtils.mkdir_p File.dirname(tgt_file)
|
32
|
+
result = converter.convert(src_file, tgt_file, :PDF)
|
33
|
+
expect(result).to eq tgt_file
|
34
|
+
FileUtils.rm tgt_file, force: true
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'converts OpenOffice document to PDF' do
|
38
|
+
src_file = File.join(file_dir, 'data', 'test.odt')
|
39
|
+
tgt_file = File.join(file_dir, 'work', 'test_odt.pdf')
|
40
|
+
FileUtils.mkdir_p File.dirname(tgt_file)
|
41
|
+
result = converter.convert(src_file, tgt_file, :PDF)
|
42
|
+
expect(result).to eq tgt_file
|
43
|
+
FileUtils.rm tgt_file, force: true
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'converts RTF document to PDF' do
|
47
|
+
src_file = File.join(file_dir, 'data', 'test.rtf')
|
48
|
+
tgt_file = File.join(file_dir, 'work', 'test_rtf.pdf')
|
49
|
+
FileUtils.mkdir_p File.dirname(tgt_file)
|
50
|
+
result = converter.convert(src_file, tgt_file, :PDF)
|
51
|
+
expect(result).to eq tgt_file
|
52
|
+
FileUtils.rm tgt_file, force: true
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'converts TXT document to PDF' do
|
56
|
+
src_file = File.join(file_dir, 'data', 'test.txt')
|
57
|
+
tgt_file = File.join(file_dir, 'work', 'test_txt.pdf')
|
58
|
+
FileUtils.mkdir_p File.dirname(tgt_file)
|
59
|
+
result = converter.convert(src_file, tgt_file, :PDF)
|
60
|
+
expect(result).to eq tgt_file
|
61
|
+
FileUtils.rm tgt_file, force: true
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'converts Excel to PDF' do
|
65
|
+
src_file = File.join(file_dir, 'data', 'test.xls')
|
66
|
+
tgt_file = File.join(file_dir, 'work', 'test_xls.pdf')
|
67
|
+
FileUtils.mkdir_p File.dirname(tgt_file)
|
68
|
+
result = converter.convert(src_file, tgt_file, :PDF)
|
69
|
+
expect(result).to eq tgt_file
|
70
|
+
FileUtils.rm tgt_file, force: true
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'converts Excel 2011 to PDF' do
|
74
|
+
src_file = File.join(file_dir, 'data', 'test.xlsx')
|
75
|
+
tgt_file = File.join(file_dir, 'work', 'test_xlsx.pdf')
|
76
|
+
FileUtils.mkdir_p File.dirname(tgt_file)
|
77
|
+
result = converter.convert(src_file, tgt_file, :PDF)
|
78
|
+
expect(result).to eq tgt_file
|
79
|
+
FileUtils.rm tgt_file, force: true
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
require 'libis/format/converter/pdf_converter'
|
5
|
+
|
6
|
+
describe 'Converters' do
|
7
|
+
|
8
|
+
let(:repository) {Libis::Format::Converter::Repository}
|
9
|
+
let(:file_dir) {File.dirname(__FILE__)}
|
10
|
+
|
11
|
+
before(:all) {
|
12
|
+
Libis::Tools::Config.logger.level = 'off'
|
13
|
+
}
|
14
|
+
|
15
|
+
context 'Pdf Converter', if: File.exists?(Libis::Format::Config[:ghostscript_path]) do
|
16
|
+
|
17
|
+
let(:converter) {Libis::Format::Converter::PdfConverter.new}
|
18
|
+
|
19
|
+
it 'converts PDF to PDF/A' do
|
20
|
+
src_file = File.join(file_dir, 'data', 'test.pdf')
|
21
|
+
tgt_file = File.join('', 'tmp', 'test_pdfa.pdf')
|
22
|
+
FileUtils.mkdir_p File.dirname(tgt_file)
|
23
|
+
result = converter.convert(src_file, tgt_file, :PDFA)
|
24
|
+
expect(result).to eq tgt_file
|
25
|
+
FileUtils.rm tgt_file, force: true
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'Converters' do
|
5
|
+
|
6
|
+
let(:repository) {Libis::Format::Converter::Repository}
|
7
|
+
let(:file_dir) {File.dirname(__FILE__)}
|
8
|
+
|
9
|
+
before(:all) {
|
10
|
+
Libis::Tools::Config.logger.level = 'off'
|
11
|
+
}
|
12
|
+
|
13
|
+
context 'Repository' do
|
14
|
+
|
15
|
+
it 'loads all converters' do
|
16
|
+
expect(repository.get_converters.size).to eq 6
|
17
|
+
# noinspection RubyResolve
|
18
|
+
expect(repository.get_converters.map(&:to_s)).to include 'Libis::Format::Converter::ImageConverter'
|
19
|
+
# noinspection RubyResolve
|
20
|
+
expect(repository.get_converters.map(&:to_s)).to include 'Libis::Format::Converter::OfficeConverter'
|
21
|
+
# noinspection RubyResolve
|
22
|
+
expect(repository.get_converters.map(&:to_s)).to include 'Libis::Format::Converter::PdfConverter'
|
23
|
+
# noinspection RubyResolve
|
24
|
+
expect(repository.get_converters.map(&:to_s)).to include 'Libis::Format::Converter::Jp2Converter'
|
25
|
+
# noinspection RubyResolve
|
26
|
+
expect(repository.get_converters.map(&:to_s)).to include 'Libis::Format::Converter::AudioConverter'
|
27
|
+
# noinspection RubyResolve
|
28
|
+
expect(repository.get_converters.map(&:to_s)).to include 'Libis::Format::Converter::VideoConverter'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'creates simple converter chain' do
|
32
|
+
chain = repository.get_converter_chain(:TIFF, :PDF)
|
33
|
+
expect(chain).to_not be nil
|
34
|
+
expect(chain.to_array.size).to eq 1
|
35
|
+
expect(chain.to_array).to match [{converter: Libis::Format::Converter::ImageConverter, input: :TIFF, output: :PDF}]
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'creates complex chain' do
|
39
|
+
chain = repository.get_converter_chain(:TIFF, :PDFA)
|
40
|
+
expect(chain).to_not be nil
|
41
|
+
expect(chain.to_array.size).to eq 2
|
42
|
+
expect(chain.to_array).to match [
|
43
|
+
{converter: Libis::Format::Converter::ImageConverter, input: :TIFF, output: :PDF},
|
44
|
+
{converter: Libis::Format::Converter::PdfConverter, input: :PDF, output: :PDFA},
|
45
|
+
]
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'creates converter chain with options' do
|
49
|
+
chain = repository.get_converter_chain(:TIFF, :PDF, {watermark: {}})
|
50
|
+
expect(chain).to_not be nil
|
51
|
+
expect(chain.to_array.size).to eq 1
|
52
|
+
expect(chain.to_array).to match [
|
53
|
+
{converter: Libis::Format::Converter::ImageConverter, input: :TIFF, output: :PDF, operations: [{method: :watermark, argument: {}}]}
|
54
|
+
]
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'perfers operations to the end of the chain' do
|
58
|
+
chain = repository.get_converter_chain(:TIFF, :PDFA, {watermark: {}})
|
59
|
+
expect(chain).to_not be nil
|
60
|
+
expect(chain.to_array.size).to eq 2
|
61
|
+
expect(chain.to_array).to match [
|
62
|
+
{converter: Libis::Format::Converter::ImageConverter, input: :TIFF, output: :PDF},
|
63
|
+
{converter: Libis::Format::Converter::PdfConverter, input: :PDF, output: :PDFA, operations: [{method: :watermark, argument: {}}]}
|
64
|
+
]
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'create chain for TIFF to JP2' do
|
68
|
+
|
69
|
+
it 'without operators' do
|
70
|
+
chain = repository.get_converter_chain(:TIFF, :JP2)
|
71
|
+
expect(chain).to_not be nil
|
72
|
+
expect(chain.to_array.size).to eq 1
|
73
|
+
expect(chain.to_array).to match [
|
74
|
+
{converter: Libis::Format::Converter::ImageConverter, input: :TIFF, output: :JP2}
|
75
|
+
]
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'with force operator' do
|
79
|
+
chain = repository.get_converter_chain(:TIFF, :JP2, {lossless: true})
|
80
|
+
expect(chain).to_not be nil
|
81
|
+
expect(chain.to_array.size).to eq 1
|
82
|
+
expect(chain.to_array).to match [
|
83
|
+
{converter: Libis::Format::Converter::Jp2Converter, input: :TIFF, output: :JP2, operations: [{method: :lossless, argument: true}]}
|
84
|
+
]
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
require 'libis/format/converter/video_converter'
|
5
|
+
|
6
|
+
describe 'Converters' do
|
7
|
+
|
8
|
+
let(:repository) {Libis::Format::Converter::Repository}
|
9
|
+
let(:file_dir) {File.dirname(__FILE__)}
|
10
|
+
|
11
|
+
before(:all) {
|
12
|
+
Libis::Tools::Config.logger.level = 'off'
|
13
|
+
}
|
14
|
+
|
15
|
+
context 'Video Converter' do
|
16
|
+
|
17
|
+
let(:converter) {Libis::Format::Converter::VideoConverter.new}
|
18
|
+
extensions = %w'3gp avi flv mkv mov mp4 mpg swf webm wmv'
|
19
|
+
targets = %w'avi flv mkv mov mp4 swf webm wmv gif'
|
20
|
+
# noinspection RubyLiteralArrayInspection
|
21
|
+
sources = [
|
22
|
+
'SampleVideo_176x144_2mb',
|
23
|
+
'SampleVideo_320x240_2mb',
|
24
|
+
'SampleVideo_360x240_2mb',
|
25
|
+
'SampleVideo_1080x720_2mb'
|
26
|
+
]
|
27
|
+
bad_converts = [
|
28
|
+
]
|
29
|
+
let(:data_dir) {File.join(file_dir, 'data', 'video')}
|
30
|
+
|
31
|
+
context 'converts' do
|
32
|
+
sources.each do |source|
|
33
|
+
context source do
|
34
|
+
extensions.each do |ext|
|
35
|
+
next unless (File.exists?(File.join(File.dirname(__FILE__), 'data', 'video', "#{source}.#{ext}")))
|
36
|
+
(targets - [ext]).each do |tgt|
|
37
|
+
next if bad_converts.include? [ext, tgt]
|
38
|
+
it "#{ext} to #{tgt}" do
|
39
|
+
src_file = File.join(data_dir, "#{source}.#{ext}")
|
40
|
+
tgt_file = File.join('', 'tmp', "test.#{source}.#{ext}.#{tgt}")
|
41
|
+
FileUtils.remove tgt_file, force: true
|
42
|
+
FileUtils.mkdir_p File.dirname(tgt_file)
|
43
|
+
converter.audio_channels(2) if %w'swf wmv'.include?(tgt)
|
44
|
+
converter.sampling_freq(44100) if tgt == 'swf'
|
45
|
+
if tgt == 'gif'
|
46
|
+
converter.start(1)
|
47
|
+
converter.duration(3)
|
48
|
+
converter.scale('100x100')
|
49
|
+
end
|
50
|
+
result = converter.convert(src_file, tgt_file, tgt.upcase.to_sym)
|
51
|
+
expect(result).to eq tgt_file
|
52
|
+
expect(File.size(result)).to be > 2000
|
53
|
+
FileUtils.remove tgt_file, force: true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'watermark' do
|
62
|
+
# noinspection RubyLiteralArrayInspection
|
63
|
+
[
|
64
|
+
'SampleVideo_176x144_2mb.3gp',
|
65
|
+
'SampleVideo_320x240_2mb.3gp',
|
66
|
+
'SampleVideo_360x240_2mb.mp4',
|
67
|
+
'SampleVideo_1080x720_2mb.mp4'
|
68
|
+
].each do |source|
|
69
|
+
it "text with default options - #{source}" do
|
70
|
+
src_file = File.join(data_dir, "#{source}")
|
71
|
+
tgt_file = File.join('', 'tmp', "test.#{source}_watermark.mp4")
|
72
|
+
FileUtils.remove tgt_file, force: true
|
73
|
+
FileUtils.mkdir_p File.dirname(tgt_file)
|
74
|
+
converter.watermark_text '© LIBIS Format gem test'
|
75
|
+
result = converter.convert(src_file, tgt_file, :MP4)
|
76
|
+
expect(result).to eq tgt_file
|
77
|
+
expect(File.size(result)).to be > 2000
|
78
|
+
FileUtils.remove tgt_file, force: true
|
79
|
+
end
|
80
|
+
|
81
|
+
it "image with default options - #{source}" do
|
82
|
+
src_file = File.join(data_dir, "#{source}")
|
83
|
+
tgt_file = File.join('', 'tmp', "test.#{source}_watermark_image.mp4")
|
84
|
+
FileUtils.remove tgt_file, force: true
|
85
|
+
FileUtils.mkdir_p File.dirname(tgt_file)
|
86
|
+
converter.watermark_image File.join(data_dir, 'copyright.png')
|
87
|
+
result = converter.convert(src_file, tgt_file, :MP4)
|
88
|
+
expect(result).to eq tgt_file
|
89
|
+
expect(File.size(result)).to be > 2000
|
90
|
+
FileUtils.remove tgt_file, force: true
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
Binary file
|
data/spec/identifier_spec.rb
CHANGED
@@ -75,18 +75,6 @@ describe 'Identfier' do
|
|
75
75
|
let (:logoutput) {::Libis::Tools::Config.logger.appenders.last.sio}
|
76
76
|
let (:dir) {File.join File.absolute_path(File.dirname(__FILE__)), 'data'}
|
77
77
|
|
78
|
-
# context 'bug test' do
|
79
|
-
#
|
80
|
-
# let (:dir) {'/nas/vol03/lbs/alma/etd-kul/sap/FIIW/out/0623689_17450'}
|
81
|
-
#
|
82
|
-
# it 'just works' do
|
83
|
-
# result = identifier.get(dir)
|
84
|
-
# ap result
|
85
|
-
# expect(result).not_to be_nil
|
86
|
-
# end
|
87
|
-
#
|
88
|
-
# end
|
89
|
-
|
90
78
|
it 'should initialize correctly' do
|
91
79
|
expect(identifier.xml_validations.size).to be 1
|
92
80
|
expect(File.basename identifier.xml_validations['archive/ead']).to eq 'ead.xsd'
|
@@ -116,7 +104,7 @@ describe 'Identfier' do
|
|
116
104
|
end
|
117
105
|
|
118
106
|
it 'should identify all files in a folder with base_dir option' do
|
119
|
-
result = identifier.get(dir, base_dir: dir)
|
107
|
+
result = identifier.get(dir, base_dir: dir, keep_output: true)
|
120
108
|
expect(result[:formats].size).to be >= formatlist.size
|
121
109
|
formatlist.each do |file, format|
|
122
110
|
expect(result[:formats][file]).to include format
|
@@ -149,7 +137,7 @@ describe 'Identfier' do
|
|
149
137
|
# expect(File.basename(identifier.fido_formats.first)).to eq 'lias_formats.xml'
|
150
138
|
it 'should identify list of test documents' do
|
151
139
|
filelist = formatlist.keys.map {|file| File.join(dir, file)}
|
152
|
-
fido_result = ::Libis::Format::Fido.instance.run_list(filelist)
|
140
|
+
fido_result = ::Libis::Format::Tool::Fido.instance.run_list(filelist)
|
153
141
|
filelist.each do |filename|
|
154
142
|
result = fido_result[filename]
|
155
143
|
result = result[0] if result
|
@@ -160,7 +148,7 @@ describe 'Identfier' do
|
|
160
148
|
|
161
149
|
it 'should identify dir of test documents' do
|
162
150
|
filelist = fidolist.keys.map {|file| File.join(dir, file)}
|
163
|
-
fido_result = ::Libis::Format::Fido.instance.run_dir(dir, false)
|
151
|
+
fido_result = ::Libis::Format::Tool::Fido.instance.run_dir(dir, false)
|
164
152
|
filelist.each do |filename|
|
165
153
|
result = fido_result[filename]
|
166
154
|
result = result[0] if result
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libis-format
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.44
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kris Dekeyser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.1'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: simplecov
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.9'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0.9'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: awesome_print
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +72,14 @@ dependencies:
|
|
86
72
|
requirements:
|
87
73
|
- - "~>"
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.9.
|
75
|
+
version: 0.9.57
|
90
76
|
type: :runtime
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.9.
|
82
|
+
version: 0.9.57
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: os
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -191,24 +177,30 @@ files:
|
|
191
177
|
- lib/libis/format/converter/pdf_converter.rb
|
192
178
|
- lib/libis/format/converter/repository.rb
|
193
179
|
- lib/libis/format/converter/video_converter.rb
|
194
|
-
- lib/libis/format/droid.rb
|
195
|
-
- lib/libis/format/extension_identification.rb
|
196
|
-
- lib/libis/format/ffmpeg.rb
|
197
|
-
- lib/libis/format/fido.rb
|
198
|
-
- lib/libis/format/file_tool.rb
|
199
|
-
- lib/libis/format/identification_tool.rb
|
200
180
|
- lib/libis/format/identifier.rb
|
201
|
-
- lib/libis/format/
|
202
|
-
- lib/libis/format/
|
203
|
-
- lib/libis/format/
|
204
|
-
- lib/libis/format/
|
205
|
-
- lib/libis/format/
|
206
|
-
- lib/libis/format/
|
207
|
-
- lib/libis/format/
|
181
|
+
- lib/libis/format/tool.rb
|
182
|
+
- lib/libis/format/tool/droid.rb
|
183
|
+
- lib/libis/format/tool/extension_identification.rb
|
184
|
+
- lib/libis/format/tool/ffmpeg.rb
|
185
|
+
- lib/libis/format/tool/fido.rb
|
186
|
+
- lib/libis/format/tool/file_tool.rb
|
187
|
+
- lib/libis/format/tool/identification_tool.rb
|
188
|
+
- lib/libis/format/tool/office_to_pdf.rb
|
189
|
+
- lib/libis/format/tool/pdf_copy.rb
|
190
|
+
- lib/libis/format/tool/pdf_merge.rb
|
191
|
+
- lib/libis/format/tool/pdf_optimizer.rb
|
192
|
+
- lib/libis/format/tool/pdf_split.rb
|
193
|
+
- lib/libis/format/tool/pdf_to_pdfa.rb
|
194
|
+
- lib/libis/format/tool/pdfa_validator.rb
|
208
195
|
- lib/libis/format/type_database.rb
|
209
196
|
- lib/libis/format/version.rb
|
210
197
|
- libis-format.gemspec
|
211
|
-
- spec/
|
198
|
+
- spec/converter_audio_spec.rb
|
199
|
+
- spec/converter_image_spec.rb
|
200
|
+
- spec/converter_office_spec.rb
|
201
|
+
- spec/converter_pdf_spec.rb
|
202
|
+
- spec/converter_repository_spec.rb
|
203
|
+
- spec/converter_video_spec.rb
|
212
204
|
- spec/data/Cevennes2.bmp
|
213
205
|
- spec/data/Cevennes2.jp2
|
214
206
|
- spec/data/Cevennes2.ppm
|
@@ -301,6 +293,7 @@ files:
|
|
301
293
|
- spec/data/video/SampleVideo_360x240_2mb.flv
|
302
294
|
- spec/data/video/SampleVideo_360x240_2mb.mkv
|
303
295
|
- spec/data/video/SampleVideo_360x240_2mb.mp4
|
296
|
+
- spec/data/video/copyright.png
|
304
297
|
- spec/identifier_spec.rb
|
305
298
|
- spec/spec_helper.rb
|
306
299
|
- spec/test_types.yml
|
@@ -335,7 +328,12 @@ signing_key:
|
|
335
328
|
specification_version: 4
|
336
329
|
summary: LIBIS File format format services.
|
337
330
|
test_files:
|
338
|
-
- spec/
|
331
|
+
- spec/converter_audio_spec.rb
|
332
|
+
- spec/converter_image_spec.rb
|
333
|
+
- spec/converter_office_spec.rb
|
334
|
+
- spec/converter_pdf_spec.rb
|
335
|
+
- spec/converter_repository_spec.rb
|
336
|
+
- spec/converter_video_spec.rb
|
339
337
|
- spec/data/Cevennes2.bmp
|
340
338
|
- spec/data/Cevennes2.jp2
|
341
339
|
- spec/data/Cevennes2.ppm
|
@@ -428,6 +426,7 @@ test_files:
|
|
428
426
|
- spec/data/video/SampleVideo_360x240_2mb.flv
|
429
427
|
- spec/data/video/SampleVideo_360x240_2mb.mkv
|
430
428
|
- spec/data/video/SampleVideo_360x240_2mb.mp4
|
429
|
+
- spec/data/video/copyright.png
|
431
430
|
- spec/identifier_spec.rb
|
432
431
|
- spec/spec_helper.rb
|
433
432
|
- spec/test_types.yml
|
data/lib/libis/format/droid.rb
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
require 'singleton'
|
2
|
-
|
3
|
-
require 'tempfile'
|
4
|
-
require 'csv'
|
5
|
-
|
6
|
-
require 'libis/format/config'
|
7
|
-
|
8
|
-
unless CSV::HeaderConverters.has_key?(:droid_headers)
|
9
|
-
CSV::HeaderConverters[:droid_headers] = lambda {|h|
|
10
|
-
h.encode(ConverterEncoding).downcase.strip.
|
11
|
-
gsub(/\W+/, "").to_sym
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
|
-
require_relative 'identification_tool'
|
16
|
-
|
17
|
-
module Libis
|
18
|
-
module Format
|
19
|
-
|
20
|
-
class Droid < Libis::Format::IdentificationTool
|
21
|
-
|
22
|
-
def run_list(filelist)
|
23
|
-
runner(filelist)
|
24
|
-
end
|
25
|
-
|
26
|
-
def run_dir(dir, recursive = true)
|
27
|
-
profile = profile_file_name
|
28
|
-
report = result_file_name
|
29
|
-
create_profile(dir, profile, recursive)
|
30
|
-
create_report(profile, report)
|
31
|
-
parse_report(report)
|
32
|
-
end
|
33
|
-
|
34
|
-
def run(file)
|
35
|
-
runner(file)
|
36
|
-
end
|
37
|
-
|
38
|
-
protected
|
39
|
-
|
40
|
-
def runner(file_or_list)
|
41
|
-
profile = profile_file_name
|
42
|
-
report = result_file_name
|
43
|
-
create_profile(file_or_list, profile)
|
44
|
-
create_report(profile, report)
|
45
|
-
parse_report(report)
|
46
|
-
end
|
47
|
-
|
48
|
-
def parse_report(report)
|
49
|
-
keys = [
|
50
|
-
:id, :parent_id, :uri, :filepath, :filename, :matchtype, :status, :filesize, :type, :extension,
|
51
|
-
:mod_time, :ext_mismatch, :hash, :format_count, :puid, :mimetype, :format_name, :format_version]
|
52
|
-
result = CSV.parse(File.readlines(report).join)
|
53
|
-
.map {|a| Hash[keys.zip(a)]}
|
54
|
-
.select {|a| a[:type] == 'File'}
|
55
|
-
# File.delete report
|
56
|
-
result.each do |r|
|
57
|
-
r.delete(:id)
|
58
|
-
r.delete(:parent_id)
|
59
|
-
r.delete(:uri)
|
60
|
-
r.delete(:filename)
|
61
|
-
r.delete(:status)
|
62
|
-
r.delete(:filesize)
|
63
|
-
r.delete(:type)
|
64
|
-
r.delete(:extension)
|
65
|
-
r.delete(:mod_time)
|
66
|
-
r.delete(:hash)
|
67
|
-
r.delete(:format_count)
|
68
|
-
r[:source] = :droid
|
69
|
-
end
|
70
|
-
File.delete report
|
71
|
-
process_output(result)
|
72
|
-
end
|
73
|
-
|
74
|
-
def create_report(profile, report)
|
75
|
-
args = [
|
76
|
-
'-e', report,
|
77
|
-
'-p', profile,
|
78
|
-
'-q'
|
79
|
-
]
|
80
|
-
result = Libis::Tools::Command.run(Libis::Format::Config[:droid_path], *args)
|
81
|
-
raise RuntimeError, "DROID report errors: #{result[:err].join("\n")}" unless result[:status] == 0
|
82
|
-
File.delete profile
|
83
|
-
end
|
84
|
-
|
85
|
-
def create_profile(file_or_list, profile, recursive = false)
|
86
|
-
args = []
|
87
|
-
files = (file_or_list.is_a?(Array)) ? file_or_list.map(&:escape_for_string) : [file_or_list.escape_for_string]
|
88
|
-
files.each { |file| args << '-a' << file}
|
89
|
-
args << '-p' << profile << '-q'
|
90
|
-
args << '-R' if recursive
|
91
|
-
result = Libis::Tools::Command.run(Libis::Format::Config[:droid_path], *args)
|
92
|
-
raise RuntimeError, "DROID profile errors: #{result[:err].join("\n")}" unless result[:status] == 0
|
93
|
-
end
|
94
|
-
|
95
|
-
def profile_file_name
|
96
|
-
File.join Dir.tmpdir, Dir::Tmpname.make_tmpname(%w'droid .profile', nil)
|
97
|
-
end
|
98
|
-
|
99
|
-
def result_file_name
|
100
|
-
File.join Dir.tmpdir, Dir::Tmpname.make_tmpname(%w'droid .csv', nil)
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
106
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require_relative 'identification_tool'
|
2
|
-
|
3
|
-
module Libis
|
4
|
-
module Format
|
5
|
-
|
6
|
-
class ExtensionIdentification < Libis::Format::IdentificationTool
|
7
|
-
|
8
|
-
def run_list(filelist)
|
9
|
-
|
10
|
-
output = runner(nil, filelist)
|
11
|
-
|
12
|
-
process_output(output)
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
def run_dir(dir, recursive = true)
|
17
|
-
|
18
|
-
filelist = find_files(dir, recursive)
|
19
|
-
|
20
|
-
output = runner(nil, filelist)
|
21
|
-
|
22
|
-
process_output(output)
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
def run(file)
|
27
|
-
|
28
|
-
output = runner(file)
|
29
|
-
|
30
|
-
process_output(output)
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
protected
|
35
|
-
|
36
|
-
def runner(*args)
|
37
|
-
|
38
|
-
args.map do |file|
|
39
|
-
info = ::Libis::Format::TypeDatabase.ext_infos(File.extname(file)).first
|
40
|
-
if info
|
41
|
-
{
|
42
|
-
filepath: file,
|
43
|
-
mimetype: (info[:MIME].first rescue nil),
|
44
|
-
puid: (info[:PUID].first rescue nil),
|
45
|
-
matchtype: 'extension',
|
46
|
-
source: :type_database
|
47
|
-
}
|
48
|
-
end
|
49
|
-
end.cleanup
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
data/lib/libis/format/ffmpeg.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'libis/tools/extend/string'
|
2
|
-
require 'libis/tools/extend/empty'
|
3
|
-
require 'libis/tools/command'
|
4
|
-
|
5
|
-
require 'csv'
|
6
|
-
require 'libis/format/config'
|
7
|
-
|
8
|
-
module Libis
|
9
|
-
module Format
|
10
|
-
|
11
|
-
class FFMpeg
|
12
|
-
include Singleton
|
13
|
-
include ::Libis::Tools::Logger
|
14
|
-
|
15
|
-
def self.run(source, target, options = {})
|
16
|
-
self.instance.run source, target, options
|
17
|
-
end
|
18
|
-
|
19
|
-
def run(source, target, options = {})
|
20
|
-
opts = []
|
21
|
-
opts += options[:global] unless options[:global].empty?
|
22
|
-
opts += options[:input] unless options[:input].empty?
|
23
|
-
opts << '-i' << source
|
24
|
-
opts += options[:filter] unless options[:filter].empty?
|
25
|
-
opts += options[:output] unless options[:output].empty?
|
26
|
-
opts << target
|
27
|
-
result = Libis::Tools::Command.run(Libis::Format::Config[:ffmpeg_path], *opts)
|
28
|
-
|
29
|
-
unless result[:status] == 0
|
30
|
-
error "FFMpeg errors: #{(result[:err] + result[:out]).join("\n")}"
|
31
|
-
return false
|
32
|
-
end
|
33
|
-
warn "FFMpeg warnings: #{(result[:err] + result[:out]).join("\n")}" unless result[:err].empty?
|
34
|
-
|
35
|
-
result[:out]
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|