Class: GitSme::AnalysisPresenter
- Inherits:
-
Object
- Object
- GitSme::AnalysisPresenter
- Defined in:
- lib/git_sme/analysis_presenter.rb
Instance Attribute Summary collapse
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#valid ⇒ Object
(also: #valid?)
readonly
Returns the value of attribute valid.
Instance Method Summary collapse
- #get_relevant_analyses(results_to_show = 10) ⇒ Object
-
#initialize(commit_analyzer, users = [], files = []) ⇒ AnalysisPresenter
constructor
A new instance of AnalysisPresenter.
Constructor Details
#initialize(commit_analyzer, users = [], files = []) ⇒ AnalysisPresenter
Returns a new instance of AnalysisPresenter.
7 8 9 10 11 12 13 14 15 |
# File 'lib/git_sme/analysis_presenter.rb', line 7 def initialize(commit_analyzer, users = [], files = []) @commit_analyzer = commit_analyzer @users = users @files = files @files = ['/'] unless @users.any? || @files.any? @valid = @commit_analyzer.valid? @error_message = @commit_analyzer. end |
Instance Attribute Details
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
3 4 5 |
# File 'lib/git_sme/analysis_presenter.rb', line 3 def @error_message end |
#valid ⇒ Object (readonly) Also known as: valid?
Returns the value of attribute valid.
3 4 5 |
# File 'lib/git_sme/analysis_presenter.rb', line 3 def valid @valid end |
Instance Method Details
#get_relevant_analyses(results_to_show = 10) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/git_sme/analysis_presenter.rb', line 17 def get_relevant_analyses(results_to_show = 10) @commit_analyzer.analyze unless @commit_analyzer.analyzed? users_to_match = @users.any? ? get_matching_keys(@commit_analyzer.analysis[:by_user].keys, @users) : [] files_to_match = @files.any? ? get_matching_keys(@commit_analyzer.analysis[:by_file].keys, @files) : [] presentable_data = [] if users_to_match.any? && files_to_match.any? users_to_match.each do |user| user_data = @commit_analyzer.analysis[:by_user][user].select { |k, v| files_to_match.include?(k) } presentable_data << presentable_file_or_user({ user => user_data }, user, results_to_show: results_to_show) end puts files_to_match.each do |file| user_data = @commit_analyzer.analysis[:by_file][file].select { |k, v| users_to_match.include?(k) } presentable_data << presentable_file_or_user({ file => user_data }, file) end elsif users_to_match.any? get_matching_keys(@commit_analyzer.analysis[:by_user].keys, users_to_match).each do |user| presentable_data << presentable_file_or_user(@commit_analyzer.analysis[:by_user], user) end elsif files_to_match.any? get_matching_keys(@commit_analyzer.analysis[:by_file].keys, files_to_match).each do |path| presentable_data << presentable_file_or_user(@commit_analyzer.analysis[:by_file], path) end end presentable_data.compact end |