module MiniMagick::Utilities
@private
Public Instance Methods
tempfile(extension) { |tempfile| ... }
click to toggle source
# File lib/mini_magick/utilities.rb, line 26 def tempfile(extension) Tempfile.new(["mini_magick", extension]).tap do |tempfile| tempfile.binmode yield tempfile if block_given? tempfile.close end end
which(cmd)
click to toggle source
Cross-platform way of finding an executable in the $PATH.
@example
MiniMagick::Utilities.which('ruby') #=> "/usr/bin/ruby"
# File lib/mini_magick/utilities.rb, line 15 def which(cmd) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV.fetch('PATH').split(File::PATH_SEPARATOR).each do |path| exts.each do |ext| exe = File.join(path, "#{cmd}#{ext}") return exe if File.executable? exe end end nil end