Sha256: 68c48a54d7bd85f57b14ebd2c9b7868f6a33810ac4eeec69afcd20334d0ce5be

Contents?: true

Size: 1.23 KB

Versions: 12

Compression:

Stored size: 1.23 KB

Contents

module LicenseFinder
  class PackageDelta
    STATUSES = [:added, :removed, :unchanged]

    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 current_version
      @current_package ? @current_package.version : nil
    end

    def previous_version
      @previous_package ? @previous_package.version : nil
    end

    def subproject_paths
      pick_package.subproject_paths
    end

    def status
      @status
    end

    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 ? @current_package : @previous_package
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
license_finder-2.1.2 lib/license_finder/package_delta.rb
license_finder-2.1.1 lib/license_finder/package_delta.rb
license_finder-2.1.0 lib/license_finder/package_delta.rb
license_finder-2.1.0.rc9 lib/license_finder/package_delta.rb
license_finder-2.1.0.rc8 lib/license_finder/package_delta.rb
license_finder-2.1.0.rc7 lib/license_finder/package_delta.rb
license_finder-2.1.0.rc6 lib/license_finder/package_delta.rb
license_finder-2.1.0.rc5 lib/license_finder/package_delta.rb
license_finder-2.1.0.rc4 lib/license_finder/package_delta.rb
license_finder-2.1.0.rc3 lib/license_finder/package_delta.rb
license_finder-2.1.0.rc2 lib/license_finder/package_delta.rb
license_finder-2.1.0.rc1 lib/license_finder/package_delta.rb