Class: Stefon::Surveyor::DeletedFiles

Inherits:
Base
  • Object
show all
Defined in:
lib/stefon/surveyor/deleted_files.rb

Overview

This class gives points to the predominant author of a file that a user deletes

Instance Attribute Summary

Attributes inherited from Base

#scores, #weight

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Stefon::Surveyor::Base

Instance Method Details

#callObject



8
9
10
# File 'lib/stefon/surveyor/deleted_files.rb', line 8

def call
  score_deleted_files.weight_scores(@weight)
end

#call_verboseObject



12
13
14
15
16
17
18
19
# File 'lib/stefon/surveyor/deleted_files.rb', line 12

def call_verbose
  array_version = score_deleted_files.to_a.map do |pair|
    desc = "Deleted #{pair.last} #{pair.last == 1 ? 'file' : 'files' }" +
      " written by: #{pair.first}"
    [pair.first, [desc]]
  end
  Surveyor::SurveyorStore[array_version]
end

#score_deleted_filesObject



21
22
23
24
25
26
27
28
# File 'lib/stefon/surveyor/deleted_files.rb', line 21

def score_deleted_files
  @grit.repo.status.deleted.keys.each do |filename|
    blame = @grit.blame_for(filename)
    top_author = @grit.file_valid_top_author(blame, filename)
    @scores[top_author] += 1
  end
  @scores
end