Sha256: dc57d593a012ed5e80315916e77410e6ba757b33303185c57daf570226d6d363

Contents?: true

Size: 908 Bytes

Versions: 4

Compression:

Stored size: 908 Bytes

Contents

module Ffprober
  module Ffmpeg
    class Version
      VERSION_REGEX = /^(ffprobe|avprobe|ffmpeg) version (\d+)\.?(\d+)\.?(\d+)*/
      NIGHTLY_REGEX = /^(ffprobe|avprobe|ffmpeg) version (N|git)-/

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

      def nightly?
        !!(ffprobe_version_output =~ NIGHTLY_REGEX)
      end

      private

      def parse_version
        @parse_version ||= begin
          ffprobe_version_output.match(VERSION_REGEX) do |match|
            [match[2].to_i, match[3].to_i, match[4].to_i]
          end || [0, 0, 0]
        end
      end

      def ffprobe_version_output
        @ffprobe_version_output ||= ffprobe_finder.path.nil? ? "" : `#{ffprobe_finder.path} -version`
      end

      def ffprobe_finder
        Ffprober::Ffmpeg::Finder
      end

      def to_s
        parse_version.join(".")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ffprober-0.4.6 lib/ffprober/ffmpeg/version.rb
ffprober-0.4.5 lib/ffprober/ffmpeg/version.rb
ffprober-0.4.4 lib/ffprober/ffmpeg/version.rb
ffprober-0.4.3 lib/ffprober/ffmpeg/version.rb