Class: Autoflog

Inherits:
Auto show all
Defined in:
lib/autoflog.rb

Direct Known Subclasses

Rails

Defined Under Namespace

Classes: Rails

Constant Summary

Constants inherited from Auto

Auto::SEP, Auto::WINDOZE

Instance Attribute Summary collapse

Attributes inherited from Auto

#file_masks, #modified, #output, #sleep, #wants_to_quit, #working_dirs

Instance Method Summary collapse

Methods inherited from Auto

add_discovery, add_hook, autodiscover, #find_files, #hook, #last_modified_time, #method_missing, #old_method_missing, #reset, run, #run, #run_metric, #wait_for_changes

Constructor Details

#initialize(*args) ⇒ Autoflog

Returns a new instance of Autoflog.



6
7
8
9
10
# File 'lib/autoflog.rb', line 6

def initialize(*args)
  super(*args)
  
  @coverage = @previous_score = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Auto

Instance Attribute Details

#previous_scoreObject

Returns the value of attribute previous_score.



4
5
6
# File 'lib/autoflog.rb', line 4

def previous_score
  @previous_score
end

#scoreObject

Returns the value of attribute score.



4
5
6
# File 'lib/autoflog.rb', line 4

def score
  @score
end

Instance Method Details

#flog_results(results) ⇒ Object



35
36
37
# File 'lib/autoflog.rb', line 35

def flog_results(results)
  results.scan(/Total score = \d*\.?\d*$/)
end

#handle_results(results) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/autoflog.rb', line 16

def handle_results(results)
  flog_result = flog_results(results).first
  return if flog_result.nil?
  
  @score = flog_result.scan(/\d*\.?\d*$/).first.to_f
  
  hook :flogged
  
  if @previous_score
    if @previous_score < @score
      hook :increased
    elsif @previous_score > @score
      hook :decreased
    end
  end
  
  @previous_score = @score
end

#make_cmdObject



12
13
14
# File 'lib/autoflog.rb', line 12

def make_cmd
  "#{flog} #{@working_dirs.join(' ')}"
end