Openacn Ruby C0 Coverage Information - RCov

ddl/DDL_module.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
ddl/DDL_module.rb 71 53
35.21%
39.62%

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 module ACN
2   module DDL
3     # Base class for devices, behaviour sets, and language sets. 
4     # Called 'module' in the ACN specification.
5     class DDLModule
6       
7       attr_accessor :ddl
8       attr_reader   :uuid
9       attr_accessor :provider
10       attr_accessor :date
11       attr_accessor :uuid_names
12       attr_writer   :label
13       attr_writer   :extends
14       #TODO alternatefor and extends
15       
16       def initialize(ddl = nil, opts = {})
17         @provider = opts[:provider] || ""
18         @date = opts[:date]
19         @uuid_names = opts[:uuid_names] || {}
20         @label = opts[:label] || {}
21         @extends = opts[:extends] || {}
22         @ddl = ddl
23         self.uuid_or_name = opts[:uuid]
24       end
25       
26       def label
27         if @label[:text].nil?
28           @ddl.translate(@label[:key], @label[:set])
29         else
30           @label[:text]
31         end
32       end
33       
34       def extends
35        @ddl.find_module(@extends[:uuid]) if @extends[:uuid]
36       end
37       
38       # # Replace the instance with uuid with this one.
39       def alternate_for(uuid)
40         @ddl.find_module(uuid)
41       end
42       
43       # Return a valid UUID
44       # Drop the leading 'U' if it is an actual UUID from the XML 
45       # or get the UUID from the uuid_names hash if it is a UUIDname.
46       def resolve_uuid(uuid_or_name) 
47         return uuid_or_name if UUID.validate(uuid_or_name)
48         if uuid_or_name.chr == 'U'
49           return uuid_or_name[1..-1] 
50         else
51           return uuid_names[uuid_or_name.to_sym]
52         end
53       end
54       
55       # Set the uuid given a UUID or name
56       # Check if the UUID is valid and set the @uuid attribute
57       def uuid_or_name=(uuid_or_name)
58         uuid_or_name ||= UUID.generate
59         @uuid = resolve_uuid(uuid_or_name)
60         raise Exception.new("UUID is not unique") unless unique_uuid?(@uuid)
61         raise Exception.new("UUID is invalid") unless UUID.validate(@uuid)
62       end
63       
64       private 
65       def unique_uuid?(uuid)
66         @ddl.modules.all?{|m| m.uuid != uuid || m == self}
67       end
68       
69     end
70   end
71 end

Generated on 2010-03-16 15:14:05 +1000 with rcov 0.9.2.1