Class: Dependabot::GithubActions::FileUpdater::WorkflowUpdater

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/github_actions/file_updater/workflow_updater.rb,
lib/dependabot/github_actions/file_updater/workflow_updater/source_updater.rb,
lib/dependabot/github_actions/file_updater/workflow_updater/version_commenter.rb,
lib/dependabot/github_actions/file_updater/workflow_updater/yaml_comment_finder.rb,
lib/dependabot/github_actions/file_updater/workflow_updater/flow_sequence_comments.rb,
lib/dependabot/github_actions/file_updater/workflow_updater/source_comment_locator.rb,
lib/dependabot/github_actions/file_updater/workflow_updater/source_comment_updater.rb

Defined Under Namespace

Classes: ContentEdit, FlowSequenceComments, SourceCommentLocator, SourceCommentUpdater, SourceUpdate, SourceUpdater, VersionCommenter, YamlCommentFinder

Instance Method Summary collapse

Constructor Details

#initialize(file:, dependency:, commenter:) ⇒ WorkflowUpdater

Returns a new instance of WorkflowUpdater.



40
41
42
43
44
45
# File 'lib/dependabot/github_actions/file_updater/workflow_updater.rb', line 40

def initialize(file:, dependency:, commenter:)
  @file = file
  @dependency = dependency
  @commenter = commenter
  @comment_finder = T.let(YamlCommentFinder.new, YamlCommentFinder)
end

Instance Method Details

#updated_contentObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/dependabot/github_actions/file_updater/workflow_updater.rb', line 48

def updated_content
  workflow_file = WorkflowFile.new(T.must(file.content))
  source_updates, fallback_pairs = requirement_updates(workflow_file)

  content = SourceUpdater.new(
    workflow_file: workflow_file,
    updates: source_updates,
    commenter: commenter,
    comment_finder: comment_finder
  ).updated_content
  fallback_pairs.each do |new_req, old_req|
    content = apply_text_update(content, new_req, old_req)
  end
  content
end