libis-format 1.0.7 → 1.1.0
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/.travis.yml +31 -19
- data/Gemfile +2 -0
- data/lib/libis/format/config.rb +2 -0
- data/lib/libis/format/converter/audio_converter.rb +6 -8
- data/lib/libis/format/converter/chain.rb +16 -4
- data/lib/libis/format/converter/email_converter.rb +38 -0
- data/lib/libis/format/converter/fop_pdf_converter.rb +0 -2
- data/lib/libis/format/converter/image_converter.rb +5 -3
- data/lib/libis/format/converter/jp2_converter.rb +3 -3
- data/lib/libis/format/converter/office_converter.rb +1 -3
- data/lib/libis/format/converter/pdf_converter.rb +4 -1
- data/lib/libis/format/converter/spreadsheet_converter.rb +1 -3
- data/lib/libis/format/converter/video_converter.rb +5 -2
- data/lib/libis/format/tool/email_to_pdf.rb +75 -0
- data/lib/libis/format/tool/{ffmpeg.rb → ff_mpeg.rb} +10 -1
- data/lib/libis/format/tool/fop_pdf.rb +11 -0
- data/lib/libis/format/tool/office_to_pdf.rb +10 -1
- data/lib/libis/format/tool/pdf_copy.rb +11 -1
- data/lib/libis/format/tool/pdf_merge.rb +11 -1
- data/lib/libis/format/tool/pdf_optimizer.rb +11 -2
- data/lib/libis/format/tool/pdf_split.rb +11 -1
- data/lib/libis/format/tool/pdf_to_pdfa.rb +10 -1
- data/lib/libis/format/tool/spreadsheet_to_ods.rb +10 -1
- data/lib/libis/format/tool.rb +1 -1
- data/lib/libis/format/version.rb +1 -1
- data/libis-format.gemspec +2 -1
- data/tools/emailconverter.jar +0 -0
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40c91211db466867a86d905e707302783d77f8ce96bce970229294fc3506f4dd
|
4
|
+
data.tar.gz: 3254048984ba29c9c6a1d556f25e7dc346ba1c0fc2082b80562c3ae64f41dc8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caa9a7a5cbc6e99c7d1afb8af83274b2db4de847fde394d3d9cdc1129019044353bdbe6527fb4aabbcb8817be175e99f6bac1eeef0b79eb3e7ab94b7594db4ce
|
7
|
+
data.tar.gz: f3ade6093b38aab4b8c529c0d80e5a822aa2042264efc8d076077f74ee0cd20ebd91dbe5b2d6d030394607fcde196b28c8dabc2659788308e926981cca880905
|
data/.travis.yml
CHANGED
@@ -2,36 +2,51 @@ language: ruby
|
|
2
2
|
sudo: false
|
3
3
|
dist: trusty
|
4
4
|
cache: bundler
|
5
|
+
|
5
6
|
rvm:
|
6
|
-
- 2.
|
7
|
-
- 2.
|
8
|
-
- 2.
|
9
|
-
- 2.
|
7
|
+
- 2.3
|
8
|
+
- 2.4
|
9
|
+
- 2.5
|
10
|
+
- 2.6
|
10
11
|
- ruby-head
|
11
|
-
- jruby-9.
|
12
|
-
- jruby-9.1.9.0
|
12
|
+
- jruby-9.1
|
13
13
|
- jruby-head
|
14
14
|
jdk:
|
15
15
|
- openjdk8
|
16
|
-
-
|
16
|
+
- openjdk10
|
17
|
+
- openjdk11
|
17
18
|
matrix:
|
18
19
|
exclude:
|
19
|
-
- rvm: 2.
|
20
|
-
jdk:
|
21
|
-
- rvm: 2.
|
22
|
-
jdk:
|
23
|
-
- rvm: 2.
|
24
|
-
jdk:
|
25
|
-
- rvm: 2.4
|
26
|
-
jdk:
|
20
|
+
- rvm: 2.3
|
21
|
+
jdk: openjdk10
|
22
|
+
- rvm: 2.3
|
23
|
+
jdk: openjdk11
|
24
|
+
- rvm: 2.4
|
25
|
+
jdk: openjdk10
|
26
|
+
- rvm: 2.4
|
27
|
+
jdk: openjdk11
|
28
|
+
- rvm: 2.5
|
29
|
+
jdk: openjdk10
|
30
|
+
- rvm: 2.5
|
31
|
+
jdk: openjdk11
|
32
|
+
- rvm: 2.6
|
33
|
+
jdk: openjdk10
|
34
|
+
- rvm: 2.6
|
35
|
+
jdk: openjdk11
|
27
36
|
- rvm: ruby-head
|
28
|
-
jdk:
|
37
|
+
jdk: openjdk10
|
38
|
+
- rvm: ruby-head
|
39
|
+
jdk: openjdk11
|
29
40
|
allow_failures:
|
30
41
|
- rvm: ruby-head
|
31
42
|
- rvm: jruby-head
|
32
43
|
branches:
|
33
44
|
only:
|
34
45
|
- master
|
46
|
+
|
47
|
+
env:
|
48
|
+
- LC_ALL=en_IE.UTF-8
|
49
|
+
|
35
50
|
before_install:
|
36
51
|
- sudo add-apt-repository ppa:mc3man/trusty-media -y
|
37
52
|
- sudo apt-get update -y -q
|
@@ -45,9 +60,6 @@ before_install:
|
|
45
60
|
- sudo locale-gen "en_US.UTF-8"
|
46
61
|
- sudo dpkg-reconfigure locales
|
47
62
|
- echo "8\n9\n" | sudo dpkg-reconfigure tzdata
|
48
|
-
env:
|
49
|
-
- LC_ALL=en_US.UTF-8
|
50
|
-
- LANG=en_US.UTF-8
|
51
63
|
addons:
|
52
64
|
apt:
|
53
65
|
packages:
|
data/Gemfile
CHANGED
data/lib/libis/format/config.rb
CHANGED
@@ -21,6 +21,7 @@ module Libis
|
|
21
21
|
Config[:fido_formats] = [(File.join(Libis::Format::DATA_DIR, 'lias_formats.xml'))]
|
22
22
|
Config[:pdf_tool] = File.join(Libis::Format::TOOL_DIR, 'PdfTool.jar')
|
23
23
|
Config[:preflight_jar] = File.join(Libis::Format::TOOL_DIR, 'pdfbox', 'preflight-app-2.0.13.jar')
|
24
|
+
Config[:emai2pdf_jar] = File.join(Libis::Format::TOOL_DIR, 'emailconverter.jar')
|
24
25
|
# noinspection RubyStringKeysInHashInspection
|
25
26
|
Config[:xml_validations] = [['archive/ead', File.join(Libis::Format::DATA_DIR, 'ead.xsd')]]
|
26
27
|
Config[:type_database] = File.join(Libis::Format::DATA_DIR, 'types.yml')
|
@@ -34,6 +35,7 @@ module Libis
|
|
34
35
|
fop: 5 * 60,
|
35
36
|
identification_tool: 5 * 60,
|
36
37
|
office_to_pdf: 5 * 60,
|
38
|
+
email2pdf: 5 * 60,
|
37
39
|
pdf_copy: 5 * 60,
|
38
40
|
pdf_merge: 5 * 60,
|
39
41
|
pdf_optimizer: 5 * 60,
|
@@ -97,19 +97,18 @@ module Libis
|
|
97
97
|
|
98
98
|
end
|
99
99
|
|
100
|
-
target
|
101
|
-
|
102
100
|
end
|
103
101
|
|
104
102
|
def assemble_and_convert(sources, target)
|
103
|
+
result = {}
|
105
104
|
Tempfile.create(%w(list .txt)) do |f|
|
106
105
|
sources.each {|src| f.puts src}
|
107
106
|
opts[:global] ||= []
|
108
107
|
opts[:global] += %w(-f concat)
|
109
108
|
f.close
|
110
|
-
|
109
|
+
result = convert_file(f.to_path, target)
|
111
110
|
end
|
112
|
-
|
111
|
+
result
|
113
112
|
end
|
114
113
|
|
115
114
|
def self.sounds_like(file1, file2, threshold, rate, channels)
|
@@ -155,6 +154,7 @@ module Libis
|
|
155
154
|
|
156
155
|
def convert_file(source, target)
|
157
156
|
opts = {global: [], input: [], filter: [], output: []}
|
157
|
+
|
158
158
|
opts[:global] << '-hide_banner'
|
159
159
|
opts[:global] << '-loglevel' << (@options[:quiet] ? 'fatal' : 'warning')
|
160
160
|
opts[:output] << '-vn' # disable input video stream in case it exists
|
@@ -168,10 +168,8 @@ module Libis
|
|
168
168
|
opts[:output] << '-ar' << @options[:sampling_freq] if @options[:sampling_freq]
|
169
169
|
opts[:output] << '-ac' << @options[:channels] if @options[:channels]
|
170
170
|
opts[:output] << '-f' << @options[:format] if @options[:format]
|
171
|
-
|
172
|
-
|
173
|
-
result
|
174
|
-
target
|
171
|
+
|
172
|
+
Libis::Format::Tool::FFMpeg.run(source, target, opts)
|
175
173
|
end
|
176
174
|
|
177
175
|
end
|
@@ -68,14 +68,18 @@ module Libis
|
|
68
68
|
end
|
69
69
|
|
70
70
|
temp_files = []
|
71
|
+
xtra_files = []
|
72
|
+
|
73
|
+
result = { commands: [] }
|
71
74
|
|
72
75
|
# noinspection RubyParenthesesAroundConditionInspection
|
73
|
-
|
76
|
+
conversion_success = converter_chain.each_with_index do |node, i|
|
74
77
|
|
75
78
|
target_type = node[:output]
|
76
79
|
converter_class = node[:converter]
|
77
80
|
converter = converter_class.new
|
78
81
|
|
82
|
+
|
79
83
|
node[:operations].each do |operation|
|
80
84
|
converter.send operation[:method], operation[:argument]
|
81
85
|
end if node[:operations]
|
@@ -90,17 +94,25 @@ module Libis
|
|
90
94
|
|
91
95
|
FileUtils.mkdir_p File.dirname(target)
|
92
96
|
|
93
|
-
|
97
|
+
r = converter.convert(src_file, target, target_type)
|
98
|
+
|
99
|
+
src_file = r[:files].first
|
100
|
+
xtra_files += r[:files][1..]
|
101
|
+
break :failed unless src_file1
|
94
102
|
|
95
|
-
|
103
|
+
result[:commands] << r.merge(converter: converter_class.name)
|
104
|
+
|
105
|
+
:success
|
96
106
|
|
97
107
|
end
|
98
108
|
|
109
|
+
result[:files] = [src_file] + xtra_files
|
110
|
+
|
99
111
|
temp_files.each do |f|
|
100
112
|
FileUtils.rm(f, force: true)
|
101
113
|
end
|
102
114
|
|
103
|
-
|
115
|
+
conversion_success == :failed ? nil : result
|
104
116
|
|
105
117
|
end
|
106
118
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require_relative 'base'
|
4
|
+
|
5
|
+
require 'libis/format/tool/email_to_pdf'
|
6
|
+
require 'libis/format/type_database'
|
7
|
+
require 'rexml/document'
|
8
|
+
|
9
|
+
module Libis
|
10
|
+
module Format
|
11
|
+
module Converter
|
12
|
+
|
13
|
+
class EmailConverter < Libis::Format::Converter::Base
|
14
|
+
|
15
|
+
def self.input_types
|
16
|
+
[ :MSG ]
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.output_types(format = nil)
|
20
|
+
return [] unless input_types.include?(format)
|
21
|
+
[ :PDF ]
|
22
|
+
end
|
23
|
+
|
24
|
+
def email_convert(_)
|
25
|
+
#force usage of this converter
|
26
|
+
end
|
27
|
+
|
28
|
+
def convert(source, target, format, opts = {})
|
29
|
+
super
|
30
|
+
|
31
|
+
Format::Tool::EmailToPdf.run(source, target)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -90,16 +90,16 @@ module Libis
|
|
90
90
|
end
|
91
91
|
|
92
92
|
|
93
|
-
Libis::Tools::Command.run(
|
93
|
+
result = Libis::Tools::Command.run(
|
94
94
|
Libis::Format::Config[:j2k_cmd],
|
95
95
|
'--input-file-name', source,
|
96
96
|
'--set-output-type', 'JP2',
|
97
97
|
*options,
|
98
98
|
'--output-file-name', target,
|
99
|
-
|
100
99
|
)
|
101
100
|
|
102
|
-
target
|
101
|
+
result.merge(files: [target], converter: self.class.name)
|
102
|
+
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require_relative 'base'
|
2
|
-
require 'libis/format/tool/
|
2
|
+
require 'libis/format/tool/ff_mpeg'
|
3
3
|
|
4
4
|
require 'fileutils'
|
5
5
|
|
@@ -179,7 +179,10 @@ module Libis
|
|
179
179
|
|
180
180
|
end
|
181
181
|
|
182
|
-
|
182
|
+
{
|
183
|
+
files: [target],
|
184
|
+
converter: self.class.name
|
185
|
+
}
|
183
186
|
|
184
187
|
end
|
185
188
|
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
|
3
|
+
require "libis/tools/extend/string"
|
4
|
+
require "libis/tools/logger"
|
5
|
+
require "libis/tools/command"
|
6
|
+
|
7
|
+
require "libis/format/config"
|
8
|
+
require "rexml/document"
|
9
|
+
|
10
|
+
module Libis
|
11
|
+
module Format
|
12
|
+
module Tool
|
13
|
+
class EmailToPdf
|
14
|
+
include ::Libis::Tools::Logger
|
15
|
+
|
16
|
+
def self.installed?
|
17
|
+
result = Libis::Tools::Command.run(Libis::Format::Config[:email2pdf_cmd], "-v")
|
18
|
+
result[:status] == 0
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.run(source, target, options = {})
|
22
|
+
new.run source, target, options
|
23
|
+
end
|
24
|
+
|
25
|
+
def run(source, target, _ = {})
|
26
|
+
timeout = Libis::Format::Config[:timeouts][:email2pdf] || 120
|
27
|
+
result = Libis::Tools::Command.run(
|
28
|
+
Libis::Format::Config[:java_cmd],
|
29
|
+
"-Duser.timezone=Europe/Brussels -Duser.language=nl -Duser.country=BE",
|
30
|
+
"jar", Libis::Format::Config[:email2pdf_cmd],
|
31
|
+
"-e", "-hd", "-a",
|
32
|
+
"-o", target,
|
33
|
+
source,
|
34
|
+
timeout: timeout,
|
35
|
+
kill_after: timeout * 2
|
36
|
+
)
|
37
|
+
|
38
|
+
warn "EmailToPdf conversion messages: \n\t#{result[:out].join("\n\t")}" unless result[:out].empty?
|
39
|
+
|
40
|
+
raise "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
|
41
|
+
raise "#{self.class} failed to generate target file #{target}" unless File.exist?(target)
|
42
|
+
raise "#{self.class} command failed with status code #{result[:status]}" unless result[:status] == 0
|
43
|
+
|
44
|
+
base_path = File.join(File.dirname(target), File.basename(target, ".*"))
|
45
|
+
headers_file = "#{base_path}.headers.xml"
|
46
|
+
headers = read_header(headers_file)
|
47
|
+
|
48
|
+
{
|
49
|
+
command: result,
|
50
|
+
files: [target, headers_file] + headers[:attachments].map { |a| File.join("#{base_path}-attachments", a) },
|
51
|
+
headers: headers
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def read_header(headers_file)
|
58
|
+
headers = {}
|
59
|
+
return headers unless File.exist?(headers_file)
|
60
|
+
doc = REXML::Document.new(File.new(headers_file))
|
61
|
+
root = doc.root
|
62
|
+
root.elements("/emailheader/*").each do |element|
|
63
|
+
case element.name
|
64
|
+
when "attachments"
|
65
|
+
headers[:attachments] = element.elements.map { |e| e.text }
|
66
|
+
else
|
67
|
+
headers[element.name.to_sym] = element.text
|
68
|
+
end
|
69
|
+
end
|
70
|
+
headers
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -13,6 +13,11 @@ module Libis
|
|
13
13
|
include Singleton
|
14
14
|
include ::Libis::Tools::Logger
|
15
15
|
|
16
|
+
def self.installed?
|
17
|
+
result = Libis::Tools::Command.run(Libis::Format::Config[:ffmpeg_cmd], "-h")
|
18
|
+
result[:status] == 0
|
19
|
+
end
|
20
|
+
|
16
21
|
def self.run(source, target, options = {})
|
17
22
|
self.instance.run source, target, options
|
18
23
|
end
|
@@ -38,7 +43,11 @@ module Libis
|
|
38
43
|
|
39
44
|
warn "FFMpeg warnings: #{(result[:err] + result[:out]).join("\n")}" unless result[:err].empty?
|
40
45
|
|
41
|
-
|
46
|
+
{
|
47
|
+
command: result,
|
48
|
+
files: [ target ]
|
49
|
+
}
|
50
|
+
|
42
51
|
end
|
43
52
|
|
44
53
|
end
|
@@ -13,6 +13,12 @@ module Libis
|
|
13
13
|
class FopPdf
|
14
14
|
include ::Libis::Tools::Logger
|
15
15
|
|
16
|
+
def self.installed?
|
17
|
+
result = Libis::Tools::Command.run(Libis::Format::Config[:java_cmd], "-version")
|
18
|
+
return false unless result[:status] == 0
|
19
|
+
File.exist?(Libis::Format::Config[:fop_jar])
|
20
|
+
end
|
21
|
+
|
16
22
|
def self.run(xml, target, options = [])
|
17
23
|
self.new.run xml, target, options
|
18
24
|
end
|
@@ -37,6 +43,11 @@ module Libis
|
|
37
43
|
raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
|
38
44
|
raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0
|
39
45
|
|
46
|
+
{
|
47
|
+
command: result,
|
48
|
+
files: [ target ]
|
49
|
+
}
|
50
|
+
|
40
51
|
end
|
41
52
|
end
|
42
53
|
|
@@ -13,6 +13,11 @@ module Libis
|
|
13
13
|
class OfficeToPdf
|
14
14
|
include ::Libis::Tools::Logger
|
15
15
|
|
16
|
+
def self.installed?
|
17
|
+
result = Libis::Tools::Command.run(Libis::Format::Config[:soffice_cmd], "--version")
|
18
|
+
result[:status] == 0
|
19
|
+
end
|
20
|
+
|
16
21
|
def self.run(source, target, options = {})
|
17
22
|
self.new.run source, target, options
|
18
23
|
end
|
@@ -50,7 +55,11 @@ module Libis
|
|
50
55
|
ensure
|
51
56
|
FileUtils.rmtree workdir rescue nil
|
52
57
|
|
53
|
-
|
58
|
+
{
|
59
|
+
command: result,
|
60
|
+
files: [ target ]
|
61
|
+
}
|
62
|
+
|
54
63
|
end
|
55
64
|
end
|
56
65
|
|
@@ -13,6 +13,12 @@ module Libis
|
|
13
13
|
class PdfCopy
|
14
14
|
include ::Libis::Tools::Logger
|
15
15
|
|
16
|
+
def self.installed?
|
17
|
+
result = Libis::Tools::Command.run(Libis::Format::Config[:java_cmd], "-version")
|
18
|
+
return false unless result[:status] == 0
|
19
|
+
File.exist?(Libis::Format::Config[:pdf_tool])
|
20
|
+
end
|
21
|
+
|
16
22
|
def self.run(source, target, options = [])
|
17
23
|
self.new.run source, target, options
|
18
24
|
end
|
@@ -38,7 +44,11 @@ module Libis
|
|
38
44
|
raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
|
39
45
|
raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0 && result[:err].empty?
|
40
46
|
|
41
|
-
|
47
|
+
{
|
48
|
+
command: result,
|
49
|
+
files: [ target ]
|
50
|
+
}
|
51
|
+
|
42
52
|
end
|
43
53
|
end
|
44
54
|
|
@@ -13,6 +13,12 @@ module Libis
|
|
13
13
|
class PdfMerge
|
14
14
|
include ::Libis::Tools::Logger
|
15
15
|
|
16
|
+
def self.installed?
|
17
|
+
result = Libis::Tools::Command.run(Libis::Format::Config[:java_cmd], "-version")
|
18
|
+
return false unless result[:status] == 0
|
19
|
+
File.exist?(Libis::Format::Config[:pdf_tool])
|
20
|
+
end
|
21
|
+
|
16
22
|
def self.run(source, target, options = [])
|
17
23
|
self.new.run source, target, options
|
18
24
|
end
|
@@ -39,7 +45,11 @@ module Libis
|
|
39
45
|
raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
|
40
46
|
raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0 && result[:err].empty?
|
41
47
|
|
42
|
-
|
48
|
+
{
|
49
|
+
command: result,
|
50
|
+
files: [ target ]
|
51
|
+
}
|
52
|
+
|
43
53
|
end
|
44
54
|
end
|
45
55
|
|
@@ -13,6 +13,11 @@ module Libis
|
|
13
13
|
class PdfOptimizer
|
14
14
|
include ::Libis::Tools::Logger
|
15
15
|
|
16
|
+
def self.installed?
|
17
|
+
result = Libis::Tools::Command.run(Libis::Format::Config[:ghostscript_cmd], "--version")
|
18
|
+
result[:status] == 0
|
19
|
+
end
|
20
|
+
|
16
21
|
def self.run(source, target, quality)
|
17
22
|
self.new.run source, target, quality
|
18
23
|
end
|
@@ -21,7 +26,7 @@ module Libis
|
|
21
26
|
|
22
27
|
timeout = Libis::Format::Config[:timeouts][:pdf_optimizer]
|
23
28
|
result = Libis::Tools::Command.run(
|
24
|
-
|
29
|
+
Libis::Format::Config[:ghostscript_cmd],
|
25
30
|
'-sDEVICE=pdfwrite',
|
26
31
|
'-dCompatibilityLevel=1.4',
|
27
32
|
"-dPDFSETTINGS=/#{quality}",
|
@@ -36,7 +41,11 @@ module Libis
|
|
36
41
|
raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
|
37
42
|
raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0
|
38
43
|
|
39
|
-
|
44
|
+
{
|
45
|
+
command: result,
|
46
|
+
files: [ target ]
|
47
|
+
}
|
48
|
+
|
40
49
|
end
|
41
50
|
end
|
42
51
|
|
@@ -13,6 +13,12 @@ module Libis
|
|
13
13
|
class PdfSplit
|
14
14
|
include ::Libis::Tools::Logger
|
15
15
|
|
16
|
+
def self.installed?
|
17
|
+
result = Libis::Tools::Command.run(Libis::Format::Config[:java_cmd], "-version")
|
18
|
+
return false unless result[:status] == 0
|
19
|
+
File.exist?(Libis::Format::Config[:pdf_tool])
|
20
|
+
end
|
21
|
+
|
16
22
|
def self.run(source, target, options = [])
|
17
23
|
self.new.run source, target, options
|
18
24
|
end
|
@@ -38,7 +44,11 @@ module Libis
|
|
38
44
|
raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
|
39
45
|
raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0 && result[:err].empty?
|
40
46
|
|
41
|
-
|
47
|
+
{
|
48
|
+
command: result,
|
49
|
+
files: [ target ] # TODO: collect the files
|
50
|
+
}
|
51
|
+
|
42
52
|
end
|
43
53
|
end
|
44
54
|
|
@@ -16,6 +16,11 @@ module Libis
|
|
16
16
|
class PdfToPdfa
|
17
17
|
include ::Libis::Tools::Logger
|
18
18
|
|
19
|
+
def self.installed?
|
20
|
+
result = Libis::Tools::Command.run(Libis::Format::Config[:ghostscript_cmd])
|
21
|
+
result == 0
|
22
|
+
end
|
23
|
+
|
19
24
|
def self.run(source, target = nil, options = {})
|
20
25
|
self.new.run source, target, options
|
21
26
|
end
|
@@ -61,7 +66,11 @@ module Libis
|
|
61
66
|
result[:err] << 'Failed to validate generated PDF/A file.'
|
62
67
|
end
|
63
68
|
|
64
|
-
|
69
|
+
{
|
70
|
+
command: result,
|
71
|
+
files: [ target ]
|
72
|
+
}
|
73
|
+
|
65
74
|
end
|
66
75
|
|
67
76
|
|
@@ -13,6 +13,11 @@ module Libis
|
|
13
13
|
class SpreadsheetToOds
|
14
14
|
include ::Libis::Tools::Logger
|
15
15
|
|
16
|
+
def self.installed?
|
17
|
+
result = Libis::Tools::Command.run(Libis::Format::Config[:soffice_cmd], "--version")
|
18
|
+
result == 0
|
19
|
+
end
|
20
|
+
|
16
21
|
def self.run(source, target, options = {})
|
17
22
|
self.new.run source, target, options
|
18
23
|
end
|
@@ -51,7 +56,11 @@ module Libis
|
|
51
56
|
ensure
|
52
57
|
FileUtils.rmtree workdir rescue nil
|
53
58
|
|
54
|
-
|
59
|
+
{
|
60
|
+
command: result,
|
61
|
+
files: [ target ]
|
62
|
+
}
|
63
|
+
|
55
64
|
end
|
56
65
|
end
|
57
66
|
|
data/lib/libis/format/tool.rb
CHANGED
@@ -10,7 +10,7 @@ module Libis
|
|
10
10
|
autoload :FileTool, 'libis/format/tool/file_tool'
|
11
11
|
|
12
12
|
autoload :OfficeToPdf, 'libis/format/tool/office_to_pdf'
|
13
|
-
autoload :FFMpeg, 'libis/format/tool/
|
13
|
+
autoload :FFMpeg, 'libis/format/tool/ff_mpeg'
|
14
14
|
autoload :FopPdf, 'libis/format/tool/fop_pdf'
|
15
15
|
autoload :PdfCopy, 'libis/format/tool/pdf_copy'
|
16
16
|
autoload :PdfMerge, 'libis/format/tool/pdf_merge'
|
data/lib/libis/format/version.rb
CHANGED
data/libis-format.gemspec
CHANGED
@@ -4,6 +4,7 @@ lib = File.expand_path('../lib', __FILE__)
|
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
|
6
6
|
require 'libis/format/version'
|
7
|
+
require 'bundler'
|
7
8
|
|
8
9
|
Gem::Specification.new do |spec|
|
9
10
|
spec.name = 'libis-format'
|
@@ -26,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
26
27
|
spec.add_development_dependency 'rspec', '~> 3.1'
|
27
28
|
spec.add_development_dependency 'awesome_print'
|
28
29
|
spec.add_development_dependency 'equivalent-xml', '~> 0.5'
|
29
|
-
if spec.platform == Gem::Platform::JAVA
|
30
|
+
if Gem::Platform::JAVA && spec.platform == Gem::Platform::JAVA
|
30
31
|
spec.add_development_dependency 'saxon-xslt'
|
31
32
|
else
|
32
33
|
spec.add_development_dependency 'nokogiri'
|
Binary file
|
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: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kris Dekeyser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -213,6 +213,7 @@ files:
|
|
213
213
|
- lib/libis/format/converter/audio_converter.rb
|
214
214
|
- lib/libis/format/converter/base.rb
|
215
215
|
- lib/libis/format/converter/chain.rb
|
216
|
+
- lib/libis/format/converter/email_converter.rb
|
216
217
|
- lib/libis/format/converter/fop_pdf_converter.rb
|
217
218
|
- lib/libis/format/converter/image_converter.rb
|
218
219
|
- lib/libis/format/converter/jp2_converter.rb
|
@@ -225,8 +226,9 @@ files:
|
|
225
226
|
- lib/libis/format/identifier.rb
|
226
227
|
- lib/libis/format/tool.rb
|
227
228
|
- lib/libis/format/tool/droid.rb
|
229
|
+
- lib/libis/format/tool/email_to_pdf.rb
|
228
230
|
- lib/libis/format/tool/extension_identification.rb
|
229
|
-
- lib/libis/format/tool/
|
231
|
+
- lib/libis/format/tool/ff_mpeg.rb
|
230
232
|
- lib/libis/format/tool/fido.rb
|
231
233
|
- lib/libis/format/tool/file_tool.rb
|
232
234
|
- lib/libis/format/tool/fop_pdf.rb
|
@@ -246,6 +248,7 @@ files:
|
|
246
248
|
- tools/PdfTool.jar
|
247
249
|
- tools/bcpkix-jdk15on-1.49.jar
|
248
250
|
- tools/bcprov-jdk15on-1.49.jar
|
251
|
+
- tools/emailconverter.jar
|
249
252
|
- tools/fop/build/fop.jar
|
250
253
|
- tools/fop/conf/fop.xconf
|
251
254
|
- tools/fop/fop
|
@@ -317,8 +320,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
317
320
|
- !ruby/object:Gem::Version
|
318
321
|
version: '0'
|
319
322
|
requirements: []
|
320
|
-
|
321
|
-
rubygems_version: 2.7.8
|
323
|
+
rubygems_version: 3.1.6
|
322
324
|
signing_key:
|
323
325
|
specification_version: 4
|
324
326
|
summary: LIBIS File format format services.
|