summaryrefslogtreecommitdiff
path: root/lib/license/finder/ext/dependency.rb
blob: 48939bfe630947a2be8aa552b132ea0f7d6635d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

module LicenseFinder
  class Dependency < Package
    attr_accessor :detection_path, :package_manager

    def initialize(package_manager, name, version, options = {})
      @package_manager = package_manager
      @detection_path = options[:detection_path] || Pathname.pwd
      super(name, version, options)
    end

    def self.from(other, detection_path)
      new(
        other.package_manager,
        other.name,
        other.version,
        description: other.description,
        detection_path: detection_path,
        homepage: other.homepage,
        install_path: other.install_path,
        spec_licenses: other.license_names_from_spec,
        summary: other.summary
      )
    end
  end
end