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.16 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-2.0.15 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-2.0.14 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
vcr-6.3.1 lib/vcr/util/version_checker.rb
vcr-6.3.0 lib/vcr/util/version_checker.rb
cloudsmith-api-2.0.13 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-2.0.12 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-2.0.11 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-2.0.10 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-2.0.9 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-2.0.8 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-2.0.7 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
vcr-6.2.0 lib/vcr/util/version_checker.rb
cloudsmith-api-2.0.6 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-2.0.5 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-2.0.4 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-2.0.3 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
cloudsmith-api-2.0.2 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/vcr-6.1.0/lib/vcr/util/version_checker.rb
cloudsmith-api-2.0.1 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/util/version_checker.rb