Class: Dependabot::Python::FileParser::PoetryLock
- Inherits:
-
Object
- Object
- Dependabot::Python::FileParser::PoetryLock
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/python/file_parser/poetry_lock.rb
Defined Under Namespace
Classes: Package
Instance Attribute Summary collapse
-
#packages ⇒ Object
readonly
Returns the value of attribute packages.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(packages) ⇒ PoetryLock
constructor
A new instance of PoetryLock.
- #version_for(name, &_normalizer) ⇒ Object
Constructor Details
#initialize(packages) ⇒ PoetryLock
Returns a new instance of PoetryLock.
59 60 61 |
# File 'lib/dependabot/python/file_parser/poetry_lock.rb', line 59 def initialize(packages) @packages = packages end |
Instance Attribute Details
#packages ⇒ Object (readonly)
Returns the value of attribute packages.
56 57 58 |
# File 'lib/dependabot/python/file_parser/poetry_lock.rb', line 56 def packages @packages end |
Class Method Details
.from_file(file) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/dependabot/python/file_parser/poetry_lock.rb', line 64 def self.from_file(file) parsed = T.cast(TomlRB.parse(T.must(file.content)), Object) document = PyprojectValueParser.object_hash(parsed, "poetry.lock") value = document["package"] packages = if value.nil? [] else PyprojectValueParser.array(value, "poetry.lock package").map do |package| Package.from_object(package) end end new(packages) rescue TomlRB::ParseError, TomlRB::ValueOverwriteError raise Dependabot::DependencyFileNotParseable, file.path end |
Instance Method Details
#version_for(name, &_normalizer) ⇒ Object
88 89 90 91 |
# File 'lib/dependabot/python/file_parser/poetry_lock.rb', line 88 def version_for(name, &_normalizer) normalized_name = yield(name) packages.find { |package| yield(package.name) == normalized_name }&.version end |