puppet 0.24.1 → 0.24.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (266) hide show
  1. data/CHANGELOG +94 -0
  2. data/Rakefile +0 -4
  3. data/bin/puppet +18 -10
  4. data/bin/puppetd +1 -1
  5. data/bin/puppetdoc +14 -4
  6. data/bin/puppetmasterd +1 -1
  7. data/bin/puppetrun +3 -8
  8. data/bin/ralsh +12 -11
  9. data/conf/freebsd/puppetd +1 -1
  10. data/conf/freebsd/puppetmasterd +1 -1
  11. data/conf/gentoo/puppet/puppet.conf +29 -0
  12. data/conf/namespaceauth.conf +20 -0
  13. data/conf/redhat/puppet.spec +4 -1
  14. data/conf/solaris/smf/puppetd.xml +1 -1
  15. data/conf/solaris/smf/puppetmasterd.xml +1 -1
  16. data/conf/suse/puppet.spec +10 -8
  17. data/examples/root/etc/puppet/{puppetmasterd.conf → puppet.conf} +6 -3
  18. data/ext/logcheck/puppet +7 -0
  19. data/ext/puppet-test +28 -5
  20. data/lib/puppet.rb +2 -1
  21. data/lib/puppet/defaults.rb +12 -5
  22. data/lib/puppet/dsl.rb +43 -45
  23. data/lib/puppet/external/{gratr/rdot.rb → dot.rb} +0 -0
  24. data/lib/puppet/external/nagios.rb +50 -0
  25. data/lib/puppet/external/nagios/base.rb +421 -0
  26. data/lib/puppet/external/nagios/parser.rb +816 -0
  27. data/lib/puppet/file_serving/file_base.rb +16 -3
  28. data/lib/puppet/file_serving/metadata.rb +29 -11
  29. data/lib/puppet/indirector/terminus.rb +1 -0
  30. data/lib/puppet/metatype/closure.rb +4 -0
  31. data/lib/puppet/metatype/evaluation.rb +2 -17
  32. data/lib/puppet/metatype/metaparams.rb +1 -1
  33. data/lib/puppet/network.rb +3 -0
  34. data/lib/puppet/network/client.rb +4 -5
  35. data/lib/puppet/network/client/master.rb +10 -7
  36. data/lib/puppet/network/handler/fileserver.rb +22 -45
  37. data/lib/puppet/network/http_pool.rb +3 -0
  38. data/lib/puppet/network/http_server/mongrel.rb +7 -1
  39. data/lib/puppet/network/http_server/webrick.rb +4 -3
  40. data/lib/puppet/network/xmlrpc/client.rb +12 -1
  41. data/lib/puppet/node/catalog.rb +51 -40
  42. data/lib/puppet/parser/ast.rb +27 -49
  43. data/lib/puppet/parser/ast/astarray.rb +5 -24
  44. data/lib/puppet/parser/ast/caseopt.rb +4 -4
  45. data/lib/puppet/parser/ast/casestatement.rb +4 -5
  46. data/lib/puppet/parser/ast/collection.rb +3 -5
  47. data/lib/puppet/parser/ast/collexpr.rb +3 -5
  48. data/lib/puppet/parser/ast/definition.rb +148 -159
  49. data/lib/puppet/parser/ast/else.rb +2 -3
  50. data/lib/puppet/parser/ast/function.rb +3 -10
  51. data/lib/puppet/parser/ast/hostclass.rb +66 -59
  52. data/lib/puppet/parser/ast/ifstatement.rb +4 -5
  53. data/lib/puppet/parser/ast/leaf.rb +6 -6
  54. data/lib/puppet/parser/ast/node.rb +26 -58
  55. data/lib/puppet/parser/ast/resource.rb +5 -7
  56. data/lib/puppet/parser/ast/resource_defaults.rb +2 -4
  57. data/lib/puppet/parser/ast/resource_override.rb +4 -6
  58. data/lib/puppet/parser/ast/resource_reference.rb +2 -4
  59. data/lib/puppet/parser/ast/resourceparam.rb +2 -4
  60. data/lib/puppet/parser/ast/selector.rb +5 -6
  61. data/lib/puppet/parser/ast/tag.rb +2 -4
  62. data/lib/puppet/parser/ast/vardef.rb +3 -4
  63. data/lib/puppet/parser/collector.rb +5 -5
  64. data/lib/puppet/parser/{compile.rb → compiler.rb} +69 -107
  65. data/lib/puppet/parser/functions.rb +3 -3
  66. data/lib/puppet/parser/interpreter.rb +32 -23
  67. data/lib/puppet/parser/lexer.rb +391 -282
  68. data/lib/puppet/parser/parser.rb +5 -4
  69. data/lib/puppet/parser/parser_support.rb +3 -6
  70. data/lib/puppet/parser/resource.rb +24 -36
  71. data/lib/puppet/parser/resource/param.rb +1 -1
  72. data/lib/puppet/parser/resource/reference.rb +7 -3
  73. data/lib/puppet/parser/scope.rb +12 -7
  74. data/lib/puppet/parser/templatewrapper.rb +1 -1
  75. data/lib/puppet/pgraph.rb +9 -98
  76. data/lib/puppet/provider/interface/redhat.rb +65 -65
  77. data/lib/puppet/provider/mount/parsed.rb +1 -1
  78. data/lib/puppet/provider/naginator.rb +55 -0
  79. data/lib/puppet/provider/nameservice/directoryservice.rb +6 -7
  80. data/lib/puppet/provider/package/fink.rb +0 -2
  81. data/lib/puppet/provider/package/gem.rb +9 -5
  82. data/lib/puppet/provider/package/openbsd.rb +1 -1
  83. data/lib/puppet/provider/package/pkgdmg.rb +3 -8
  84. data/lib/puppet/provider/package/portage.rb +4 -4
  85. data/lib/puppet/provider/package/yumhelper.py +8 -6
  86. data/lib/puppet/provider/parsedfile.rb +7 -1
  87. data/lib/puppet/provider/service/debian.rb +2 -0
  88. data/lib/puppet/provider/service/gentoo.rb +4 -0
  89. data/lib/puppet/provider/service/init.rb +1 -1
  90. data/lib/puppet/provider/sshkey/parsed.rb +2 -0
  91. data/lib/puppet/provider/user/useradd.rb +1 -1
  92. data/lib/puppet/rails.rb +4 -0
  93. data/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb +17 -0
  94. data/lib/puppet/rails/fact_value.rb +4 -0
  95. data/lib/puppet/rails/host.rb +1 -2
  96. data/lib/puppet/rails/param_value.rb +4 -0
  97. data/lib/puppet/rails/resource_tag.rb +4 -0
  98. data/lib/puppet/rails/source_file.rb +4 -1
  99. data/lib/puppet/relationship.rb +5 -1
  100. data/lib/puppet/reports/tagmail.rb +12 -1
  101. data/lib/puppet/resource_reference.rb +1 -1
  102. data/lib/puppet/simple_graph.rb +78 -11
  103. data/lib/puppet/sslcertificates.rb +1 -1
  104. data/lib/puppet/sslcertificates/ca.rb +3 -3
  105. data/lib/puppet/transaction.rb +7 -4
  106. data/lib/puppet/transportable.rb +1 -1
  107. data/lib/puppet/type.rb +3 -10
  108. data/lib/puppet/type/cron.rb +18 -0
  109. data/lib/puppet/type/exec.rb +18 -12
  110. data/lib/puppet/type/{pfile.rb → file.rb} +66 -84
  111. data/lib/puppet/type/file/checksum.rb +271 -0
  112. data/lib/puppet/type/{pfile → file}/content.rb +10 -15
  113. data/lib/puppet/type/{pfile → file}/ensure.rb +15 -8
  114. data/lib/puppet/type/{pfile → file}/group.rb +0 -0
  115. data/lib/puppet/type/{pfile → file}/mode.rb +0 -0
  116. data/lib/puppet/type/{pfile → file}/owner.rb +0 -0
  117. data/lib/puppet/type/{pfile → file}/source.rb +34 -48
  118. data/lib/puppet/type/{pfile → file}/target.rb +0 -0
  119. data/lib/puppet/type/{pfile → file}/type.rb +0 -0
  120. data/lib/puppet/type/{pfilebucket.rb → filebucket.rb} +0 -0
  121. data/lib/puppet/type/host.rb +13 -0
  122. data/lib/puppet/type/mailalias.rb +1 -1
  123. data/lib/puppet/type/nagios_command.rb +3 -0
  124. data/lib/puppet/type/nagios_contact.rb +3 -0
  125. data/lib/puppet/type/nagios_contactgroup.rb +3 -0
  126. data/lib/puppet/type/nagios_host.rb +3 -0
  127. data/lib/puppet/type/nagios_hostextinfo.rb +3 -0
  128. data/lib/puppet/type/nagios_hostgroup.rb +3 -0
  129. data/lib/puppet/type/nagios_hostgroupescalation.rb +3 -0
  130. data/lib/puppet/type/nagios_service.rb +3 -0
  131. data/lib/puppet/type/nagios_servicedependency.rb +3 -0
  132. data/lib/puppet/type/nagios_serviceescalation.rb +3 -0
  133. data/lib/puppet/type/nagios_serviceextinfo.rb +3 -0
  134. data/lib/puppet/type/nagios_timeperiod.rb +3 -0
  135. data/lib/puppet/type/package.rb +4 -12
  136. data/lib/puppet/type/service.rb +9 -0
  137. data/lib/puppet/type/sshkey.rb +3 -3
  138. data/lib/puppet/util/autoload.rb +5 -5
  139. data/lib/puppet/util/checksums.rb +51 -13
  140. data/lib/puppet/util/constant_inflector.rb +14 -0
  141. data/lib/puppet/util/filetype.rb +1 -1
  142. data/lib/puppet/util/graph.rb +3 -9
  143. data/lib/puppet/util/nagios_maker.rb +57 -0
  144. data/lib/puppet/util/settings.rb +19 -16
  145. data/lib/puppet/util/tagging.rb +39 -0
  146. data/test/executables/puppetbin.rb +17 -0
  147. data/test/language/ast.rb +8 -58
  148. data/test/language/ast/casestatement.rb +3 -3
  149. data/test/language/ast/resource.rb +6 -7
  150. data/test/language/ast/resource_reference.rb +12 -12
  151. data/test/language/ast/selector.rb +2 -2
  152. data/test/language/ast/variable.rb +2 -2
  153. data/test/language/functions.rb +24 -24
  154. data/test/language/parser.rb +20 -8
  155. data/test/language/resource.rb +5 -42
  156. data/test/language/scope.rb +21 -37
  157. data/test/language/snippets.rb +7 -0
  158. data/test/lib/puppettest.rb +28 -14
  159. data/test/lib/puppettest/parsertesting.rb +10 -10
  160. data/test/lib/puppettest/support/resources.rb +1 -1
  161. data/test/network/client/master.rb +10 -0
  162. data/test/network/handler/fileserver.rb +51 -49
  163. data/test/network/server/webrick.rb +1 -1
  164. data/test/other/dsl.rb +3 -4
  165. data/test/other/transactions.rb +6 -4
  166. data/test/rails/ast.rb +2 -2
  167. data/test/rails/configuration.rb +1 -1
  168. data/test/rails/railsparameter.rb +2 -0
  169. data/test/rails/railsresource.rb +1 -0
  170. data/test/ral/manager/type.rb +4 -4
  171. data/test/ral/providers/cron/crontab.rb +3 -1
  172. data/test/ral/providers/package.rb +1 -1
  173. data/test/ral/{types → type}/basic.rb +2 -2
  174. data/test/ral/{types → type}/cron.rb +0 -0
  175. data/test/ral/{types → type}/exec.rb +42 -2
  176. data/test/ral/{types → type}/file.rb +34 -79
  177. data/test/ral/{types → type}/file/target.rb +0 -0
  178. data/test/ral/{types → type}/filebucket.rb +0 -0
  179. data/test/ral/{types → type}/fileignoresource.rb +0 -0
  180. data/test/ral/{types → type}/filesources.rb +8 -27
  181. data/test/ral/{types → type}/group.rb +0 -0
  182. data/test/ral/{types → type}/host.rb +16 -0
  183. data/test/ral/{types → type}/mailalias.rb +0 -0
  184. data/test/ral/{types → type}/parameter.rb +0 -0
  185. data/test/ral/{types → type}/port.rb +0 -0
  186. data/test/ral/{types → type}/property.rb +0 -0
  187. data/test/ral/{types → type}/resources.rb +0 -0
  188. data/test/ral/{types → type}/service.rb +0 -0
  189. data/test/ral/{types → type}/sshkey.rb +0 -0
  190. data/test/ral/{types → type}/tidy.rb +1 -0
  191. data/test/ral/{types → type}/user.rb +0 -0
  192. data/test/ral/{types → type}/yumrepo.rb +0 -0
  193. data/test/ral/{types → type}/zone.rb +0 -0
  194. data/test/util/autoload.rb +24 -5
  195. metadata +60 -107
  196. data/conf/gentoo/puppet/puppetca.conf +0 -29
  197. data/conf/gentoo/puppet/puppetd.conf +0 -29
  198. data/conf/gentoo/puppet/puppetmasterd.conf +0 -29
  199. data/examples/root/etc/puppet/puppetd.conf +0 -4
  200. data/lib/puppet/external/gratr.rb +0 -33
  201. data/lib/puppet/external/gratr/adjacency_graph.rb +0 -257
  202. data/lib/puppet/external/gratr/base.rb +0 -34
  203. data/lib/puppet/external/gratr/biconnected.rb +0 -116
  204. data/lib/puppet/external/gratr/chinese_postman.rb +0 -123
  205. data/lib/puppet/external/gratr/common.rb +0 -73
  206. data/lib/puppet/external/gratr/comparability.rb +0 -92
  207. data/lib/puppet/external/gratr/digraph.rb +0 -116
  208. data/lib/puppet/external/gratr/digraph_distance.rb +0 -185
  209. data/lib/puppet/external/gratr/dot.rb +0 -90
  210. data/lib/puppet/external/gratr/edge.rb +0 -145
  211. data/lib/puppet/external/gratr/graph.rb +0 -303
  212. data/lib/puppet/external/gratr/graph_api.rb +0 -83
  213. data/lib/puppet/external/gratr/import.rb +0 -44
  214. data/lib/puppet/external/gratr/labels.rb +0 -90
  215. data/lib/puppet/external/gratr/maximum_flow.rb +0 -64
  216. data/lib/puppet/external/gratr/search.rb +0 -409
  217. data/lib/puppet/external/gratr/strong_components.rb +0 -127
  218. data/lib/puppet/external/gratr/undirected_graph.rb +0 -153
  219. data/lib/puppet/rails/external/tagging/acts_as_taggable.rb +0 -62
  220. data/lib/puppet/rails/external/tagging/init.rb +0 -5
  221. data/lib/puppet/rails/external/tagging/tag.rb +0 -50
  222. data/lib/puppet/rails/external/tagging/tagging.rb +0 -12
  223. data/lib/puppet/rails/puppet_class.rb +0 -6
  224. data/lib/puppet/reference/node_source.rb +0 -9
  225. data/lib/puppet/reference/report.rb +0 -21
  226. data/lib/puppet/type/pfile/checksum.rb +0 -326
  227. data/test/language/ast/definition.rb +0 -166
  228. data/test/language/ast/hostclass.rb +0 -184
  229. data/test/language/compile.rb +0 -569
  230. data/test/language/lexer.rb +0 -276
  231. data/test/lib/mocha.rb +0 -19
  232. data/test/lib/mocha/any_instance_method.rb +0 -35
  233. data/test/lib/mocha/auto_verify.rb +0 -113
  234. data/test/lib/mocha/central.rb +0 -35
  235. data/test/lib/mocha/class_method.rb +0 -62
  236. data/test/lib/mocha/deprecation.rb +0 -22
  237. data/test/lib/mocha/exception_raiser.rb +0 -17
  238. data/test/lib/mocha/expectation.rb +0 -378
  239. data/test/lib/mocha/expectation_error.rb +0 -6
  240. data/test/lib/mocha/infinite_range.rb +0 -25
  241. data/test/lib/mocha/inspect.rb +0 -39
  242. data/test/lib/mocha/instance_method.rb +0 -8
  243. data/test/lib/mocha/is_a.rb +0 -9
  244. data/test/lib/mocha/metaclass.rb +0 -7
  245. data/test/lib/mocha/missing_expectation.rb +0 -27
  246. data/test/lib/mocha/mock.rb +0 -207
  247. data/test/lib/mocha/multiple_yields.rb +0 -20
  248. data/test/lib/mocha/no_yields.rb +0 -11
  249. data/test/lib/mocha/object.rb +0 -110
  250. data/test/lib/mocha/parameter_matchers.rb +0 -9
  251. data/test/lib/mocha/parameter_matchers/all_of.rb +0 -39
  252. data/test/lib/mocha/parameter_matchers/any_of.rb +0 -44
  253. data/test/lib/mocha/parameter_matchers/anything.rb +0 -30
  254. data/test/lib/mocha/parameter_matchers/has_entry.rb +0 -39
  255. data/test/lib/mocha/parameter_matchers/has_key.rb +0 -39
  256. data/test/lib/mocha/parameter_matchers/has_value.rb +0 -39
  257. data/test/lib/mocha/parameter_matchers/includes.rb +0 -37
  258. data/test/lib/mocha/pretty_parameters.rb +0 -28
  259. data/test/lib/mocha/return_values.rb +0 -31
  260. data/test/lib/mocha/setup_and_teardown.rb +0 -23
  261. data/test/lib/mocha/single_return_value.rb +0 -24
  262. data/test/lib/mocha/single_yield.rb +0 -18
  263. data/test/lib/mocha/standalone.rb +0 -32
  264. data/test/lib/mocha/stub.rb +0 -18
  265. data/test/lib/mocha/test_case_adapter.rb +0 -49
  266. data/test/lib/mocha/yield_parameters.rb +0 -31
@@ -1,127 +0,0 @@
1
- #--
2
- # Copyright (c) 2006 Shawn Patrick Garbett
3
- #
4
- # Redistribution and use in source and binary forms, with or without modification,
5
- # are permitted provided that the following conditions are met:
6
- #
7
- # * Redistributions of source code must retain the above copyright notice(s),
8
- # this list of conditions and the following disclaimer.
9
- # * Redistributions in binary form must reproduce the above copyright notice,
10
- # this list of conditions and the following disclaimer in the documentation
11
- # and/or other materials provided with the distribution.
12
- # * Neither the name of the Shawn Garbett nor the names of its contributors
13
- # may be used to endorse or promote products derived from this software
14
- # without specific prior written permission.
15
- #
16
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
- # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20
- # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
- # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22
- # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23
- # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24
- # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
- # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
- #++
27
-
28
-
29
- require 'set'
30
-
31
- module GRATR
32
- module Graph
33
- module StrongComponents
34
- # strong_components computes the strongly connected components
35
- # of a graph using Tarjan's algorithm based on DFS. See: Robert E. Tarjan
36
- # _Depth_First_Search_and_Linear_Graph_Algorithms_. SIAM Journal on
37
- # Computing, 1(2):146-160, 1972
38
- #
39
- # The output of the algorithm is an array of components where is
40
- # component is an array of vertices
41
- #
42
- # A strongly connected component of a directed graph G=(V,E) is a maximal
43
- # set of vertices U which is in V such that for every pair of
44
- # vertices u and v in U, we have both a path from u to v
45
- # and path from v to u. That is to say that u and v are reachable
46
- # from each other.
47
- #
48
- def strong_components
49
-
50
- dfs_num = 0
51
- stack = []; result = []; root = {}; comp = {}; number = {}
52
-
53
- # Enter vertex callback
54
- enter = Proc.new do |v|
55
- root[v] = v
56
- comp[v] = :new
57
- number[v] = (dfs_num += 1)
58
- stack.push(v)
59
- end
60
-
61
- # Exit vertex callback
62
- exit = Proc.new do |v|
63
- adjacent(v).each do |w|
64
- if comp[w] == :new
65
- root[v] = (number[root[v]] < number[root[w]] ? root[v] : root[w])
66
- end
67
- end
68
- if root[v] == v
69
- component = []
70
- begin
71
- w = stack.pop
72
- comp[w] = :assigned
73
- component << w
74
- end until w == v
75
- result << component
76
- end
77
- end
78
-
79
- # Execute depth first search
80
- dfs({:enter_vertex => enter, :exit_vertex => exit}); result
81
-
82
- end # strong_components
83
-
84
- # Returns a condensation graph of the strongly connected components
85
- # Each node is an array of nodes from the original graph
86
- def condensation
87
- sc = strong_components
88
- cg = self.class.new
89
- map = sc.inject({}) do |a,c|
90
- c.each {|v| a[v] = c }; a
91
- end
92
- sc.each do |c|
93
- c.each do |v|
94
- adjacent(v).each {|v| cg.add_edge!(c, map[v]) unless c == map[v]}
95
- end
96
- end; cg
97
- end
98
-
99
- # Compute transitive closure of a graph. That is any node that is reachable
100
- # along a path is added as a directed edge.
101
- def transitive_closure!
102
- cgtc = condensation.gratr_inner_transitive_closure!
103
- cgtc.each do |cgv|
104
- cgtc.adjacent(cgv).each do |adj|
105
- cgv.each do |u|
106
- adj.each {|v| add_edge!(u,v)}
107
- end
108
- end
109
- end; self
110
- end
111
-
112
- # This returns the transitive closure of a graph. The original graph
113
- # is not changed.
114
- def transitive_closure() self.class.new(self).transitive_closure!; end
115
-
116
- private
117
- def gratr_inner_transitive_closure! # :nodoc:
118
- topsort.reverse.each do |u|
119
- adjacent(u).each do |v|
120
- adjacent(v).each {|w| add_edge!(u,w) unless edge?(u,w)}
121
- end
122
- end; self
123
- end
124
- end # StrongComponens
125
-
126
- end # Graph
127
- end # GRATR
@@ -1,153 +0,0 @@
1
- #--
2
- # Copyright (c) 2006 Shawn Patrick Garbett
3
- # Copyright (c) 2002,2004,2005 by Horst Duchene
4
- #
5
- # Redistribution and use in source and binary forms, with or without modification,
6
- # are permitted provided that the following conditions are met:
7
- #
8
- # * Redistributions of source code must retain the above copyright notice(s),
9
- # this list of conditions and the following disclaimer.
10
- # * Redistributions in binary form must reproduce the above copyright notice,
11
- # this list of conditions and the following disclaimer in the documentation
12
- # and/or other materials provided with the distribution.
13
- # * Neither the name of the Shawn Garbett nor the names of its contributors
14
- # may be used to endorse or promote products derived from this software
15
- # without specific prior written permission.
16
- #
17
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
- # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
21
- # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
- # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
- # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
- # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
- # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
- # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
- #++
28
-
29
-
30
- require 'puppet/external/gratr/adjacency_graph'
31
- require 'puppet/external/gratr/search'
32
- require 'puppet/external/gratr/biconnected'
33
- require 'puppet/external/gratr/comparability'
34
- require 'set'
35
-
36
- module GRATR
37
- class UndirectedGraph
38
- include AdjacencyGraph
39
- include Graph::Search
40
- include Graph::Biconnected
41
- include Graph::Comparability
42
-
43
- def initialize(*params)
44
- raise ArgumentError if params.any? do |p|
45
- !(p.kind_of? GRATR::Graph or p.kind_of? Array)
46
- end if self.class == GRATR::UndirectedGraph
47
- super(*params)
48
- end
49
-
50
- # UndirectedGraph is by definition undirected, always returns false
51
- def directed?() false; end
52
-
53
- # Redefine degree (default was sum)
54
- def degree(v) in_degree(v); end
55
-
56
- # A vertex of an undirected graph is balanced by definition
57
- def balanced?(v) true; end
58
-
59
- # UndirectedGraph uses UndirectedEdge for the edge class.
60
- def edge_class() @parallel_edges ? GRATR::MultiUndirectedEdge : GRATR::UndirectedEdge; end
61
-
62
- def remove_edge!(u, v=nil)
63
- unless u.kind_of? GRATR::Edge
64
- raise ArgumentError if @parallel_edges
65
- u = edge_class[u,v]
66
- end
67
- super(u.reverse) unless u.source == u.target
68
- super(u)
69
- end
70
-
71
- # A triangulated graph is an undirected perfect graph that every cycle of length greater than
72
- # three possesses a chord. They have also been called chordal, rigid circuit, monotone transitive,
73
- # and perfect elimination graphs.
74
- #
75
- # Implementation taken from Golumbic's, "Algorithmic Graph Theory and
76
- # Perfect Graphs" pg. 90
77
- def triangulated?
78
- a = Hash.new {|h,k| h[k]=Set.new}; sigma=lexicograph_bfs
79
- inv_sigma = sigma.inject({}) {|acc,val| acc[val] = sigma.index(val); acc}
80
- sigma[0..-2].each do |v|
81
- x = adjacent(v).select {|w| inv_sigma[v] < inv_sigma[w] }
82
- unless x.empty?
83
- u = sigma[x.map {|y| inv_sigma[y]}.min]
84
- a[u].merge(x - [u])
85
- end
86
- return false unless a[v].all? {|z| adjacent?(v,z)}
87
- end
88
- true
89
- end
90
-
91
- def chromatic_number
92
- return triangulated_chromatic_number if triangulated?
93
- raise NotImplementedError
94
- end
95
-
96
- # An interval graph can have its vertices into one-to-one
97
- # correspondence with a set of intervals F of a linearly ordered
98
- # set (like the real line) such that two vertices are connected
99
- # by an edge of G if and only if their corresponding intervals
100
- # have nonempty intersection.
101
- def interval?() triangulated? and complement.comparability?; end
102
-
103
- # A permutation diagram consists of n points on each of two parallel
104
- # lines and n straight line segments matchin the points. The intersection
105
- # graph of the line segments is called a permutation graph.
106
- def permutation?() comparability? and complement.comparability?; end
107
-
108
- # An undirected graph is defined to be split if there is a partition
109
- # V = S + K of its vertex set into a stable set S and a complete set K.
110
- def split?() triangulated? and complement.triangulated?; end
111
-
112
- private
113
- # Implementation taken from Golumbic's, "Algorithmic Graph Theory and
114
- # Perfect Graphs" pg. 99
115
- def triangulated_chromatic_number
116
- chi = 1; s= Hash.new {|h,k| h[k]=0}
117
- sigma=lexicograph_bfs
118
- inv_sigma = sigma.inject({}) {|acc,val| acc[val] = sigma.index(val); acc}
119
- sigma.each do |v|
120
- x = adjacent(v).select {|w| inv_sigma[v] < inv_sigma[w] }
121
- unless x.empty?
122
- u = sigma[x.map {|y| inv_sigma[y]}.min]
123
- s[u] = [s[u], x.size-1].max
124
- chi = [chi, x.size+1].max if s[v] < x.size
125
- end
126
- end; chi
127
- end
128
-
129
- end # UndirectedGraph
130
-
131
- # This is a UndirectedGraph that allows for parallel edges, but does not
132
- # allow loops
133
- class UndirectedPseudoGraph < UndirectedGraph
134
- def initialize(*params)
135
- raise ArgumentError if params.any? do |p|
136
- !(p.kind_of? Graph or p.kind_of? Array)
137
- end
138
- super(:parallel_edges, *params)
139
- end
140
- end
141
-
142
- # This is a UndirectedGraph that allows for parallel edges and loops
143
- class UndirectedMultiGraph < UndirectedGraph
144
- def initialize(*params)
145
- raise ArgumentError if params.any? do |p|
146
- !(p.kind_of? Graph or p.kind_of? Array)
147
- end
148
- super(:parallel_edges, :loops, *params)
149
- end
150
- end
151
-
152
-
153
- end # GRATR
@@ -1,62 +0,0 @@
1
- module ActiveRecord
2
- module Acts #:nodoc:
3
- module Taggable #:nodoc:
4
- def self.included(base)
5
- base.extend(ClassMethods)
6
- end
7
-
8
- module ClassMethods
9
- def acts_as_taggable(options = {})
10
- write_inheritable_attribute(:acts_as_taggable_options, {
11
- :taggable_type => ActiveRecord::Base.send(:class_name_of_active_record_descendant, self).to_s,
12
- :from => options[:from]
13
- })
14
-
15
- class_inheritable_reader :acts_as_taggable_options
16
-
17
- has_many :taggings, :as => :taggable, :dependent => :destroy
18
- has_many :tags, :through => :taggings
19
-
20
- include ActiveRecord::Acts::Taggable::InstanceMethods
21
- extend ActiveRecord::Acts::Taggable::SingletonMethods
22
- end
23
- end
24
-
25
- module SingletonMethods
26
- def find_tagged_with(list)
27
- find_by_sql([
28
- "SELECT #{table_name}.* FROM #{table_name}, tags, taggings " +
29
- "WHERE #{table_name}.#{primary_key} = taggings.taggable_id " +
30
- "AND taggings.taggable_type = ? " +
31
- "AND taggings.tag_id = tags.id AND tags.name IN (?)",
32
- acts_as_taggable_options[:taggable_type], list
33
- ])
34
- end
35
- def tags(options = {})
36
- options.merge!(:taggable_type => self.to_s)
37
- Tag.tags(options)
38
- end
39
- end
40
-
41
- module InstanceMethods
42
- def tag_with(list)
43
- Tag.transaction do
44
- taggings.destroy_all
45
-
46
- Tag.parse(list).each do |name|
47
- if acts_as_taggable_options[:from]
48
- send(acts_as_taggable_options[:from]).tags.find_or_create_by_name(name).on(self)
49
- else
50
- Tag.find_or_create_by_name(name).on(self)
51
- end
52
- end
53
- end
54
- end
55
-
56
- def tag_list
57
- tags.collect { |tag| tag.name.include?(" ") ? "'#{tag.name}'" : tag.name }.join(" ")
58
- end
59
- end
60
- end
61
- end
62
- end
@@ -1,5 +0,0 @@
1
- require 'puppet/rails/external/tagging/acts_as_taggable'
2
- ActiveRecord::Base.send(:include, ActiveRecord::Acts::Taggable)
3
-
4
- require 'puppet/rails/external/tagging/tagging'
5
- require 'puppet/rails/external/tagging/tag'
@@ -1,50 +0,0 @@
1
- class Tag < ActiveRecord::Base
2
- has_many :taggings
3
-
4
- def self.tags(options = {})
5
- query = "select tags.id, name, count(*) as count"
6
- query << " from taggings, tags"
7
- query << " where tags.id = tag_id"
8
- query << " group by tag_id"
9
- query << " order by #{options[:order]}" if options[:order] != nil
10
- query << " limit #{options[:limit]}" if options[:limit] != nil
11
- tags = Tag.find_by_sql(query)
12
- end
13
-
14
- def self.parse(list)
15
- tag_names = []
16
-
17
- # first, pull out the quoted tags
18
- list.gsub!(/\"(.*?)\"\s*/ ) { tag_names << $1; "" }
19
-
20
- # then, replace all commas with a space
21
- list.gsub!(/,/, " ")
22
-
23
- # then, get whatever's left
24
- tag_names.concat list.split(/\s/)
25
-
26
- # strip whitespace from the names
27
- tag_names = tag_names.map { |t| t.strip }
28
-
29
- # delete any blank tag names
30
- tag_names = tag_names.delete_if { |t| t.empty? }
31
-
32
- return tag_names
33
- end
34
-
35
- def tagged
36
- @tagged ||= taggings.collect { |tagging| tagging.taggable }
37
- end
38
-
39
- def on(taggable)
40
- taggings.build :taggable => taggable
41
- end
42
-
43
- def ==(comparison_object)
44
- super || name == comparison_object.to_s
45
- end
46
-
47
- def to_s
48
- name
49
- end
50
- end
@@ -1,12 +0,0 @@
1
- class Tagging < ActiveRecord::Base
2
- belongs_to :tag
3
- belongs_to :taggable, :polymorphic => true
4
-
5
- def self.tagged_class(taggable)
6
- ActiveRecord::Base.send(:class_name_of_active_record_descendant, taggable.class).to_s
7
- end
8
-
9
- def self.find_taggable(tagged_class, tagged_id)
10
- tagged_class.constantize.find(tagged_id)
11
- end
12
- end
@@ -1,6 +0,0 @@
1
- class Puppet::Rails::PuppetClass < ActiveRecord::Base
2
- has_many :resources
3
- has_many :source_files
4
- has_many :hosts
5
- end
6
-
@@ -1,9 +0,0 @@
1
- require 'puppet/node'
2
-
3
- noderef = Puppet::Util::Reference.newreference :node_source, :doc => "Sources of node configuration information" do
4
- Puppet::Network::Handler.node.docs
5
- end
6
-
7
- noderef.header = "
8
- Nodes can be searched for in different locations. This document describes those different locations.
9
- "
@@ -1,21 +0,0 @@
1
- report = Puppet::Util::Reference.newreference :report, :doc => "All available transaction reports" do
2
- Puppet::Network::Handler.report.reportdocs
3
- end
4
-
5
- report.header = "
6
- Puppet clients can report back to the server after each transaction. This
7
- transaction report is sent as a YAML dump of the
8
- ``Puppet::Transaction::Report`` class and includes every log message that was
9
- generated during the transaction along with as many metrics as Puppet knows how
10
- to collect. See `ReportsAndReporting Reports and Reporting`:trac:
11
- for more information on how to use reports.
12
-
13
- Currently, clients default to not sending in reports; you can enable reporting
14
- by setting the ``report`` parameter to true.
15
-
16
- To use a report, set the ``reports`` parameter on the server; multiple
17
- reports must be comma-separated. You can also specify ``none`` to disable
18
- reports entirely.
19
-
20
- Puppet provides multiple report handlers that will process client reports:
21
- "