Sha256: 7b980b7beff08359712301085837ab6bf75aac717a9bafe18934ccbf68dd1f63

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

require "rubygems"
require "rake/clean"

def locate_mime_database
  possible_paths = [
    (File.expand_path(ENV["FREEDESKTOP_MIME_TYPES_PATH"]) if ENV["FREEDESKTOP_MIME_TYPES_PATH"]),
    "/usr/local/share/mime/packages/freedesktop.org.xml",
    "/opt/homebrew/share/mime/packages/freedesktop.org.xml",
    "/usr/share/mime/packages/freedesktop.org.xml"
  ].compact
  path = possible_paths.find { |candidate| File.exist?(candidate) }

  return path unless path.nil?
  raise(<<-ERROR.gsub(/^ {3}/, ""))
   Could not find MIME type database in the following locations: #{possible_paths}

   Ensure you have either installed the shared-mime-info package for your distribution, or
   obtain a version of freedesktop.org.xml and set FREEDESKTOP_MIME_TYPES_PATH to the location
   of that file.
  ERROR
end

desc "Build a file pointing at the database"
task :default do
  mime_database_path = locate_mime_database
  open("../../lib/mimemagic/path.rb", "w") do |f|
    f.print(%Q{
      class MimeMagic
        DATABASE_PATH="#{mime_database_path}"
      end
    })
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
test_mimemagick-0.3.2 ext/mimemagic/Rakefile
mimemagic-0.4.2 ext/mimemagic/Rakefile
mimemagic-0.3.9 ext/mimemagic/Rakefile