Jldrill Git C0 Coverage Information - RCov

lib/jldrill/model/items/edict/Definition.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/jldrill/model/items/edict/Definition.rb 63 48
100.00%
100.00%

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/edict/GrammarType"
2 
3 module JLDrill
4 
5     # Holds a definition for an Edict entry.  Each definition
6     # may have one or more type indicating its type of speach
7     # (verb, noun, etc)
8     class Definition
9 
10         DEFINITION_RE = /^(\(\S*\))\s?(.*)/
11         SEPARATOR_RE = /\)|,/
12         COMMA_RE = /[,]/
13 
14         attr_reader :types, :value
15         attr_writer :types, :value
16         	
17         def initialize()
18             @value = ""
19             @types = []
20         end
21         
22         def Definition.create(string)
23             definition = Definition.new
24             definition.parse(string)
25             definition
26         end
27 
28         def parse(string)
29             @types = []
30             while string =~ DEFINITION_RE
31         	    types = GrammarType.create($1)
32         	    if(types.empty?)
33         	        # There were no types in the parenthesis, so it must
34         	        # be part of the definition.
35         	        @value += $1 + " "
36         	    else
37         	        @types += types
38         	    end
39                 string = $2
40             end
41             @value += string.gsub(COMMA_RE, "\\,")
42         end
43         
44         def eql?(definition)
45             @value.eql?(definition.value) && (@types.size == definition.types.size) &&
46                 @types.all? do |x|
47                     definition.types.find do |y|
48                         x.eql?(y)
49                     end
50                 end
51         end        
52 
53         def to_s
54           	retVal = ""
55           	if @types.size > 0
56           	    retVal += "(" + @types.join(",") + ")"
57           	end
58           	retVal += @value
59           	retVal
60         end
61     end
62 end
63 

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