Jldrill Git C0 Coverage Information - RCov

lib/jldrill/model/items/ListField.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/jldrill/model/items/ListField.rb 89 72
97.75%
97.22%

Key

Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.

Coverage Details

1 require "jldrill/model/items/Field"
2 
3 # Represents a list type Field in a Vocabulary
4 
5 module JLDrill
6     class ListField < Field
7 
8         SEPARATOR_RE = /[^\\],/
9 
10         def initialize(name, data)
11             super(name)
12             @contents = data
13         end
14 
15         def fromString(string)
16             if string.nil? || string.empty?
17                 @contents = nil
18             else
19                 @contents = string.split(",")
20                 merge = false
21                 delete = []
22                 lastItem = 0
23                 0.upto(@contents.size - 1) do |i|
24                     if merge
25                         @contents[lastItem] += "," + @contents[i]
26                         delete.push(i)
27                     else
28                         lastItem = i
29                     end
30                     merge = @contents[i].end_with?("\\")
31                     @contents[i].strip!
32                 end
33                 delete.reverse.each do |i|
34                     @contents.delete_at(i)
35                 end
36             end
37         end
38 
39         def contents
40             @contents
41         end
42 
43         def raw
44             if assigned?
45                 @contents.join(",")
46             else
47                 ""
48             end
49         end
50 
51         # I stupidly didn't have spaces for my raw output previously
52         # so this means that I've got to duplicate this method here.
53         def output
54             if assigned?
55                 processOutput(@contents.join(", "))
56             else
57                 ""
58             end
59         end
60 
61 
62         def copy(field)
63             @contents = []
64             if field.assigned?
65                 field.contents.each do |a|
66                     @contents.push(a)
67                 end
68             else
69                 @contents = nil
70             end
71         end
72 
73         def eql?(array)
74             if !assigned?
75                 return array.nil? || array.empty?
76             end
77                
78             if array.nil? || array.empty?
79                 return false
80             end
81 
82             if @contents.size != array.size
83                 return false
84             end
85 
86             return @contents.eql?(array)
87         end
88     end
89 end

Generated on Mon May 23 16:17:46 +0900 2011 with rcov 0.9.8