Sha256: 1a008dfa810db23b74a6a7bc4068d88afb7b33b74dc0368bbfc7d9ea86849717

Contents?: true

Size: 1.1 KB

Versions: 43

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module LicenseFinder
  class PackageDelta
    STATUSES = %i[added removed unchanged].freeze

    def initialize(status, current_package, previous_package)
      @status = status
      @current_package = current_package
      @previous_package = previous_package
    end

    def name
      pick_package.name
    end

    def version
      pick_package.version
    end

    def aggregate_paths
      pick_package.aggregate_paths
    end

    attr_reader :status

    def licenses
      pick_package.licenses
    end

    def merged_package?
      pick_package.class == MergedPackage
    end

    def method_missing(_method_name)
      nil
    end

    def self.added(package)
      new(:added, package, nil)
    end

    def self.removed(package)
      new(:removed, nil, package)
    end

    def self.unchanged(current_package, previous_package)
      new(:unchanged, current_package, previous_package)
    end

    def <=>(other)
      STATUSES.index(status) <=> STATUSES.index(other.status)
    end

    private

    def pick_package
      @current_package || @previous_package
    end
  end
end

Version data entries

43 entries across 43 versions & 2 rubygems

Version Path
license_finder-6.15.0 lib/license_finder/package_delta.rb
gitlab-license_finder-6.14.2.1 lib/license_finder/package_delta.rb
license_finder-6.14.2 lib/license_finder/package_delta.rb
license_finder-6.14.1 lib/license_finder/package_delta.rb
license_finder-6.13.0 lib/license_finder/package_delta.rb
license_finder-6.12.2 lib/license_finder/package_delta.rb
license_finder-6.12.1 lib/license_finder/package_delta.rb
license_finder-6.12.0 lib/license_finder/package_delta.rb
license_finder-6.11.0 lib/license_finder/package_delta.rb
license_finder-6.10.1 lib/license_finder/package_delta.rb
license_finder-6.10.0 lib/license_finder/package_delta.rb
license_finder-6.9.0 lib/license_finder/package_delta.rb
license_finder-6.8.2 lib/license_finder/package_delta.rb
license_finder-6.8.1 lib/license_finder/package_delta.rb
license_finder-6.8.0 lib/license_finder/package_delta.rb
license_finder-6.7.0 lib/license_finder/package_delta.rb
license_finder-6.6.2 lib/license_finder/package_delta.rb
license_finder-6.6.1 lib/license_finder/package_delta.rb
license_finder-6.6.0 lib/license_finder/package_delta.rb
license_finder-6.5.0 lib/license_finder/package_delta.rb