Sha256: 044ec0fa561099059bb4043623530e1227106a05aa4ceefde3ed113fb1f635a7

Contents?: true

Size: 900 Bytes

Versions: 2

Compression:

Stored size: 900 Bytes

Contents

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

    MIN_VERSION = Gem::Version.new("0.9.0")
    MAX_VERSION = Gem::Version.new("1.2.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
      @version_output ||= `#{Ffprober.path} -version`
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ffprober-0.3.1 lib/ffprober/ffprobe_version.rb
ffprober-0.3.0 lib/ffprober/ffprobe_version.rb