Class: Dependabot::MetadataFinders::Base::ChangelogFinder

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/metadata_finders/base/changelog_finder.rb

Overview

rubocop:disable Metrics/ClassLength

Constant Summary collapse

CHANGELOG_NAMES =

Earlier entries are preferred

T.let(
  %w(changelog news changes history release whatsnew releases).freeze,
  T::Array[String]
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source:, dependency:, credentials:, suggested_changelog_url: nil) ⇒ ChangelogFinder

Returns a new instance of ChangelogFinder.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/dependabot/metadata_finders/base/changelog_finder.rb', line 51

def initialize(
  source:,
  dependency:,
  credentials:,
  suggested_changelog_url: nil
)
  @source = source
  @dependency = dependency
  @credentials = credentials
  @suggested_changelog_url = suggested_changelog_url
  # strip fragment from URL, if present
  @suggested_changelog_url = @suggested_changelog_url&.split("#")&.first

  @new_version = T.let(nil, T.nilable(String))
  @changelog_from_suggested_url = T.let(nil, T.untyped)
end

Instance Attribute Details

#credentialsObject (readonly)

Returns the value of attribute credentials.



37
38
39
# File 'lib/dependabot/metadata_finders/base/changelog_finder.rb', line 37

def credentials
  @credentials
end

#dependencyObject (readonly)

Returns the value of attribute dependency.



34
35
36
# File 'lib/dependabot/metadata_finders/base/changelog_finder.rb', line 34

def dependency
  @dependency
end

#sourceObject (readonly)

Returns the value of attribute source.



31
32
33
# File 'lib/dependabot/metadata_finders/base/changelog_finder.rb', line 31

def source
  @source
end

#suggested_changelog_urlObject (readonly)

Returns the value of attribute suggested_changelog_url.



40
41
42
# File 'lib/dependabot/metadata_finders/base/changelog_finder.rb', line 40

def suggested_changelog_url
  @suggested_changelog_url
end

Instance Method Details

#changelog_textObject



74
75
76
77
78
79
80
81
# File 'lib/dependabot/metadata_finders/base/changelog_finder.rb', line 74

def changelog_text
  return unless full_changelog_text

  ChangelogPruner.new(
    dependency: dependency,
    changelog_text: full_changelog_text
  ).pruned_text
end

#changelog_urlObject



69
70
71
# File 'lib/dependabot/metadata_finders/base/changelog_finder.rb', line 69

def changelog_url
  changelog&.html_url
end

#upgrade_guide_textObject



89
90
91
92
93
94
95
96
# File 'lib/dependabot/metadata_finders/base/changelog_finder.rb', line 89

def upgrade_guide_text
  return unless upgrade_guide

  @upgrade_guide_text ||= T.let(
    fetch_file_text(upgrade_guide),
    T.nilable(String)
  )
end

#upgrade_guide_urlObject



84
85
86
# File 'lib/dependabot/metadata_finders/base/changelog_finder.rb', line 84

def upgrade_guide_url
  upgrade_guide&.html_url
end