Class: Dependabot::GithubActions::FileUpdater::WorkflowUpdater::SourceUpdater
- Inherits:
-
Object
- Object
- Dependabot::GithubActions::FileUpdater::WorkflowUpdater::SourceUpdater
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/github_actions/file_updater/workflow_updater/source_updater.rb
Instance Method Summary collapse
-
#initialize(workflow_file:, updates:, commenter:, comment_finder:) ⇒ SourceUpdater
constructor
A new instance of SourceUpdater.
- #updated_content ⇒ Object
Constructor Details
#initialize(workflow_file:, updates:, commenter:, comment_finder:) ⇒ SourceUpdater
Returns a new instance of SourceUpdater.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/dependabot/github_actions/file_updater/workflow_updater/source_updater.rb', line 21 def initialize(workflow_file:, updates:, commenter:, comment_finder:) @workflow_file = workflow_file @updates = updates @commenter = commenter @metadata_builder = T.let(WorkflowFile::MetadataBuilder.new(workflow_file), WorkflowFile::MetadataBuilder) @comment_locator = T.let( SourceCommentLocator.new( workflow_file: workflow_file, comment_finder: comment_finder, metadata_builder: @metadata_builder ), SourceCommentLocator ) @comment_updater = T.let( SourceCommentUpdater.new( workflow_file: workflow_file, commenter: commenter, metadata_builder: @metadata_builder, comment_locator: @comment_locator ), SourceCommentUpdater ) end |
Instance Method Details
#updated_content ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/dependabot/github_actions/file_updater/workflow_updater/source_updater.rb', line 46 def updated_content return workflow_file.content if updates.empty? sequence_updates = grouped_flow_sequence_updates edits = sequence_updates.flat_map do |sequence, grouped_updates| (sequence, grouped_updates) end updates.each do |update| sequence = (sequence_updates, update) source_node = T.must(update.declaration.source_node) = sequence_updates.keys.any? do || node_within?(source_node, ) end edits << source_value_edit(update) unless next if sequence edits.concat(comment_updater.edits_for(update)) end apply_content_edits(edits) end |