Method: Licensed::Dependency#initialize
- Defined in:
- lib/licensed/dependency.rb
#initialize(name:, version:, path:, search_root: nil, metadata: {}, errors: []) ⇒ Dependency
Create a new project dependency
name - unique dependency name version - dependency version path - absolute file path to the dependency, to find license contents search_root - (optional) the root location to search for dependency license contents metadata - (optional) additional dependency data to cache errors - (optional) errors encountered when evaluating dependency
Returns a new dependency object. Dependency metadata and license contents are available if no errors are set on the dependency.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/licensed/dependency.rb', line 24 def initialize(name:, version:, path:, search_root: nil, metadata: {}, errors: []) @name = name @version = version @metadata = @errors = errors path = path.to_s @path = path # enforcing absolute paths makes life much easier when determining # an absolute file path in #notices if File.exist?(path) && !Pathname.new(path).absolute? # this is an internal error related to source implementation and # should be raised, not stored to be handled by reporters raise ArgumentError, "dependency path #{path} must be absolute" end super(path, search_root: search_root, detect_readme: true, detect_packages: true) end |