nucleon 0.1.19 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/Gemfile.lock +1 -0
  4. data/TODO.rdoc +0 -3
  5. data/VERSION +1 -1
  6. data/bin/nucleon +19 -0
  7. data/lib/core/config.rb +11 -7
  8. data/lib/core/environment.rb +338 -0
  9. data/lib/core/facade.rb +150 -98
  10. data/lib/core/manager.rb +160 -249
  11. data/lib/core/mixin/action/project.rb +2 -2
  12. data/lib/core/mixin/macro/plugin_interface.rb +11 -11
  13. data/lib/core/plugin/action.rb +277 -24
  14. data/lib/core/plugin/base.rb +22 -14
  15. data/lib/core/plugin/command.rb +1 -1
  16. data/lib/core/plugin/event.rb +3 -3
  17. data/lib/core/plugin/extension.rb +1 -1
  18. data/lib/core/plugin/project.rb +15 -15
  19. data/lib/core/plugin/template.rb +1 -1
  20. data/lib/core/plugin/translator.rb +1 -1
  21. data/lib/core/util/cache.rb +1 -1
  22. data/lib/core/util/cli.rb +32 -3
  23. data/lib/core/util/console.rb +30 -10
  24. data/lib/core/util/data.rb +11 -3
  25. data/lib/core/util/logger.rb +1 -1
  26. data/lib/core/util/shell.rb +6 -3
  27. data/lib/core/util/ssh.rb +148 -24
  28. data/lib/nucleon/action/extract.rb +11 -4
  29. data/lib/nucleon/action/{add.rb → project/add.rb} +13 -4
  30. data/lib/nucleon/action/{create.rb → project/create.rb} +12 -3
  31. data/lib/nucleon/action/{remove.rb → project/remove.rb} +11 -2
  32. data/lib/nucleon/action/{save.rb → project/save.rb} +11 -2
  33. data/lib/nucleon/action/{update.rb → project/update.rb} +11 -2
  34. data/lib/nucleon/command/bash.rb +1 -1
  35. data/lib/nucleon/event/regex.rb +1 -1
  36. data/lib/nucleon/project/git.rb +3 -3
  37. data/lib/nucleon/template/{json.rb → JSON.rb} +1 -1
  38. data/lib/nucleon/template/{yaml.rb → YAML.rb} +1 -1
  39. data/lib/nucleon/template/wrapper.rb +1 -1
  40. data/lib/nucleon/translator/{json.rb → JSON.rb} +1 -1
  41. data/lib/nucleon/translator/{yaml.rb → YAML.rb} +1 -1
  42. data/lib/nucleon_base.rb +26 -15
  43. data/locales/en.yml +69 -44
  44. data/nucleon.gemspec +129 -11
  45. data/rdoc/site/0.1.19/ARCHITECTURE_rdoc.html +634 -0
  46. data/rdoc/site/0.1.19/Hash.html +347 -0
  47. data/rdoc/site/0.1.19/Kernel.html +413 -0
  48. data/rdoc/site/0.1.19/Nucleon.html +570 -0
  49. data/rdoc/site/0.1.19/Nucleon/Action.html +280 -0
  50. data/rdoc/site/0.1.19/Nucleon/Action/Add.html +458 -0
  51. data/rdoc/site/0.1.19/Nucleon/Action/Create.html +415 -0
  52. data/rdoc/site/0.1.19/Nucleon/Action/Extract.html +413 -0
  53. data/rdoc/site/0.1.19/Nucleon/Action/Remove.html +461 -0
  54. data/rdoc/site/0.1.19/Nucleon/Action/Save.html +434 -0
  55. data/rdoc/site/0.1.19/Nucleon/Action/Update.html +381 -0
  56. data/rdoc/site/0.1.19/Nucleon/Codes.html +563 -0
  57. data/rdoc/site/0.1.19/Nucleon/Command.html +275 -0
  58. data/rdoc/site/0.1.19/Nucleon/Command/Bash.html +544 -0
  59. data/rdoc/site/0.1.19/Nucleon/Config.html +1623 -0
  60. data/rdoc/site/0.1.19/Nucleon/Config/Collection.html +509 -0
  61. data/rdoc/site/0.1.19/Nucleon/Config/Options.html +489 -0
  62. data/rdoc/site/0.1.19/Nucleon/Core.html +635 -0
  63. data/rdoc/site/0.1.19/Nucleon/Errors.html +275 -0
  64. data/rdoc/site/0.1.19/Nucleon/Errors/BatchError.html +281 -0
  65. data/rdoc/site/0.1.19/Nucleon/Errors/NucleonError.html +657 -0
  66. data/rdoc/site/0.1.19/Nucleon/Errors/SSHUnavailable.html +281 -0
  67. data/rdoc/site/0.1.19/Nucleon/Event.html +275 -0
  68. data/rdoc/site/0.1.19/Nucleon/Event/Regex.html +467 -0
  69. data/rdoc/site/0.1.19/Nucleon/Facade.html +2336 -0
  70. data/rdoc/site/0.1.19/Nucleon/Gems.html +635 -0
  71. data/rdoc/site/0.1.19/Nucleon/Manager.html +1828 -0
  72. data/rdoc/site/0.1.19/Nucleon/Mixin.html +284 -0
  73. data/rdoc/site/0.1.19/Nucleon/Mixin/Action.html +277 -0
  74. data/rdoc/site/0.1.19/Nucleon/Mixin/Action/Commit.html +381 -0
  75. data/rdoc/site/0.1.19/Nucleon/Mixin/Action/Project.html +395 -0
  76. data/rdoc/site/0.1.19/Nucleon/Mixin/Action/Push.html +371 -0
  77. data/rdoc/site/0.1.19/Nucleon/Mixin/Colors.html +545 -0
  78. data/rdoc/site/0.1.19/Nucleon/Mixin/ConfigCollection.html +481 -0
  79. data/rdoc/site/0.1.19/Nucleon/Mixin/ConfigOptions.html +449 -0
  80. data/rdoc/site/0.1.19/Nucleon/Mixin/Macro.html +276 -0
  81. data/rdoc/site/0.1.19/Nucleon/Mixin/Macro/ObjectInterface.html +695 -0
  82. data/rdoc/site/0.1.19/Nucleon/Mixin/Macro/PluginInterface.html +682 -0
  83. data/rdoc/site/0.1.19/Nucleon/Mixin/Settings.html +481 -0
  84. data/rdoc/site/0.1.19/Nucleon/Mixin/SubConfig.html +887 -0
  85. data/rdoc/site/0.1.19/Nucleon/Parallel.html +325 -0
  86. data/rdoc/site/0.1.19/Nucleon/Parallel/ClassMethods.html +325 -0
  87. data/rdoc/site/0.1.19/Nucleon/Parallel/InstanceMethods.html +334 -0
  88. data/rdoc/site/0.1.19/Nucleon/Plugin.html +282 -0
  89. data/rdoc/site/0.1.19/Nucleon/Plugin/Action.html +1368 -0
  90. data/rdoc/site/0.1.19/Nucleon/Plugin/Action/Option.html +459 -0
  91. data/rdoc/site/0.1.19/Nucleon/Plugin/Base.html +1737 -0
  92. data/rdoc/site/0.1.19/Nucleon/Plugin/Command.html +721 -0
  93. data/rdoc/site/0.1.19/Nucleon/Plugin/Event.html +442 -0
  94. data/rdoc/site/0.1.19/Nucleon/Plugin/Extension.html +281 -0
  95. data/rdoc/site/0.1.19/Nucleon/Plugin/Project.html +2864 -0
  96. data/rdoc/site/0.1.19/Nucleon/Plugin/Template.html +476 -0
  97. data/rdoc/site/0.1.19/Nucleon/Plugin/Translator.html +371 -0
  98. data/rdoc/site/0.1.19/Nucleon/Project.html +276 -0
  99. data/rdoc/site/0.1.19/Nucleon/Project/Git.html +1801 -0
  100. data/rdoc/site/0.1.19/Nucleon/Project/Github.html +549 -0
  101. data/rdoc/site/0.1.19/Nucleon/Template.html +277 -0
  102. data/rdoc/site/0.1.19/Nucleon/Template/Json.html +329 -0
  103. data/rdoc/site/0.1.19/Nucleon/Template/Wrapper.html +329 -0
  104. data/rdoc/site/0.1.19/Nucleon/Template/Yaml.html +329 -0
  105. data/rdoc/site/0.1.19/Nucleon/Translator.html +276 -0
  106. data/rdoc/site/0.1.19/Nucleon/Translator/Json.html +366 -0
  107. data/rdoc/site/0.1.19/Nucleon/Translator/Yaml.html +366 -0
  108. data/rdoc/site/0.1.19/Nucleon/Util.html +285 -0
  109. data/rdoc/site/0.1.19/Nucleon/Util/CLI.html +388 -0
  110. data/rdoc/site/0.1.19/Nucleon/Util/CLI/Parser.html +1183 -0
  111. data/rdoc/site/0.1.19/Nucleon/Util/Cache.html +780 -0
  112. data/rdoc/site/0.1.19/Nucleon/Util/Console.html +1294 -0
  113. data/rdoc/site/0.1.19/Nucleon/Util/Data.html +1399 -0
  114. data/rdoc/site/0.1.19/Nucleon/Util/Disk.html +522 -0
  115. data/rdoc/site/0.1.19/Nucleon/Util/Git.html +361 -0
  116. data/rdoc/site/0.1.19/Nucleon/Util/Liquid.html +365 -0
  117. data/rdoc/site/0.1.19/Nucleon/Util/Logger.html +806 -0
  118. data/rdoc/site/0.1.19/Nucleon/Util/Package.html +558 -0
  119. data/rdoc/site/0.1.19/Nucleon/Util/SSH.html +910 -0
  120. data/rdoc/site/0.1.19/Nucleon/Util/SSH/Keypair.html +453 -0
  121. data/rdoc/site/0.1.19/Nucleon/Util/Shell.html +686 -0
  122. data/rdoc/site/0.1.19/Nucleon/Util/Shell/Result.html +497 -0
  123. data/rdoc/site/0.1.19/README_rdoc.html +312 -0
  124. data/rdoc/site/0.1.19/TODO_rdoc.html +267 -0
  125. data/rdoc/site/0.1.19/created.rid +60 -0
  126. data/rdoc/site/0.1.19/images/add.png +0 -0
  127. data/rdoc/site/0.1.19/images/brick.png +0 -0
  128. data/rdoc/site/0.1.19/images/brick_link.png +0 -0
  129. data/rdoc/site/0.1.19/images/bug.png +0 -0
  130. data/rdoc/site/0.1.19/images/bullet_black.png +0 -0
  131. data/rdoc/site/0.1.19/images/bullet_toggle_minus.png +0 -0
  132. data/rdoc/site/0.1.19/images/bullet_toggle_plus.png +0 -0
  133. data/rdoc/site/0.1.19/images/date.png +0 -0
  134. data/rdoc/site/0.1.19/images/delete.png +0 -0
  135. data/rdoc/site/0.1.19/images/find.png +0 -0
  136. data/rdoc/site/0.1.19/images/loadingAnimation.gif +0 -0
  137. data/rdoc/site/0.1.19/images/macFFBgHack.png +0 -0
  138. data/rdoc/site/0.1.19/images/package.png +0 -0
  139. data/rdoc/site/0.1.19/images/page_green.png +0 -0
  140. data/rdoc/site/0.1.19/images/page_white_text.png +0 -0
  141. data/rdoc/site/0.1.19/images/page_white_width.png +0 -0
  142. data/rdoc/site/0.1.19/images/plugin.png +0 -0
  143. data/rdoc/site/0.1.19/images/ruby.png +0 -0
  144. data/rdoc/site/0.1.19/images/tag_blue.png +0 -0
  145. data/rdoc/site/0.1.19/images/tag_green.png +0 -0
  146. data/rdoc/site/0.1.19/images/transparent.png +0 -0
  147. data/rdoc/site/0.1.19/images/wrench.png +0 -0
  148. data/rdoc/site/0.1.19/images/wrench_orange.png +0 -0
  149. data/rdoc/site/0.1.19/images/zoom.png +0 -0
  150. data/rdoc/site/0.1.19/index.html +311 -0
  151. data/rdoc/site/0.1.19/js/darkfish.js +155 -0
  152. data/rdoc/site/0.1.19/js/jquery.js +18 -0
  153. data/rdoc/site/0.1.19/js/navigation.js +142 -0
  154. data/rdoc/site/0.1.19/js/search.js +94 -0
  155. data/rdoc/site/0.1.19/js/search_index.js +1 -0
  156. data/rdoc/site/0.1.19/js/searcher.js +228 -0
  157. data/rdoc/site/0.1.19/rdoc.css +543 -0
  158. data/rdoc/site/0.1.19/table_of_contents.html +1541 -0
  159. metadata +140 -11
@@ -7,8 +7,9 @@ module Parallel
7
7
 
8
8
  def self.included(klass)
9
9
  if Nucleon.parallel?
10
- klass.send :include, Celluloid
11
- end
10
+ klass.send :include, Celluloid
11
+ klass.finalizer :parallel_finalize
12
+ end
12
13
  klass.send :include, InstanceMethods
13
14
  klass.extend ClassMethods
14
15
  end
@@ -16,22 +17,62 @@ module Parallel
16
17
  #---
17
18
 
18
19
  module InstanceMethods
19
- def parallel(method, split_args, *shared_args)
20
+ def parallel_finalize
21
+ # Override if needed
22
+ end
23
+
24
+ #---
25
+
26
+ def parallel(method, args, *shared_args)
27
+ results = nil
28
+
29
+ case args
30
+ when Hash
31
+ results = parallel_hash(method, args, *shared_args)
32
+ when Array, String, Symbol
33
+ results = parallel_array(method, args, *shared_args)
34
+ end
35
+ results
36
+ end
37
+
38
+ #---
39
+
40
+ def parallel_array(method, array_args, *shared_args)
20
41
  results = []
21
- split_args = [ split_args ] unless split_args.is_a?(Array)
42
+ array_args = [ array_args ] unless array_args.is_a?(Array)
22
43
 
23
44
  if Nucleon.parallel?
24
- split_args.each do |arg|
45
+ array_args.each do |arg|
25
46
  results << future.send(method, arg, *shared_args)
26
47
  end
27
48
  results.map { |future| future.value } # Wait for all to finish.
28
49
  else
29
- split_args.each do |arg|
50
+ array_args.each do |arg|
30
51
  results << send(method, arg, *shared_args)
31
52
  end
32
53
  end
33
54
  results
34
55
  end
56
+
57
+ #---
58
+
59
+ def parallel_hash(method, hash_args, *shared_args)
60
+ results = {}
61
+
62
+ if Nucleon.parallel?
63
+ hash_args.each do |key, value|
64
+ results[key] = future.send(method, key, value, *shared_args)
65
+ end
66
+ results.keys.each do |key| # Wait for all to finish.
67
+ results[key] = results[key].value
68
+ end
69
+ else
70
+ hash_args.each do |key, value|
71
+ results[key] = send(method, key, value, *shared_args)
72
+ end
73
+ end
74
+ results
75
+ end
35
76
  end
36
77
 
37
78
  #---
@@ -95,33 +136,35 @@ module Facade
95
136
 
96
137
  #---
97
138
 
98
- def manager(collection, name, klass)
99
- name = name.to_sym
100
-
101
- if collection.has_key?(name)
102
- manager = collection[name]
139
+ def manager(collection, name, klass, reset = false)
140
+ name = name.to_sym
141
+ actor_id = "#{klass}::#{name}".to_sym
142
+
143
+ if collection.has_key?(actor_id)
144
+ manager = parallel? ? Celluloid::Actor[actor_id] : collection[actor_id]
103
145
  else
104
146
  if parallel?
105
- klass.supervise_as name
106
- manager = Celluloid::Actor[name]
147
+ klass.supervise_as(actor_id, actor_id, reset)
148
+ manager = Celluloid::Actor[actor_id]
107
149
  else
108
- manager = klass.new # Managers should not have initialization parameters
150
+ manager = klass.new(actor_id, reset) # Managers should have standardized initialization parameters
109
151
  end
110
- collection[name] = manager
152
+ collection[actor_id] = manager
111
153
  end
112
- test_connection(manager)
113
- manager
154
+ test_connection(actor_id, manager)
114
155
  end
115
156
 
116
- def test_connection(manager)
157
+ def test_connection(actor_id, manager)
117
158
  if parallel?
118
159
  begin
119
160
  # Raise error if no test method found but retry for dead actors
120
161
  manager.test_connection
162
+
121
163
  rescue Celluloid::DeadActorError
122
164
  retry
123
165
  end
124
166
  end
167
+ manager
125
168
  end
126
169
 
127
170
  #-----------------------------------------------------------------------------
@@ -203,98 +246,110 @@ module Facade
203
246
  Manager.connection.namespaces
204
247
  end
205
248
 
206
- def define_namespace(*namespaces)
207
- Manager.connection.namespace(*namespaces)
208
- end
209
-
210
249
  #---
211
250
 
212
- def types
213
- Manager.connection.types
251
+ def types(namespace)
252
+ Manager.connection.types(namespace)
214
253
  end
215
254
 
216
- def define_type(type_info)
217
- Manager.connection.define_type(type_info)
255
+ def define_types(namespace, type_info)
256
+ Manager.connection.define_types(namespace, type_info)
218
257
  end
219
258
 
220
- def type_default(type)
221
- Manager.connection.type_default(type)
259
+ def type_default(namespace, plugin_type)
260
+ Manager.connection.type_default(namespace, plugin_type)
222
261
  end
223
262
 
224
263
  #---
225
264
 
265
+ def load_plugins(base_dir = nil)
266
+ base_dir = base_dir.nil? ? Dir.pwd : base_dir
267
+
268
+ search_plugins = lambda do |search_dir|
269
+ lib_dir = File.join(search_dir, 'lib')
270
+
271
+ if File.directory?(lib_dir)
272
+ logger.debug("Registering plugins at #{lib_dir}")
273
+ register(lib_dir)
274
+ end
275
+
276
+ parent_search_dir = search_dir.sub(/#{File::SEPARATOR}[^#{File::SEPARATOR}]+$/, '')
277
+ search_plugins.call(parent_search_dir) unless parent_search_dir.split(File::SEPARATOR).empty?
278
+ end
279
+
280
+ search_plugins.call(base_dir)
281
+ end
282
+
226
283
  def register(base_path, &code)
227
284
  Manager.connection.register(base_path, &code)
228
285
  Manager.connection.autoload
229
286
  end
230
287
 
231
- def loaded_plugins(type = nil, provider = nil)
232
- Manager.connection.loaded_plugins(type, provider)
288
+ def loaded_plugins(namespace = nil, plugin_type = nil, provider = nil)
289
+ Manager.connection.loaded_plugins(namespace, plugin_type, provider)
233
290
  end
234
291
 
235
292
  #---
236
293
 
237
- def active_plugins(type = nil, provider = nil)
238
- Manager.connection.plugins(type, provider)
294
+ def active_plugins(namespace = nil, plugin_type = nil, provider = nil)
295
+ Manager.connection.active_plugins(namespace, plugin_type, provider)
239
296
  end
240
297
 
241
298
  #---
242
299
 
243
- def plugin(type, provider, options = {})
244
- Manager.connection.load(type, provider, options)
300
+ def plugin(namespace, plugin_type, provider, options = {})
301
+ Manager.connection.load(namespace, plugin_type, provider, options)
245
302
  end
246
303
 
247
304
  #---
248
305
 
249
- def plugins(type, data, build_hash = false, keep_array = false)
250
- Manager.connection.load_multiple(type, data, build_hash, keep_array)
306
+ def plugins(namespace, plugin_type, data, build_hash = false, keep_array = false)
307
+ Manager.connection.load_multiple(namespace, plugin_type, data, build_hash, keep_array)
251
308
  end
252
309
 
253
310
  #---
254
311
 
255
- def create_plugin(type, provider, options = {})
256
- Manager.connection.create(type, provider, options)
312
+ def create_plugin(namespace, plugin_type, provider, options = {})
313
+ Manager.connection.create(namespace, plugin_type, provider, options)
257
314
  end
258
315
 
259
316
  #---
260
317
 
261
- def get_plugin(type, name)
262
- Manager.connection.get(type, name)
318
+ def get_plugin(namespace, plugin_type, plugin_name)
319
+ Manager.connection.get(namespace, plugin_type, plugin_name)
263
320
  end
264
321
 
265
322
  #---
266
323
 
267
- def remove_plugin(plugin)
268
- Manager.connection.remove(plugin)
324
+ def remove_plugin_by_name(namespace, plugin_type, plugin_instance_name)
325
+ Manager.connection.remove_by_name(namespace, plugin_type, plugin_instance_name)
269
326
  end
270
327
 
271
- #---
272
-
273
- def plugin_class(type)
274
- Manager.connection.plugin_class(type)
328
+ def remove_plugin(plugin)
329
+ Manager.connection.remove(plugin)
275
330
  end
276
331
 
277
332
  #---
278
333
 
279
- def provider_class(namespace, type, provider)
280
- Manager.connection.provider_class(namespace, type, provider)
334
+ def plugin_class(namespace, plugin_type)
335
+ Manager.connection.plugin_class(namespace, plugin_type)
281
336
  end
282
337
 
283
338
  #-----------------------------------------------------------------------------
284
339
  # Core plugin type facade
285
340
 
286
341
  def extension(provider)
287
- plugin(:extension, provider, {})
342
+ plugin(:nucleon, :extension, provider, {})
288
343
  end
289
344
 
290
345
  #---
291
346
 
292
347
  def action(provider, options)
293
- plugin(:action, provider, options)
348
+ plugin(:nucleon, :action, provider, options)
294
349
  end
295
350
 
296
351
  def actions(data, build_hash = false, keep_array = false)
297
- plugins(:action, data, build_hash, keep_array)
352
+ plugins(:nucleon, :action, data, build_hash, keep_array)
298
353
  end
299
354
 
300
355
  def action_config(provider)
@@ -313,55 +368,72 @@ module Facade
313
368
  Plugin::Action.exec_cli(provider, args, quiet, name)
314
369
  end
315
370
 
371
+ def search_actions(args)
372
+ action_info = Plugin::Action.search_actions(args)
373
+
374
+ action_components = action_info[:components]
375
+ action = action_info[:actions]
376
+
377
+ action_components.each do |component|
378
+ args.shift
379
+ end
380
+
381
+ [ action, action_components, args ]
382
+ end
383
+
384
+ def action_help(action = nil, extended_help = false)
385
+ Plugin::Action.action_help(action, extended_help)
386
+ end
387
+
316
388
  #---
317
389
 
318
390
  def project(options, provider = nil)
319
- plugin(:project, provider, options)
391
+ plugin(:nucleon, :project, provider, options)
320
392
  end
321
393
 
322
394
  def projects(data, build_hash = false, keep_array = false)
323
- plugins(:project, data, build_hash, keep_array)
395
+ plugins(:nucleon, :project, data, build_hash, keep_array)
324
396
  end
325
397
 
326
398
  #-----------------------------------------------------------------------------
327
399
  # Utility plugin type facade
328
400
 
329
401
  def command(options, provider = nil)
330
- plugin(:command, provider, options)
402
+ plugin(:nucleon, :command, provider, options)
331
403
  end
332
404
 
333
405
  def commands(data, build_hash = false, keep_array = false)
334
- plugins(:command, data, build_hash, keep_array)
406
+ plugins(:nucleon, :command, data, build_hash, keep_array)
335
407
  end
336
408
 
337
409
  #---
338
410
 
339
411
  def event(options, provider = nil)
340
- plugin(:event, provider, options)
412
+ plugin(:nucleon, :event, provider, options)
341
413
  end
342
414
 
343
415
  def events(data, build_hash = false, keep_array = false)
344
- plugins(:event, data, build_hash, keep_array)
416
+ plugins(:nucleon, :event, data, build_hash, keep_array)
345
417
  end
346
418
 
347
419
  #---
348
420
 
349
421
  def template(options, provider = nil)
350
- plugin(:template, provider, options)
422
+ plugin(:nucleon, :template, provider, options)
351
423
  end
352
424
 
353
425
  def templates(data, build_hash = false, keep_array = false)
354
- plugins(:template, data, build_hash, keep_array)
426
+ plugins(:nucleon, :template, data, build_hash, keep_array)
355
427
  end
356
428
 
357
429
  #---
358
430
 
359
431
  def translator(options, provider = nil)
360
- plugin(:translator, provider, options)
432
+ plugin(:nucleon, :translator, provider, options)
361
433
  end
362
434
 
363
435
  def translators(data, build_hash = false, keep_array = false)
364
- plugins(:translator, data, build_hash, keep_array)
436
+ plugins(:nucleon, :translator, data, build_hash, keep_array)
365
437
  end
366
438
 
367
439
  #-----------------------------------------------------------------------------
@@ -433,62 +505,41 @@ module Facade
433
505
  #---
434
506
 
435
507
  def executable(args, name = 'nucleon') #ARGV
436
- Signal.trap("INT") { exit 1 }
437
-
438
508
  logger.info("`#{name}` invoked: #{args.inspect}")
439
509
 
440
510
  $stdout.sync = true
441
511
  $stderr.sync = true
442
512
 
443
513
  exit_status = nil
514
+
515
+ # We need to catch this early.
516
+ Util::Console.use_colors = ! args.include?("--no-color")
517
+ args = args - [ "--no-color", "--color" ]
444
518
 
445
519
  begin
446
520
  logger.debug("Beginning execution run")
447
521
 
448
- arg_components = Util::CLI::Parser.split(args, "#{name} <action> [ <arg> ... ]")
522
+ load_plugins
523
+
524
+ arg_components = Util::CLI::Parser.split(args, cyan(name) + yellow(" <action components> [<arg> ...]"))
449
525
  main_command = arg_components.shift
450
- sub_command = arg_components.shift
451
- sub_args = arg_components
452
526
 
453
- lib_dir = File.join(Dir.pwd, 'lib')
454
- if File.directory?(lib_dir)
455
- logger.debug("Registering plugins at #{lib_dir}")
456
- Nucleon.register(lib_dir)
457
- end
458
-
459
- if main_command.processed && sub_command
460
- exit_status = action_cli(sub_command, sub_args, false, name)
527
+ action, action_components, args = search_actions(args)
528
+
529
+ if main_command.processed && action.is_a?(Hash)
530
+ exit_status = action_cli(action[:provider], args, false, name)
461
531
  else
462
532
  puts I18n.t('nucleon.core.exec.help.usage') + ': ' + main_command.help + "\n"
463
- puts I18n.t('nucleon.core.exec.help.header') + ":\n\n"
533
+ puts I18n.t('nucleon.core.exec.help.header') + ":\n"
464
534
 
465
- help_data = {}
466
- extended_help = main_command.options[:extended_help]
467
-
468
- loaded_plugins(:action).each do |provider, data|
469
- namespace = data[:namespace]
470
-
471
- help_data[namespace] = {} unless help_data.has_key?(namespace)
472
- help_data[namespace][provider] = data
473
- end
535
+ action = main_command.processed ? action : nil
536
+ puts action_help(action, args.include?("--help"))
474
537
 
475
- help_data.each do |namespace, actions|
476
- actions.each do |provider, data|
477
- if extended_help
478
- help_text = action(provider, { :args => [ '-h' ], :quiet => true }).help
479
- else
480
- help_text = action(provider, { :settings => {}, :quiet => true }).help
481
- end
482
- puts sprintf(" %-15s : %s\n", namespace, help_text)
483
- end
484
- puts "\n"
485
- end
486
-
487
- puts "\n" + I18n.t('nucleon.core.exec.help.footer', { :name => name }) + "\n\n"
538
+ puts "\n" + I18n.t('nucleon.core.exec.help.footer', { :command => cyan(name) + yellow(" <action> -h") }) + "\n\n"
488
539
  exit_status = code.help_wanted
489
540
  end
490
541
 
491
- rescue Exception => error
542
+ rescue => error
492
543
  logger.error("Nucleon executable experienced an error:")
493
544
  logger.error(error.inspect)
494
545
  logger.error(error.message)
@@ -499,6 +550,7 @@ module Facade
499
550
  exit_status = error.status_code if error.respond_to?(:status_code)
500
551
  exit_status = code.unknown_status if exit_status.nil?
501
552
  end
553
+
502
554
  exit_status
503
555
  end
504
556
 
@@ -6,28 +6,40 @@ class Manager
6
6
 
7
7
  #-----------------------------------------------------------------------------
8
8
 
9
- @@supervisors = {}
9
+ @@supervisors = {}
10
+ @@environments = {}
10
11
 
11
12
  #-----------------------------------------------------------------------------
12
13
  # Plugin manager interface
13
14
 
14
- def self.connection(name = :core)
15
- Nucleon.manager(@@supervisors, name, self)
15
+ def self.connection(name = :core, reset = false)
16
+ Nucleon.manager(@@supervisors, name, self, reset)
16
17
  end
17
18
 
18
19
  #---
19
20
 
20
- def initialize
21
- @logger = Nucleon.logger
21
+ def initialize(actor_id, reset)
22
+ @logger = Nucleon.logger
23
+ @actor_id = actor_id
22
24
 
23
- @namespaces = {}
24
- @types = {}
25
- @load_info = {}
26
- @plugins = {}
25
+ if reset || ! @@environments[@actor_id]
26
+ @@environments[@actor_id] = Environment.new
27
+ end
27
28
  end
28
29
 
29
- #-----------------------------------------------------------------------------
30
- # Property accessor / modifiers
30
+ #---
31
+
32
+ def parallel_finalize
33
+ active_plugins.each do |namespace, namespace_plugins|
34
+ namespace_plugins.each do |plugin_type, type_plugins|
35
+ type_plugins.each do |instance_name, plugin|
36
+ remove(plugin)
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ #---
31
43
 
32
44
  attr_reader :logger
33
45
 
@@ -39,93 +51,81 @@ class Manager
39
51
 
40
52
  #---
41
53
 
42
- def namespaces
43
- @namespaces.keys
54
+ def test_connection
55
+ true
44
56
  end
45
57
 
46
- def define_namespace(*names)
47
- names.each do |namespace|
48
- @namespaces[namespace.to_sym] = true
49
- end
58
+ #-----------------------------------------------------------------------------
59
+ # Plugin model accessors / modifiers
60
+
61
+ def namespaces
62
+ @@environments[@actor_id].namespaces
50
63
  end
51
64
 
52
65
  #---
53
66
 
54
- def types
55
- @types.keys
67
+ def types(namespace)
68
+ @@environments[@actor_id].plugin_types(namespace)
56
69
  end
57
70
 
58
- #---
71
+ def define_type(namespace, plugin_type, default_provider)
72
+ @@environments[@actor_id].define_plugin_type(namespace, plugin_type, default_provider)
73
+ end
59
74
 
60
- def type_default(type)
61
- @types[type.to_sym]
75
+ def define_types(namespace, type_info)
76
+ @@environments[@actor_id].define_plugin_types(namespace, type_info)
62
77
  end
63
78
 
64
- #---
79
+ def type_defined?(namespace, plugin_type)
80
+ @@environments[@actor_id].plugin_type_defined?(namespace, plugin_type)
81
+ end
65
82
 
66
- def loaded_plugins(type = nil, provider = nil)
67
- results = {}
68
- type = type.to_sym if type
69
- provider = provider.to_sym if provider
70
-
71
- if type && @load_info.has_key?(type)
72
- if provider && @load_info.has_key?(provider)
73
- results = @load_info[type][provider]
74
- else
75
- results = @load_info[type]
76
- end
77
- elsif ! type
78
- results = @load_info
79
- end
80
- results
83
+ def type_default(namespace, plugin_type)
84
+ @@environments[@actor_id].plugin_type_default(namespace, plugin_type)
81
85
  end
82
-
86
+
83
87
  #---
84
88
 
85
- def plugins(type = nil, provider = nil)
86
- results = {}
87
- type = type.to_sym if type
88
- provider = provider.to_sym if provider
89
-
90
- if type && @plugins.has_key?(type)
91
- if provider && ! @plugins[type].keys.empty?
92
- @plugins[type].each do |instance_name, plugin|
93
- plugin = @plugins[type][instance_name]
94
- results[instance_name] = plugin if plugin.plugin_provider == provider
95
- end
96
- else
97
- results = @plugins[type]
98
- end
99
- elsif ! type
100
- results = @plugins
101
- end
102
- results
103
- end
89
+ def loaded_plugin(namespace, plugin_type, provider)
90
+ @@environments[@actor_id].loaded_plugin(namespace, plugin_type, provider)
91
+ end
104
92
 
105
- #-----------------------------------------------------------------------------
106
- # Operations
93
+ def loaded_plugins(namespace = nil, plugin_type = nil, provider = nil)
94
+ @@environments[@actor_id].loaded_plugins(namespace, plugin_type, provider)
95
+ end
107
96
 
108
- def test_connection
109
- true
97
+ def define_plugin(namespace, plugin_type, base_path, file, &code)
98
+ @@environments[@actor_id].define_plugin(namespace, plugin_type, base_path, file, &code)
99
+ end
100
+
101
+ def plugin_has_provider?(namespace, plugin_type, provider)
102
+ @@environments[@actor_id].plugin_has_provider?(namespace, plugin_type, provider)
110
103
  end
111
104
 
112
105
  #---
113
106
 
107
+ def active_plugins(namespace = nil, plugin_type = nil, provider = nil)
108
+ @@environments[@actor_id].active_plugins(namespace, plugin_type, provider)
109
+ end
110
+
111
+ #-----------------------------------------------------------------------------
112
+ # Plugin registration / initialization
113
+
114
114
  def reload(core = false, &code)
115
115
  logger.info("Loading Nucleon plugins at #{Time.now}")
116
116
 
117
117
  if core
118
118
  Celluloid.logger = logger if Nucleon.parallel?
119
119
 
120
- define_namespace :nucleon
121
-
122
- define_type :extension => nil, # Core
123
- :action => :update, # Core
124
- :project => :git, # Core
125
- :command => :bash, # Core
126
- :event => :regex, # Utility
127
- :template => :json, # Utility
128
- :translator => :json # Utility
120
+ define_types :nucleon, {
121
+ :extension => nil, # Core
122
+ :action => :update, # Core
123
+ :project => :git, # Core
124
+ :command => :bash, # Core
125
+ :event => :regex, # Utility
126
+ :template => :json, # Utility
127
+ :translator => :json # Utility
128
+ }
129
129
  end
130
130
 
131
131
  # Allow block level namespace and type registration
@@ -137,21 +137,6 @@ class Manager
137
137
 
138
138
  #---
139
139
 
140
- def define_type(type_info)
141
- if type_info.is_a?(Hash)
142
- logger.info("Defining plugin types at #{Time.now}")
143
-
144
- type_info.each do |type, default_provider|
145
- logger.debug("Mapping plugin type #{type} to default provider #{default_provider}")
146
- @types[type.to_sym] = default_provider
147
- end
148
- else
149
- logger.warn("Defined types must be specified as a hash to be registered properly")
150
- end
151
- end
152
-
153
- #---
154
-
155
140
  def load_plugins(core = false, &code)
156
141
  if core
157
142
  # Register core plugins
@@ -196,7 +181,7 @@ class Manager
196
181
  logger.info("Loading directories from #{base_path} at #{Time.now}")
197
182
  Dir.entries(base_path).each do |path|
198
183
  unless path.match(/^\.\.?$/)
199
- register_type(namespace, base_path, path, &code) if types.include?(path.to_sym)
184
+ register_type(namespace, base_path, path, &code) if type_defined?(namespace, path)
200
185
  end
201
186
  end
202
187
  end
@@ -211,70 +196,50 @@ class Manager
211
196
  if File.directory?(base_directory)
212
197
  logger.info("Registering #{base_directory} at #{Time.now}")
213
198
 
214
- Dir.glob(File.join(base_directory, '*.rb')).each do |file|
215
- add_build_info(namespace, plugin_type, file, &code)
199
+ Dir.glob(File.join(base_directory, '**', '*.rb')).each do |file|
200
+ define_plugin(namespace, plugin_type, base_directory, file, &code)
216
201
  end
217
202
  end
218
203
  end
219
204
  protected :register_type
220
205
 
221
- #---
222
-
223
- def add_build_info(namespace, type, file, &code)
224
- type = type.to_sym
225
-
226
- @load_info[type] = {} unless @load_info.has_key?(type)
227
-
228
- components = file.split(File::SEPARATOR)
229
- provider = components.pop.sub(/\.rb/, '').to_sym
230
- directory = components.join(File::SEPARATOR)
231
-
232
- logger.info("Loading nucleon #{type} plugin #{provider} at #{Time.now}")
233
-
234
- unless @load_info[type].has_key?(provider)
235
- data = {
236
- :namespace => namespace,
237
- :type => type,
238
- :provider => provider,
239
- :directory => directory,
240
- :file => file
241
- }
242
- code.call(data) if code
243
-
244
- logger.debug("Plugin #{type} loaded: #{data.inspect}")
245
- @load_info[type][provider] = data
246
- end
247
- end
248
- protected :add_build_info
249
-
250
206
  #---
251
207
 
252
208
  def autoload
253
209
  logger.info("Autoloading registered plugins at #{Time.now}")
254
210
 
255
- @load_info.keys.each do |type|
256
- logger.debug("Autoloading type: #{type}")
211
+ load_info = loaded_plugins
212
+
213
+ load_info.keys.each do |namespace|
214
+ load_info[namespace].keys.each do |plugin_type|
215
+ logger.debug("Autoloading type: #{plugin_type}")
257
216
 
258
- @load_info[type].each do |provider, plugin|
259
- logger.debug("Autoloading provider #{provider} at #{plugin[:directory]}")
217
+ load_info[namespace][plugin_type].each do |provider, plugin|
218
+ logger.debug("Autoloading provider #{provider} at #{plugin[:directory]}")
260
219
 
261
- nucleon_require(plugin[:directory], provider)
220
+ require plugin[:file]
221
+
222
+ load_info[namespace][plugin_type][provider][:class] = class_const(plugin[:class_components])
223
+ logger.debug("Updated #{plugin_type} #{provider} load info")
262
224
 
263
- @load_info[type][provider][:class] = provider_class(plugin[:namespace], type, provider)
264
- logger.debug("Updated #{type} #{provider} load info: #{@load_info[type][provider].inspect}")
265
-
266
- # Make sure extensions are listening from the time they are loaded
267
- load(:extension, provider, { :name => provider }) if type == :extension # Create a persistent instance
225
+ # Make sure extensions are listening from the time they are loaded
226
+ if plugin[:namespace] == :nucleon && plugin_type == :extension
227
+ # Create a persistent instance
228
+ load(plugin[:namespace], :extension, provider, { :name => provider })
229
+ end
230
+ end
268
231
  end
269
232
  end
270
233
  end
271
234
 
272
- #---
235
+ #-----------------------------------------------------------------------------
236
+ # Plugin workflow
273
237
 
274
- def load_base(type, provider, options = {})
275
- logger.info("Fetching plugin #{type} provider #{provider} at #{Time.now}")
238
+ def load_base(namespace, plugin_type, provider, options = {})
239
+ logger.info("Fetching plugin #{namespace} #{plugin_type} provider #{provider} at #{Time.now}")
276
240
 
277
- options = translate_type(type, options)
241
+ type_info = loaded_plugin(namespace, plugin_type, provider)
242
+ options = translate_type(type_info, options)
278
243
  config = Config.ensure(options)
279
244
  name = config.get(:name, nil)
280
245
  ensure_new = config.delete(:new, false)
@@ -282,7 +247,7 @@ class Manager
282
247
  if name
283
248
  logger.debug("Looking up existing instance of #{name}")
284
249
 
285
- if existing_instance = get(type, name)
250
+ if existing_instance = get(namespace, plugin_type, name)
286
251
  unless ensure_new
287
252
  config.export.each do |property_name, value|
288
253
  unless [ :name, :meta ].include?(property_name)
@@ -291,38 +256,38 @@ class Manager
291
256
  end
292
257
  existing_instance.normalize(true)
293
258
 
294
- logger.debug("Using existing instance of #{type}, #{name}")
259
+ logger.debug("Using existing instance of #{plugin_type}, #{name}")
295
260
  return existing_instance
296
261
  end
297
262
  end
298
263
  end
299
- create(type, provider, options)
264
+ create(namespace, plugin_type, provider, config)
300
265
  end
301
266
 
302
267
  #---
303
268
 
304
- def load(type, provider = nil, options = {})
305
- default_provider = type_default(type)
269
+ def load(namespace, plugin_type, provider = nil, options = {})
270
+ default_provider = type_default(namespace, plugin_type)
306
271
 
307
272
  # Allow options to override provider
308
273
  config = Config.ensure(options)
309
274
  provider = config.delete(:provider, provider)
310
275
  provider = default_provider unless provider
311
276
 
312
- load_base(type, provider, config)
277
+ load_base(namespace, plugin_type, provider, config)
313
278
  end
314
279
 
315
280
  #---
316
281
 
317
- def load_multiple(type, data, build_hash = false, keep_array = false)
318
- logger.info("Fetching multiple plugins of #{type} at #{Time.now}")
282
+ def load_multiple(namespace, plugin_type, data, build_hash = false, keep_array = false)
283
+ logger.info("Fetching multiple plugins of #{plugin_type} at #{Time.now}")
319
284
 
320
285
  group = ( build_hash ? {} : [] )
321
- klass = plugin_class(type)
322
- data = klass.build_info(type, data) if klass.respond_to?(:build_info)
286
+ klass = plugin_class(namespace, plugin_type)
287
+ data = klass.build_info(namespace, plugin_type, data) if klass.respond_to?(:build_info)
323
288
 
324
289
  data.each do |options|
325
- if plugin = load(type, options[:provider], options)
290
+ if plugin = load(namespace, plugin_type, options[:provider], options)
326
291
  if build_hash
327
292
  group[plugin.plugin_name] = plugin
328
293
  else
@@ -336,69 +301,46 @@ class Manager
336
301
 
337
302
  #---
338
303
 
339
- def create(type, provider, options = {})
340
- type = type.to_sym
341
- provider = provider.to_sym
342
-
343
- unless @types.has_key?(type)
344
- logger.warn("Plugin type #{type} creation requested but it has not been registered yet")
345
- return nil
346
- end
347
-
348
- info = @load_info[type][provider] if Util::Data.exists?(@load_info, [ type, provider ])
349
-
350
- if info
351
- logger.debug("Plugin information for #{provider} #{type} found.")
352
-
353
- instance_name = "#{provider}_" + Nucleon.sha1(options)
354
- options = translate(info[:namespace], type, provider, options)
355
-
356
- @plugins[type] = {} unless @plugins.has_key?(type)
304
+ def create(namespace, plugin_type, provider, options = {})
305
+ @@environments[@actor_id].create_plugin(namespace, plugin_type, provider, options) do |type_info, plugin_options|
306
+ logger.info("Creating new plugin #{provider} #{plugin_type}")
357
307
 
358
- unless instance_name && @plugins[type].has_key?(instance_name)
359
- info[:instance_name] = instance_name
360
- options[:meta] = Config.new(info).import(Util::Data.hash(options[:meta]))
361
-
362
- logger.info("Creating new plugin #{provider} #{type}")
363
-
364
- plugin = info[:class].new(type, provider, options)
365
-
366
- @plugins[type][instance_name] = plugin
367
- end
368
- return @plugins[type][instance_name]
308
+ plugin_options = translate(type_info, plugin_options)
309
+ plugin_options[:meta] = Config.new(type_info).import(Util::Data.hash(plugin_options[:meta]))
310
+ plugin_options
369
311
  end
370
-
371
- logger.warn("Plugin information cannot be found for plugin #{type} #{provider}")
372
- nil
373
312
  end
374
313
 
375
314
  #---
376
315
 
377
- def get(type, name)
378
- logger.info("Fetching plugin #{type} #{name}")
379
-
380
- if @plugins.has_key?(type)
381
- @plugins[type].each do |instance_name, plugin|
382
- if plugin.plugin_name.to_s == name.to_s
383
- logger.debug("Plugin #{type} #{name} found")
384
- return plugin
385
- end
386
- end
387
- end
388
- logger.debug("Plugin #{type} #{name} not found")
389
- nil
316
+ def get(namespace, plugin_type, plugin_name)
317
+ @@environments[@actor_id].get_plugin(namespace, plugin_type, plugin_name)
390
318
  end
391
319
 
392
320
  #---
393
321
 
322
+ def remove_by_name(namespace, plugin_type, plugin_instance_name)
323
+ active_instances = active_plugins(namespace, plugin_type)
324
+
325
+ if active_instances.has_key?(plugin_instance_name)
326
+ @@environments[@actor_id].remove_plugin(namespace, plugin_type, plugin_instance_name) do |plugin|
327
+ logger.debug("Removing #{plugin_type} #{plugin_instance_name}")
328
+
329
+ if plugin.respond_to?(:terminate) # For Celluloid plugins
330
+ plugin.terminate
331
+ else
332
+ plugin.remove_plugin
333
+ end
334
+ end
335
+ end
336
+ end
337
+
394
338
  def remove(plugin)
395
- if plugin && plugin.respond_to?(:plugin_type) && @plugins.has_key?(plugin.plugin_type)
396
- logger.debug("Removing #{plugin.plugin_type} #{plugin.plugin_name}")
397
- @plugins[plugin.plugin_type].delete(plugin.plugin_instance_name)
398
- plugin.remove_plugin
399
- plugin.terminate if plugin.respond_to?(:terminate) # For Celluloid plugins
400
- else
401
- logger.warn("Cannot remove plugin: #{plugin.inspect}")
339
+ begin # TODO: Figure out what do do about the plugin proxy being terminated before respond_to? method called.
340
+ if plugin && plugin.respond_to?(:plugin_type)
341
+ remove_by_name(plugin.plugin_namespace, plugin.plugin_type, plugin.plugin_instance_name)
342
+ end
343
+ rescue
402
344
  end
403
345
  end
404
346
 
@@ -408,11 +350,9 @@ class Manager
408
350
  def exec(method, options = {})
409
351
  results = nil
410
352
 
411
- if Nucleon.log_level == :hook # To save processing on rendering
412
- logger.hook("Executing extension hook #{Nucleon.blue(method)} at #{Nucleon.green(Time.now.to_s)}")
413
- end
353
+ logger.info("Executing extension hook #{Nucleon.blue(method)} at #{Nucleon.green(Time.now.to_s)}")
414
354
 
415
- extensions = plugins(:extension)
355
+ extensions = active_plugins(:nucleon, :extension)
416
356
 
417
357
  extensions.each do |name, plugin|
418
358
  provider = plugin.plugin_provider
@@ -424,7 +364,7 @@ class Manager
424
364
  results = {} if results.nil?
425
365
 
426
366
  result = plugin.send(method, options)
427
- logger.info("Completed hook #{method} at #{Time.now} with: #{result.inspect}")
367
+ logger.info("Completed hook #{method} at #{Time.now}")
428
368
 
429
369
  if block_given?
430
370
  results[provider] = yield(:process, result)
@@ -452,7 +392,7 @@ class Manager
452
392
  def config(type, options = {})
453
393
  config = Config.ensure(options)
454
394
 
455
- logger.debug("Generating #{type} extended configuration from: #{config.export.inspect}")
395
+ logger.debug("Generating #{type} extended configuration")
456
396
 
457
397
  exec("#{type}_config", Config.new(config.export)) do |op, data|
458
398
  if op == :reduce
@@ -465,8 +405,6 @@ class Manager
465
405
  end
466
406
  end
467
407
  config.delete(:extension_type)
468
-
469
- logger.debug("Final extended configuration: #{config.export.inspect}")
470
408
  config
471
409
  end
472
410
 
@@ -475,7 +413,7 @@ class Manager
475
413
  def check(method, options = {})
476
414
  config = Config.ensure(options)
477
415
 
478
- logger.debug("Checking extension #{method} given: #{config.export.inspect}")
416
+ logger.debug("Checking extension #{method}")
479
417
 
480
418
  success = exec(method, config.import({ :extension_type => :check })) do |op, data|
481
419
  if op == :reduce
@@ -496,7 +434,7 @@ class Manager
496
434
  def value(method, value, options = {})
497
435
  config = Config.ensure(options)
498
436
 
499
- logger.debug("Setting extension #{method} value given: #{value.inspect}")
437
+ logger.debug("Setting extension #{method} value")
500
438
 
501
439
  exec(method, config.import({ :value => value, :extension_type => :value })) do |op, data|
502
440
  if op == :process
@@ -530,72 +468,45 @@ class Manager
530
468
  #-----------------------------------------------------------------------------
531
469
  # Utilities
532
470
 
533
- def translate_type(type, options)
534
- klass = plugin_class(type)
535
- logger.debug("Executing option translation for: #{klass.inspect}")
471
+ def translate_type(type_info, options)
472
+ if type_info
473
+ klass = plugin_class(type_info[:namespace], type_info[:type])
474
+ logger.debug("Executing option translation for: #{klass.inspect}")
536
475
 
537
- options = klass.send(:translate, options) if klass.respond_to?(:translate)
476
+ options = klass.send(:translate, options) if klass.respond_to?(:translate)
477
+ end
538
478
  options
539
479
  end
540
480
 
541
481
  #---
542
482
 
543
- def translate(namespace, type, provider, options)
544
- klass = provider_class(namespace, type, provider)
545
- logger.debug("Executing option translation for: #{klass.inspect}")
483
+ def translate(type_info, options)
484
+ if type_info
485
+ klass = type_info[:class]
486
+
487
+ logger.debug("Executing option translation for: #{klass.inspect}")
546
488
 
547
- options = klass.send(:translate, options) if klass.respond_to?(:translate)
489
+ options = klass.send(:translate, options) if klass.respond_to?(:translate)
490
+ end
548
491
  options
549
492
  end
550
493
 
551
494
  #---
552
495
 
553
496
  def class_name(name, separator = '::', want_array = FALSE)
554
- components = []
555
-
556
- case name
557
- when String, Symbol
558
- components = name.to_s.split(separator)
559
- when Array
560
- components = name
561
- end
562
-
563
- components.collect! do |value|
564
- value = value.to_s.strip
565
- value[0] = value.capitalize[0] if value =~ /^[a-z]/
566
- value
567
- end
568
-
569
- if want_array
570
- return components
571
- end
572
- components.join(separator)
497
+ @@environments[@actor_id].class_name(name, separator, want_array)
573
498
  end
574
499
 
575
500
  #---
576
501
 
577
502
  def class_const(name, separator = '::')
578
- components = class_name(name, separator, TRUE)
579
- constant = Object
580
-
581
- components.each do |component|
582
- constant = constant.const_defined?(component) ?
583
- constant.const_get(component) :
584
- constant.const_missing(component)
585
- end
586
- constant
587
- end
588
-
589
- #---
590
-
591
- def plugin_class(type)
592
- class_const([ :nucleon, :plugin, type ])
503
+ @@environments[@actor_id].class_const(name, separator)
593
504
  end
594
505
 
595
506
  #---
596
507
 
597
- def provider_class(namespace, type, provider)
598
- class_const([ namespace, type, provider ])
508
+ def plugin_class(namespace, plugin_type)
509
+ @@environments[@actor_id].plugin_class(namespace, plugin_type)
599
510
  end
600
511
  end
601
512
  end