Sha256: 2249a88cf12b9036aed85805710a715e2fd7ebbbc83089eac9c170ffb9ff7095

Contents?: true

Size: 1.11 KB

Versions: 31

Compression:

Stored size: 1.11 KB

Contents

require_relative 'identification_tool'

module Libis
  module Format
    module Tool

      class ExtensionIdentification < Libis::Format::Tool::IdentificationTool

        def run_list(filelist, _options = {})

          output = runner(nil, filelist)

          process_output(output)

        end

        def run_dir(dir, recursive = true, _options = {})

          filelist = find_files(dir, recursive)

          output = runner(nil, filelist)

          process_output(output)

        end

        def run(file, _options)

          output = runner(file)

          process_output(output)

        end

        protected

        def runner(*args)

          args.map do |file|
            info = ::Libis::Format::TypeDatabase.ext_infos(File.extname(file)).first
            if info
              {
                  filepath: file,
                  mimetype: (info[:MIME].first rescue nil),
                  puid: (info[:PUID].first rescue nil),
                  matchtype: 'extension',
                  tool: :type_database
              }
            end
          end.cleanup

        end

      end

    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
libis-format-1.2.7 lib/libis/format/tool/extension_identification.rb
libis-format-1.2.6 lib/libis/format/tool/extension_identification.rb
libis-format-1.2.5 lib/libis/format/tool/extension_identification.rb
libis-format-1.2.3 lib/libis/format/tool/extension_identification.rb
libis-format-1.2.2 lib/libis/format/tool/extension_identification.rb
libis-format-1.2.1 lib/libis/format/tool/extension_identification.rb
libis-format-1.2.0 lib/libis/format/tool/extension_identification.rb
libis-format-1.1.0 lib/libis/format/tool/extension_identification.rb
libis-format-1.0.8 lib/libis/format/tool/extension_identification.rb
libis-format-1.0.7 lib/libis/format/tool/extension_identification.rb
libis-format-1.0.5 lib/libis/format/tool/extension_identification.rb
libis-format-1.0.4 lib/libis/format/tool/extension_identification.rb
libis-format-1.0.2 lib/libis/format/tool/extension_identification.rb
libis-format-1.0.1 lib/libis/format/tool/extension_identification.rb
libis-format-1.0.0 lib/libis/format/tool/extension_identification.rb
libis-format-0.9.74 lib/libis/format/tool/extension_identification.rb
libis-format-0.9.72 lib/libis/format/tool/extension_identification.rb
libis-format-0.9.70 lib/libis/format/tool/extension_identification.rb
libis-format-0.9.69 lib/libis/format/tool/extension_identification.rb
libis-format-0.9.68 lib/libis/format/tool/extension_identification.rb