librariesio / bibliothecary

:notebook_with_decorative_cover: Libraries.io Package Manager Manifest Parsers
https://libraries.io/rubygems/bibliothecary
GNU Affero General Public License v3.0
89 stars 36 forks source link

[10.0.0 branch] Return a new Dependency class instead of raw Hash objects, from analyses' :dependencies result. #596

Closed tiegz closed 2 months ago

tiegz commented 2 months ago

This defines a new Bibliothecary::Dependency class, and proposes to return instances of that object from parsed manifests, instead of Hashes.

Current behavior (<10.0)

Bibliothecary returns a list of dependency Hashes in its analyses, e.g.:

analysis = Bibliothecary.analyse_file("package.json", "package.json")
analysis[:dependencies]
=> [{ name: "jquery", requirement: ">= 1.9.1", type: "runtime" }]

New behavior (>= 10.0)

analysis = Bibliothecary.analyse_file("package.json", "package.json")
analysis[:dependencies]
=> [Bibliothecary::Dependency.new(name: "jquery", requirement: ">= 1.9.1", type: "runtime")],

Benefits

Having a dedicated Dependency class will:

Downsides

TODO