lib/ffprober/ffmpeg/finder.rb in ffprober-0.4.6 vs lib/ffprober/ffmpeg/finder.rb in ffprober-0.5.1
- old
+ new
@@ -1,23 +1,28 @@
module Ffprober
module Ffmpeg
class Finder
- def self.path
- @path ||= begin
- path = ENV["PATH"].split(File::PATH_SEPARATOR).detect do |path_to_check|
- File.executable?(File.join(path_to_check, executable_name))
- end
+ SEARCH_PATHS = ENV["PATH"]
- path && File.expand_path(executable_name, path)
- end
+ def self.path
+ fail Ffprober::NoFfprobeFound if executable_path.nil?
+ @path ||= File.expand_path(executable_name, executable_path)
end
def self.executable_name
@executable_name ||= self.windows? ? "ffprobe.exe" : "ffprobe"
end
def self.windows?
!!(RUBY_PLATFORM =~ /(mingw|mswin)/)
+ end
+
+ def self.executable_path
+ @@executable_path ||= begin
+ SEARCH_PATHS.split(File::PATH_SEPARATOR).detect do |path_to_check|
+ File.executable?(File.join(path_to_check, executable_name))
+ end
+ end
end
end
end
end