Class: Dependabot::MetadataFinders::Base::ReleaseFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/metadata_finders/base/release_finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source:, dependency:, credentials:) ⇒ ReleaseFinder

Returns a new instance of ReleaseFinder.



14
15
16
17
18
# File 'lib/dependabot/metadata_finders/base/release_finder.rb', line 14

def initialize(source:, dependency:, credentials:)
  @source = source
  @dependency = dependency
  @credentials = credentials
end

Instance Attribute Details

#credentialsObject (readonly)

Returns the value of attribute credentials.



12
13
14
# File 'lib/dependabot/metadata_finders/base/release_finder.rb', line 12

def credentials
  @credentials
end

#dependencyObject (readonly)

Returns the value of attribute dependency.



12
13
14
# File 'lib/dependabot/metadata_finders/base/release_finder.rb', line 12

def dependency
  @dependency
end

#sourceObject (readonly)

Returns the value of attribute source.



12
13
14
# File 'lib/dependabot/metadata_finders/base/release_finder.rb', line 12

def source
  @source
end

Instance Method Details

#releases_textObject



32
33
34
35
36
37
# File 'lib/dependabot/metadata_finders/base/release_finder.rb', line 32

def releases_text
  return unless relevant_releases.any?
  return if relevant_releases.all? { |r| r.body.nil? || r.body == "" }

  relevant_releases.map { |r| serialize_release(r) }.join("\n\n")
end

#releases_urlObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/dependabot/metadata_finders/base/release_finder.rb', line 20

def releases_url
  return unless source

  case source.provider
  when "github" then "#{source.url}/releases"
  when "gitlab" then "#{source.url}/tags"
  when "bitbucket" then nil
  when "azure" then "#{source.url}/tags"
  else raise "Unexpected repo provider '#{source.provider}'"
  end
end