Class: Dependabot::Swift::FileParser::PackageResolvedParser

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/swift/file_parser/package_resolved_parser.rb

Constant Summary collapse

SUPPORTED_VERSIONS =
T.let([1, 2, 3].freeze, T::Array[Integer])
PIN_KEYS =

Maps schema version to the JSON keys used for each pin field

T.let(
  {
    1 => { url: "repositoryURL", identity: "package", state: "state" },
    2 => { url: "location", identity: "identity", state: "state" },
    3 => { url: "location", identity: "identity", state: "state" }
  }.freeze,
  T::Hash[Integer, T::Hash[Symbol, String]]
)

Instance Method Summary collapse

Constructor Details

#initialize(resolved_file) ⇒ PackageResolvedParser

Returns a new instance of PackageResolvedParser.



31
32
33
# File 'lib/dependabot/swift/file_parser/package_resolved_parser.rb', line 31

def initialize(resolved_file)
  @resolved_file = resolved_file
end

Instance Method Details

#parseObject



36
37
38
39
40
41
42
# File 'lib/dependabot/swift/file_parser/package_resolved_parser.rb', line 36

def parse
  parsed = parse_json
  schema_version = detect_schema_version(parsed)
  pins = extract_pins(parsed, schema_version)

  pins.filter_map { |pin| build_dependency(pin, schema_version) }
end