Class: Gitlab::Blame
- Inherits:
-
Object
- Object
- Gitlab::Blame
- Defined in:
- lib/gitlab/blame.rb
Instance Attribute Summary collapse
-
#blob ⇒ Object
Returns the value of attribute blob.
-
#commit ⇒ Object
Returns the value of attribute commit.
Instance Method Summary collapse
- #groups(highlight: true) ⇒ Object
-
#initialize(blob, commit) ⇒ Blame
constructor
A new instance of Blame.
Constructor Details
#initialize(blob, commit) ⇒ Blame
Returns a new instance of Blame.
7 8 9 10 |
# File 'lib/gitlab/blame.rb', line 7 def initialize(blob, commit) @blob = blob @commit = commit end |
Instance Attribute Details
#blob ⇒ Object
Returns the value of attribute blob
5 6 7 |
# File 'lib/gitlab/blame.rb', line 5 def blob @blob end |
#commit ⇒ Object
Returns the value of attribute commit
5 6 7 |
# File 'lib/gitlab/blame.rb', line 5 def commit @commit end |
Instance Method Details
#groups(highlight: true) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gitlab/blame.rb', line 12 def groups(highlight: true) prev_sha = nil groups = [] current_group = nil i = 0 blame.each do |commit, line| commit = Commit.new(commit, project) commit. # preload author sha = commit.sha if prev_sha != sha groups << current_group if current_group current_group = { commit: commit, lines: [] } end line = highlighted_lines[i].html_safe if highlight current_group[:lines] << line prev_sha = sha i += 1 end groups << current_group if current_group groups end |