Sha256: 384936cb0fa4cf6f8a60d060f4144a66bb3d643eb4e0211dd9680b3a46d777d2
Contents?: true
Size: 1.81 KB
Versions: 1021
Compression:
Stored size: 1.81 KB
Contents
# File parsers File parsers take a set of dependency files and extract a list of dependencies for the project. There is a `Dependabot::FileParsers` class for each language Dependabot supports. ## Public API Each `Dependabot::FileParsers` class implements the following methods: | Method | Description | |---------------------|-----------------------------------------------------------------------------------------------| | `#parse` | Returns an array of `Dependabot::Dependency` instances, representing the dependencies for the project. Each `Dependabot::Dependency` has a `name`, `version` and a `requirements` array | An integration might look as follows: ```ruby require 'dependabot/file_parsers' files = fetcher.files parser_class = Dependabot::FileParsers::Ruby::Bundler source = Dependabot::Source.new(provider: 'github', repo: "gocardless/business") parser = parser_class.new(dependency_files: files, source: source) dependencies = parser.parse puts "Found the following dependencies: #{dependencies.map(&:name)}" ``` ## Writing a file parser for a new language All new file parsers should inherit from `Dependabot::FileParsers::Base` and implement the following methods: | Method | Description | |-------------------------|-----------------------------------------------------------------------------------------------| | `#parse` | See Public API section. | | `#check_required_files` | Raise a runtime error unless an appropriate set of files is provided. Private. | To ensure the above are implemented, you should include `it_behaves_like "a dependency file parser"` in your specs for the new file parser.
Version data entries
1,021 entries across 1,021 versions & 2 rubygems