Class: Banzai::ReferenceParser::CommitParser

Inherits:
BaseParser
  • Object
show all
Defined in:
lib/banzai/reference_parser/commit_parser.rb

Instance Method Summary collapse

Methods inherited from BaseParser

#can?, #collection_cache_key, #collection_objects_for_ids, data_attribute, #find_projects_for_hash_keys, #gather_attributes_per_project, #gather_references, #grouped_objects_for_nodes, #initialize, #nodes_user_can_reference, #nodes_visible_to_user, #process, #project_for_node, #projects_for_nodes, #references_relation, #unique_attribute_values

Constructor Details

This class inherits a constructor from Banzai::ReferenceParser::BaseParser

Instance Method Details

#commit_ids_per_project(nodes) ⇒ Object


17
18
19
# File 'lib/banzai/reference_parser/commit_parser.rb', line 17

def commit_ids_per_project(nodes)
  gather_attributes_per_project(nodes, self.class.data_attribute)
end

#find_commits(project, ids) ⇒ Object


21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/banzai/reference_parser/commit_parser.rb', line 21

def find_commits(project, ids)
  commits = []

  return commits unless project.valid_repo?

  ids.each do |id|
    commit = project.commit(id)

    commits << commit if commit
  end

  commits
end

#referenced_by(nodes, options = {}) ⇒ Object


8
9
10
11
12
13
14
15
# File 'lib/banzai/reference_parser/commit_parser.rb', line 8

def referenced_by(nodes, options = {})
  commit_ids = commit_ids_per_project(nodes)
  projects = find_projects_for_hash_keys(commit_ids)

  projects.flat_map do |project|
    find_commits(project, commit_ids[project.id])
  end
end