Class: AnalDiffist::TextBasedDiffist
- Inherits:
-
Object
- Object
- AnalDiffist::TextBasedDiffist
- Defined in:
- lib/analdiffist/text_based_diffist.rb
Instance Method Summary collapse
- #clean_up_flog(flog_result) ⇒ Object
- #diff(f1, f2) ⇒ Object
- #do_analytics(ref_name) ⇒ Object
- #get_file_name(ref_name) ⇒ Object
-
#initialize ⇒ TextBasedDiffist
constructor
A new instance of TextBasedDiffist.
- #report_results ⇒ Object
Constructor Details
#initialize ⇒ TextBasedDiffist
Returns a new instance of TextBasedDiffist.
4 5 6 7 |
# File 'lib/analdiffist/text_based_diffist.rb', line 4 def initialize @targets = AnalDiffist::TargetFinder.new @files = [] end |
Instance Method Details
#clean_up_flog(flog_result) ⇒ Object
39 40 41 |
# File 'lib/analdiffist/text_based_diffist.rb', line 39 def clean_up_flog(flog_result) flog_result.gsub(/:[0-9]+$/, '') end |
#diff(f1, f2) ⇒ Object
42 43 44 |
# File 'lib/analdiffist/text_based_diffist.rb', line 42 def diff f1, f2 puts `git diff --color=always -U0 -- '#{f1}' '#{f2}'` end |
#do_analytics(ref_name) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/analdiffist/text_based_diffist.rb', line 13 def do_analytics ref_name dest_filename = get_file_name ref_name puts puts 'collecting reek' reek_result = `reek -q #{@targets}` puts 'collecting flog' flog_result = `flog -g #{@targets}` File.open(dest_filename, 'w') do |f| puts 'writing analytics to ' + dest_filename f.write"--- Analytics for #{ref_name} ---\n\n" f.write"\n\n--- FLOG ---\n\n" f.write clean_up_flog(flog_result) f.write"\n\n--- REEK ---\n\n" f.write reek_result end @files << dest_filename end |
#get_file_name(ref_name) ⇒ Object
35 36 37 |
# File 'lib/analdiffist/text_based_diffist.rb', line 35 def get_file_name ref_name File.join(Dir.tmpdir, "#{ref_name.gsub('/', '_')}-analytics.txt") end |
#report_results ⇒ Object
8 9 10 11 |
# File 'lib/analdiffist/text_based_diffist.rb', line 8 def report_results puts 'results:' diff @files[0], @files[1] end |