C0 code coverage information
Generated on Wed Oct 07 08:33:56 -0700 2009 with rcov 0.8.2.1
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.
1 # Licensed to the Apache Software Foundation (ASF) under one or more
2 # contributor license agreements. See the NOTICE file distributed with this
3 # work for additional information regarding copyright ownership. The ASF
4 # licenses this file to you under the Apache License, Version 2.0 (the
5 # "License"); you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations under
14 # the License.
15
16
17 module Buildr
18
19 # Collection of options for controlling Buildr.
20 class Options
21
22 # We use this to present environment variable as arrays.
23 class EnvArray < Array #:nodoc:
24
25 def initialize(name)
26 @name = name.upcase
27 replace((ENV[@name] || ENV[@name.downcase] || '').split(/\s*,\s*/).reject(&:empty?))
28 end
29
30 (Array.instance_methods - Object.instance_methods - Enumerable.instance_methods).sort.each do |method|
31 class_eval %{def #{method}(*args, &block) ; result = super ; write ; result ; end}
32 end
33
34 private
35
36 def write
37 ENV[@name.downcase] = nil
38 ENV[@name] = map(&:to_s).join(',')
39 end
40
41 end
42
43
44 # Wraps around the proxy environment variables:
45 # * :http -- HTTP_PROXY
46 # * :https -- HTTPS_PROXY
47 # * :exclude -- NO_PROXY
48 class Proxies
49
50 # Returns the HTTP_PROXY URL.
51 def http
52 ENV['HTTP_PROXY'] || ENV['http_proxy']
53 end
54
55 # Sets the HTTP_PROXY URL.
56 def http=(url)
57 ENV['http_proxy'] = nil
58 ENV['HTTP_PROXY'] = url
59 end
60
61 # Returns the HTTPS_PROXY URL.
62 def https
63 ENV['HTTPS_PROXY'] || ENV['https_proxy']
64 end
65
66 # Sets the HTTPS_PROXY URL.
67 def https=(url)
68 ENV['https_proxy'] = nil
69 ENV['HTTPS_PROXY'] = url
70 end
71
72 # Returns list of hosts to exclude from proxying (NO_PROXY).
73 def exclude
74 @exclude ||= EnvArray.new('NO_PROXY')
75 end
76
77 # Sets list of hosts to exclude from proxy (NO_PROXY). Accepts host name, array of names,
78 # or nil to clear the list.
79 def exclude=(url)
80 exclude.clear
81 exclude.concat [url].flatten if url
82 exclude
83 end
84
85 end
86
87 # :call-seq:
88 # proxy => options
89 #
90 # Returns the proxy options. Currently supported options are:
91 # * :http -- HTTP proxy for use when downloading.
92 # * :exclude -- Do not use proxy for these hosts/domains.
93 #
94 # For example:
95 # options.proxy.http = 'http://proxy.acme.com:8080'
96 # You can also set it using the environment variable HTTP_PROXY.
97 #
98 # You can exclude individual hosts from being proxied, or entire domains, for example:
99 # options.proxy.exclude = 'optimus'
100 # options.proxy.exclude = ['optimus', 'prime']
101 # options.proxy.exclude << '*.internal'
102 def proxy
103 @proxy ||= Proxies.new
104 end
105
106 end
107
108
109 class << self
110
111 # :call-seq:
112 # options => Options
113 #
114 # Returns the Buildr options. See Options.
115 def options
116 @options ||= Options.new
117 end
118
119 end
120
121 # :call-seq:
122 # options => Options
123 #
124 # Returns the Buildr options. See Options.
125 def options
126 Buildr.options
127 end
128
129 end
Generated using the rcov code coverage analysis tool for Ruby
version 0.8.2.1.