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

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/github_actions/file_updater/workflow_updater/source_comment_locator.rb

Defined Under Namespace

Classes: LocatedComment

Instance Method Summary collapse

Constructor Details

#initialize(workflow_file:, comment_finder:, metadata_builder:) ⇒ SourceCommentLocator

Returns a new instance of SourceCommentLocator.



27
28
29
30
31
# File 'lib/dependabot/github_actions/file_updater/workflow_updater/source_comment_locator.rb', line 27

def initialize(workflow_file:, comment_finder:, metadata_builder:)
  @workflow_file = workflow_file
  @comment_finder = comment_finder
  @metadata_builder = 
end

Instance Method Details

#find_line(source) ⇒ Object



57
58
59
# File 'lib/dependabot/github_actions/file_updater/workflow_updater/source_comment_locator.rb', line 57

def find_line(source)
  comment_finder.find_line(source)
end

#for_declaration(declaration) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/dependabot/github_actions/file_updater/workflow_updater/source_comment_locator.rb', line 34

def for_declaration(declaration)
  anchor = .comment_anchor(declaration)
  return unless anchor

  locate(
    line: anchor.first,
    column: anchor.last,
    owner_sequence: declaration.steps_sequence,
    block_scalar: block_scalar?(declaration.source_node)
  )
end

#for_sequence(sequence) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/dependabot/github_actions/file_updater/workflow_updater/source_comment_locator.rb', line 47

def for_sequence(sequence)
  locate(
    line: workflow_file.node_end_line(sequence),
    column: workflow_file.node_end_column(sequence),
    owner_sequence: sequence,
    block_scalar: false
  )
end