Class: LicenseScout::DependencyManager::Mix

Inherits:
Base
  • Object
show all
Defined in:
lib/license_scout/dependency_manager/mix.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#directory

Instance Method Summary collapse

Constructor Details

#initialize(directory) ⇒ Mix

Returns a new instance of Mix.


26
27
28
29
30
# File 'lib/license_scout/dependency_manager/mix.rb', line 26

def initialize(directory)
  super(directory)

  @packaged_dependencies = {}
end

Instance Attribute Details

#packaged_dependenciesObject (readonly)

Returns the value of attribute packaged_dependencies.


24
25
26
# File 'lib/license_scout/dependency_manager/mix.rb', line 24

def packaged_dependencies
  @packaged_dependencies
end

Instance Method Details

#dependenciesObject


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/license_scout/dependency_manager/mix.rb', line 52

def dependencies
  parse_packaged_dependencies

  # Some dependencies are obtained via 'pkg' identifier of rebar. These
  # dependencies include their version in the rebar.lock file. Here we
  # parse the rebar.lock and remember all the versions we find.
  packaged_dependencies.map do |dep_name, dep_version|
    dep_path = Dir.glob(File.join(directory, "**", "deps", dep_name)).first

    dependency = new_dependency(dep_name, dep_version, dep_path)

    Array(hex_info(dep_name).dig("meta", "licenses")).each do |license|
      dependency.add_license(license, "https://hex.pm/api/packages/#{dep_name}")
    end

    dependency
  end.compact
end

#detected?Boolean

Returns:

  • (Boolean)

48
49
50
# File 'lib/license_scout/dependency_manager/mix.rb', line 48

def detected?
  File.exist?(mix_lock_path)
end

#install_commandObject


44
45
46
# File 'lib/license_scout/dependency_manager/mix.rb', line 44

def install_command
  "mix deps.get"
end

#nameObject


32
33
34
# File 'lib/license_scout/dependency_manager/mix.rb', line 32

def name
  "elixir_mix"
end

#signatureObject


40
41
42
# File 'lib/license_scout/dependency_manager/mix.rb', line 40

def signature
  "mix.lock file"
end

#typeObject


36
37
38
# File 'lib/license_scout/dependency_manager/mix.rb', line 36

def type
  "elixir"
end