Class: Dependabot::Python::FileParser::PepDependency

Inherits:
T::ImmutableStruct
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/python/file_parser/pep_dependency.rb

Class Method Summary collapse

Class Method Details

.from_helper_result(result) ⇒ Object



24
25
26
27
28
# File 'lib/dependabot/python/file_parser/pep_dependency.rb', line 24

def self.from_helper_result(result)
  PyprojectValueParser.array(result, "PEP dependency result").map do |value|
    from_object(value)
  end
end

.from_object(value) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/dependabot/python/file_parser/pep_dependency.rb', line 31

def self.from_object(value)
  hash = PyprojectValueParser.object_hash(value, "PEP dependency")
  new(
    name: PyprojectValueParser.string(hash["name"], "PEP dependency name"),
    version: PyprojectValueParser.optional_string(hash["version"], "PEP dependency version"),
    markers: PyprojectValueParser.optional_string(hash["markers"], "PEP dependency markers"),
    file: PyprojectValueParser.string(hash["file"], "PEP dependency file"),
    requirement: PyprojectValueParser.optional_string(hash["requirement"], "PEP dependency requirement"),
    source_requirement: PyprojectValueParser.optional_string(
      hash["source_requirement"],
      "PEP dependency source_requirement"
    ),
    extras: PyprojectValueParser.string_array(hash["extras"], "PEP dependency extras"),
    requirement_type: PyprojectValueParser.optional_string(
      hash["requirement_type"],
      "PEP dependency requirement_type"
    )
  )
end