Class: CodeRatioPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/tipster/presenters/code_ratio_presenter.rb

Instance Method Summary collapse

Constructor Details

#initialize(id = current_commit_id) ⇒ CodeRatioPresenter

Returns a new instance of CodeRatioPresenter.



9
10
11
# File 'lib/tipster/presenters/code_ratio_presenter.rb', line 9

def initialize(id = current_commit_id)
	@commit_id = id
end

Instance Method Details

#change_listObject



27
28
29
# File 'lib/tipster/presenters/code_ratio_presenter.rb', line 27

def change_list
	CommitHistoryContext.new(git_output).change_list
end

#current_commit_idObject



19
20
21
# File 'lib/tipster/presenters/code_ratio_presenter.rb', line 19

def current_commit_id
	LatestCommit.new.id
end

#git_outputObject



23
24
25
# File 'lib/tipster/presenters/code_ratio_presenter.rb', line 23

def git_output
	FilesChanged.new(@commit_id).list
end

#pass?Boolean

Returns:

  • (Boolean)


13
14
15
16
17
# File 'lib/tipster/presenters/code_ratio_presenter.rb', line 13

def pass?
  code_ratio_heuristic = CodeRatioHeuristic.new
  code_ratio_heuristic.apply(change_list)
  code_ratio_heuristic.pass?
end

#statusObject



31
32
33
34
35
36
37
38
# File 'lib/tipster/presenters/code_ratio_presenter.rb', line 31

def status
  safe = pass?
	result = 'Warning: Your commit is risky due to a lack of tests.  Consider adding more tests and amending your commit.'
  if safe
    result = 'Your commit has adequate tests and will not be flagged as risky.'
  end
HeuristicStatus.new(safe ,result)
end