Sha256: ec1d68ff1ca6e2d1d51d1679521174267cbcc6f6d56e0581779f86bac01fbd3b

Contents?: true

Size: 944 Bytes

Versions: 3

Compression:

Stored size: 944 Bytes

Contents

module Ffprober
  class FfprobeVersion
    @@version_regex = /^(ffprobe|avprobe|ffmpeg) version (\d+)\.?(\d+)\.?(\d+)*/
    @@nightly_regex = /^(ffprobe|avprobe|ffmpeg) version (N|git)-/

    MIN_VERSION = Gem::Version.new("0.9.0")
    MAX_VERSION = Gem::Version.new("2.0.1")

    def self.valid?
      self.new.valid?
    end

    def valid?
      nightly? || (MIN_VERSION <= version && version <= MAX_VERSION)
    end

    def parse_version
      @parse_version ||= begin
        _p = version_output.match(@@version_regex)
        if _p.nil?
          [0, 0, 0]
        else
          [_p[2].to_i, _p[3].to_i, _p[4].to_i]
        end
      end
    end

    def version
      @version ||= Gem::Version.new(parse_version.join("."))
    end

    def nightly?
      !!(version_output =~ @@nightly_regex)
    end

    def version_output
      return "" if Ffprober.path.nil?
      @version_output ||= `#{Ffprober.path} -version`
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ffprober-0.3.6 lib/ffprober/ffprobe_version.rb
ffprober-0.3.5 lib/ffprober/ffprobe_version.rb
ffprober-0.3.4 lib/ffprober/ffprobe_version.rb