Class: Dependabot::Hex::FileParser

Inherits:
FileParsers::Base
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/hex/file_parser.rb

Instance Method Summary collapse

Instance Method Details

#parseObject

Raises:

  • (::Dependabot::UnexpectedExternalCode)


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/dependabot/hex/file_parser.rb', line 21

def parse
  # TODO: git sourced dependency's mixfiles are evaluated. Provide guards before removing this.
  raise ::Dependabot::UnexpectedExternalCode if @reject_external_code

  dependency_set = DependencySet.new

  dependency_details.each do |dep|
    git_dependency = dep["source"]&.fetch("type") == "git"

    dependency_set <<
      Dependency.new(
        name: dep["name"],
        version: git_dependency ? dep["checksum"] : dep["version"],
        requirements: [{
          requirement: dep["requirement"],
          groups: dep["groups"],
          source: dep["source"] && symbolize_keys(dep["source"]),
          file: dep["from"]
        }],
        package_manager: "hex"
      )
  end

  dependency_set.dependencies.sort_by(&:name)
end