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.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +1 -0
- data/TODO.rdoc +0 -3
- data/VERSION +1 -1
- data/bin/nucleon +19 -0
- data/lib/core/config.rb +11 -7
- data/lib/core/environment.rb +338 -0
- data/lib/core/facade.rb +150 -98
- data/lib/core/manager.rb +160 -249
- data/lib/core/mixin/action/project.rb +2 -2
- data/lib/core/mixin/macro/plugin_interface.rb +11 -11
- data/lib/core/plugin/action.rb +277 -24
- data/lib/core/plugin/base.rb +22 -14
- data/lib/core/plugin/command.rb +1 -1
- data/lib/core/plugin/event.rb +3 -3
- data/lib/core/plugin/extension.rb +1 -1
- data/lib/core/plugin/project.rb +15 -15
- data/lib/core/plugin/template.rb +1 -1
- data/lib/core/plugin/translator.rb +1 -1
- data/lib/core/util/cache.rb +1 -1
- data/lib/core/util/cli.rb +32 -3
- data/lib/core/util/console.rb +30 -10
- data/lib/core/util/data.rb +11 -3
- data/lib/core/util/logger.rb +1 -1
- data/lib/core/util/shell.rb +6 -3
- data/lib/core/util/ssh.rb +148 -24
- data/lib/nucleon/action/extract.rb +11 -4
- data/lib/nucleon/action/{add.rb → project/add.rb} +13 -4
- data/lib/nucleon/action/{create.rb → project/create.rb} +12 -3
- data/lib/nucleon/action/{remove.rb → project/remove.rb} +11 -2
- data/lib/nucleon/action/{save.rb → project/save.rb} +11 -2
- data/lib/nucleon/action/{update.rb → project/update.rb} +11 -2
- data/lib/nucleon/command/bash.rb +1 -1
- data/lib/nucleon/event/regex.rb +1 -1
- data/lib/nucleon/project/git.rb +3 -3
- data/lib/nucleon/template/{json.rb → JSON.rb} +1 -1
- data/lib/nucleon/template/{yaml.rb → YAML.rb} +1 -1
- data/lib/nucleon/template/wrapper.rb +1 -1
- data/lib/nucleon/translator/{json.rb → JSON.rb} +1 -1
- data/lib/nucleon/translator/{yaml.rb → YAML.rb} +1 -1
- data/lib/nucleon_base.rb +26 -15
- data/locales/en.yml +69 -44
- data/nucleon.gemspec +129 -11
- data/rdoc/site/0.1.19/ARCHITECTURE_rdoc.html +634 -0
- data/rdoc/site/0.1.19/Hash.html +347 -0
- data/rdoc/site/0.1.19/Kernel.html +413 -0
- data/rdoc/site/0.1.19/Nucleon.html +570 -0
- data/rdoc/site/0.1.19/Nucleon/Action.html +280 -0
- data/rdoc/site/0.1.19/Nucleon/Action/Add.html +458 -0
- data/rdoc/site/0.1.19/Nucleon/Action/Create.html +415 -0
- data/rdoc/site/0.1.19/Nucleon/Action/Extract.html +413 -0
- data/rdoc/site/0.1.19/Nucleon/Action/Remove.html +461 -0
- data/rdoc/site/0.1.19/Nucleon/Action/Save.html +434 -0
- data/rdoc/site/0.1.19/Nucleon/Action/Update.html +381 -0
- data/rdoc/site/0.1.19/Nucleon/Codes.html +563 -0
- data/rdoc/site/0.1.19/Nucleon/Command.html +275 -0
- data/rdoc/site/0.1.19/Nucleon/Command/Bash.html +544 -0
- data/rdoc/site/0.1.19/Nucleon/Config.html +1623 -0
- data/rdoc/site/0.1.19/Nucleon/Config/Collection.html +509 -0
- data/rdoc/site/0.1.19/Nucleon/Config/Options.html +489 -0
- data/rdoc/site/0.1.19/Nucleon/Core.html +635 -0
- data/rdoc/site/0.1.19/Nucleon/Errors.html +275 -0
- data/rdoc/site/0.1.19/Nucleon/Errors/BatchError.html +281 -0
- data/rdoc/site/0.1.19/Nucleon/Errors/NucleonError.html +657 -0
- data/rdoc/site/0.1.19/Nucleon/Errors/SSHUnavailable.html +281 -0
- data/rdoc/site/0.1.19/Nucleon/Event.html +275 -0
- data/rdoc/site/0.1.19/Nucleon/Event/Regex.html +467 -0
- data/rdoc/site/0.1.19/Nucleon/Facade.html +2336 -0
- data/rdoc/site/0.1.19/Nucleon/Gems.html +635 -0
- data/rdoc/site/0.1.19/Nucleon/Manager.html +1828 -0
- data/rdoc/site/0.1.19/Nucleon/Mixin.html +284 -0
- data/rdoc/site/0.1.19/Nucleon/Mixin/Action.html +277 -0
- data/rdoc/site/0.1.19/Nucleon/Mixin/Action/Commit.html +381 -0
- data/rdoc/site/0.1.19/Nucleon/Mixin/Action/Project.html +395 -0
- data/rdoc/site/0.1.19/Nucleon/Mixin/Action/Push.html +371 -0
- data/rdoc/site/0.1.19/Nucleon/Mixin/Colors.html +545 -0
- data/rdoc/site/0.1.19/Nucleon/Mixin/ConfigCollection.html +481 -0
- data/rdoc/site/0.1.19/Nucleon/Mixin/ConfigOptions.html +449 -0
- data/rdoc/site/0.1.19/Nucleon/Mixin/Macro.html +276 -0
- data/rdoc/site/0.1.19/Nucleon/Mixin/Macro/ObjectInterface.html +695 -0
- data/rdoc/site/0.1.19/Nucleon/Mixin/Macro/PluginInterface.html +682 -0
- data/rdoc/site/0.1.19/Nucleon/Mixin/Settings.html +481 -0
- data/rdoc/site/0.1.19/Nucleon/Mixin/SubConfig.html +887 -0
- data/rdoc/site/0.1.19/Nucleon/Parallel.html +325 -0
- data/rdoc/site/0.1.19/Nucleon/Parallel/ClassMethods.html +325 -0
- data/rdoc/site/0.1.19/Nucleon/Parallel/InstanceMethods.html +334 -0
- data/rdoc/site/0.1.19/Nucleon/Plugin.html +282 -0
- data/rdoc/site/0.1.19/Nucleon/Plugin/Action.html +1368 -0
- data/rdoc/site/0.1.19/Nucleon/Plugin/Action/Option.html +459 -0
- data/rdoc/site/0.1.19/Nucleon/Plugin/Base.html +1737 -0
- data/rdoc/site/0.1.19/Nucleon/Plugin/Command.html +721 -0
- data/rdoc/site/0.1.19/Nucleon/Plugin/Event.html +442 -0
- data/rdoc/site/0.1.19/Nucleon/Plugin/Extension.html +281 -0
- data/rdoc/site/0.1.19/Nucleon/Plugin/Project.html +2864 -0
- data/rdoc/site/0.1.19/Nucleon/Plugin/Template.html +476 -0
- data/rdoc/site/0.1.19/Nucleon/Plugin/Translator.html +371 -0
- data/rdoc/site/0.1.19/Nucleon/Project.html +276 -0
- data/rdoc/site/0.1.19/Nucleon/Project/Git.html +1801 -0
- data/rdoc/site/0.1.19/Nucleon/Project/Github.html +549 -0
- data/rdoc/site/0.1.19/Nucleon/Template.html +277 -0
- data/rdoc/site/0.1.19/Nucleon/Template/Json.html +329 -0
- data/rdoc/site/0.1.19/Nucleon/Template/Wrapper.html +329 -0
- data/rdoc/site/0.1.19/Nucleon/Template/Yaml.html +329 -0
- data/rdoc/site/0.1.19/Nucleon/Translator.html +276 -0
- data/rdoc/site/0.1.19/Nucleon/Translator/Json.html +366 -0
- data/rdoc/site/0.1.19/Nucleon/Translator/Yaml.html +366 -0
- data/rdoc/site/0.1.19/Nucleon/Util.html +285 -0
- data/rdoc/site/0.1.19/Nucleon/Util/CLI.html +388 -0
- data/rdoc/site/0.1.19/Nucleon/Util/CLI/Parser.html +1183 -0
- data/rdoc/site/0.1.19/Nucleon/Util/Cache.html +780 -0
- data/rdoc/site/0.1.19/Nucleon/Util/Console.html +1294 -0
- data/rdoc/site/0.1.19/Nucleon/Util/Data.html +1399 -0
- data/rdoc/site/0.1.19/Nucleon/Util/Disk.html +522 -0
- data/rdoc/site/0.1.19/Nucleon/Util/Git.html +361 -0
- data/rdoc/site/0.1.19/Nucleon/Util/Liquid.html +365 -0
- data/rdoc/site/0.1.19/Nucleon/Util/Logger.html +806 -0
- data/rdoc/site/0.1.19/Nucleon/Util/Package.html +558 -0
- data/rdoc/site/0.1.19/Nucleon/Util/SSH.html +910 -0
- data/rdoc/site/0.1.19/Nucleon/Util/SSH/Keypair.html +453 -0
- data/rdoc/site/0.1.19/Nucleon/Util/Shell.html +686 -0
- data/rdoc/site/0.1.19/Nucleon/Util/Shell/Result.html +497 -0
- data/rdoc/site/0.1.19/README_rdoc.html +312 -0
- data/rdoc/site/0.1.19/TODO_rdoc.html +267 -0
- data/rdoc/site/0.1.19/created.rid +60 -0
- data/rdoc/site/0.1.19/images/add.png +0 -0
- data/rdoc/site/0.1.19/images/brick.png +0 -0
- data/rdoc/site/0.1.19/images/brick_link.png +0 -0
- data/rdoc/site/0.1.19/images/bug.png +0 -0
- data/rdoc/site/0.1.19/images/bullet_black.png +0 -0
- data/rdoc/site/0.1.19/images/bullet_toggle_minus.png +0 -0
- data/rdoc/site/0.1.19/images/bullet_toggle_plus.png +0 -0
- data/rdoc/site/0.1.19/images/date.png +0 -0
- data/rdoc/site/0.1.19/images/delete.png +0 -0
- data/rdoc/site/0.1.19/images/find.png +0 -0
- data/rdoc/site/0.1.19/images/loadingAnimation.gif +0 -0
- data/rdoc/site/0.1.19/images/macFFBgHack.png +0 -0
- data/rdoc/site/0.1.19/images/package.png +0 -0
- data/rdoc/site/0.1.19/images/page_green.png +0 -0
- data/rdoc/site/0.1.19/images/page_white_text.png +0 -0
- data/rdoc/site/0.1.19/images/page_white_width.png +0 -0
- data/rdoc/site/0.1.19/images/plugin.png +0 -0
- data/rdoc/site/0.1.19/images/ruby.png +0 -0
- data/rdoc/site/0.1.19/images/tag_blue.png +0 -0
- data/rdoc/site/0.1.19/images/tag_green.png +0 -0
- data/rdoc/site/0.1.19/images/transparent.png +0 -0
- data/rdoc/site/0.1.19/images/wrench.png +0 -0
- data/rdoc/site/0.1.19/images/wrench_orange.png +0 -0
- data/rdoc/site/0.1.19/images/zoom.png +0 -0
- data/rdoc/site/0.1.19/index.html +311 -0
- data/rdoc/site/0.1.19/js/darkfish.js +155 -0
- data/rdoc/site/0.1.19/js/jquery.js +18 -0
- data/rdoc/site/0.1.19/js/navigation.js +142 -0
- data/rdoc/site/0.1.19/js/search.js +94 -0
- data/rdoc/site/0.1.19/js/search_index.js +1 -0
- data/rdoc/site/0.1.19/js/searcher.js +228 -0
- data/rdoc/site/0.1.19/rdoc.css +543 -0
- data/rdoc/site/0.1.19/table_of_contents.html +1541 -0
- metadata +140 -11
data/lib/core/plugin/base.rb
CHANGED
|
@@ -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(
|
|
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
|
|
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 #{
|
|
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
|
-
|
|
141
|
+
Nucleon.code
|
|
132
142
|
end
|
|
133
143
|
|
|
134
144
|
def codes(*codes)
|
|
135
|
-
|
|
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(
|
|
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 #{
|
|
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(
|
|
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
|
|
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
|
|
305
|
+
rescue => error
|
|
298
306
|
logger.error(error.inspect)
|
|
299
307
|
logger.error(error.message)
|
|
300
308
|
|
data/lib/core/plugin/command.rb
CHANGED
data/lib/core/plugin/event.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
module Nucleon
|
|
3
3
|
module Plugin
|
|
4
|
-
class Event <
|
|
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(
|
|
30
|
+
def self.build_info(namespace, plugin_type, data)
|
|
31
31
|
data = data.split(/\s*,\s*/) if data.is_a?(String)
|
|
32
|
-
return super(
|
|
32
|
+
return super(namespace, plugin_type, data)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
#---
|
data/lib/core/plugin/project.rb
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
module Nucleon
|
|
3
3
|
module Plugin
|
|
4
|
-
class Project <
|
|
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
|
-
|
|
490
|
-
|
|
491
|
-
|
|
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(
|
|
877
|
+
def self.build_info(namespace, plugin_type, data)
|
|
878
878
|
data = data.split(/\s*,\s*/) if data.is_a?(String)
|
|
879
|
-
super(
|
|
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
|
data/lib/core/plugin/template.rb
CHANGED
data/lib/core/util/cache.rb
CHANGED
|
@@ -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
|
data/lib/core/util/cli.rb
CHANGED
|
@@ -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)
|
data/lib/core/util/console.rb
CHANGED
|
@@ -9,7 +9,7 @@ class Console
|
|
|
9
9
|
|
|
10
10
|
#---
|
|
11
11
|
|
|
12
|
-
@@console_lock =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
286
|
+
return string.to_s unless use_colors
|
|
267
287
|
|
|
268
288
|
color = color.to_sym
|
|
269
289
|
string = string.to_s
|
data/lib/core/util/data.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
data/lib/core/util/logger.rb
CHANGED
|
@@ -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
|
#-----------------------------------------------------------------------------
|