Abstracting Services In Ruby C0 Coverage Information - RCov

lib/asir/client.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/asir/client.rb 104 59
61.54%
38.98%

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 ASIR
2   # !SLIDE
3   # Client support for any Module
4   #
5   # Extend Module with #client proxy support.
6   module Client
7     # !SLIDE
8     # Client Mixin
9     def self.included target
10       super
11       target.extend ModuleMethods if Module === target
12       target.send(:include, InstanceMethods) if Class === target
13     end
14 
15     module CommonMethods
16       def client_options &blk
17         client._configure(&blk)
18       end
19     end
20 
21     module ModuleMethods
22       include CommonMethods
23       # Proxies are cached for Module/Class methods because serialization will not include
24       # Transport.
25       def client
26         @_asir_client ||= ASIR::Client::Proxy.new(self)
27       end
28     end
29 
30     module InstanceMethods
31       include CommonMethods
32       # Proxies are not cached in instances because receiver is to be serialized by
33       # its Transport's Coder.
34       def client
35         ASIR::Client::Proxy.new(self)
36       end
37     end
38 
39     # !SLIDE
40     # Client Proxy
41     #
42     # Provide client interface proxy to a service.
43     class Proxy
44       attr_accessor :receiver, :transport
45 
46       def transport
47         @transport ||= Transport::Local.new
48       end
49 
50       # Accept messages as a proxy for thje receiver.
51       # Blocks are used represent a "continuation" for the Response.
52       def send selector, *arguments, &block
53         request = Request.new(receiver, selector, arguments, block)
54         request = @before_send_request.call(request) if @before_send_request
55         @__configure.call(request) if @__configure
56         result = transport.send_request(request)
57         result
58       end
59       # Accept all other messages to be encoded and transported to a service.
60       alias :method_missing :send
61 
62       # !SLIDE
63       # Proxy Configuration
64 
65       # A Proc to call with the Request object before sending to transport#send_request(request).
66       # Must return a Request object.
67       attr_accessor :before_send_request
68 
69       # A Proc to call with the Request object before sending to transport#send_request(request).
70       # See #_configure.
71       attr_accessor :__configure
72 
73       # Returns a new Client proxy with a block to be called with the Request.
74       # This block can configure additional options of the Request before
75       # it is sent to the Transport.
76       def _configure &blk
77         client = self.dup
78         client.__configure = blk
79         client
80       end
81       alias :_options :_configure
82 
83       # !SLIDE
84       # Configuration Callbacks
85 
86       def initialize rcvr
87         key = Module === (@receiver = rcvr) ? @receiver : @receiver.class
88         (@@config_callbacks[key] || 
89          @@config_callbacks[key.name] || 
90          @@config_callbacks[nil] ||
91          IDENTITY_LAMBDA).call(self)
92       end
93 
94       @@config_callbacks ||= { }
95       def self.config_callbacks
96         @@config_callbacks
97       end
98 
99       # !SLIDE END
100     end
101     # !SLIDE END
102   end
103   # !SLIDE END
104 end

Generated on Fri Jan 27 17:37:46 -0600 2012 with rcov 0.9.8