Class: Dependabot::Composer::FileFetcher::PathDependencyBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/composer/file_fetcher/path_dependency_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(path:, directory:, lockfile:) ⇒ PathDependencyBuilder

Returns a new instance of PathDependencyBuilder.



12
13
14
15
16
# File 'lib/dependabot/composer/file_fetcher/path_dependency_builder.rb', line 12

def initialize(path:, directory:, lockfile:)
  @path = path
  @directory = directory
  @lockfile = lockfile
end

Instance Method Details

#dependency_fileObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dependabot/composer/file_fetcher/path_dependency_builder.rb', line 18

def dependency_file
  filename = File.join(path, "composer.json")

  # Current we just return `nil` if a path dependency can't be built.
  # In future we may wish to change that to a raise. (We'll get errors
  # in the UpdateChecker or FileUpdater if we fail to build files.)
  built_content = build_path_dep_content
  return unless built_content

  DependencyFile.new(
    name: Pathname.new(filename).cleanpath.to_path,
    content: built_content,
    directory: directory,
    support_file: true
  )
end