libis-format 0.9.49 → 0.9.50

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47b210d27058d7ee640e2435f952d8dc58537deb
4
- data.tar.gz: 531d8103bea3b028c4d51f10aa793e8488b03df9
3
+ metadata.gz: 495a17a421b0c23121d7e38feb91755b0dbfdfd0
4
+ data.tar.gz: e6b9687dca16d98c3e1c67dc6d89f90e20989acc
5
5
  SHA512:
6
- metadata.gz: 2288f2bc2962c96fdaf361c9db9da137c98acbe084962a0fa47f503df8fdc030dc8600f5c62d98bac6ad8e2a6f89f002e22a1a5c4f33a3c2af189a137d583299
7
- data.tar.gz: 48a6446cc762623fac7403c70a6c80b4fedab6b409973653bb6a2038180d2dd7e85c1ca0e73b17a1fb7a0ea52c50c4c5371528b432161c8a5b4b6b7718109c7d
6
+ metadata.gz: f6c5fb037d0d5de37a0020d043401335db1874045f945981cab6c5edf9b4bb2cad212cde590dbdfa210740683301f0e5e9e17af838d01a05d42a499736825e81
7
+ data.tar.gz: dd65ca5bc986263ac03be6812bdab42a939746bc5c23182d92123a66c44d4e2f0cda0b6a80b07caaf027a5f523ec4d46e7ad826ab9500cec72820a54deffc0ac
@@ -24,6 +24,21 @@ module Libis
24
24
  Config[:type_database] = File.join(Libis::Format::DATA_DIR, 'types.yml')
25
25
  Config[:raw_audio_convert_cmd] = 'sox %s -e signed -b 16 -t wav %s rate %d channels %d'
26
26
  Config[:watermark_font] = '/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf'
27
+ Config[:timeouts] = {
28
+ droid: 5 * 60,
29
+ ffmpeg: 5 * 60,
30
+ fido: 5 * 60,
31
+ file_tool: 5 * 60,
32
+ fop: 5 * 60,
33
+ identification_tool: 5 * 60,
34
+ office_to_pdf: 5 * 60,
35
+ pdf_copy: 5 * 60,
36
+ pdf_merge: 5 * 60,
37
+ pdf_optimizer: 5 * 60,
38
+ pdf_split: 5 * 60,
39
+ pdf_to_pdfa: 5 * 60,
40
+ pdfa_validator: 5 * 60,
41
+ }
27
42
 
28
43
  end
29
44
  end
@@ -1,5 +1,3 @@
1
- require 'nokogiri'
2
-
3
1
  require_relative 'base'
4
2
 
5
3
  module Libis
@@ -29,61 +27,71 @@ module Libis
29
27
  return nil
30
28
  end
31
29
 
32
- doc = nil
33
- begin
34
- doc = Nokogiri::XML(File.read(source)) do |config|
35
- config.options = Nokogiri::XML::ParseOptions::STRICT | Nokogiri::XML::ParseOptions::NOBLANKS
36
- end
37
- rescue Nokogiri::XML::SyntaxError => e
38
- if e.fatal? || e.error?
39
- error "Error parsing XML input '#{source}': #{e.messsage} @ #{e.backtrace[0]}"
40
- return nil
41
- end
42
- end
43
-
44
30
  unless @options[:xsl_file]
45
31
  error 'No xsl_file supplied'
46
32
  return nil
47
33
  end
48
34
 
49
- file = @options[:xsl_file]
35
+ FileUtils.mkpath(File.dirname(target))
50
36
 
51
- unless File.file?(file) && File.exist?(file) && File.readable?(file)
52
- error "XSL file '#{@options[:xsl_file]}' does not exist or is not readable"
53
- return nil
54
- end
37
+ if RUBY_PLATFORM == "java"
38
+ require 'saxon-xslt'
39
+ xsl = Saxon.XSLT(File.open(@options[:xsl_file]))
40
+ xml = Saxon.XML(File.open(source))
41
+ result = xsl.transform(xml)
42
+ File.open(target, 'w') {|f| f.write(result.to_s)}
43
+ else
44
+ require 'nokogiri'
45
+
46
+ doc = nil
47
+ begin
48
+ doc = Nokogiri::XML(File.read(source)) do |config|
49
+ config.options = Nokogiri::XML::ParseOptions::STRICT | Nokogiri::XML::ParseOptions::NOBLANKS
50
+ end
51
+ rescue Nokogiri::XML::SyntaxError => e
52
+ if e.fatal? || e.error?
53
+ error "Error parsing XML input '#{source}': #{e.messsage} @ #{e.backtrace[0]}"
54
+ return nil
55
+ end
56
+ end
55
57
 
56
- FileUtils.mkpath(File.dirname(target))
58
+ file = @options[:xsl_file]
57
59
 
58
- xsl = nil
60
+ unless File.file?(file) && File.exist?(file) && File.readable?(file)
61
+ error "XSL file '#{@options[:xsl_file]}' does not exist or is not readable"
62
+ return nil
63
+ end
59
64
 
60
- begin
61
- fp = File.open(file, 'r')
62
- xsl = Nokogiri::XSLT(fp) do |config|
63
- config.options = Nokogiri::XML::ParseOptions::STRICT | Nokogiri::XML::ParseOptions::NOBLANKS
65
+ xsl = nil
66
+
67
+ begin
68
+ fp = File.open(file, 'r')
69
+ xsl = Nokogiri::XSLT(fp) do |config|
70
+ config.options = Nokogiri::XML::ParseOptions::STRICT | Nokogiri::XML::ParseOptions::NOBLANKS
71
+ end
72
+ rescue Nokogiri::XML::SyntaxError => e
73
+ if e.fatal? || e.error?
74
+ error "Error parsing XSL input '#{file}': #{e.message} @ #{e.backtrace[0]}"
75
+ return nil
76
+ end
77
+ ensure
78
+ fp.close
64
79
  end
65
- rescue Nokogiri::XML::SyntaxError => e
66
- if e.fatal? || e.error?
67
- error "Error parsing XSL input '#{file}': #{e.message} @ #{e.backtrace[0]}"
80
+
81
+ begin
82
+ target_xml = xsl.transform(doc)
83
+ fp = File.open(target, 'w')
84
+ fp.write(target_xml)
85
+ rescue Exception => e
86
+ error "Error transforming '#{source}' with '#{file}': #{e.message} @ #{e.backtrace[0]}"
68
87
  return nil
88
+ ensure
89
+ fp.close unless fp.nil? or fp.closed?
69
90
  end
70
- ensure
71
- fp.close
72
- end
73
91
 
74
- begin
75
- target_xml = xsl.transform(doc)
76
- fp = File.open(target, 'w')
77
- fp.write(target_xml)
78
- rescue Exception => e
79
- error "Error transforming '#{source}' with '#{file}': #{e.message} @ #{e.backtrace[0]}"
80
- return nil
81
- ensure
82
- fp.close
92
+ target
83
93
  end
84
94
 
85
- target
86
-
87
95
  end
88
96
 
89
97
  end
@@ -74,8 +74,16 @@ module Libis
74
74
  '-p', profile,
75
75
  '-q'
76
76
  ]
77
- result = Libis::Tools::Command.run(Libis::Format::Config[:droid_path], *args)
78
- raise RuntimeError, "DROID report errors: #{result[:err].join("\n")}" unless result[:status] == 0
77
+ timeout = Libis::Format::Config[:timeouts][:droid]
78
+ result = Libis::Tools::Command.run(
79
+ Libis::Format::Config[:droid_path], *args,
80
+ timeout: timeout,
81
+ kill_after: timeout * 2
82
+ )
83
+ result[:err].select! {|x| x =~ /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3} ERROR /}
84
+ raise RuntimeError, "#{self.class} report took too long (> #{timeout} seconds) to complete" if result[:timeout]
85
+ raise RuntimeError, "#{self.class} report errors: #{result[:err].join("\n")}" unless result[:err].empty?
86
+
79
87
  File.delete profile
80
88
  end
81
89
 
@@ -83,10 +91,18 @@ module Libis
83
91
  args = []
84
92
  files = (file_or_list.is_a?(Array)) ? file_or_list.map(&:escape_for_string) : [file_or_list.escape_for_string]
85
93
  files.each {|file| args << '-a' << file}
86
- args << '-p' << profile << '-q'
94
+ args << '-q'
95
+ args << '-p' << profile
87
96
  args << '-R' if recursive
88
- result = Libis::Tools::Command.run(Libis::Format::Config[:droid_path], *args)
89
- raise RuntimeError, "DROID profile errors: #{result[:err].join("\n")}" unless result[:status] == 0
97
+ timeout = Libis::Format::Config[:timeouts][:droid]
98
+ result = Libis::Tools::Command.run(
99
+ Libis::Format::Config[:droid_path], *args,
100
+ timeout: timeout,
101
+ kill_after: timeout * 2
102
+ )
103
+ result[:err].select! {|x| x =~ /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3} ERROR /}
104
+ raise RuntimeError, "#{self.class} profile took too long (> #{timeout} seconds) to complete" if result[:timeout]
105
+ raise RuntimeError, "#{self.class} profile errors: #{result[:err].join("\n")}" unless result[:err].empty?
90
106
  end
91
107
 
92
108
  def profile_file_name
@@ -25,12 +25,17 @@ module Libis
25
25
  opts += options[:filter] unless options[:filter].empty?
26
26
  opts += options[:output] unless options[:output].empty?
27
27
  opts << target
28
- result = Libis::Tools::Command.run(Libis::Format::Config[:ffmpeg_path], *opts)
29
28
 
30
- unless result[:status] == 0
31
- error "FFMpeg errors: #{(result[:err] + result[:out]).join("\n")}"
32
- return false
33
- end
29
+ timeout = Libis::Format::Config[:timeouts][:ffmpeg]
30
+ result = Libis::Tools::Command.run(
31
+ Libis::Format::Config[:ffmpeg_path], *opts,
32
+ timeout: timeout,
33
+ kill_after: timeout * 2
34
+ )
35
+
36
+ raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
37
+ raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0
38
+
34
39
  warn "FFMpeg warnings: #{(result[:err] + result[:out]).join("\n")}" unless result[:err].empty?
35
40
 
36
41
  result[:out]
@@ -74,17 +74,23 @@ module Libis
74
74
  args << '-q'
75
75
 
76
76
  # Run command and capture results
77
- fido = ::Libis::Tools::Command.run(Libis::Format::Config[:fido_path], *args)
77
+ timeout = Libis::Format::Config[:timeouts][:fido]
78
+ result = ::Libis::Tools::Command.run(
79
+ Libis::Format::Config[:fido_path], *args,
80
+ timeout: timeout,
81
+ kill_after: timeout * 2
82
+ )
78
83
 
79
84
  # Log warning if needed
80
- raise RuntimeError, "Fido errors: #{fido[:err].join("\n")}" unless fido[:err].empty?
85
+ raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
86
+ raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0 && result[:err].empty?
81
87
 
82
88
  # Parse output (CSV) text into array and return result
83
89
  keys = [:status, :time, :puid, :format_name, :format_version, :filesize, :filepath, :mimetype, :matchtype]
84
- result = CSV.parse(fido[:out].join("\n"))
90
+ data = CSV.parse(result[:out].join("\n"))
85
91
  .map {|a| Hash[keys.zip(a)]}
86
92
  .select {|a| a[:status] == 'OK'}
87
- result.each do |r|
93
+ data.each do |r|
88
94
  r.delete(:time)
89
95
  r.delete(:status)
90
96
  r.delete(:filesize)
@@ -59,13 +59,18 @@ module Libis
59
59
  opts << filename.escape_for_string if filename
60
60
 
61
61
  # Run the UNIX file command and capture the results
62
- file_tool = ::Libis::Tools::Command.run('file', *opts)
63
-
64
- raise RuntimeError, "File command errors: #{file_tool[:err].join("\n")}" unless file_tool[:err].empty?
62
+ timeout = Libis::Format::Config[:timeouts][:file_tool]
63
+ result = ::Libis::Tools::Command.run(
64
+ 'file', *opts,
65
+ timeout: timeout,
66
+ kill_after: timeout * 2
67
+ )
65
68
 
69
+ raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
70
+ raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0 && result[:err].empty?
66
71
 
67
72
  # Parse output text into array and return result
68
- file_tool[:out].map do |line|
73
+ result[:out].map do |line|
69
74
  r = line.split(/:\s+/)
70
75
  {filepath: r[0], mimetype: r[1], matchtype: 'magic', tool: :file}
71
76
  end
@@ -23,14 +23,20 @@ module Libis
23
23
  # TODO: import library and execute in current VM. For now do exactly as in MRI.
24
24
  end
25
25
 
26
- Libis::Tools::Command.run(
26
+ timeout = Libis::Format::Config[:timeouts][:fop]
27
+ result = Libis::Tools::Command.run(
27
28
  Libis::Format::Config[:java_path],
28
29
  "-Dfop.home=#{File.dirname(Libis::Format::Config[:fop_jar])}",
29
30
  '-jar', Libis::Format::Config[:fop_jar],
30
31
  '-fo', xml,
31
- '-pdf', target
32
+ '-pdf', target,
33
+ timeout: timeout,
34
+ kill_after: timeout * 2
32
35
  )
33
36
 
37
+ raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
38
+ raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0
39
+
34
40
  end
35
41
  end
36
42
 
@@ -31,19 +31,22 @@ module Libis
31
31
 
32
32
  export_filter = options[:export_filter] || 'pdf'
33
33
 
34
+ timeout = Libis::Format::Config[:timeouts][:office_to_pdf]
34
35
  result = Libis::Tools::Command.run(
35
36
  Libis::Format::Config[:soffice_path], '--headless',
36
37
  '--convert-to', export_filter,
37
- '--outdir', workdir, src_file
38
+ '--outdir', workdir, src_file,
39
+ timeout: timeout,
40
+ kill_after: timeout * 2
38
41
  )
39
42
 
40
- unless result[:status] == 0
41
- warn "PdfConvert errors: #{(result[:err] + result[:out]).join("\n")}"
42
- return false
43
- end
43
+ raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
44
+ raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0 && result[:err].empty?
44
45
 
45
46
  FileUtils.copy tgt_file, target, preserve: true
46
- FileUtils.rmtree workdir
47
+
48
+ ensure
49
+ FileUtils.rmtree workdir rescue nil
47
50
 
48
51
  result[:out]
49
52
  end
@@ -23,15 +23,21 @@ module Libis
23
23
  # TODO: import library and execute in current VM. For now do exactly as in MRI.
24
24
  end
25
25
 
26
- Libis::Tools::Command.run(
26
+ timeout = Libis::Format::Config[:timeouts][:pdf_copy]
27
+ result = Libis::Tools::Command.run(
27
28
  Libis::Format::Config[:java_path],
28
29
  '-cp', Libis::Format::Config[:pdf_tool],
29
30
  'CopyPdf',
30
31
  '--file_input', source,
31
32
  '--file_output', target,
32
- *options
33
+ *options,
34
+ timeout: timeout,
35
+ kill_after: timeout * 2
33
36
  )
34
37
 
38
+ raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
39
+ raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0 && result[:err].empty?
40
+
35
41
  end
36
42
  end
37
43
 
@@ -24,15 +24,21 @@ module Libis
24
24
  # TODO: import library and execute in current VM. For now do exactly as in MRI.
25
25
  end
26
26
 
27
- Libis::Tools::Command.run(
27
+ timeout = Libis::Format::Config[:timeouts][:pdf_merge]
28
+ result = Libis::Tools::Command.run(
28
29
  Libis::Format::Config[:java_path],
29
30
  '-cp', Libis::Format::Config[:pdf_tool],
30
31
  'MergePdf',
31
32
  '--file_output', target,
32
33
  *options,
33
34
  *source,
35
+ timeout: timeout,
36
+ kill_after: timeout * 2
34
37
  )
35
38
 
39
+ raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
40
+ raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0 && result[:err].empty?
41
+
36
42
  end
37
43
  end
38
44
 
@@ -19,7 +19,8 @@ module Libis
19
19
 
20
20
  def run(source, target, quality)
21
21
 
22
- Libis::Tools::Command.run(
22
+ timeout = Libis::Format::Config[:timeouts][:pdf_optimizer]
23
+ result = Libis::Tools::Command.run(
23
24
  'gs',
24
25
  '-sDEVICE=pdfwrite',
25
26
  '-dCompatibilityLevel=1.4',
@@ -27,9 +28,14 @@ module Libis
27
28
  '-dNOPAUSE',
28
29
  '-dBATCH',
29
30
  "-sOutputFile=#{target}",
30
- "#{source}"
31
+ "#{source}",
32
+ timeout: timeout,
33
+ kill_after: timeout * 2
31
34
  )
32
35
 
36
+ raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
37
+ raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0 && result[:err].empty?
38
+
33
39
  end
34
40
  end
35
41
 
@@ -23,15 +23,21 @@ module Libis
23
23
  # TODO: import library and execute in current VM. For now do exactly as in MRI.
24
24
  end
25
25
 
26
- Libis::Tools::Command.run(
26
+ timeout = Libis::Format::Config[:timeouts][:pdf_split]
27
+ result = Libis::Tools::Command.run(
27
28
  Libis::Format::Config[:java_path],
28
29
  '-cp', Libis::Format::Config[:pdf_tool],
29
30
  'SplitPdf',
30
31
  '--file_input', source,
31
32
  '--file_output', target,
32
- *options
33
+ *options,
34
+ timeout: timeout,
35
+ kill_after: timeout * 2
33
36
  )
34
37
 
38
+ raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
39
+ raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0 && result[:err].empty?
40
+
35
41
  end
36
42
  end
37
43
 
@@ -37,6 +37,7 @@ module Libis
37
37
  gsub('[** Fill in ICC reference name **]', icc_info[:icc_ref])
38
38
  end
39
39
 
40
+ timeout = Libis::Format::Config[:timeouts][:pdf_to_pdfa]
40
41
  result = Libis::Tools::Command.run(
41
42
  Libis::Format::Config[:ghostscript_path],
42
43
  '-dBATCH', '-dNOPAUSE', '-dNOOUTERSAVE',
@@ -46,9 +47,14 @@ module Libis
46
47
  "-sOutputICCProfile=#{icc_file}",
47
48
  '-o', File.absolute_path(target),
48
49
  def_filename,
49
- source
50
+ source,
51
+ timeout: timeout,
52
+ kill_after: timeout * 2
50
53
  )
51
54
 
55
+ raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
56
+ raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0 && result[:err].empty?
57
+
52
58
  FileUtils.rm [icc_file, def_filename].compact, force: true
53
59
 
54
60
  unless Format::Tool::PdfaValidator.run(target)
@@ -21,6 +21,7 @@ module Libis
21
21
 
22
22
  src_file = File.absolute_path(source)
23
23
 
24
+ timeout = Libis::Format::Config[:timeouts][:pdfa_validator]
24
25
  if (pdfa = Libis::Format::Config[:pdfa_path])
25
26
  # Keep it clean: tool generates fontconfig/ cache dir in current working dir
26
27
  previous_wd = Dir.getwd
@@ -31,9 +32,14 @@ module Libis
31
32
  '--noxml',
32
33
  '--level', 'B',
33
34
  '--verb', '0',
34
- src_file
35
+ src_file,
36
+ timeout: timeout,
37
+ kill_after: timeout * 2
35
38
  )
36
39
 
40
+ raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
41
+ raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0 && result[:err].empty?
42
+
37
43
  Dir.chdir(previous_wd)
38
44
 
39
45
  unless result[:out].any? {|line| line =~ /^VLD-\[PASS\]/}
@@ -46,8 +52,13 @@ module Libis
46
52
  result = Libis::Tools::Command.run(
47
53
  Libis::Format::Config[:java_path],
48
54
  '-jar', jar,
49
- src_file
55
+ src_file,
56
+ timeout: timeout,
57
+ kill_after: timeout * 2
50
58
  )
59
+ raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
60
+ raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:err].empty?
61
+
51
62
  unless result[:status] == 0
52
63
  warn "Validator failed to validate the PDF file '%s' against PDF/A-1B constraints:\n%s", source,
53
64
  result[:out].join("\n")
@@ -1,5 +1,5 @@
1
1
  module Libis
2
2
  module Format
3
- VERSION = '0.9.49'
3
+ VERSION = '0.9.50'
4
4
  end
5
5
  end
data/libis-format.gemspec CHANGED
@@ -27,6 +27,11 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'rspec', '~> 3.1'
28
28
  spec.add_development_dependency 'awesome_print'
29
29
  spec.add_development_dependency 'equivalent-xml', '~> 0.5'
30
+ if spec.platform == Gem::Platform::JAVA
31
+ spec.add_development_dependency 'saxon-xslt'
32
+ else
33
+ spec.add_development_dependency 'nokogiri'
34
+ end
30
35
 
31
36
  spec.add_runtime_dependency 'libis-tools', '~> 0.9.57'
32
37
  spec.add_runtime_dependency 'os', '= 0.9.6'
@@ -21,16 +21,15 @@ describe 'Converters' do
21
21
  let(:data_dir) {File.join(file_dir, 'data', 'xml')}
22
22
 
23
23
  it 'converts XML-FO to PDF' do
24
- src_file = File.join data_dir, '134476_fo.XML'
25
- tgt_file = File.join '', 'tmp', '134476_ead.pdf'
26
- cmp_file = File.join data_dir, '134476_ead.pdf'
27
- FileUtils.remove tgt_file, force: true
28
- FileUtils.mkdir_p File.dirname(tgt_file)
29
- result = converter.convert src_file, tgt_file, :PDF
30
- expect(result).to eq tgt_file
31
- # tgt = Nokogiri::XML(File.read(tgt_file))
32
- # cmp = Nokogiri::XML(File.read(cmp_file))
33
- # expect(tgt.root).to be_equivalent_to(cmp.root).respecting_element_order
24
+ if File.exist?(Libis::Format::Config[:fop_jar])
25
+ src_file = File.join data_dir, '134476_fo.XML'
26
+ tgt_file = File.join '', 'tmp', '134476_ead.pdf'
27
+ cmp_file = File.join data_dir, '134476_ead.pdf'
28
+ FileUtils.remove tgt_file, force: true
29
+ FileUtils.mkdir_p File.dirname(tgt_file)
30
+ result = converter.convert src_file, tgt_file, :PDF
31
+ expect(result).to eq tgt_file
32
+ end
34
33
  end
35
34
 
36
35
  end
@@ -13,7 +13,7 @@ describe 'Converters' do
13
13
  context 'Repository' do
14
14
 
15
15
  it 'loads all converters' do
16
- expect(repository.get_converters.size).to eq 6
16
+ expect(repository.get_converters.size).to eq 8
17
17
  # noinspection RubyResolve
18
18
  expect(repository.get_converters.map(&:to_s)).to include 'Libis::Format::Converter::ImageConverter'
19
19
  # noinspection RubyResolve
@@ -26,6 +26,10 @@ describe 'Converters' do
26
26
  expect(repository.get_converters.map(&:to_s)).to include 'Libis::Format::Converter::AudioConverter'
27
27
  # noinspection RubyResolve
28
28
  expect(repository.get_converters.map(&:to_s)).to include 'Libis::Format::Converter::VideoConverter'
29
+ # noinspection RubyResolve
30
+ expect(repository.get_converters.map(&:to_s)).to include 'Libis::Format::Converter::XsltConverter'
31
+ # noinspection RubyResolve
32
+ expect(repository.get_converters.map(&:to_s)).to include 'Libis::Format::Converter::FopPdfConverter'
29
33
  end
30
34
 
31
35
  it 'creates simple converter chain' do
@@ -1,11 +1,11 @@
1
1
  <?xml version="1.0" encoding="windows-1252"?>
2
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
2
+ <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
3
3
  <xsl:strip-space elements="*"/>
4
4
  <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
5
5
  <xsl:include href="header_nolink_pdf.xsl"/>
6
6
  <!-- Creates the body of the finding aid.-->
7
7
  <xsl:template match="/ead">
8
- <fo:root>
8
+ <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
9
9
  <fo:layout-master-set>
10
10
  <fo:simple-page-master master-name="pages" page-width="21cm" page-height="29.7cm"
11
11
  margin-top="1cm" margin-bottom="1cm"
@@ -437,10 +437,10 @@
437
437
  <fo:list-item-label end-indent="label-end()">
438
438
  <fo:block font-family="Times">
439
439
  <xsl:variable name="value-attr">
440
- <xsl:choose>
441
- <xsl:when test="../@start"><xsl:number value="position() + ../@start - 1"/></xsl:when>
442
- <xsl:otherwise><xsl:number value="position()"/></xsl:otherwise>
443
- </xsl:choose>
440
+ <xsl:choose>
441
+ <xsl:when test="../@start"><xsl:number value="position() + ../@start - 1"/></xsl:when>
442
+ <xsl:otherwise><xsl:number value="position()"/></xsl:otherwise>
443
+ </xsl:choose>
444
444
  </xsl:variable>
445
445
  </fo:block>
446
446
  </fo:list-item-label>
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="windows-1252"?>
2
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
2
+ <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3
3
 
4
4
  <xsl:variable name="REC_ID" select="ead/eadheader/eadid/@identifier"/>
5
5
  <xsl:variable name="TITLE_HEADER" select="ead/eadheader[1]/filedesc[1]/titlestmt[1]/titleproper[1]"/>
@@ -117,4 +117,4 @@
117
117
  </xsl:variable>
118
118
 
119
119
 
120
- </xsl:stylesheet>
120
+ </xsl:stylesheet>
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="windows-1252"?>
2
2
  <xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml"
3
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
3
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
4
4
  xmlns:ead="urn:isbn:1-931666-22-9"
5
5
  xmlns:ns2="http://www.w3.org/1999/xlink">
6
6
  <xsl:strip-space elements="*"/>