Class: OldeCodeFinder::Finder
- Inherits:
-
Object
- Object
- OldeCodeFinder::Finder
- Defined in:
- lib/olde_code_finder/finder.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#pctg ⇒ Object
Returns the value of attribute pctg.
Instance Method Summary collapse
- #check_by_author(author) ⇒ Object
- #check_by_date(date_string) ⇒ Object
-
#initialize(file, pctg) ⇒ Finder
constructor
A new instance of Finder.
Constructor Details
#initialize(file, pctg) ⇒ Finder
Returns a new instance of Finder.
8 9 10 11 |
# File 'lib/olde_code_finder/finder.rb', line 8 def initialize(file, pctg) @file = file @pctg = pctg end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
6 7 8 |
# File 'lib/olde_code_finder/finder.rb', line 6 def file @file end |
#pctg ⇒ Object
Returns the value of attribute pctg.
6 7 8 |
# File 'lib/olde_code_finder/finder.rb', line 6 def pctg @pctg end |
Instance Method Details
#check_by_author(author) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/olde_code_finder/finder.rb', line 13 def () return if binary? total_lines = git_blame_output.size = git_blame_output.grep(/#{}/).size actual_percent = calculate_percent(, total_lines) if actual_percent > pctg.to_f puts "More than #{pctg}% of #{file} was written by #{} (#{actual_percent}%)" end end |
#check_by_date(date_string) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/olde_code_finder/finder.rb', line 23 def check_by_date(date_string) return if binary? years_ago = date_string.match(/^(\d+)/)[1].to_i date_threshold = (Date.today - (years_ago*365)) total_lines = git_blame_output.size older_lines = git_blame_output.select {|line| Date.strptime(line.match(/.*(\d{4}-\d{2}-\d{2})/)[1]) < date_threshold }.size actual_percent = calculate_percent(older_lines, total_lines) if actual_percent > pctg.to_f puts "More than #{pctg}% of #{file} was written more than #{years_ago} years ago (#{actual_percent}%)" end end |