Sha256: f2759736626e15f94dd18d3e2ce7804dee45db4206b007d91f60b5345213696d

Contents?: true

Size: 863 Bytes

Versions: 1

Compression:

Stored size: 863 Bytes

Contents

require 'hydra-file_characterization'
require 'mime/types'

module Hydra
  module Derivatives
    module ExtractMetadata

      def extract_metadata
        return unless has_content?
        Hydra::FileCharacterization.characterize(content, filename_for_characterization.join(""), :fits) do |config|
          config[:fits] = Hydra::Derivatives.fits_path
        end
      end

      protected

      def filename_for_characterization
        registered_mime_type = MIME::Types[mime_type].first
        Logger.warn "Unable to find a registered mime type for #{mime_type.inspect} on #{uri}" unless registered_mime_type
        extension = registered_mime_type ? ".#{registered_mime_type.extensions.first}" : ''
        version_id = 1 # TODO fixme
        m = /\/([^\/]*)$/.match(uri)
        ["#{m[1]}-#{version_id}", "#{extension}"]
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hydra-derivatives-1.2.1 lib/hydra/derivatives/extract_metadata.rb