nucleon 0.1.19 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -3,9 +3,13 @@ module Nucleon
3
3
  module Plugin
4
4
  class Base < Core
5
5
 
6
+ def self.register_ids
7
+ :name
8
+ end
9
+
6
10
  # All Plugin classes should directly or indirectly extend Base
7
11
 
8
- def initialize(type, provider, options)
12
+ def initialize(namespace, plugin_type, provider, options)
9
13
  config = Util::Data.clean(Config.ensure(options), false)
10
14
  name = Util::Data.ensure_value(config.delete(:plugin_name), config.delete(:name, provider))
11
15
 
@@ -13,11 +17,11 @@ class Base < Core
13
17
 
14
18
  set_meta(config.delete(:meta, Config.new))
15
19
 
16
- # No logging statements aove this line!!
17
- super(config.import({ :logger => "#{plugin_type}->#{plugin_provider}" }), {}, true, false)
20
+ # No logging statements above this line!!
21
+ super(config.import({ :logger => "#{namespace}->#{plugin_type}->#{plugin_provider}" }), {}, true, false)
18
22
  myself.plugin_name = name
19
-
20
- logger.debug("Normalizing #{plugin_type} plugin #{plugin_name} with meta data: #{meta.inspect}")
23
+
24
+ logger.debug("Normalizing #{namespace} #{plugin_type} plugin #{plugin_name}")
21
25
  normalize(false)
22
26
 
23
27
  @initialized = true
@@ -25,6 +29,12 @@ class Base < Core
25
29
 
26
30
  #---
27
31
 
32
+ def parallel_finalize
33
+ remove_plugin
34
+ end
35
+
36
+ #---
37
+
28
38
  def method_missing(method, *args, &block)
29
39
  return nil
30
40
  end
@@ -128,11 +138,11 @@ class Base < Core
128
138
  # Status codes
129
139
 
130
140
  def code
131
- CORL.code
141
+ Nucleon.code
132
142
  end
133
143
 
134
144
  def codes(*codes)
135
- CORL.codes(*codes)
145
+ Nucleon.codes(*codes)
136
146
  end
137
147
 
138
148
  #---
@@ -238,14 +248,14 @@ class Base < Core
238
248
  #-----------------------------------------------------------------------------
239
249
  # Utilities
240
250
 
241
- def self.build_info(type, data)
251
+ def self.build_info(namespace, plugin_type, data)
242
252
  plugins = []
243
253
 
244
254
  if data.is_a?(Hash)
245
255
  data = [ data ]
246
256
  end
247
257
 
248
- logger.debug("Building plugin list of #{type} from data: #{data.inspect}")
258
+ logger.debug("Building plugin list of #{plugin_type}")
249
259
 
250
260
  if data.is_a?(Array)
251
261
  data.each do |info|
@@ -253,11 +263,9 @@ class Base < Core
253
263
  info = translate(info)
254
264
 
255
265
  if Util::Data.empty?(info[:provider])
256
- info[:provider] = Nucleon.type_default(type)
266
+ info[:provider] = Nucleon.type_default(namespace, plugin_type)
257
267
  end
258
268
 
259
- logger.debug("Translated plugin info: #{info.inspect}")
260
-
261
269
  plugins << info
262
270
  end
263
271
  end
@@ -268,7 +276,7 @@ class Base < Core
268
276
  #---
269
277
 
270
278
  def self.translate(data)
271
- logger.debug("Translating data to internal plugin structure: #{data.inspect}")
279
+ logger.debug("Translating input data to internal plugin structure")
272
280
  return ( data.is_a?(Hash) ? symbol_map(data) : data )
273
281
  end
274
282
 
@@ -294,7 +302,7 @@ class Base < Core
294
302
  return result if return_result
295
303
  return true
296
304
 
297
- rescue Exception => error
305
+ rescue => error
298
306
  logger.error(error.inspect)
299
307
  logger.error(error.message)
300
308
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Nucleon
3
3
  module Plugin
4
- class Command < Base
4
+ class Command < Nucleon.plugin_class(:nucleon, :base)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Command plugin interface
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Nucleon
3
3
  module Plugin
4
- class Event < Base
4
+ class Event < Nucleon.plugin_class(:nucleon, :base)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Event plugin interface
@@ -27,9 +27,9 @@ class Event < Base
27
27
  #-----------------------------------------------------------------------------
28
28
  # Utilities
29
29
 
30
- def self.build_info(type, data)
30
+ def self.build_info(namespace, plugin_type, data)
31
31
  data = data.split(/\s*,\s*/) if data.is_a?(String)
32
- return super(type, data)
32
+ return super(namespace, plugin_type, data)
33
33
  end
34
34
 
35
35
  #---
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Nucleon
3
3
  module Plugin
4
- class Extension < Base
4
+ class Extension < Nucleon.plugin_class(:nucleon, :base)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Extension plugin interface
@@ -1,11 +1,7 @@
1
1
 
2
2
  module Nucleon
3
3
  module Plugin
4
- class Project < Base
5
-
6
- @@ignore_lock = Mutex.new
7
-
8
- #---
4
+ class Project < Nucleon.plugin_class(:nucleon, :base)
9
5
 
10
6
  @@projects = {}
11
7
 
@@ -14,6 +10,12 @@ class Project < Base
14
10
  def self.collection
15
11
  @@projects
16
12
  end
13
+
14
+ #---
15
+
16
+ def self.register_ids
17
+ [ :name, :directory ]
18
+ end
17
19
 
18
20
  #-----------------------------------------------------------------------------
19
21
  # Constructor / Destructor
@@ -48,7 +50,7 @@ class Project < Base
48
50
 
49
51
  set_url(get(:url)) if get(:url, false)
50
52
 
51
- myself.plugin_name = path if ! plugin_name || plugin_name == plugin_provider
53
+ myself.plugin_name = path if ! plugin_name || plugin_name.to_sym == plugin_provider
52
54
 
53
55
  ui.resource = plugin_name
54
56
  logger = plugin_name
@@ -476,7 +478,7 @@ class Project < Base
476
478
  end
477
479
  end
478
480
  else
479
- logger.warn("Project #{name} does not meet the criteria for persistence and can be committed to")
481
+ logger.warn("Project #{name} does not meet the criteria for persistence and can not be committed to")
480
482
  end
481
483
  success
482
484
  end
@@ -486,11 +488,9 @@ class Project < Base
486
488
  def ignore(files)
487
489
  return unless directory && manage_ignore?
488
490
 
489
- @@ignore_lock.synchronize do
490
- files = nil
491
- files = yield if block_given?
492
- commit(files, { :message => "Adding project ignores." }) if files
493
- end
491
+ files = nil
492
+ files = yield if block_given?
493
+ commit(files, { :message => "Adding project ignores." }) if files
494
494
  end
495
495
 
496
496
  #-----------------------------------------------------------------------------
@@ -874,9 +874,9 @@ class Project < Base
874
874
  #-----------------------------------------------------------------------------
875
875
  # Utilities
876
876
 
877
- def self.build_info(type, data)
877
+ def self.build_info(namespace, plugin_type, data)
878
878
  data = data.split(/\s*,\s*/) if data.is_a?(String)
879
- super(type, data)
879
+ super(namespace, plugin_type, data)
880
880
  end
881
881
 
882
882
  #---
@@ -914,7 +914,7 @@ class Project < Base
914
914
 
915
915
  logger.debug("Translating project reference: #{provider} #{url} #{revision}")
916
916
 
917
- if provider && Nucleon.loaded_plugins(:project).keys.include?(provider.to_sym)
917
+ if provider && Nucleon.loaded_plugins(:nucleon, :project).keys.include?(provider.to_sym)
918
918
  klass = Nucleon.class_const([ :nucleon, :project, provider ])
919
919
  expanded_url = klass.send(:expand_url, url, editable) if klass.respond_to?(:expand_url)
920
920
  end
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Nucleon
3
3
  module Plugin
4
- class Template < Base
4
+ class Template < Nucleon.plugin_class(:nucleon, :base)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Template plugin interface
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Nucleon
3
3
  module Plugin
4
- class Translator < Base
4
+ class Translator < Nucleon.plugin_class(:nucleon, :base)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Translator plugin interface
@@ -21,7 +21,7 @@ class Cache < Core
21
21
  FileUtils.mkdir_p(base_path) unless File.directory?(base_path)
22
22
 
23
23
  @cache_id = id.to_sym
24
- @cache_translator = Nucleon.type_default(:translator)
24
+ @cache_translator = Nucleon.type_default(:nucleon, :translator)
25
25
  @cache_filename = "#{id}.#{translator}"
26
26
  @cache_path = File.join(@cache_root, @cache_filename)
27
27
  end
@@ -2,7 +2,7 @@
2
2
  module Nucleon
3
3
  module Util
4
4
  module CLI
5
-
5
+
6
6
  #-----------------------------------------------------------------------------
7
7
  # Utilities
8
8
 
@@ -32,7 +32,11 @@ module CLI
32
32
  attr_accessor :options
33
33
  attr_accessor :arguments
34
34
  attr_accessor :processed
35
-
35
+
36
+ #---
37
+
38
+ include Mixin::Colors
39
+
36
40
  #---
37
41
 
38
42
  def initialize(args, banner = '', help = '', split_help = false)
@@ -100,6 +104,12 @@ module CLI
100
104
  parser.separator help
101
105
  end
102
106
  end
107
+
108
+ #---
109
+
110
+ def version
111
+ # Override in executable script
112
+ end
103
113
 
104
114
  #---
105
115
 
@@ -108,7 +118,15 @@ module CLI
108
118
  error = false
109
119
 
110
120
  self.processed = false
111
-
121
+
122
+ option_bool(:version, false,
123
+ '--version',
124
+ 'nucleon.core.util.cli.options.version'
125
+ )
126
+ option_bool(:color, true,
127
+ '--[no]-color',
128
+ 'nucleon.core.util.cli.options.color'
129
+ )
112
130
  option_str(:log_level, nil,
113
131
  '--log_level STR',
114
132
  'nucleon.core.util.cli.options.log_level'
@@ -133,6 +151,13 @@ module CLI
133
151
  parser.parse!(args)
134
152
 
135
153
  # Now we can act on options given
154
+ Util::Console.use_colors = options[:color] unless split_help
155
+
156
+ if options[:version]
157
+ puts version
158
+ exit 0
159
+ end
160
+
136
161
  return if options[:help]
137
162
 
138
163
  parse_encoded
@@ -218,6 +243,10 @@ module CLI
218
243
 
219
244
  encoded_properties.each do |name, value|
220
245
  self.options[name] = value
246
+
247
+ if name == :color
248
+ Util::Console.use_colors = value
249
+ end
221
250
  end
222
251
  end
223
252
  options.delete(:encoded_params)
@@ -9,7 +9,7 @@ class Console
9
9
 
10
10
  #---
11
11
 
12
- @@console_lock = Mutex.new
12
+ @@console_lock = Nucleon.console_lock
13
13
  @@quiet = false
14
14
  @@use_colors = true
15
15
 
@@ -78,7 +78,7 @@ class Console
78
78
  #---
79
79
 
80
80
  def self.use_colors
81
- @@use_colors
81
+ @@use_colors && ! ENV['NUCLEON_NO_COLOR']
82
82
  end
83
83
 
84
84
  def self.use_colors=use_colors
@@ -105,9 +105,9 @@ class Console
105
105
  end
106
106
 
107
107
  if options[:sync]
108
- @@console_lock.synchronize do
108
+ #@@console_lock.synchronize do
109
109
  render.call
110
- end
110
+ #end
111
111
  else
112
112
  render.call
113
113
  end
@@ -140,9 +140,9 @@ class Console
140
140
  end
141
141
 
142
142
  if options[:sync]
143
- @@console_lock.synchronize do
143
+ #@@console_lock.synchronize do
144
144
  return collect.call
145
- end
145
+ #end
146
146
  else
147
147
  return collect.call
148
148
  end
@@ -176,9 +176,9 @@ class Console
176
176
  end
177
177
 
178
178
  if options[:sync]
179
- @@console_lock.synchronize do
179
+ #@@console_lock.synchronize do
180
180
  return collect.call
181
- end
181
+ #end
182
182
  else
183
183
  return collect.call
184
184
  end
@@ -222,7 +222,27 @@ class Console
222
222
  if @resource && ! @resource.empty? && options[:prefix]
223
223
  prefix = "[#{@resource}]"
224
224
  end
225
- message = "#{prefix} #{message}".lstrip
225
+
226
+ lines = []
227
+ prev_color = nil
228
+ escaped_clear = Regexp.escape(@@colors[:clear])
229
+
230
+ message.split("\n").each do |line|
231
+ line = prev_color + line if prev_color
232
+
233
+ lines << "#{prefix} #{line}".sub(/^ +/, '')
234
+
235
+ # Set next previous color
236
+ if line =~ /#{escaped_clear}$/
237
+ prev_color = nil
238
+ else
239
+ line_section = line.split(/#{escaped_clear}/).pop
240
+ prev_colors = line_section.scan(/\e\[[0-9][0-9]?m/)
241
+ prev_color = prev_colors.pop unless prev_colors.empty?
242
+ end
243
+ end
244
+
245
+ message = lines.join("\n")
226
246
 
227
247
  if @@use_colors && @color
228
248
  if options.has_key?(:color)
@@ -263,7 +283,7 @@ class Console
263
283
 
264
284
  def self.colorize(string, color)
265
285
  return '' unless string
266
- return string.to_s unless @@use_colors
286
+ return string.to_s unless use_colors
267
287
 
268
288
  color = color.to_sym
269
289
  string = string.to_s
@@ -341,9 +341,13 @@ class Data
341
341
 
342
342
  #---
343
343
 
344
- def self.rm_keys(data, keys)
344
+ def self.rm_keys(data, keys, symbolize = false)
345
345
  keys = [ keys ] unless keys.is_a?(Array)
346
+ data = hash(data)
347
+ data = symbol_map(data) if symbolize
348
+
346
349
  keys.each do |key|
350
+ key = key.to_sym if symbolize
347
351
  data.delete(key)
348
352
  end
349
353
  data
@@ -351,10 +355,14 @@ class Data
351
355
 
352
356
  #---
353
357
 
354
- def self.subset(data, keys)
358
+ def self.subset(data, keys, symbolize = false)
355
359
  keys = [ keys ] unless keys.is_a?(Array)
356
- new_data = {}
360
+ data = hash(data)
361
+ data = symbol_map(data) if symbolize
362
+ new_data = {}
363
+
357
364
  keys.each do |key|
365
+ key = key.to_sym if symbolize
358
366
  new_data[key] = data[key] if data.has_key?(key)
359
367
  end
360
368
  new_data
@@ -109,7 +109,7 @@ class Logger
109
109
  else
110
110
  @logger = logger
111
111
  end
112
- self.class.add_logger(@resource, @logger)
112
+ self.class.add_logger(@resource, @logger) unless self.class.loggers.has_key?(@resource)
113
113
  end
114
114
 
115
115
  #-----------------------------------------------------------------------------