copland 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/doc/README +88 -0
  2. data/doc/manual-html/chapter-1.html +454 -0
  3. data/doc/manual-html/chapter-10.html +399 -0
  4. data/doc/manual-html/chapter-11.html +600 -0
  5. data/doc/manual-html/chapter-12.html +406 -0
  6. data/doc/manual-html/chapter-2.html +382 -0
  7. data/doc/manual-html/chapter-3.html +424 -0
  8. data/doc/manual-html/chapter-4.html +432 -0
  9. data/doc/manual-html/chapter-5.html +381 -0
  10. data/doc/manual-html/chapter-6.html +364 -0
  11. data/doc/manual-html/chapter-7.html +434 -0
  12. data/doc/manual-html/chapter-8.html +373 -0
  13. data/doc/manual-html/chapter-9.html +324 -0
  14. data/doc/manual-html/copland.png +0 -0
  15. data/doc/manual-html/index.html +331 -0
  16. data/doc/manual-html/manual.css +179 -0
  17. data/doc/manual-html/tutorial-1.html +407 -0
  18. data/doc/manual-html/tutorial-2.html +451 -0
  19. data/doc/manual-html/tutorial-3.html +484 -0
  20. data/doc/manual-html/tutorial-4.html +446 -0
  21. data/doc/manual-html/tutorial-5.html +520 -0
  22. data/doc/manual/chapter.erb +18 -0
  23. data/doc/manual/example.erb +18 -0
  24. data/doc/manual/img/copland.png +0 -0
  25. data/doc/manual/index.erb +30 -0
  26. data/doc/manual/manual.css +179 -0
  27. data/doc/manual/manual.rb +239 -0
  28. data/doc/manual/manual.yml +2643 -0
  29. data/doc/manual/page.erb +102 -0
  30. data/doc/manual/tutorial.erb +30 -0
  31. data/doc/packages/copland.html +764 -0
  32. data/doc/packages/copland.lib.html +439 -0
  33. data/doc/packages/copland.remote.html +2096 -0
  34. data/doc/packages/copland.webrick.html +925 -0
  35. data/doc/packages/index.html +49 -0
  36. data/doc/packages/packrat.css +125 -0
  37. data/examples/calc/calc.rb +47 -0
  38. data/examples/calc/package.yml +35 -0
  39. data/examples/calc/services.rb +74 -0
  40. data/examples/solitaire-cipher/README +11 -0
  41. data/examples/solitaire-cipher/Rakefile +57 -0
  42. data/examples/solitaire-cipher/bin/main.rb +14 -0
  43. data/examples/solitaire-cipher/lib/cipher.rb +230 -0
  44. data/examples/solitaire-cipher/lib/cli.rb +24 -0
  45. data/examples/solitaire-cipher/lib/package.yml +106 -0
  46. data/examples/solitaire-cipher/test/tc_deck.rb +30 -0
  47. data/examples/solitaire-cipher/test/tc_key-stream.rb +19 -0
  48. data/examples/solitaire-cipher/test/tc_keying-algorithms.rb +31 -0
  49. data/examples/solitaire-cipher/test/tc_solitaire-cipher.rb +66 -0
  50. data/examples/solitaire-cipher/test/tc_unkeyed-algorithm.rb +17 -0
  51. data/examples/solitaire-cipher/test/tests.rb +2 -0
  52. data/lib/copland.rb +56 -0
  53. data/lib/copland/class-factory.rb +95 -0
  54. data/lib/copland/configuration-point.rb +38 -0
  55. data/lib/copland/configuration-point/common.rb +203 -0
  56. data/lib/copland/configuration-point/errors.rb +44 -0
  57. data/lib/copland/configuration-point/list.rb +59 -0
  58. data/lib/copland/configuration-point/map.rb +59 -0
  59. data/lib/copland/configuration/errors.rb +43 -0
  60. data/lib/copland/configuration/loader.rb +113 -0
  61. data/lib/copland/configuration/yaml/configuration-point.rb +87 -0
  62. data/lib/copland/configuration/yaml/implementor.rb +134 -0
  63. data/lib/copland/configuration/yaml/interceptor.rb +63 -0
  64. data/lib/copland/configuration/yaml/listener.rb +56 -0
  65. data/lib/copland/configuration/yaml/loader.rb +122 -0
  66. data/lib/copland/configuration/yaml/package.rb +125 -0
  67. data/lib/copland/configuration/yaml/parser.rb +71 -0
  68. data/lib/copland/configuration/yaml/schema.rb +165 -0
  69. data/lib/copland/configuration/yaml/service-point.rb +116 -0
  70. data/lib/copland/configuration/yaml/utils.rb +82 -0
  71. data/lib/copland/default-schema-processor.rb +144 -0
  72. data/lib/copland/errors.rb +82 -0
  73. data/lib/copland/event-producer.rb +95 -0
  74. data/lib/copland/impl/builder-factory.rb +112 -0
  75. data/lib/copland/impl/copland-config.yml +1 -0
  76. data/lib/copland/impl/include-exclude.rb +140 -0
  77. data/lib/copland/impl/logging-interceptor.rb +106 -0
  78. data/lib/copland/impl/package.yml +217 -0
  79. data/lib/copland/impl/startup.rb +116 -0
  80. data/lib/copland/impl/symbol-source-manager.rb +131 -0
  81. data/lib/copland/impl/symbol-source.rb +63 -0
  82. data/lib/copland/instantiator.rb +38 -0
  83. data/lib/copland/instantiator/abstract.rb +91 -0
  84. data/lib/copland/instantiator/complex.rb +96 -0
  85. data/lib/copland/instantiator/identity.rb +58 -0
  86. data/lib/copland/instantiator/simple.rb +68 -0
  87. data/lib/copland/interceptor-chain.rb +166 -0
  88. data/lib/copland/interceptor.rb +139 -0
  89. data/lib/copland/log-factory.rb +206 -0
  90. data/lib/copland/models.rb +39 -0
  91. data/lib/copland/models/abstract.rb +78 -0
  92. data/lib/copland/models/prototype-deferred.rb +58 -0
  93. data/lib/copland/models/prototype.rb +58 -0
  94. data/lib/copland/models/proxy.rb +100 -0
  95. data/lib/copland/models/singleton-deferred.rb +59 -0
  96. data/lib/copland/models/singleton.rb +77 -0
  97. data/lib/copland/models/threaded.rb +65 -0
  98. data/lib/copland/ordering.rb +123 -0
  99. data/lib/copland/package.rb +246 -0
  100. data/lib/copland/registry.rb +368 -0
  101. data/lib/copland/schema.rb +206 -0
  102. data/lib/copland/service-point.rb +282 -0
  103. data/lib/copland/utils.rb +221 -0
  104. data/lib/copland/version.rb +47 -0
  105. data/test/conf-test/list-bad-key.yml +30 -0
  106. data/test/conf-test/list-bad-missing.yml +28 -0
  107. data/test/conf-test/list-bad-type.yml +28 -0
  108. data/test/conf-test/list-good.yml +29 -0
  109. data/test/conf-test/map-bad-key.yml +25 -0
  110. data/test/conf-test/map-bad-missing.yml +24 -0
  111. data/test/conf-test/map-bad-type.yml +23 -0
  112. data/test/conf-test/map-good.yml +25 -0
  113. data/test/configuration-point/package.yml +52 -0
  114. data/test/configuration/yaml/config/copland-config.yml +2 -0
  115. data/test/configuration/yaml/config/module.yml +2 -0
  116. data/test/configuration/yaml/config/subdir/copland-config.yml +2 -0
  117. data/test/configuration/yaml/config/subdir/package.yml +4 -0
  118. data/test/configuration/yaml/defaults/package.yml +5 -0
  119. data/test/configuration/yaml/defaults/subdir/package.yml +4 -0
  120. data/test/configuration/yaml/tc_config-loader.rb +86 -0
  121. data/test/configuration/yaml/tc_configuration-point-processor.rb +134 -0
  122. data/test/configuration/yaml/tc_implementor-processor.rb +104 -0
  123. data/test/configuration/yaml/tc_interceptor-processor.rb +85 -0
  124. data/test/configuration/yaml/tc_listener-processor.rb +69 -0
  125. data/test/configuration/yaml/tc_loader.rb +74 -0
  126. data/test/configuration/yaml/tc_package-processor.rb +120 -0
  127. data/test/configuration/yaml/tc_parser.rb +94 -0
  128. data/test/configuration/yaml/tc_schema-parser.rb +160 -0
  129. data/test/configuration/yaml/tc_service-point-processor.rb +104 -0
  130. data/test/configuration/yaml/tc_type-validator.rb +90 -0
  131. data/test/custom-logger.yml +3 -0
  132. data/test/impl/logging/package.yml +44 -0
  133. data/test/impl/logging/services.rb +84 -0
  134. data/test/impl/startup/package.yml +46 -0
  135. data/test/impl/startup/services.rb +47 -0
  136. data/test/impl/symbols/package.yml +24 -0
  137. data/test/impl/symbols/services.rb +38 -0
  138. data/test/impl/tc_builder-factory.rb +173 -0
  139. data/test/impl/tc_logging-interceptor.rb +148 -0
  140. data/test/impl/tc_startup.rb +59 -0
  141. data/test/impl/tc_symbol-sources.rb +61 -0
  142. data/test/logger.yml +6 -0
  143. data/test/mock.rb +201 -0
  144. data/test/schema/bad-package.yml +65 -0
  145. data/test/schema/package.yml +102 -0
  146. data/test/schema/services.rb +5 -0
  147. data/test/services/package.yml +79 -0
  148. data/test/services/simple.rb +87 -0
  149. data/test/tc_class-factory.rb +93 -0
  150. data/test/tc_complex-instantiator.rb +107 -0
  151. data/test/tc_configuration-point-contrib.rb +74 -0
  152. data/test/tc_configuration-point-schema.rb +122 -0
  153. data/test/tc_configuration-point.rb +91 -0
  154. data/test/tc_default-schema-processor.rb +297 -0
  155. data/test/tc_identity-instantiator.rb +61 -0
  156. data/test/tc_interceptors.rb +84 -0
  157. data/test/tc_logger.rb +131 -0
  158. data/test/tc_models.rb +176 -0
  159. data/test/tc_package.rb +165 -0
  160. data/test/tc_proxy.rb +65 -0
  161. data/test/tc_registry.rb +141 -0
  162. data/test/tc_schema.rb +78 -0
  163. data/test/tc_service-point.rb +178 -0
  164. data/test/tc_service.rb +70 -0
  165. data/test/tc_simple-instantiator.rb +61 -0
  166. data/test/tests.rb +93 -0
  167. data/tutorial/01/main.rb +7 -0
  168. data/tutorial/01/package.yml +8 -0
  169. data/tutorial/01/tutorial.rb +7 -0
  170. data/tutorial/02/main.rb +10 -0
  171. data/tutorial/02/package.yml +27 -0
  172. data/tutorial/02/tutorial.rb +46 -0
  173. data/tutorial/03/main.rb +24 -0
  174. data/tutorial/03/package.yml +29 -0
  175. data/tutorial/03/tutorial.rb +48 -0
  176. data/tutorial/04/main.rb +24 -0
  177. data/tutorial/04/package.yml +35 -0
  178. data/tutorial/04/tutorial.rb +48 -0
  179. data/tutorial/05/functions/package.yml +16 -0
  180. data/tutorial/05/functions/services.rb +15 -0
  181. data/tutorial/05/main.rb +10 -0
  182. data/tutorial/05/package.yml +35 -0
  183. data/tutorial/05/tutorial.rb +53 -0
  184. metadata +260 -0
@@ -0,0 +1,6 @@
1
+ filename: ./sample.log
2
+ default-format: "%Y-%m-%d %H:%M:%S"
3
+ default-level: INFO
4
+ levels:
5
+ level.*: WARN
6
+ level.test.*: DEBUG
@@ -0,0 +1,201 @@
1
+ #--
2
+ # =============================================================================
3
+ # Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
4
+ # All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are met:
8
+ #
9
+ # * Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ #
12
+ # * Redistributions in binary form must reproduce the above copyright
13
+ # notice, this list of conditions and the following disclaimer in the
14
+ # documentation and/or other materials provided with the distribution.
15
+ #
16
+ # * The names of its contributors may not be used to endorse or promote
17
+ # products derived from this software without specific prior written
18
+ # permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+ # POSSIBILITY OF SUCH DAMAGE.
31
+ # =============================================================================
32
+ #++
33
+
34
+ require 'copland/class-factory'
35
+
36
+ class Factory
37
+ def initialize( pool )
38
+ @pool = pool
39
+ @factory = Copland::ClassFactory.instance
40
+ end
41
+
42
+ def get( *args )
43
+ @factory.get( @pool, *args )
44
+ end
45
+ end
46
+
47
+ class MockPackage
48
+ attr_reader :registry
49
+
50
+ def initialize( registry )
51
+ @registry = registry
52
+ end
53
+
54
+ def add_service_point( point )
55
+ ( @svc_points ||= Hash.new )[ point.name ] = point
56
+ end
57
+
58
+ def add_schema( schema )
59
+ end
60
+
61
+ def name
62
+ "test"
63
+ end
64
+
65
+ def service( name )
66
+ @svc_points[ name ].instance
67
+ end
68
+
69
+ def service_point( name )
70
+ @svc_points[ name ]
71
+ end
72
+ end
73
+
74
+ class MockService
75
+ def initialize( message )
76
+ @message = message
77
+ @message.gsub!( /^.*$/, "initialized!" )
78
+ end
79
+
80
+ def noop
81
+ true
82
+ end
83
+ end
84
+
85
+ class MockServicePoint
86
+ attr_reader :pending_interceptors
87
+ attr_reader :event_producers
88
+ attr_reader :listeners
89
+ attr_reader :schema
90
+ attr_reader :owner
91
+
92
+ attr_accessor :instantiator
93
+ attr_accessor :parameter_processor
94
+
95
+ def initialize( message="" )
96
+ @message = message
97
+ @pending_interceptors = []
98
+ @event_producers = []
99
+ @listeners = []
100
+ end
101
+
102
+ def instance
103
+ instantiate
104
+ end
105
+
106
+ def instantiate
107
+ MockService.new( @message )
108
+ end
109
+
110
+ def name
111
+ "point"
112
+ end
113
+
114
+ def full_name
115
+ "mock.service." + name
116
+ end
117
+
118
+ def add_event_producer( a )
119
+ @event_producers.push a
120
+ end
121
+
122
+ def add_pending_interceptor( a )
123
+ @pending_interceptors.push a
124
+ end
125
+ end
126
+
127
+ class MockConfigurationPoint
128
+ def name
129
+ "point"
130
+ end
131
+
132
+ def full_name
133
+ "mock.service." + name
134
+ end
135
+
136
+ def contribute( value )
137
+ end
138
+
139
+ def fixate!
140
+ end
141
+
142
+ def fixated?
143
+ false
144
+ end
145
+ end
146
+
147
+ class MockRegistry
148
+ attr_reader :packages
149
+
150
+ def initialize
151
+ @packages = Hash.new
152
+ end
153
+
154
+ def add_package( pkg )
155
+ @packages[ pkg.name ] = pkg
156
+ end
157
+
158
+ def package( name )
159
+ @packages[ name ]
160
+ end
161
+
162
+ def service( name )
163
+ pkg, name = name.match( /(.*)\.([^\.]*)/ )[1,2]
164
+ @packages[ pkg ].service( name )
165
+ end
166
+
167
+ def fixated?
168
+ false
169
+ end
170
+
171
+ def fixate!
172
+ end
173
+ end
174
+
175
+ class MockLogIO
176
+ attr_reader :message
177
+
178
+ def initialize
179
+ clear
180
+ end
181
+
182
+ def write( message )
183
+ @message << message << "\n"
184
+ end
185
+
186
+ def clear
187
+ @message = ""
188
+ end
189
+
190
+ def close
191
+ @message = "<closed>"
192
+ end
193
+ end
194
+
195
+ class MockLoader
196
+ attr_reader :used
197
+
198
+ def use_library( library )
199
+ ( @used ||= [] ).push library
200
+ end
201
+ end
@@ -0,0 +1,65 @@
1
+ ---
2
+ id: test
3
+
4
+ configuration-points:
5
+
6
+ Test1:
7
+ type: map
8
+ schema:
9
+ name: Alpha
10
+ definition:
11
+ a:
12
+ name: Bravo
13
+ definition:
14
+ b:
15
+ type: string
16
+ c:
17
+ type: string
18
+ d:
19
+ type: string
20
+
21
+ Test2:
22
+ type: map
23
+ schema: Alpha
24
+
25
+ Test3:
26
+ type: map
27
+ schema:
28
+ definition:
29
+ e: Alpha
30
+ f: Bravo
31
+ g:
32
+ definition:
33
+ h: Bravo
34
+ i:
35
+ type: string
36
+
37
+ contributions:
38
+
39
+ Test1:
40
+ a:
41
+ b: but soft!
42
+ c: what light through yonder window breaks?
43
+ d: it is the east,
44
+
45
+ Test2:
46
+ a:
47
+ b: and juliet is the sun.
48
+ c: arise,
49
+ d: fair sun,
50
+
51
+ Test3:
52
+ e:
53
+ a:
54
+ b: and kill the envious moon,
55
+ c: which is pale and sick with grief that thou her maid art far more fair than she.
56
+ d: be not her maid,
57
+ f:
58
+ b: for she is envious.
59
+ c: her vestal livery is but sick and green,
60
+ g:
61
+ h:
62
+ b: and none but fools do wear it.
63
+ c: cast it off!
64
+ bogus: die die die!
65
+ i: she is my lady, she is my love...
@@ -0,0 +1,102 @@
1
+ ---
2
+ id: test
3
+
4
+ configuration-points:
5
+
6
+ Test1:
7
+ type: map
8
+ schema:
9
+ name: Alpha
10
+ definition:
11
+ a:
12
+ name: Bravo
13
+ definition:
14
+ b:
15
+ type: string
16
+ c:
17
+ type: string
18
+ d:
19
+ type: string
20
+
21
+ Test2:
22
+ type: map
23
+ schema: Alpha
24
+
25
+ Test3:
26
+ type: map
27
+ schema:
28
+ definition:
29
+ e: Alpha
30
+ f: Bravo
31
+ g:
32
+ definition:
33
+ h: Bravo
34
+ i:
35
+ type: string
36
+
37
+ Test4:
38
+ type: map
39
+ schema:
40
+ extend: Bravo
41
+ definition:
42
+ d:
43
+ type: string
44
+
45
+ service-points:
46
+
47
+ Object:
48
+ implementor: schema/services/SchemaObject
49
+ schema:
50
+ definition:
51
+ e: Alpha
52
+ f: Bravo
53
+ g:
54
+ definition:
55
+ h: Bravo
56
+ i:
57
+ type: string
58
+
59
+ Object2:
60
+ model: prototype
61
+ implementor:
62
+ factory: Object
63
+ e:
64
+ a:
65
+ c: test
66
+ g:
67
+ h:
68
+ b: friend
69
+
70
+ contributions:
71
+
72
+ Test1:
73
+ a:
74
+ b: but soft!
75
+ c: what light through yonder window breaks?
76
+ d: it is the east,
77
+
78
+ Test2:
79
+ a:
80
+ b: and juliet is the sun.
81
+ c: arise,
82
+ d: fair sun,
83
+
84
+ Test3:
85
+ e:
86
+ a:
87
+ b: and kill the envious moon,
88
+ c: which is pale and sick with grief that thou her maid art far more fair than she.
89
+ d: be not her maid,
90
+ f:
91
+ b: for she is envious.
92
+ c: her vestal livery is but sick and green,
93
+ g:
94
+ h:
95
+ b: and none but fools do wear it.
96
+ c: cast it off!
97
+ i: she is my lady, she is my love.
98
+
99
+ Test4:
100
+ b: oh, that she knew she were!
101
+ c: Two of the fairest stars in all the heavens,
102
+ d: having some business, ...
@@ -0,0 +1,5 @@
1
+ class SchemaObject
2
+ def create_instance( point, parms )
3
+ return { :point => point, :parms => parms }
4
+ end
5
+ end
@@ -0,0 +1,79 @@
1
+ ---
2
+ id: service-test
3
+ description: >-
4
+ A simple package for unit-testing various features of services.
5
+
6
+ configuration-points:
7
+
8
+ Messages:
9
+ type: list
10
+
11
+ service-points:
12
+
13
+ Simple:
14
+ implementor: services/simple/Simple
15
+ model: singleton
16
+
17
+ Producer:
18
+ implementor: services/simple/Producer
19
+ model: singleton
20
+
21
+ Listener:
22
+ implementor: services/simple/Listener
23
+ model: singleton
24
+ listen-to:
25
+ - Producer
26
+ - copland.Registry
27
+
28
+ InterceptorA:
29
+ implementor:
30
+ class: services/simple/SimpleInterceptorFactory
31
+ properties:
32
+ messages: !!configuration Messages
33
+ type: A
34
+
35
+ InterceptorB:
36
+ implementor:
37
+ class: services/simple/SimpleInterceptorFactory
38
+ properties:
39
+ messages: !!configuration Messages
40
+ type: B
41
+
42
+ InterceptorC:
43
+ implementor:
44
+ class: services/simple/SimpleInterceptorFactory
45
+ properties:
46
+ messages: !!configuration Messages
47
+ type: C
48
+
49
+
50
+ Intercepted1:
51
+ implementor: services/simple/Simple
52
+ interceptors:
53
+ - service: service-test.InterceptorA
54
+
55
+ InterceptorOrderingError1:
56
+ implementor: services/simple/Simple
57
+ interceptors:
58
+ - service: service-test.InterceptorA
59
+ before: service-test.InterceptorB
60
+ - service: service-test.InterceptorB
61
+ before: service-test.InterceptorA
62
+
63
+ InterceptorOrderingError2:
64
+ implementor: services/simple/Simple
65
+ interceptors:
66
+ - service: service-test.InterceptorA
67
+ after: service-test.InterceptorB
68
+ - service: service-test.InterceptorB
69
+ after: service-test.InterceptorA
70
+
71
+ InterceptorOrdering1:
72
+ implementor: services/simple/Simple
73
+ interceptors:
74
+ - service: service-test.InterceptorA
75
+ after: service-test.InterceptorB
76
+ - service: service-test.InterceptorB
77
+ after: service-test.InterceptorC
78
+ - service: service-test.InterceptorC
79
+ before: service-test.InterceptorA