libis-format 1.3.2 → 2.0.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/.coveralls.yml +2 -0
 - data/.gitignore +20 -0
 - data/.travis.yml +70 -0
 - data/Gemfile +0 -12
 - data/README.md +2 -2
 - data/Rakefile +8 -0
 - data/base/Dockerfile +35 -0
 - data/base/Dockerfile.alpine +20 -0
 - data/base/Dockerfile.rvm +56 -0
 - data/base/rework_path +20 -0
 - data/bin/{pdf_tool → pdf_copy} +2 -3
 - data/data/PDFA_def.ps +3 -3
 - data/data/eciRGB_v2.icc +0 -0
 - data/data/types.yml +4 -17
 - data/docker_cfg.yml +1 -0
 - data/lib/libis/format/cli/convert.rb +4 -4
 - data/lib/libis/format/cli/prompt_helper.rb +24 -32
 - data/lib/libis/format/command_line.rb +3 -2
 - data/lib/libis/format/config.rb +23 -19
 - data/lib/libis/format/converter/audio_converter.rb +31 -56
 - data/lib/libis/format/converter/base.rb +36 -16
 - data/lib/libis/format/converter/chain.rb +32 -52
 - data/lib/libis/format/converter/fop_pdf_converter.rb +8 -4
 - data/lib/libis/format/converter/image_assembler.rb +82 -0
 - data/lib/libis/format/converter/image_converter.rb +40 -153
 - data/lib/libis/format/converter/image_splitter.rb +80 -0
 - data/lib/libis/format/converter/image_watermarker.rb +261 -0
 - data/lib/libis/format/converter/jp2_converter.rb +38 -36
 - data/lib/libis/format/converter/office_converter.rb +28 -22
 - data/lib/libis/format/converter/pdf_assembler.rb +66 -0
 - data/lib/libis/format/converter/pdf_converter.rb +52 -200
 - data/lib/libis/format/converter/pdf_optimizer.rb +70 -0
 - data/lib/libis/format/converter/pdf_splitter.rb +65 -0
 - data/lib/libis/format/converter/pdf_watermarker.rb +110 -0
 - data/lib/libis/format/converter/repository.rb +13 -7
 - data/lib/libis/format/converter/spreadsheet_converter.rb +16 -10
 - data/lib/libis/format/converter/video_converter.rb +58 -47
 - data/lib/libis/format/converter/xslt_converter.rb +11 -13
 - data/lib/libis/format/converter.rb +1 -1
 - data/lib/libis/format/identifier.rb +46 -44
 - data/lib/libis/format/info.rb +27 -0
 - data/lib/libis/format/library.rb +147 -0
 - data/lib/libis/format/tool/droid.rb +30 -29
 - data/lib/libis/format/tool/extension_identification.rb +26 -24
 - data/lib/libis/format/tool/{ff_mpeg.rb → ffmpeg.rb} +10 -17
 - data/lib/libis/format/tool/fido.rb +27 -22
 - data/lib/libis/format/tool/file_tool.rb +24 -11
 - data/lib/libis/format/tool/fop_pdf.rb +14 -25
 - data/lib/libis/format/tool/identification_tool.rb +40 -38
 - data/lib/libis/format/tool/office_to_pdf.rb +18 -30
 - data/lib/libis/format/tool/pdf_copy.rb +47 -0
 - data/lib/libis/format/tool/pdf_merge.rb +48 -0
 - data/lib/libis/format/tool/pdf_optimizer.rb +19 -22
 - data/lib/libis/format/tool/pdf_split.rb +47 -0
 - data/lib/libis/format/tool/pdf_to_pdfa.rb +31 -45
 - data/lib/libis/format/tool/pdfa_validator.rb +30 -24
 - data/lib/libis/format/tool/spreadsheet_to_ods.rb +18 -29
 - data/lib/libis/format/tool.rb +3 -4
 - data/lib/libis/format/version.rb +1 -3
 - data/lib/libis/format/yaml_loader.rb +71 -0
 - data/lib/libis/format.rb +7 -5
 - data/lib/libis-format.rb +0 -2
 - data/libis-format.gemspec +18 -24
 - data/tools/PdfTool.jar +0 -0
 - data/tools/pdfbox/pdfbox-app-2.0.13.jar +0 -0
 - data/tools/pdfbox/{preflight-app-3.0.3.jar → preflight-app-2.0.13.jar} +0 -0
 - metadata +85 -125
 - data/data/AdobeRGB1998.icc +0 -0
 - data/lib/libis/format/converter/email_converter.rb +0 -35
 - data/lib/libis/format/tool/msg_to_pdf.rb +0 -270
 - data/lib/libis/format/tool/pdf_tool.rb +0 -52
 - data/lib/libis/format/type_database.rb +0 -156
 - data/lib/libis/format/type_database_impl.rb +0 -153
 - data/tools/pdf2pdfa +0 -395
 - data/tools/pdfbox/pdfbox-app-3.0.3.jar +0 -0
 - /data/bin/{droid_tool → droid} +0 -0
 - /data/bin/{fido_tool → fido} +0 -0
 
| 
         @@ -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
         
     | 
| 
         @@ -1,5 +1,6 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #  
     | 
| 
      
 1 
     | 
    
         
            +
            # coding: utf-8
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            require 'set'
         
     | 
| 
       3 
4 
     | 
    
         
             
            require 'singleton'
         
     | 
| 
       4 
5 
     | 
    
         | 
| 
       5 
6 
     | 
    
         
             
            require 'libis/tools/logger'
         
     | 
| 
         @@ -10,6 +11,7 @@ require_relative 'chain' 
     | 
|
| 
       10 
11 
     | 
    
         
             
            module Libis
         
     | 
| 
       11 
12 
     | 
    
         
             
              module Format
         
     | 
| 
       12 
13 
     | 
    
         
             
                module Converter
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
       13 
15 
     | 
    
         
             
                  class Repository
         
     | 
| 
       14 
16 
     | 
    
         
             
                    include Singleton
         
     | 
| 
       15 
17 
     | 
    
         
             
                    include ::Libis::Tools::Logger
         
     | 
| 
         @@ -22,15 +24,15 @@ module Libis 
     | 
|
| 
       22 
24 
     | 
    
         
             
                      @converters_glob = File.join(File.dirname(__FILE__), '*_converter.rb')
         
     | 
| 
       23 
25 
     | 
    
         
             
                    end
         
     | 
| 
       24 
26 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
                    def  
     | 
| 
      
 27 
     | 
    
         
            +
                    def Repository.register(converter_class)
         
     | 
| 
       26 
28 
     | 
    
         
             
                      instance.converters.add? converter_class
         
     | 
| 
       27 
29 
     | 
    
         
             
                    end
         
     | 
| 
       28 
30 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
                    def  
     | 
| 
      
 31 
     | 
    
         
            +
                    def Repository.get_converters
         
     | 
| 
       30 
32 
     | 
    
         
             
                      instance.get_converters
         
     | 
| 
       31 
33 
     | 
    
         
             
                    end
         
     | 
| 
       32 
34 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
                    def get_converters 
     | 
| 
      
 35 
     | 
    
         
            +
                    def get_converters
         
     | 
| 
       34 
36 
     | 
    
         
             
                      if converters.empty?
         
     | 
| 
       35 
37 
     | 
    
         
             
                        Dir.glob(converters_glob).each do |filename|
         
     | 
| 
       36 
38 
     | 
    
         
             
                          # noinspection RubyResolve
         
     | 
| 
         @@ -40,12 +42,12 @@ module Libis 
     | 
|
| 
       40 
42 
     | 
    
         
             
                      converters
         
     | 
| 
       41 
43 
     | 
    
         
             
                    end
         
     | 
| 
       42 
44 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
                    def  
     | 
| 
      
 45 
     | 
    
         
            +
                    def Repository.get_converter_chain(src_type, tgt_type, operations = {})
         
     | 
| 
       44 
46 
     | 
    
         
             
                      instance.get_converter_chain src_type, tgt_type, operations
         
     | 
| 
       45 
47 
     | 
    
         
             
                    end
         
     | 
| 
       46 
48 
     | 
    
         | 
| 
       47 
49 
     | 
    
         
             
                    def get_converter_chain(src_type, tgt_type, operations = {})
         
     | 
| 
       48 
     | 
    
         
            -
                      msg = "conversion from #{src_type} to #{tgt_type}"
         
     | 
| 
      
 50 
     | 
    
         
            +
                      msg = "conversion from #{src_type.to_s} to #{tgt_type.to_s}"
         
     | 
| 
       49 
51 
     | 
    
         
             
                      chain_list = find_chains src_type, tgt_type, operations
         
     | 
| 
       50 
52 
     | 
    
         
             
                      # if chain_list.length > 1
         
     | 
| 
       51 
53 
     | 
    
         
             
                      #   warn "Found more than one conversion chain for #{msg}. Picking the first one."
         
     | 
| 
         @@ -68,6 +70,7 @@ module Libis 
     | 
|
| 
       68 
70 
     | 
    
         
             
                    end
         
     | 
| 
       69 
71 
     | 
    
         | 
| 
       70 
72 
     | 
    
         
             
                    def build_chains(chain)
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
       71 
74 
     | 
    
         
             
                      found = []
         
     | 
| 
       72 
75 
     | 
    
         
             
                      chains = [chain]
         
     | 
| 
       73 
76 
     | 
    
         | 
| 
         @@ -78,15 +81,18 @@ module Libis 
     | 
|
| 
       78 
81 
     | 
    
         
             
                          new_chains += chains.map { |c| c.append(converter) }.flatten
         
     | 
| 
       79 
82 
     | 
    
         
             
                        end
         
     | 
| 
       80 
83 
     | 
    
         | 
| 
       81 
     | 
    
         
            -
                        found = new_chains.select 
     | 
| 
      
 84 
     | 
    
         
            +
                        found = new_chains.select { |c| c.valid?}
         
     | 
| 
       82 
85 
     | 
    
         
             
                        return found unless found.empty?
         
     | 
| 
       83 
86 
     | 
    
         | 
| 
       84 
87 
     | 
    
         
             
                        chains = new_chains
         
     | 
| 
       85 
88 
     | 
    
         
             
                      end
         
     | 
| 
       86 
89 
     | 
    
         | 
| 
       87 
90 
     | 
    
         
             
                      found
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
       88 
92 
     | 
    
         
             
                    end
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
       89 
94 
     | 
    
         
             
                  end
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
       90 
96 
     | 
    
         
             
                end
         
     | 
| 
       91 
97 
     | 
    
         
             
              end
         
     | 
| 
       92 
98 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,38 +1,44 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #  
     | 
| 
      
 1 
     | 
    
         
            +
            # encoding: utf-8
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            require_relative 'base'
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            require 'libis/format/tool/spreadsheet_to_ods'
         
     | 
| 
       6 
     | 
    
         
            -
            require 'libis/format/ 
     | 
| 
      
 6 
     | 
    
         
            +
            require 'libis/format/library'
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
            module Libis
         
     | 
| 
       9 
9 
     | 
    
         
             
              module Format
         
     | 
| 
       10 
10 
     | 
    
         
             
                module Converter
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       11 
12 
     | 
    
         
             
                  class SpreadsheetConverter < Libis::Format::Converter::Base
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
       12 
14 
     | 
    
         
             
                    def self.input_types
         
     | 
| 
       13 
     | 
    
         
            -
                       
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
                      [
         
     | 
| 
      
 16 
     | 
    
         
            +
                          :MSXLS,
         
     | 
| 
      
 17 
     | 
    
         
            +
                          :MSXLSX,
         
     | 
| 
      
 18 
     | 
    
         
            +
                          :OO_CALC
         
     | 
| 
       17 
19 
     | 
    
         
             
                      ]
         
     | 
| 
       18 
20 
     | 
    
         
             
                    end
         
     | 
| 
       19 
21 
     | 
    
         | 
| 
       20 
22 
     | 
    
         
             
                    def self.output_types(format = nil)
         
     | 
| 
       21 
     | 
    
         
            -
                      return [] unless input_types.include?(format)
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
      
 23 
     | 
    
         
            +
                      return [] unless input_types.include?(format) if format
         
     | 
| 
       23 
24 
     | 
    
         
             
                      [:OO_CALC]
         
     | 
| 
       24 
25 
     | 
    
         
             
                    end
         
     | 
| 
       25 
26 
     | 
    
         | 
| 
       26 
27 
     | 
    
         
             
                    def spreadsheet_convert(_)
         
     | 
| 
       27 
     | 
    
         
            -
                      # 
     | 
| 
      
 28 
     | 
    
         
            +
                      #force usage of this converter
         
     | 
| 
       28 
29 
     | 
    
         
             
                    end
         
     | 
| 
       29 
30 
     | 
    
         | 
| 
       30 
31 
     | 
    
         
             
                    def convert(source, target, format, opts = {})
         
     | 
| 
       31 
32 
     | 
    
         
             
                      super
         
     | 
| 
       32 
33 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
                      Format::Tool::SpreadsheetToOds.run(source, target)
         
     | 
| 
      
 34 
     | 
    
         
            +
                      return nil unless Format::Tool::SpreadsheetToOds.run(source, target)
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                      target
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
       34 
38 
     | 
    
         
             
                    end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
       35 
40 
     | 
    
         
             
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
       36 
42 
     | 
    
         
             
                end
         
     | 
| 
       37 
43 
     | 
    
         
             
              end
         
     | 
| 
       38 
44 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,26 +1,29 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
1 
     | 
    
         
             
            require_relative 'base'
         
     | 
| 
       4 
     | 
    
         
            -
            require 'libis/format/tool/ 
     | 
| 
      
 2 
     | 
    
         
            +
            require 'libis/format/tool/ffmpeg'
         
     | 
| 
       5 
3 
     | 
    
         | 
| 
       6 
4 
     | 
    
         
             
            require 'fileutils'
         
     | 
| 
       7 
5 
     | 
    
         | 
| 
       8 
6 
     | 
    
         
             
            module Libis
         
     | 
| 
       9 
7 
     | 
    
         
             
              module Format
         
     | 
| 
       10 
8 
     | 
    
         
             
                module Converter
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
       11 
10 
     | 
    
         
             
                  class VideoConverter < Libis::Format::Converter::Base
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       12 
12 
     | 
    
         
             
                    def self.input_types
         
     | 
| 
       13 
     | 
    
         
            -
                       
     | 
| 
      
 13 
     | 
    
         
            +
                      [:WEBM, :MP4, :MPG, :MKV, :MJP2, :QTFF, :AVI, :OGGV, :WMV, :DV, :FLV, :SWF]
         
     | 
| 
       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 
     | 
    
         
            +
                      [:GIF, :WEBM, :MP4, :MPG, :MKV, :MJP2, :QTFF, :AVI, :OGGV, :WMV, :DV, :FLV, :SWF]
         
     | 
| 
      
 19 
     | 
    
         
            +
                    end
         
     | 
| 
       18 
20 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
      
 21 
     | 
    
         
            +
                    def initialize
         
     | 
| 
      
 22 
     | 
    
         
            +
                      super
         
     | 
| 
       20 
23 
     | 
    
         
             
                    end
         
     | 
| 
       21 
24 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
                    def quiet( 
     | 
| 
       23 
     | 
    
         
            -
                      @flags[:quiet] = !! 
     | 
| 
      
 25 
     | 
    
         
            +
                    def quiet(v)
         
     | 
| 
      
 26 
     | 
    
         
            +
                      @flags[:quiet] = !!v
         
     | 
| 
       24 
27 
     | 
    
         
             
                    end
         
     | 
| 
       25 
28 
     | 
    
         | 
| 
       26 
29 
     | 
    
         
             
                    def format(format)
         
     | 
| 
         @@ -123,10 +126,10 @@ module Libis 
     | 
|
| 
       123 
126 
     | 
    
         | 
| 
       124 
127 
     | 
    
         
             
                    # @param [Boolean] value If set to true automatically selects optimal format for web viewing. Default: false
         
     | 
| 
       125 
128 
     | 
    
         
             
                    def web_stream(value)
         
     | 
| 
       126 
     | 
    
         
            -
                       
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
                       
     | 
| 
      
 129 
     | 
    
         
            +
                      if value
         
     | 
| 
      
 130 
     | 
    
         
            +
                        @options[:video_codec] = 'h264'
         
     | 
| 
      
 131 
     | 
    
         
            +
                        @options[:audio_codec] = 'acc'
         
     | 
| 
      
 132 
     | 
    
         
            +
                      end
         
     | 
| 
       130 
133 
     | 
    
         
             
                    end
         
     | 
| 
       131 
134 
     | 
    
         | 
| 
       132 
135 
     | 
    
         
             
                    # @param [String] name name of a preset. See FFMpeg documentation for more info
         
     | 
| 
         @@ -167,7 +170,7 @@ module Libis 
     | 
|
| 
       167 
170 
     | 
    
         | 
| 
       168 
171 
     | 
    
         
             
                      elsif File.directory?(source)
         
     | 
| 
       169 
172 
     | 
    
         | 
| 
       170 
     | 
    
         
            -
                        sources = Dir[File.join(source, '**', '*')].reject { 
     | 
| 
      
 173 
     | 
    
         
            +
                        sources = Dir[File.join(source, '**', '*')].reject {|p| File.directory? p}
         
     | 
| 
       171 
174 
     | 
    
         
             
                        assemble_and_convert(sources, target)
         
     | 
| 
       172 
175 
     | 
    
         | 
| 
       173 
176 
     | 
    
         
             
                      else
         
     | 
| 
         @@ -176,17 +179,15 @@ module Libis 
     | 
|
| 
       176 
179 
     | 
    
         | 
| 
       177 
180 
     | 
    
         
             
                      end
         
     | 
| 
       178 
181 
     | 
    
         | 
| 
       179 
     | 
    
         
            -
                       
     | 
| 
       180 
     | 
    
         
            -
             
     | 
| 
       181 
     | 
    
         
            -
                        converter: self.class.name
         
     | 
| 
       182 
     | 
    
         
            -
                      }
         
     | 
| 
      
 182 
     | 
    
         
            +
                      target
         
     | 
| 
      
 183 
     | 
    
         
            +
             
     | 
| 
       183 
184 
     | 
    
         
             
                    end
         
     | 
| 
       184 
185 
     | 
    
         | 
| 
       185 
186 
     | 
    
         
             
                    def assemble_and_convert(sources, target)
         
     | 
| 
       186 
     | 
    
         
            -
                      Tempfile.create(%w 
     | 
| 
       187 
     | 
    
         
            -
                        sources.each { 
     | 
| 
      
 187 
     | 
    
         
            +
                      Tempfile.create(%w(list .txt)) do |f|
         
     | 
| 
      
 188 
     | 
    
         
            +
                        sources.each {|src| f.puts src}
         
     | 
| 
       188 
189 
     | 
    
         
             
                        opts[:global] ||= []
         
     | 
| 
       189 
     | 
    
         
            -
                        opts[:global] += %w 
     | 
| 
      
 190 
     | 
    
         
            +
                        opts[:global] += %w(-f concat)
         
     | 
| 
       190 
191 
     | 
    
         
             
                        f.close
         
     | 
| 
       191 
192 
     | 
    
         
             
                        target = convert_file(f.to_path, target)
         
     | 
| 
       192 
193 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -197,15 +198,15 @@ module Libis 
     | 
|
| 
       197 
198 
     | 
    
         | 
| 
       198 
199 
     | 
    
         
             
                    def convert_file(source, target)
         
     | 
| 
       199 
200 
     | 
    
         
             
                      # FLV special: only supports aac and speex audio codecs
         
     | 
| 
       200 
     | 
    
         
            -
                      format = (@options[:format] || File.extname(target)[1 
     | 
| 
       201 
     | 
    
         
            -
                      @options[:audio_codec] ||= 'aac' if %w 
     | 
| 
      
 201 
     | 
    
         
            +
                      format = (@options[:format] || File.extname(target)[1..-1]).to_s.downcase
         
     | 
| 
      
 202 
     | 
    
         
            +
                      @options[:audio_codec] ||= 'aac' if %w'flv'.include?(format)
         
     | 
| 
       202 
203 
     | 
    
         | 
| 
       203 
204 
     | 
    
         
             
                      # SWF special: only supports mp3 audio codec
         
     | 
| 
       204 
     | 
    
         
            -
                      format = (@options[:format] || File.extname(target)[1 
     | 
| 
       205 
     | 
    
         
            -
                      @options[:audio_codec] ||= 'mp3' if %w 
     | 
| 
      
 205 
     | 
    
         
            +
                      format = (@options[:format] || File.extname(target)[1..-1]).to_s.downcase
         
     | 
| 
      
 206 
     | 
    
         
            +
                      @options[:audio_codec] ||= 'mp3' if %w'swf'.include?(format)
         
     | 
| 
       206 
207 
     | 
    
         | 
| 
       207 
208 
     | 
    
         
             
                      # Set up FFMpeg command line parameters
         
     | 
| 
       208 
     | 
    
         
            -
                      opts = { 
     | 
| 
      
 209 
     | 
    
         
            +
                      opts = {global: [], input: [], filter: [], output: []}
         
     | 
| 
       209 
210 
     | 
    
         
             
                      opts[:global] << '-hide_banner'
         
     | 
| 
       210 
211 
     | 
    
         
             
                      opts[:global] << '-loglevel' << (@options[:quiet] ? 'fatal' : 'warning')
         
     | 
| 
       211 
212 
     | 
    
         | 
| 
         @@ -213,21 +214,29 @@ module Libis 
     | 
|
| 
       213 
214 
     | 
    
         
             
                      @options[:watermark_opacity] ||= 0.5
         
     | 
| 
       214 
215 
     | 
    
         
             
                      if @options[:watermark_image]
         
     | 
| 
       215 
216 
     | 
    
         
             
                        opts[:filter] << '-i' << @options[:watermark_image] << '-filter_complex'
         
     | 
| 
       216 
     | 
    
         
            -
                        opts[:filter] <<  
     | 
| 
       217 
     | 
    
         
            -
             
     | 
| 
      
 217 
     | 
    
         
            +
                        opts[:filter] << "[1:v]format=argb,colorchannelmixer=aa=%f[wm];[0:v][wm]overlay=%s" %
         
     | 
| 
      
 218 
     | 
    
         
            +
                            [@options[:watermark_opacity], watermark_position_text]
         
     | 
| 
       218 
219 
     | 
    
         
             
                      elsif @options[:watermark_text]
         
     | 
| 
       219 
220 
     | 
    
         
             
                        @options[:watermark_text_size] ||= 10
         
     | 
| 
       220 
221 
     | 
    
         
             
                        @options[:watermark_text_color] ||= 'white'
         
     | 
| 
       221 
222 
     | 
    
         
             
                        @options[:watermark_text_shadow_color] ||= 'black'
         
     | 
| 
       222 
223 
     | 
    
         
             
                        @options[:watermark_text_shadow_offset] ||= 1
         
     | 
| 
       223 
     | 
    
         
            -
                        filter_text =  
     | 
| 
       224 
     | 
    
         
            -
             
     | 
| 
       225 
     | 
    
         
            -
             
     | 
| 
       226 
     | 
    
         
            -
             
     | 
| 
       227 
     | 
    
         
            -
             
     | 
| 
       228 
     | 
    
         
            -
             
     | 
| 
       229 
     | 
    
         
            -
             
     | 
| 
       230 
     | 
    
         
            -
             
     | 
| 
      
 224 
     | 
    
         
            +
                        filter_text = "drawtext=text='%s':%s:fontfile=%s:fontsize=%d:fontcolor=%s@%f" %
         
     | 
| 
      
 225 
     | 
    
         
            +
                            [
         
     | 
| 
      
 226 
     | 
    
         
            +
                                @options[:watermark_text],
         
     | 
| 
      
 227 
     | 
    
         
            +
                                watermark_position_text(true),
         
     | 
| 
      
 228 
     | 
    
         
            +
                                Config[:watermark_font],
         
     | 
| 
      
 229 
     | 
    
         
            +
                                @options[:watermark_text_size],
         
     | 
| 
      
 230 
     | 
    
         
            +
                                @options[:watermark_text_color],
         
     | 
| 
      
 231 
     | 
    
         
            +
                                @options[:watermark_opacity]
         
     | 
| 
      
 232 
     | 
    
         
            +
                            ]
         
     | 
| 
      
 233 
     | 
    
         
            +
                        filter_text += ':shadowcolor=%s@%f:shadowx=%d:shadowy=%d' %
         
     | 
| 
      
 234 
     | 
    
         
            +
                            [
         
     | 
| 
      
 235 
     | 
    
         
            +
                                @options[:watermark_text_shadow_color],
         
     | 
| 
      
 236 
     | 
    
         
            +
                                @options[:watermark_opacity],
         
     | 
| 
      
 237 
     | 
    
         
            +
                                @options[:watermark_text_shadow_offset],
         
     | 
| 
      
 238 
     | 
    
         
            +
                                @options[:watermark_text_shadow_offset]
         
     | 
| 
      
 239 
     | 
    
         
            +
                            ] if @options[:watermark_text_shadow_offset] > 0
         
     | 
| 
       231 
240 
     | 
    
         
             
                        opts[:filter] << '-vf' << filter_text
         
     | 
| 
       232 
241 
     | 
    
         
             
                      end
         
     | 
| 
       233 
242 
     | 
    
         
             
                      opts[:output] << '-ac' << @options[:audio_channels] if @options[:audio_channels]
         
     | 
| 
         @@ -239,7 +248,7 @@ module Libis 
     | 
|
| 
       239 
248 
     | 
    
         
             
                      opts[:output] << '-map_metadata:g' << '0:g' # Copy global metadata
         
     | 
| 
       240 
249 
     | 
    
         
             
                      opts[:output] << '-map_metadata:s:a' << '0:s:a' # Copy audio metadata
         
     | 
| 
       241 
250 
     | 
    
         
             
                      opts[:output] << '-map_metadata:s:v' << '0:s:v' # Copy video metadata
         
     | 
| 
       242 
     | 
    
         
            -
                      opts[:input] << '-accurate_seek' << (@options[:start].to_i 
     | 
| 
      
 251 
     | 
    
         
            +
                      opts[:input] << '-accurate_seek' << (@options[:start].to_i < 0 ? '-sseof' : '-ss') << @options[:start] if @options[:start]
         
     | 
| 
       243 
252 
     | 
    
         
             
                      opts[:input] << '-t' << @options[:duration] if @options[:duration]
         
     | 
| 
       244 
253 
     | 
    
         
             
                      opts[:output] << '-qscale' << @options[:video_quality] if @options[:video_quality]
         
     | 
| 
       245 
254 
     | 
    
         
             
                      opts[:output] << '-q:a' << @options[:audio_quality] if @options[:audio_quality]
         
     | 
| 
         @@ -265,19 +274,21 @@ module Libis 
     | 
|
| 
       265 
274 
     | 
    
         
             
                      w = for_text ? 'tw' : 'w'
         
     | 
| 
       266 
275 
     | 
    
         
             
                      h = for_text ? 'th' : 'h'
         
     | 
| 
       267 
276 
     | 
    
         
             
                      case @options[:watermark_position]
         
     | 
| 
       268 
     | 
    
         
            -
             
     | 
| 
       269 
     | 
    
         
            -
             
     | 
| 
       270 
     | 
    
         
            -
             
     | 
| 
       271 
     | 
    
         
            -
             
     | 
| 
       272 
     | 
    
         
            -
             
     | 
| 
       273 
     | 
    
         
            -
             
     | 
| 
       274 
     | 
    
         
            -
             
     | 
| 
       275 
     | 
    
         
            -
             
     | 
| 
       276 
     | 
    
         
            -
             
     | 
| 
       277 
     | 
    
         
            -
             
     | 
| 
      
 277 
     | 
    
         
            +
                        when 'bottom_left'
         
     | 
| 
      
 278 
     | 
    
         
            +
                          "x=#{margin}:y=H-#{h}-#{margin}"
         
     | 
| 
      
 279 
     | 
    
         
            +
                        when 'top_left'
         
     | 
| 
      
 280 
     | 
    
         
            +
                          "x=#{margin}:y=#{margin}"
         
     | 
| 
      
 281 
     | 
    
         
            +
                        when 'bottom_right'
         
     | 
| 
      
 282 
     | 
    
         
            +
                          "x=W-#{w}-#{margin}:y=H-#{h}-#{margin}"
         
     | 
| 
      
 283 
     | 
    
         
            +
                        when 'top_right'
         
     | 
| 
      
 284 
     | 
    
         
            +
                          "x=W-#{w}-#{margin}:y=#{margin}"
         
     | 
| 
      
 285 
     | 
    
         
            +
                        else
         
     | 
| 
      
 286 
     | 
    
         
            +
                          "x=#{margin}:y=H-#{h}-#{margin}"
         
     | 
| 
       278 
287 
     | 
    
         
             
                      end
         
     | 
| 
       279 
288 
     | 
    
         
             
                    end
         
     | 
| 
      
 289 
     | 
    
         
            +
             
     | 
| 
       280 
290 
     | 
    
         
             
                  end
         
     | 
| 
      
 291 
     | 
    
         
            +
             
     | 
| 
       281 
292 
     | 
    
         
             
                end
         
     | 
| 
       282 
293 
     | 
    
         
             
              end
         
     | 
| 
       283 
     | 
    
         
            -
            end
         
     | 
| 
      
 294 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,19 +1,18 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
1 
     | 
    
         
             
            require_relative 'base'
         
     | 
| 
       4 
2 
     | 
    
         | 
| 
       5 
3 
     | 
    
         
             
            module Libis
         
     | 
| 
       6 
4 
     | 
    
         
             
              module Format
         
     | 
| 
       7 
5 
     | 
    
         
             
                module Converter
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
       8 
7 
     | 
    
         
             
                  class XsltConverter < Libis::Format::Converter::Base
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
       9 
9 
     | 
    
         
             
                    def self.input_types
         
     | 
| 
       10 
10 
     | 
    
         
             
                      [:XML]
         
     | 
| 
       11 
11 
     | 
    
         
             
                    end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
                    def self.output_types(format = nil)
         
     | 
| 
       14 
     | 
    
         
            -
                      return []  
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                      %i[XML HTML TXT]
         
     | 
| 
      
 14 
     | 
    
         
            +
                      return [] unless input_types.include?(format) if format
         
     | 
| 
      
 15 
     | 
    
         
            +
                      [:XML, :HTML, :TXT]
         
     | 
| 
       17 
16 
     | 
    
         
             
                    end
         
     | 
| 
       18 
17 
     | 
    
         | 
| 
       19 
18 
     | 
    
         
             
                    def xsl_file(file_path)
         
     | 
| 
         @@ -35,12 +34,12 @@ module Libis 
     | 
|
| 
       35 
34 
     | 
    
         | 
| 
       36 
35 
     | 
    
         
             
                      FileUtils.mkpath(File.dirname(target))
         
     | 
| 
       37 
36 
     | 
    
         | 
| 
       38 
     | 
    
         
            -
                      if RUBY_PLATFORM ==  
     | 
| 
      
 37 
     | 
    
         
            +
                      if RUBY_PLATFORM == "java"
         
     | 
| 
       39 
38 
     | 
    
         
             
                        require 'saxon-xslt'
         
     | 
| 
       40 
39 
     | 
    
         
             
                        xsl = Saxon.XSLT(File.open(@options[:xsl_file]))
         
     | 
| 
       41 
40 
     | 
    
         
             
                        xml = Saxon.XML(File.open(source))
         
     | 
| 
       42 
41 
     | 
    
         
             
                        result = xsl.transform(xml)
         
     | 
| 
       43 
     | 
    
         
            -
                        File. 
     | 
| 
      
 42 
     | 
    
         
            +
                        File.open(target, 'w') {|f| f.write(result.to_s)}
         
     | 
| 
       44 
43 
     | 
    
         
             
                      else
         
     | 
| 
       45 
44 
     | 
    
         
             
                        require 'nokogiri'
         
     | 
| 
       46 
45 
     | 
    
         | 
| 
         @@ -87,17 +86,16 @@ module Libis 
     | 
|
| 
       87 
86 
     | 
    
         
             
                          error "Error transforming '#{source}' with '#{file}': #{e.message} @ #{e.backtrace[0]}"
         
     | 
| 
       88 
87 
     | 
    
         
             
                          return nil
         
     | 
| 
       89 
88 
     | 
    
         
             
                        ensure
         
     | 
| 
       90 
     | 
    
         
            -
                          fp.close unless fp.nil?  
     | 
| 
      
 89 
     | 
    
         
            +
                          fp.close unless fp.nil? or fp.closed?
         
     | 
| 
       91 
90 
     | 
    
         
             
                        end
         
     | 
| 
       92 
91 
     | 
    
         | 
| 
       93 
     | 
    
         
            -
                         
     | 
| 
       94 
     | 
    
         
            -
                          command: { status: 0 },
         
     | 
| 
       95 
     | 
    
         
            -
                          files: [target]
         
     | 
| 
       96 
     | 
    
         
            -
                        }
         
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
      
 92 
     | 
    
         
            +
                        target
         
     | 
| 
       98 
93 
     | 
    
         
             
                      end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
       99 
95 
     | 
    
         
             
                    end
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
       100 
97 
     | 
    
         
             
                  end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
       101 
99 
     | 
    
         
             
                end
         
     | 
| 
       102 
100 
     | 
    
         
             
              end
         
     | 
| 
       103 
101 
     | 
    
         
             
            end
         
     |