C0 code coverage information generated on Wed Mar 15 10:52:01 MST 2006


Marked code looks like this.
This line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this.
Finally, here's a line marked as not executed.
Name Total lines Lines of code Total coverage Code coverage
./test/../lib/hostname.rb 106 106
98.1% 
100.0% 
  1 class HostName
  2   def initialize(ip, hostname, ref_code)
  3     @hostname = hostname.split('-')
  4     @ip = ip.split('.')
  5 
  6     set_ref_code(ref_code)
  7     set_name
  8     set_power_code
  9   end
 10 
 11   def verify_name
 12     # reference_check and ordinal_check are too similar, I need to
 13     # see how to break this with the failover reference, or change
 14     # the way I'm doing ordinal and ref code assignments in the
 15     # initializer
 16     reference_check or return false
 17     power_check or return false
 18     true
 19   end
 20 
 21   def hostname
 22     @hostname.join('-')
 23   end
 24 
 25   def ip
 26     @ip.join('.')
 27   end
 28 
 29   def ref_code
 30     case @ref_code
 31     when 'p'
 32       'pp'
 33     when 's'
 34       'sp'
 35     else
 36       @ref_code
 37     end
 38   end
 39 
 40   def to_s
 41     hostname + '|' + ip + '|' + ref_code
 42   end
 43 
 44 private
 45 
 46   def set_ref_code(ref_code)
 47     case ref_code
 48     when 'pp'
 49       @ref_code = 'p'
 50     when 'sp'
 51       @ref_code = 's'
 52     else
 53       @ref_code = ref_code
 54     end
 55   end
 56 
 57   def set_power_code
 58     unless @power_indicator == ''
 59       if @ip[3].to_i % 2 == 0
 60         @power_code = 'b'
 61       else
 62         @power_code = 'a'
 63       end
 64     else
 65       @power_code = ''
 66     end
 67   end
 68 
 69 
 70   def set_name
 71     if @hostname.length >= 3
 72       if @ref_code == 'p' or @ref_code == 's'
 73         @name = @hostname[0].split('')
 74         @ref_indicator = @name[0]
 75         @ordinal_indicator = @name[0]
 76         @power_indicator = @name[1]
 77       else
 78         @name = @hostname[1].split('')
 79         @ref_indicator = @hostname[0]
 80         if @name.length == 4
 81           @power_indicator = @name[1]
 82         elsif @name.length == 2
 83           @power_indicator = ''
 84         end
 85       end
 86     end
 87   end
 88 
 89 
 90   def reference_check
 91     unless @ref_indicator == @ref_code
 92       return false
 93     end
 94     true
 95   end
 96 
 97   def power_check
 98     unless @power_indicator == @power_code
 99       return false
100     end
101     true
102   end
103 
104 end
105 
106 # vim:ts=2:sw=2:sts=2:et

Valid XHTML 1.0!Valid CSS!