Class: Dependabot::NpmAndYarn::FileParser::LockfileParser
- Inherits:
-
Object
- Object
- Dependabot::NpmAndYarn::FileParser::LockfileParser
- Defined in:
- lib/dependabot/npm_and_yarn/file_parser/lockfile_parser.rb
Instance Method Summary collapse
-
#initialize(dependency_files:) ⇒ LockfileParser
constructor
A new instance of LockfileParser.
- #lockfile_details(dependency_name:, requirement:, manifest_name:) ⇒ Object
- #parse ⇒ Object
Constructor Details
#initialize(dependency_files:) ⇒ LockfileParser
Returns a new instance of LockfileParser.
11 12 13 |
# File 'lib/dependabot/npm_and_yarn/file_parser/lockfile_parser.rb', line 11 def initialize(dependency_files:) @dependency_files = dependency_files end |
Instance Method Details
#lockfile_details(dependency_name:, requirement:, manifest_name:) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/dependabot/npm_and_yarn/file_parser/lockfile_parser.rb', line 23 def lockfile_details(dependency_name:, requirement:, manifest_name:) potential_lockfiles_for_manifest(manifest_name).each do |lockfile| details = if [*package_locks, *shrinkwraps].include?(lockfile) npm_lockfile_details(lockfile, dependency_name, manifest_name) else yarn_lockfile_details(lockfile, dependency_name, requirement, manifest_name) end return details if details end nil end |
#parse ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/dependabot/npm_and_yarn/file_parser/lockfile_parser.rb', line 15 def parse dependency_set = Dependabot::NpmAndYarn::FileParser::DependencySet.new dependency_set += yarn_lock_dependencies if yarn_locks.any? dependency_set += package_lock_dependencies if package_locks.any? dependency_set += shrinkwrap_dependencies if shrinkwraps.any? dependency_set.dependencies end |