Class: CodeChurnHeuristic
- Inherits:
-
Object
- Object
- CodeChurnHeuristic
- Defined in:
- lib/tipster/heuristics/code_churn_heuristic.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
- #apply(changed_files) ⇒ Object
- #churn_ratio(file) ⇒ Object
-
#initialize ⇒ CodeChurnHeuristic
constructor
A new instance of CodeChurnHeuristic.
- #pass? ⇒ Boolean
- #process(file) ⇒ Object
Constructor Details
#initialize ⇒ CodeChurnHeuristic
Returns a new instance of CodeChurnHeuristic.
9 10 11 12 |
# File 'lib/tipster/heuristics/code_churn_heuristic.rb', line 9 def initialize @files = Hash.new @passing_ratio = 0.5 end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
7 8 9 |
# File 'lib/tipster/heuristics/code_churn_heuristic.rb', line 7 def files @files end |
Instance Method Details
#apply(changed_files) ⇒ Object
14 15 16 |
# File 'lib/tipster/heuristics/code_churn_heuristic.rb', line 14 def apply(changed_files) changed_files.each { |file| process(file) } end |
#churn_ratio(file) ⇒ Object
22 23 24 25 26 |
# File 'lib/tipster/heuristics/code_churn_heuristic.rb', line 22 def churn_ratio(file) total_lines = FileInfo.new(file.file_name).line_count churned_lines = file.lines_modified churned_lines.to_f / total_lines.to_f end |
#pass? ⇒ Boolean
28 29 30 31 32 33 34 35 |
# File 'lib/tipster/heuristics/code_churn_heuristic.rb', line 28 def pass? @files.each do |key, value| if value > @passing_ratio return false end end true end |
#process(file) ⇒ Object
18 19 20 |
# File 'lib/tipster/heuristics/code_churn_heuristic.rb', line 18 def process(file) @files[file.file_name] = churn_ratio file end |