Class: LicenseFinder::PackageDelta

Inherits:
Object
  • Object
show all
Defined in:
lib/license_finder/package_delta.rb

Constant Summary collapse

STATUSES =
%i[added removed unchanged].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, current_package, previous_package) ⇒ PackageDelta

Returns a new instance of PackageDelta.



7
8
9
10
11
# File 'lib/license_finder/package_delta.rb', line 7

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(_method_name) ⇒ Object



35
36
37
# File 'lib/license_finder/package_delta.rb', line 35

def method_missing(_method_name)
  nil
end

Instance Attribute Details

#statusObject (readonly)

Returns the value of attribute status.



25
26
27
# File 'lib/license_finder/package_delta.rb', line 25

def status
  @status
end

Class Method Details

.added(package) ⇒ Object



39
40
41
# File 'lib/license_finder/package_delta.rb', line 39

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

.removed(package) ⇒ Object



43
44
45
# File 'lib/license_finder/package_delta.rb', line 43

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

.unchanged(current_package, previous_package) ⇒ Object



47
48
49
# File 'lib/license_finder/package_delta.rb', line 47

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

Instance Method Details

#<=>(other) ⇒ Object



51
52
53
# File 'lib/license_finder/package_delta.rb', line 51

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

#aggregate_pathsObject



21
22
23
# File 'lib/license_finder/package_delta.rb', line 21

def aggregate_paths
  pick_package.aggregate_paths
end

#licensesObject



27
28
29
# File 'lib/license_finder/package_delta.rb', line 27

def licenses
  pick_package.licenses
end

#merged_package?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/license_finder/package_delta.rb', line 31

def merged_package?
  pick_package.instance_of?(MergedPackage)
end

#nameObject



13
14
15
# File 'lib/license_finder/package_delta.rb', line 13

def name
  pick_package.name
end

#versionObject



17
18
19
# File 'lib/license_finder/package_delta.rb', line 17

def version
  pick_package.version
end