Sha256: c20725a42e27aea94c9f32ab6f3273bf6291807fad7a3a5758940190d0a389de

Contents?: true

Size: 1005 Bytes

Versions: 8

Compression:

Stored size: 1005 Bytes

Contents

require_relative 'identification_tool'

module Libis
  module Format

    class ExtensionIdentification < Libis::Format::IdentificationTool

      def run_list(filelist)

        output = runner(nil, filelist)

        process_output(output)

      end

      def run_dir(dir, recursive = true)

        filelist = find_files(dir, recursive)

        output = runner(nil, filelist)

        process_output(output)

      end

      def run(file)

        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',
                source: :type_database
            }
          end
        end.cleanup

      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
libis-format-0.9.41 lib/libis/format/extension_identification.rb
libis-format-0.9.40 lib/libis/format/extension_identification.rb
libis-format-0.9.39 lib/libis/format/extension_identification.rb
libis-format-0.9.38 lib/libis/format/extension_identification.rb
libis-format-0.9.37 lib/libis/format/extension_identification.rb
libis-format-0.9.36 lib/libis/format/extension_identification.rb
libis-format-0.9.35 lib/libis/format/extension_identification.rb
libis-format-0.9.33 lib/libis/format/extension_identification.rb