Sha256: 9fd640d30b52b5c10c5419a651cb1a2a6fcad7d419a62067909b7e2471e5f2e9

Contents?: true

Size: 738 Bytes

Versions: 3

Compression:

Stored size: 738 Bytes

Contents

# frozen_string_literal: true

module Ffprober
  module Ffmpeg
    class Finder
      SEARCH_PATHS = ENV['PATH']

      def self.path
        raise Ffprober::NoFfprobeFound if executable_path.nil?
        @path ||= File.expand_path(executable_name, executable_path)
      end

      def self.executable_name
        @executable_name ||= windows? ? 'ffprobe.exe' : 'ffprobe'
      end

      def self.windows?
        !(RUBY_PLATFORM =~ /(mingw|mswin)/).nil?
      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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ffprober-0.5.5 lib/ffprober/ffmpeg/finder.rb
ffprober-0.5.3 lib/ffprober/ffmpeg/finder.rb
ffprober-0.5.2 lib/ffprober/ffmpeg/finder.rb