Sha256: 91a50a88a9fb61d7fa5bb16c4bfcc0ffc94d37e4ead1a698932b027a7090ed03

Contents?: true

Size: 1.13 KB

Versions: 72

Compression:

Stored size: 1.13 KB

Contents

module VCR
  # @private
  class VersionChecker
    def initialize(library_name, library_version, min_version)
      @library_name    = library_name
      @library_version = library_version
      @min_version     = min_version

      @major,     @minor,     @patch     = parse_version(library_version)
      @min_major, @min_minor, @min_patch = parse_version(min_version)
    end

    def check_version!
      raise_too_low_error if too_low?
    end

  private

    def too_low?
      compare_version == :too_low
    end

    def raise_too_low_error
      raise Errors::LibraryVersionTooLowError,
        "You are using #{@library_name} #{@library_version}. " +
        "VCR requires version #{version_requirement}."
    end

    def compare_version
      case
        when @major < @min_major then :too_low
        when @major > @min_major then :ok
        when @minor < @min_minor then :too_low
        when @minor > @min_minor then :ok
        when @patch < @min_patch then :too_low
      end
    end

    def version_requirement
      ">= #{@min_version}"
    end

    def parse_version(version)
      version.split('.').map { |v| v.to_i }
    end
  end
end

Version data entries

72 entries across 72 versions & 9 rubygems

Version Path
cloudsmith-api-2.0.0 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-1.142.3 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-1.120.3 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-1.61.3 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-1.42.3 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
vcr-6.1.0 lib/vcr/util/version_checker.rb
cloudsmith-api-1.33.7 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-1.30.0 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-0.57.1 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-0.54.15 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-0.53.79 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-0.53.17 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-0.53.3 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-0.53.1 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-0.52.121 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-0.52.92 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-0.52.79 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-0.52.5 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-0.52.0 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-0.51.93 vendor/bundle/ruby/2.3.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb