libis-format 1.2.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.travis.yml +19 -23
  4. data/Gemfile +0 -2
  5. data/README.md +2 -2
  6. data/base/Dockerfile +5 -3
  7. data/base/rework_path +5 -10
  8. data/data/PDFA_def.ps +3 -3
  9. data/data/eciRGB_v2.icc +0 -0
  10. data/lib/libis/format/cli/convert.rb +4 -4
  11. data/lib/libis/format/config.rb +3 -3
  12. data/lib/libis/format/converter/audio_converter.rb +6 -38
  13. data/lib/libis/format/converter/base.rb +21 -8
  14. data/lib/libis/format/converter/chain.rb +7 -19
  15. data/lib/libis/format/converter/fop_pdf_converter.rb +2 -0
  16. data/lib/libis/format/converter/image_assembler.rb +82 -0
  17. data/lib/libis/format/converter/image_converter.rb +21 -141
  18. data/lib/libis/format/converter/image_splitter.rb +80 -0
  19. data/lib/libis/format/converter/image_watermarker.rb +261 -0
  20. data/lib/libis/format/converter/jp2_converter.rb +4 -4
  21. data/lib/libis/format/converter/office_converter.rb +5 -3
  22. data/lib/libis/format/converter/pdf_assembler.rb +66 -0
  23. data/lib/libis/format/converter/pdf_converter.rb +31 -98
  24. data/lib/libis/format/converter/pdf_optimizer.rb +70 -0
  25. data/lib/libis/format/converter/pdf_splitter.rb +65 -0
  26. data/lib/libis/format/converter/pdf_watermarker.rb +110 -0
  27. data/lib/libis/format/converter/spreadsheet_converter.rb +5 -3
  28. data/lib/libis/format/converter/video_converter.rb +3 -6
  29. data/lib/libis/format/converter/xslt_converter.rb +14 -15
  30. data/lib/libis/format/identifier.rb +3 -3
  31. data/lib/libis/format/info.rb +27 -0
  32. data/lib/libis/format/library.rb +147 -0
  33. data/lib/libis/format/tool/extension_identification.rb +4 -4
  34. data/lib/libis/format/tool/{ff_mpeg.rb → ffmpeg.rb} +1 -10
  35. data/lib/libis/format/tool/fop_pdf.rb +0 -12
  36. data/lib/libis/format/tool/identification_tool.rb +6 -6
  37. data/lib/libis/format/tool/office_to_pdf.rb +1 -10
  38. data/lib/libis/format/tool/pdf_copy.rb +1 -11
  39. data/lib/libis/format/tool/pdf_merge.rb +1 -11
  40. data/lib/libis/format/tool/pdf_optimizer.rb +2 -11
  41. data/lib/libis/format/tool/pdf_split.rb +1 -11
  42. data/lib/libis/format/tool/pdf_to_pdfa.rb +43 -59
  43. data/lib/libis/format/tool/pdfa_validator.rb +35 -28
  44. data/lib/libis/format/tool/spreadsheet_to_ods.rb +2 -10
  45. data/lib/libis/format/tool.rb +1 -1
  46. data/lib/libis/format/version.rb +1 -1
  47. data/lib/libis/format/yaml_loader.rb +71 -0
  48. data/lib/libis/format.rb +5 -2
  49. data/libis-format.gemspec +3 -5
  50. data/tools/fop/fop.bat +75 -75
  51. data/tools/fop/fop.cmd +31 -31
  52. data/tools/fop/fop.js +341 -341
  53. data/tools/fop/lib/avalon-framework.NOTICE.TXT +11 -11
  54. data/tools/fop/lib/xml-apis.LICENSE-SAX.html +17 -17
  55. data/tools/fop/lib/xml-apis.LICENSE.DOM-documentation.html +74 -74
  56. data/tools/fop/lib/xml-apis.LICENSE.DOM-software.html +66 -66
  57. metadata +19 -29
  58. data/data/AdobeRGB1998.icc +0 -0
  59. data/lib/libis/format/converter/email_converter.rb +0 -38
  60. data/lib/libis/format/tool/email_to_pdf.rb +0 -75
  61. data/lib/libis/format/type_database.rb +0 -133
  62. data/lib/libis/format/type_database_impl.rb +0 -120
  63. data/tools/emailconverter.jar +0 -0
  64. data/tools/pdf2pdfa +0 -395
  65. /data/bin/{droid_tool → droid} +0 -0
  66. /data/bin/{fido_tool → fido} +0 -0
@@ -5,13 +5,13 @@ require_relative 'base'
5
5
  require 'libis/tools/extend/hash'
6
6
  require 'libis/format/tool/pdf_copy'
7
7
  require 'libis/format/tool/pdf_to_pdfa'
8
- require 'libis/format/tool/pdfa_validator'
9
8
  require 'libis/format/tool/pdf_optimizer'
10
9
 
11
10
  module Libis
12
11
  module Format
13
12
  module Converter
14
13
 
14
+ # noinspection DuplicatedCode
15
15
  class PdfConverter < Libis::Format::Converter::Base
16
16
 
17
17
  def self.input_types
@@ -19,84 +19,34 @@ module Libis
19
19
  end
20
20
 
21
21
  def self.output_types(format = nil)
22
- return [] unless input_types.include?(format)
22
+ return [] unless input_types.include?(format) if format
23
23
  [:PDF, :PDFA]
24
24
  end
25
25
 
26
- def pdf_convert(_)
27
- #force usage of this converter
26
+ def title(v)
27
+ @options[:title] = v.blank? ? nil : v
28
28
  end
29
29
 
30
- # Set metadata for Pdf file
31
- #
32
- # valid metadata keys are):
33
- # - title
34
- # - author
35
- # - creator
36
- # - keywords
37
- # - subject
38
- #
39
- # @param [Hash] values list of metadata values to set
40
- def metadata(values = {})
41
- values.key_strings_to_symbols!
42
- values.each do |k, v|
43
- next unless [:title, :author, :creator, :keywords, :subject].include?(k)
44
- @options["md_#{k}"] = v
45
- end
30
+ def author(v)
31
+ @options[:author] = v.blank? ? nil : v
46
32
  end
47
33
 
48
- # Select a partial list of pages
49
- # @param [String] selection as described in com.itextpdf.text.pdf.SequenceList: [!][o][odd][e][even]start-end
50
- def range(selection)
51
- @options[:ranges] = selection
34
+ def creator(v)
35
+ @options[:creator] = v.blank? ? nil : v
52
36
  end
53
37
 
54
- # Create or use a watermark image.
55
- #
56
- # The watermark options are (use symbols):
57
- # - text: text to create a watermark from
58
- # - file: watermark image to use
59
- # - rotation: rotation of the watermark text (in degrees; integer number)
60
- # - size: font size of the watermark text
61
- # - opacity: opacity of the watermark (fraction 0.0 - 1.0)
62
- # - gap: size of the gap between watermark instances. Integer value is absolute size in points (1/72 inch). Fractions are percentage of widht/height.
63
- # If both options are given, the file will be used as-is if it exists and is a valid image file. Otherwise the
64
- # file will be created or overwritten with a newly created watermark image.
65
- #
66
- # The created watermark file will be a PNG image with transparent background containing the supplied text
67
- # slanted by 30 degrees counter-clockwise.
68
- #
69
- # @param [Hash] options Hash of options for watermark creation.
70
- def watermark(options = {})
71
- options.key_strings_to_symbols!
72
- if options[:file] && File.exist?(options[:file])
73
- @options['wm_image'] = options[:file]
74
- else
75
- @options['wm_text'] = (options[:text] || '© LIBIS').split('\n')
76
- @options['wm_text_rotation'] = options[:rotation] if options[:rotation]
77
- @options['wm_font_size'] = options[:size] if options[:size]
78
- end
79
- @options['wm_opacity'] = options[:opacity] || '0.3'
80
- @options['wm_gap_ratio'] = options[:gap] if options[:gap].to_s =~ /^\s*(0+\.\d+|1\.0+)\s*$/
81
- @options['wm_gap_size'] = options[:gap] if options[:gap].to_s =~ /^\s*\d+\s*$/
38
+ def keywords(v)
39
+ @options[:keywords] = v.blank? ? nil : v
82
40
  end
83
41
 
84
- # Optimize the PDF
85
- #
86
- # This reduces the graphics quality to a level in order to limit file size. This option relies on the
87
- # presence of ghostscript and takes one argument: the quality level. It should be one of:
88
- #
89
- # - 0 : lowest quality (Acrobat Distiller 'Screen Optimized' equivalent)
90
- # - 1 : medium quality (Acrobat Distiller 'eBook' equivalent)
91
- # - 2 : good quality
92
- # - 3 : high quality (Acrobat Distiller 'Print Optimized' equivalent)
93
- # - 4 : highest quality (Acrobat Distiller 'Prepress Optimized' equivalent)
94
- #
95
- # Note that the optimization is intended to be used with PDF's containing high-resolution images.
96
- #
97
- # @param [Integer] setting quality setting. [0-4]
98
- def optimize(setting = 1)
99
- @options['optimize'] = %w(screen ebook default printer prepress)[setting] if (0..4) === setting
42
+ def subject(v)
43
+ @options[:subject] = v.blank? ? nil : v
44
+ end
45
+
46
+ # Select a partial list of pages
47
+ # @param [String] selection as described in com.itextpdf.text.pdf.SequenceList: [!][o][odd][e][even]start-end
48
+ def range(selection)
49
+ @options[:ranges] = selection.blank? ? nil : selection
100
50
  end
101
51
 
102
52
  def convert(source, target, format, opts = {})
@@ -104,12 +54,6 @@ module Libis
104
54
 
105
55
  result = nil
106
56
 
107
- if (quality = @options.delete('optimize'))
108
- result = optimize_pdf(source, target, quality)
109
- return nil unless result
110
- source = result
111
- end
112
-
113
57
  unless @options.empty?
114
58
  result = convert_pdf(source, target)
115
59
  return nil unless result
@@ -120,24 +64,17 @@ module Libis
120
64
  result = pdf_to_pdfa(source, target)
121
65
  end
122
66
 
123
- {
124
- files: [result],
125
- converter: self.class.name
126
- }
67
+ result
127
68
 
128
69
  end
129
70
 
130
- def optimize_pdf(source, target, quality)
131
-
132
- using_temp(target) do |tmpname|
133
- result = Libis::Format::Tool::PdfOptimizer.run(source, tmpname, quality)
134
- unless result[:status] == 0
135
- error("Pdf optimization encountered errors:\n%s", (result[:err] + result[:out]).join("\n"))
136
- next nil
137
- end
138
- tmpname
139
- end
140
- end
71
+ OPTIONS_TABLE = {
72
+ title: 'md_title',
73
+ author: 'md_author',
74
+ creator: 'md_creator',
75
+ keywords: 'md_keywords',
76
+ subject: 'md_subject'
77
+ }
141
78
 
142
79
  def convert_pdf(source, target)
143
80
 
@@ -148,8 +85,9 @@ module Libis
148
85
  if v.nil?
149
86
  nil
150
87
  else
88
+ k = OPTIONS_TABLE[k] || k
151
89
  ["--#{k}", (v.is_a?(Array) ? v : v.to_s)]
152
- end}.flatten
90
+ end}.compact.flatten
153
91
  )
154
92
  unless result[:err].empty?
155
93
  error("Pdf conversion encountered errors:\n%s", result[:err].join(join("\n")))
@@ -164,16 +102,11 @@ module Libis
164
102
 
165
103
  using_temp(target) do |tmpname|
166
104
  result = Libis::Format::Tool::PdfToPdfa.run source, tmpname
167
-
168
- if result[:command][:status] != 0
169
- error("Pdf/A conversion encountered errors:\n%s", (result[:command][:out] + result[:command][:err]).join("\n"))
105
+ if result[:status] != 0
106
+ error("Pdf/A conversion encountered errors:\n%s", result[:err].join("\n"))
170
107
  next nil
171
108
  else
172
- r = Libis::Format::Tool::PdfaValidator.run tmpname
173
- if r[:status] != 0
174
- error "Pdf/A file failed to validate with following errors:\n%s", (r[:err] || r[:out] || []).join("\n")
175
- next nil
176
- end
109
+ warn("Pdf/A conversion warnings:\n%s", result[:err].join("\n")) unless result[:err].empty?
177
110
  end
178
111
  tmpname
179
112
  end
@@ -0,0 +1,70 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative 'base'
4
+
5
+ require 'libis/tools/extend/hash'
6
+ require 'libis/format/tool/pdf_copy'
7
+ require 'libis/format/tool/pdf_to_pdfa'
8
+ require 'libis/format/tool/pdf_optimizer'
9
+
10
+ module Libis
11
+ module Format
12
+ module Converter
13
+
14
+ class PdfOptimizer < Libis::Format::Converter::Base
15
+
16
+ def self.input_types
17
+ [:PDF]
18
+ end
19
+
20
+ def self.output_types(format = nil)
21
+ return [] unless input_types.include?(format) if format
22
+ [:PDF]
23
+ end
24
+
25
+ def pdf_optimize(_)
26
+ #force usage of this converter
27
+ end
28
+
29
+ # Optimize the PDF
30
+ #
31
+ # This reduces the graphics quality to a level in order to limit file size. This option relies on the
32
+ # presence of ghostscript and takes one argument: the quality level. It should be one of:
33
+ #
34
+ # - 0 : lowest quality (Acrobat Distiller 'Screen Optimized' equivalent)
35
+ # - 1 : medium quality (Acrobat Distiller 'eBook' equivalent)
36
+ # - 2 : good quality
37
+ # - 3 : high quality (Acrobat Distiller 'Print Optimized' equivalent)
38
+ # - 4 : highest quality (Acrobat Distiller 'Prepress Optimized' equivalent)
39
+ #
40
+ # Note that the optimization is intended to be used with PDF's containing high-resolution images.
41
+ #
42
+ # @param [Integer] setting quality setting. [0-4]
43
+ def quality(setting = 1)
44
+ @quality = %w(screen ebook default printer prepress)[setting] if (0..4) === setting
45
+ end
46
+
47
+ def convert(source, target, format, opts = {})
48
+ super
49
+
50
+ optimize_pdf(source, target, @quality || 'ebook')
51
+
52
+ end
53
+
54
+ def optimize_pdf(source, target, quality)
55
+
56
+ using_temp(target) do |tmpname|
57
+ result = Libis::Format::Tool::PdfOptimizer.run(source, tmpname, quality)
58
+ unless result[:status] == 0
59
+ error("Pdf optimization encountered errors:\n%s", (result[:err] + result[:out]).join("\n"))
60
+ next nil
61
+ end
62
+ tmpname
63
+ end
64
+ end
65
+
66
+ end
67
+
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,65 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative 'base'
4
+
5
+ require 'libis/format/tool/pdf_split'
6
+
7
+ module Libis
8
+ module Format
9
+ module Converter
10
+
11
+ # noinspection DuplicatedCode
12
+ class PdfSplitter < Libis::Format::Converter::Base
13
+
14
+ def self.input_types
15
+ [:PDF]
16
+ end
17
+
18
+ def self.output_types(format = nil)
19
+ return [] unless input_types.include?(format) if format
20
+ [:PDF]
21
+ end
22
+
23
+ def pdf_split(_)
24
+ #force usage of this converter
25
+ end
26
+
27
+ def self.category
28
+ :splitter
29
+ end
30
+
31
+ # Split at given page. If omitted or nil, the source PDF will be split at every page
32
+ def page(v)
33
+ @page = v unless v.blank
34
+ end
35
+
36
+ def convert(source, target, format, opts = {})
37
+ super
38
+
39
+ result = split(source, target)
40
+ return nil unless result
41
+
42
+ result
43
+ end
44
+
45
+ private
46
+
47
+ def split(source, target)
48
+
49
+ options = @page ? ['--page', @page] : ['--every_page']
50
+ using_temp(target) do |tmpname|
51
+ result = Libis::Format::Tool::PdfSplit.run(source, tmpname, *options)
52
+ unless result[:err].empty?
53
+ error("Pdf split encountered errors:\n%s", result[:err].join(join("\n")))
54
+ next nil
55
+ end
56
+ tmpname
57
+ end
58
+
59
+ end
60
+
61
+ end
62
+
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,110 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative 'base'
4
+
5
+ require 'libis/tools/extend/hash'
6
+ require 'libis/format/tool/pdf_copy'
7
+ require 'libis/format/tool/pdf_to_pdfa'
8
+ require 'libis/format/tool/pdf_optimizer'
9
+
10
+ module Libis
11
+ module Format
12
+ module Converter
13
+
14
+ class PdfWatermarker < Libis::Format::Converter::Base
15
+
16
+ def self.input_types
17
+ [:PDF]
18
+ end
19
+
20
+ def self.output_types(format = nil)
21
+ return [] unless input_types.include?(format) if format
22
+ [:PDF]
23
+ end
24
+
25
+ def pdf_watermark(_)
26
+ #force usage of this converter
27
+ end
28
+
29
+ def initialize
30
+ super
31
+ @options[:text] = '© LIBIS'
32
+ @options[:opacity] = '0.3'
33
+ end
34
+
35
+ def file(v)
36
+ @options[:file] = v.blank? ? nil : v
37
+ end
38
+
39
+ def text(v)
40
+ @options[:text] = v
41
+ end
42
+
43
+ def rotation(v)
44
+ @options[:rotation] = v unless v.blank?
45
+ end
46
+
47
+ def size(v)
48
+ @options[:size] = v unless v.blank?
49
+ end
50
+
51
+ def opacity(v)
52
+ @options[:opacity] = v unless v.blank?
53
+ end
54
+
55
+ def gap_size(v)
56
+ @options[:gap_size] = v
57
+ end
58
+
59
+ def gap_ratio(v)
60
+ @options[:gap_ratio] = v
61
+ end
62
+
63
+ def convert(source, target, format, opts = {})
64
+ super
65
+
66
+ result = convert_pdf(source, target)
67
+ return nil unless result
68
+
69
+ result
70
+
71
+ end
72
+
73
+ OPTIONS_TABLE = {
74
+ file: 'wm_image',
75
+ text: 'wm_text',
76
+ rotation: 'wm_text_rotation',
77
+ size: 'wm_font_size',
78
+ opacity: 'wm_opacity',
79
+ gap_size: 'wm_gap_size',
80
+ gap_ratio: 'wm_gap_ratio'
81
+ }
82
+ # noinspection DuplicatedCode
83
+ def convert_pdf(source, target)
84
+
85
+ using_temp(target) do |tmpname|
86
+ result = Libis::Format::Tool::PdfCopy.run(
87
+ source, tmpname,
88
+ @options.map {|k, v|
89
+ if v.nil?
90
+ nil
91
+ else
92
+ v = v.split('\n') unless v.blank? if k == :text
93
+ k = OPTIONS_TABLE[k] || k
94
+ ["--#{k}", (v.is_a?(Array) ? v : v.to_s)]
95
+ end}.compact.flatten
96
+ )
97
+ unless result[:err].empty?
98
+ error("Pdf conversion encountered errors:\n%s", result[:err].join(join("\n")))
99
+ next nil
100
+ end
101
+ tmpname
102
+ end
103
+
104
+ end
105
+
106
+ end
107
+
108
+ end
109
+ end
110
+ end
@@ -3,7 +3,7 @@
3
3
  require_relative 'base'
4
4
 
5
5
  require 'libis/format/tool/spreadsheet_to_ods'
6
- require 'libis/format/type_database'
6
+ require 'libis/format/library'
7
7
 
8
8
  module Libis
9
9
  module Format
@@ -20,7 +20,7 @@ module Libis
20
20
  end
21
21
 
22
22
  def self.output_types(format = nil)
23
- return [] unless input_types.include?(format)
23
+ return [] unless input_types.include?(format) if format
24
24
  [:OO_CALC]
25
25
  end
26
26
 
@@ -31,7 +31,9 @@ module Libis
31
31
  def convert(source, target, format, opts = {})
32
32
  super
33
33
 
34
- Format::Tool::SpreadsheetToOds.run(source, target)
34
+ return nil unless Format::Tool::SpreadsheetToOds.run(source, target)
35
+
36
+ target
35
37
 
36
38
  end
37
39
 
@@ -1,5 +1,5 @@
1
1
  require_relative 'base'
2
- require 'libis/format/tool/ff_mpeg'
2
+ require 'libis/format/tool/ffmpeg'
3
3
 
4
4
  require 'fileutils'
5
5
 
@@ -14,7 +14,7 @@ module Libis
14
14
  end
15
15
 
16
16
  def self.output_types(format = nil)
17
- return [] unless input_types.include?(format)
17
+ return [] unless input_types.include?(format) if format
18
18
  [:GIF, :WEBM, :MP4, :MPG, :MKV, :MJP2, :QTFF, :AVI, :OGGV, :WMV, :DV, :FLV, :SWF]
19
19
  end
20
20
 
@@ -179,10 +179,7 @@ module Libis
179
179
 
180
180
  end
181
181
 
182
- {
183
- files: [target],
184
- converter: self.class.name
185
- }
182
+ target
186
183
 
187
184
  end
188
185
 
@@ -1,17 +1,17 @@
1
- require_relative "base"
1
+ require_relative 'base'
2
2
 
3
3
  module Libis
4
4
  module Format
5
5
  module Converter
6
+
6
7
  class XsltConverter < Libis::Format::Converter::Base
8
+
7
9
  def self.input_types
8
10
  [:XML]
9
11
  end
10
12
 
11
13
  def self.output_types(format = nil)
12
- if format
13
- return [] unless input_types.include?(format)
14
- end
14
+ return [] unless input_types.include?(format) if format
15
15
  [:XML, :HTML, :TXT]
16
16
  end
17
17
 
@@ -28,20 +28,20 @@ module Libis
28
28
  end
29
29
 
30
30
  unless @options[:xsl_file]
31
- error "No xsl_file supplied"
31
+ error 'No xsl_file supplied'
32
32
  return nil
33
33
  end
34
34
 
35
35
  FileUtils.mkpath(File.dirname(target))
36
36
 
37
37
  if RUBY_PLATFORM == "java"
38
- require "saxon-xslt"
38
+ require 'saxon-xslt'
39
39
  xsl = Saxon.XSLT(File.open(@options[:xsl_file]))
40
40
  xml = Saxon.XML(File.open(source))
41
41
  result = xsl.transform(xml)
42
- File.write(target, result.to_s)
42
+ File.open(target, 'w') {|f| f.write(result.to_s)}
43
43
  else
44
- require "nokogiri"
44
+ require 'nokogiri'
45
45
 
46
46
  doc = nil
47
47
  begin
@@ -65,7 +65,7 @@ module Libis
65
65
  xsl = nil
66
66
 
67
67
  begin
68
- fp = File.open(file, "r")
68
+ fp = File.open(file, 'r')
69
69
  xsl = Nokogiri::XSLT(fp) do |config|
70
70
  config.options = Nokogiri::XML::ParseOptions::STRICT | Nokogiri::XML::ParseOptions::NOBLANKS
71
71
  end
@@ -80,7 +80,7 @@ module Libis
80
80
 
81
81
  begin
82
82
  target_xml = xsl.transform(doc)
83
- fp = File.open(target, "w")
83
+ fp = File.open(target, 'w')
84
84
  fp.write(target_xml)
85
85
  rescue Exception => e
86
86
  error "Error transforming '#{source}' with '#{file}': #{e.message} @ #{e.backtrace[0]}"
@@ -89,14 +89,13 @@ module Libis
89
89
  fp.close unless fp.nil? or fp.closed?
90
90
  end
91
91
 
92
- {
93
- command: {status: 0},
94
- files: [target]
95
- }
96
-
92
+ target
97
93
  end
94
+
98
95
  end
96
+
99
97
  end
98
+
100
99
  end
101
100
  end
102
101
  end
@@ -9,7 +9,7 @@ require 'libis/tools/extend/string'
9
9
  require 'libis/tools/extend/empty'
10
10
  require 'nori/core_ext/object'
11
11
 
12
- require 'libis/format/type_database'
12
+ require 'libis/format/library'
13
13
 
14
14
  require_relative 'config'
15
15
  require_relative 'tool/fido'
@@ -132,7 +132,7 @@ module Libis
132
132
  if doc.validates_against?(xsd_file)
133
133
  log_msg result, :debug, "XML file validated against XML Schema: #{xsd_file}"
134
134
  info = {mimetype: mime, tool_raw: file_result[:tool], tool: :xsd_validation, match_type: 'xsd_validation', format_version: '', }
135
- file_result.merge! Libis::Format::TypeDatabase.enrich(info, PUID: :puid, MIME: :mimetype, NAME: :format_name)
135
+ file_result.merge! Libis::Format::Library.enrich(info, puid: :puid, mimetype: :mimetype, name: :format_name)
136
136
  end
137
137
  rescue => e
138
138
  # Do nothing - probably Nokogiri chrashed during validation. Could have many causes
@@ -208,7 +208,7 @@ module Libis
208
208
  end
209
209
 
210
210
  def get_mimetype(puid)
211
- ::Libis::Format::TypeDatabase.puid_typeinfo(puid)[:MIME].first rescue nil
211
+ ::Libis::Format::Library.get_field_by(:puid, puid, :mimetypes)
212
212
  end
213
213
 
214
214
  def get_best_result(results)
@@ -0,0 +1,27 @@
1
+ module Libis
2
+ module Format
3
+ class Info
4
+ attr_reader :name, :category, :description, :puids, :mimetypes, :extensions
5
+
6
+ def initialize(name:, category:, description: '', puids: [], mimetypes: [], extensions: [])
7
+ @name = name
8
+ @category = category
9
+ @description = description
10
+ @puids = puids
11
+ @mimetypes = mimetypes
12
+ @extensions = extensions
13
+ end
14
+
15
+ def to_hash
16
+ {
17
+ name: name,
18
+ description: description.dup,
19
+ category: category,
20
+ puids: puids.dup,
21
+ mimetypes: mimetypes.dup,
22
+ extensions: extensions.dup
23
+ }
24
+ end
25
+ end
26
+ end
27
+ end