nucleon 0.2.8 → 0.2.9
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/VERSION +1 -1
- data/lib/core/config.rb +30 -12
- data/lib/core/facade.rb +22 -14
- data/lib/core/manager.rb +6 -6
- data/lib/core/mixin/action/registration.rb +115 -111
- data/lib/core/mixin/sub_config.rb +3 -3
- data/lib/core/util/cli.rb +35 -10
- data/lib/core/util/ssh.rb +2 -2
- data/lib/nucleon/project/github.rb +3 -1
- data/locales/en.yml +20 -17
- data/nucleon.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f37db6374efb2285de5bd242cce45eb5817e2d5
|
4
|
+
data.tar.gz: d5fd9959abf368f329756ea44c24d844a0dc5ea3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb017436c867b27eb087ef11e1de3cde238f65777a49fb3eaa0120e0dac595ccee944c60a67ec1de90a98b33edf8ef7bad02d98d36fa95de283413846a9aa7e4
|
7
|
+
data.tar.gz: 23db6461c2f61e51d6497ff6329d6588c66e01c34edece43a1356cd4e138a724f0f85b471c5ac5ba51883bcbbfce8e34c5ef55cd30d4d9c336a2705244507f03
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.9
|
data/lib/core/config.rb
CHANGED
@@ -239,7 +239,7 @@ class Config
|
|
239
239
|
@properties = {}
|
240
240
|
|
241
241
|
if defaults.is_a?(Hash) && ! defaults.empty?
|
242
|
-
defaults = symbol_map(
|
242
|
+
defaults = symbol_map(Util::Data.clone(defaults))
|
243
243
|
end
|
244
244
|
|
245
245
|
case data
|
@@ -248,7 +248,7 @@ class Config
|
|
248
248
|
when Hash
|
249
249
|
@properties = {}
|
250
250
|
if data.is_a?(Hash)
|
251
|
-
@properties = Util::Data.merge([ defaults, symbol_map(
|
251
|
+
@properties = Util::Data.merge([ defaults, symbol_map(Util::Data.clone(data)) ], force, basic_merge)
|
252
252
|
end
|
253
253
|
else
|
254
254
|
@properties = defaults if defaults.is_a?(Hash)
|
@@ -339,7 +339,7 @@ class Config
|
|
339
339
|
end
|
340
340
|
|
341
341
|
keys = keys.flatten.compact
|
342
|
-
key = keys.shift
|
342
|
+
key = keys.shift
|
343
343
|
|
344
344
|
if data.has_key?(key)
|
345
345
|
value = data[key]
|
@@ -388,7 +388,7 @@ class Config
|
|
388
388
|
end
|
389
389
|
|
390
390
|
keys = keys.flatten.compact
|
391
|
-
key = keys.shift
|
391
|
+
key = keys.shift
|
392
392
|
has_key = data.has_key?(key)
|
393
393
|
existing = {
|
394
394
|
:key => key,
|
@@ -435,7 +435,7 @@ class Config
|
|
435
435
|
# - #array
|
436
436
|
#
|
437
437
|
def get(keys, default = nil, format = false)
|
438
|
-
return fetch(@properties, array(keys).flatten, default, format)
|
438
|
+
return fetch(@properties, symbol_array(array(keys).flatten), default, format)
|
439
439
|
end
|
440
440
|
|
441
441
|
# Fetch value for key path in the configuration object.
|
@@ -548,7 +548,7 @@ class Config
|
|
548
548
|
# - #array
|
549
549
|
#
|
550
550
|
def set(keys, value, delete_nil = false, &code) # :yields: key, value, existing
|
551
|
-
modify(@properties, array(keys).flatten, value, delete_nil, &code)
|
551
|
+
modify(@properties, symbol_array(array(keys).flatten), value, delete_nil, &code)
|
552
552
|
return self
|
553
553
|
end
|
554
554
|
|
@@ -570,7 +570,7 @@ class Config
|
|
570
570
|
# - #array
|
571
571
|
#
|
572
572
|
def append(keys, value)
|
573
|
-
modify(@properties, array(keys).flatten, value, false) do |key, processed_value, existing|
|
573
|
+
modify(@properties, symbol_array(array(keys).flatten), value, false) do |key, processed_value, existing|
|
574
574
|
if existing.is_a?(Array)
|
575
575
|
[ existing, processed_value ].flatten
|
576
576
|
else
|
@@ -599,7 +599,7 @@ class Config
|
|
599
599
|
# - #array
|
600
600
|
#
|
601
601
|
def prepend(keys, value, reverse = false)
|
602
|
-
modify(@properties, array(keys).flatten, value, false) do |key, processed_value, existing|
|
602
|
+
modify(@properties, symbol_array(array(keys).flatten), value, false) do |key, processed_value, existing|
|
603
603
|
processed_value = processed_value.reverse if reverse && processed_value.is_a?(Array)
|
604
604
|
|
605
605
|
if existing.is_a?(Array)
|
@@ -650,7 +650,7 @@ class Config
|
|
650
650
|
# - #array
|
651
651
|
#
|
652
652
|
def delete(keys, default = nil)
|
653
|
-
existing = modify(@properties, array(keys).flatten, nil, true)
|
653
|
+
existing = modify(@properties, symbol_array(array(keys).flatten), nil, true)
|
654
654
|
return existing[:value] unless existing[:value].nil?
|
655
655
|
return default
|
656
656
|
end
|
@@ -708,7 +708,7 @@ class Config
|
|
708
708
|
|
709
709
|
case properties
|
710
710
|
when Hash
|
711
|
-
data = [ @properties, symbol_map(
|
711
|
+
data = [ @properties, symbol_map(Util::Data.clone(properties)) ]
|
712
712
|
data = data.reverse if import_type != :override
|
713
713
|
|
714
714
|
@properties = Util::Data.merge(data, config)
|
@@ -724,7 +724,7 @@ class Config
|
|
724
724
|
end
|
725
725
|
|
726
726
|
when Array
|
727
|
-
|
727
|
+
Util::Data.clone(properties).each do |item|
|
728
728
|
import_base(item, config)
|
729
729
|
end
|
730
730
|
end
|
@@ -792,7 +792,7 @@ class Config
|
|
792
792
|
# * *Errors*
|
793
793
|
#
|
794
794
|
def export
|
795
|
-
return @properties
|
795
|
+
return Util::Data.clone(@properties)
|
796
796
|
end
|
797
797
|
|
798
798
|
#*****************************************************************************
|
@@ -822,6 +822,24 @@ class Config
|
|
822
822
|
return self.class.symbol_map(data)
|
823
823
|
end
|
824
824
|
|
825
|
+
# Return a symbolized array
|
826
|
+
#
|
827
|
+
# * *Parameters*
|
828
|
+
# - [Array<String, Symbol>] *array* Array of strings or symbols
|
829
|
+
#
|
830
|
+
# * *Returns*
|
831
|
+
# - [Array<Symbol>] Returns array of symbols
|
832
|
+
#
|
833
|
+
# * *Errors*
|
834
|
+
#
|
835
|
+
def symbol_array(array)
|
836
|
+
result = []
|
837
|
+
array.each do |item|
|
838
|
+
result << item.to_sym unless item.nil?
|
839
|
+
end
|
840
|
+
result
|
841
|
+
end
|
842
|
+
|
825
843
|
# Return hash as a string map.
|
826
844
|
#
|
827
845
|
# This method converts all hash keys to strings. Nested hashes are
|
data/lib/core/facade.rb
CHANGED
@@ -170,12 +170,14 @@ module Facade
|
|
170
170
|
#-----------------------------------------------------------------------------
|
171
171
|
|
172
172
|
def admin?
|
173
|
-
is_admin
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
173
|
+
is_admin = ( ENV['USER'] == 'root' )
|
174
|
+
unless is_admin
|
175
|
+
ext_admin = exec(:check_admin) do |op, results|
|
176
|
+
if op == :reduce
|
177
|
+
results.values.include?(true)
|
178
|
+
else
|
179
|
+
results ? true : false
|
180
|
+
end
|
179
181
|
end
|
180
182
|
end
|
181
183
|
is_admin || ext_admin ? true : false
|
@@ -215,7 +217,7 @@ module Facade
|
|
215
217
|
updated_time = Time.parse(@@ip_cache['updated'])
|
216
218
|
cache_duration = (Time.new - updated_time) / 60 # Seconds to minutes
|
217
219
|
|
218
|
-
if cache_duration >= value(:external_address_lifetime,
|
220
|
+
if cache_duration >= value(:external_address_lifetime, 360)
|
219
221
|
external_ip = fetch_ip.call
|
220
222
|
end
|
221
223
|
end
|
@@ -262,7 +264,7 @@ module Facade
|
|
262
264
|
|
263
265
|
#---
|
264
266
|
|
265
|
-
def load_plugins(base_dir = nil)
|
267
|
+
def load_plugins(base_dir = nil, search_parents = true)
|
266
268
|
base_dir = base_dir.nil? ? Dir.pwd : base_dir
|
267
269
|
|
268
270
|
search_plugins = lambda do |search_dir|
|
@@ -273,8 +275,10 @@ module Facade
|
|
273
275
|
register(lib_dir)
|
274
276
|
end
|
275
277
|
|
276
|
-
|
277
|
-
|
278
|
+
if search_parents
|
279
|
+
parent_search_dir = search_dir.sub(/#{File::SEPARATOR}[^#{File::SEPARATOR}]+$/, '')
|
280
|
+
search_plugins.call(parent_search_dir) unless parent_search_dir.split(File::SEPARATOR).empty?
|
281
|
+
end
|
278
282
|
end
|
279
283
|
|
280
284
|
search_plugins.call(base_dir)
|
@@ -516,7 +520,7 @@ module Facade
|
|
516
520
|
end
|
517
521
|
|
518
522
|
def executable(args, name = 'nucleon') #ARGV
|
519
|
-
|
523
|
+
$0 = name.to_s # Set process name
|
520
524
|
|
521
525
|
$stdout.sync = true
|
522
526
|
$stderr.sync = true
|
@@ -529,12 +533,15 @@ module Facade
|
|
529
533
|
args = args - [ "--no-color", "--color" ]
|
530
534
|
|
531
535
|
begin
|
532
|
-
|
536
|
+
arg_components = Util::CLI::Parser.split(args, cyan(name) + yellow(" <action components> [<arg> ...]"))
|
537
|
+
main_command = arg_components.shift
|
538
|
+
|
539
|
+
logger.info("Beginning #{name} execution run with arguments: #{args.inspect}")
|
533
540
|
|
541
|
+
exec(:executable_load)
|
534
542
|
load_plugins
|
535
543
|
|
536
|
-
|
537
|
-
main_command = arg_components.shift
|
544
|
+
exec(:executable_init, { :name => name, :args => args })
|
538
545
|
|
539
546
|
action, action_components, args = search_actions(args)
|
540
547
|
|
@@ -567,6 +574,7 @@ module Facade
|
|
567
574
|
|
568
575
|
ui.error(action_error.message, { :prefix => false }) if action_error.message
|
569
576
|
end
|
577
|
+
exec(:executable_exit, { :status => exit_status })
|
570
578
|
exit_status
|
571
579
|
end
|
572
580
|
|
data/lib/core/manager.rb
CHANGED
@@ -660,13 +660,13 @@ class Manager
|
|
660
660
|
|
661
661
|
logger.info("Executing extension hook #{Nucleon.blue(method)} at #{Nucleon.green(Time.now.to_s)}")
|
662
662
|
|
663
|
-
extensions = active_plugins(:nucleon, :extension)
|
663
|
+
extensions = Util::Data.clone(active_plugins(:nucleon, :extension))
|
664
664
|
|
665
665
|
extensions.each do |name, plugin|
|
666
666
|
provider = plugin.plugin_provider
|
667
667
|
result = nil
|
668
668
|
|
669
|
-
logger.
|
669
|
+
logger.info("Checking extension #{provider}")
|
670
670
|
|
671
671
|
if plugin.respond_to?(method)
|
672
672
|
results = {} if results.nil?
|
@@ -698,7 +698,7 @@ class Manager
|
|
698
698
|
def config(type, options = {})
|
699
699
|
config = Config.ensure(options)
|
700
700
|
|
701
|
-
logger.
|
701
|
+
logger.info("Generating #{type} extended configuration")
|
702
702
|
|
703
703
|
exec("#{type}_config", Config.new(config.export, {}, true, false)) do |op, data|
|
704
704
|
if op == :reduce
|
@@ -717,7 +717,7 @@ class Manager
|
|
717
717
|
def check(method, options = {})
|
718
718
|
config = Config.ensure(options)
|
719
719
|
|
720
|
-
logger.
|
720
|
+
logger.info("Checking extension #{method}")
|
721
721
|
|
722
722
|
success = exec(method, config.import({ :extension_type => :check })) do |op, data|
|
723
723
|
if op == :reduce
|
@@ -736,7 +736,7 @@ class Manager
|
|
736
736
|
def value(method, value, options = {})
|
737
737
|
config = Config.ensure(options)
|
738
738
|
|
739
|
-
logger.
|
739
|
+
logger.info("Setting extension #{method} value")
|
740
740
|
|
741
741
|
exec(method, config.import({ :value => value, :extension_type => :value })) do |op, data|
|
742
742
|
if op == :process
|
@@ -752,7 +752,7 @@ class Manager
|
|
752
752
|
config = Config.ensure(options)
|
753
753
|
values = []
|
754
754
|
|
755
|
-
logger.
|
755
|
+
logger.info("Collecting extension #{method} values")
|
756
756
|
|
757
757
|
exec(method, config.import({ :extension_type => :collect })) do |op, data|
|
758
758
|
if op == :process
|
@@ -3,303 +3,307 @@ module Nucleon
|
|
3
3
|
module Mixin
|
4
4
|
module Action
|
5
5
|
module Registration
|
6
|
-
|
6
|
+
|
7
7
|
#-----------------------------------------------------------------------------
|
8
8
|
# Registration definitions
|
9
|
-
|
9
|
+
|
10
10
|
def register_bool(name, default = false, locale = nil, &code)
|
11
11
|
register(name, :bool, default, locale, &code)
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
#---
|
15
|
-
|
15
|
+
|
16
16
|
def register_int(name, default = nil, locale = nil, &code)
|
17
17
|
register(name, :int, default, locale, &code)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
#---
|
21
|
-
|
21
|
+
|
22
22
|
def register_float(name, default = nil, locale = nil, &code)
|
23
23
|
register(name, :float, default, locale, &code)
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
#---
|
27
|
-
|
27
|
+
|
28
28
|
def register_str(name, default = '', locale = nil, &code)
|
29
29
|
register(name, :str, default, locale, &code)
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
#---
|
33
|
-
|
33
|
+
|
34
34
|
def register_array(name, default = [], locale = nil, &code)
|
35
35
|
register(name, :array, default, locale, &code)
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
#---
|
39
|
-
|
39
|
+
|
40
40
|
def register_file(name, default = nil, locale = nil, &code)
|
41
41
|
name = name.to_sym
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
|
43
|
+
option_locale, validation_locale = split_locales(locale)
|
44
|
+
|
45
|
+
register_str(name, default, option_locale) do |value|
|
46
|
+
success = validate_file(value, validation_locale)
|
45
47
|
success = code.call(value, success) if code
|
46
48
|
success
|
47
49
|
end
|
48
50
|
end
|
49
|
-
|
51
|
+
|
50
52
|
#---
|
51
|
-
|
53
|
+
|
52
54
|
def register_files(name, default = nil, locale = nil, &code)
|
53
55
|
name = name.to_sym
|
54
|
-
|
56
|
+
|
55
57
|
option_locale, validation_locale = split_locales(locale)
|
56
|
-
|
58
|
+
|
57
59
|
register_array(name, default, option_locale) do |values|
|
58
60
|
success = validate_files(values, validation_locale)
|
59
61
|
success = code.call(values, success) if code
|
60
62
|
success
|
61
|
-
end
|
63
|
+
end
|
62
64
|
end
|
63
|
-
|
65
|
+
|
64
66
|
#---
|
65
|
-
|
67
|
+
|
66
68
|
def register_directory(name, default = nil, locale = nil, &code)
|
67
69
|
name = name.to_sym
|
68
|
-
|
69
|
-
|
70
|
-
|
70
|
+
|
71
|
+
option_locale, validation_locale = split_locales(locale)
|
72
|
+
|
73
|
+
register_str(name, default, option_locale) do |value|
|
74
|
+
success = validate_directory(value, validation_locale)
|
71
75
|
success = code.call(value, success) if code
|
72
76
|
success
|
73
77
|
end
|
74
78
|
end
|
75
|
-
|
79
|
+
|
76
80
|
#---
|
77
|
-
|
81
|
+
|
78
82
|
def register_directories(name, default = nil, locale = nil, &code)
|
79
83
|
name = name.to_sym
|
80
|
-
|
84
|
+
|
81
85
|
option_locale, validation_locale = split_locales(locale)
|
82
|
-
|
86
|
+
|
83
87
|
register_array(name, default, option_locale) do |values|
|
84
88
|
success = validate_directories(values, validation_locale)
|
85
89
|
success = code.call(values, success) if code
|
86
90
|
success
|
87
|
-
end
|
91
|
+
end
|
88
92
|
end
|
89
|
-
|
93
|
+
|
90
94
|
#---
|
91
|
-
|
95
|
+
|
92
96
|
def register_plugin_type(namespace, name, default = nil, locale = nil, &code)
|
93
97
|
name = name.to_sym
|
94
|
-
|
98
|
+
|
95
99
|
option_locale, validation_locale = split_locales(locale)
|
96
|
-
|
100
|
+
|
97
101
|
register_str(name, default, option_locale) do |value|
|
98
102
|
success = validate_plugin_types(namespace, name, value, validation_locale)
|
99
103
|
success = code.call(value, success) if code
|
100
104
|
success
|
101
|
-
end
|
105
|
+
end
|
102
106
|
end
|
103
|
-
|
107
|
+
|
104
108
|
#---
|
105
|
-
|
109
|
+
|
106
110
|
def register_plugin_types(namespace, name, default = nil, locale = nil, &code)
|
107
111
|
name = name.to_sym
|
108
|
-
|
112
|
+
|
109
113
|
option_locale, validation_locale = split_locales(locale)
|
110
|
-
|
114
|
+
|
111
115
|
register_array(name, default, option_locale) do |values|
|
112
116
|
success = validate_plugin_types(namespace, name, values, validation_locale)
|
113
117
|
success = code.call(values, success) if code
|
114
118
|
success
|
115
|
-
end
|
119
|
+
end
|
116
120
|
end
|
117
|
-
|
121
|
+
|
118
122
|
#---
|
119
|
-
|
123
|
+
|
120
124
|
def register_plugin_provider(namespace, type, name, default = nil, locale = nil, &code)
|
121
|
-
name = name.to_sym
|
122
|
-
|
125
|
+
name = name.to_sym
|
126
|
+
|
123
127
|
option_locale, validation_locale = split_locales(locale)
|
124
|
-
|
128
|
+
|
125
129
|
register_str(name, default, option_locale) do |value|
|
126
130
|
success = validate_plugin_providers(namespace, type, name, value, validation_locale)
|
127
131
|
success = code.call(value, success) if code
|
128
132
|
success
|
129
|
-
end
|
133
|
+
end
|
130
134
|
end
|
131
|
-
|
135
|
+
|
132
136
|
#---
|
133
|
-
|
137
|
+
|
134
138
|
def register_plugin_providers(namespace, type, name, default = nil, locale = nil, &code)
|
135
139
|
name = name.to_sym
|
136
|
-
|
140
|
+
|
137
141
|
option_locale, validation_locale = split_locales(locale)
|
138
|
-
|
142
|
+
|
139
143
|
register_array(name, default, option_locale) do |values|
|
140
144
|
success = validate_plugin_providers(namespace, type, name, values, validation_locale)
|
141
145
|
success = code.call(values, success) if code
|
142
146
|
success
|
143
|
-
end
|
147
|
+
end
|
144
148
|
end
|
145
|
-
|
149
|
+
|
146
150
|
#---
|
147
|
-
|
151
|
+
|
148
152
|
def register_plugin(namespace, type, name, default = nil, locale = nil, &code)
|
149
153
|
name = name.to_sym
|
150
|
-
|
154
|
+
|
151
155
|
option_locale, validation_locale = split_locales(locale)
|
152
|
-
|
156
|
+
|
153
157
|
register_str(name, default, option_locale) do |value|
|
154
158
|
success = validate_plugins(namespace, type, name, value, validation_locale)
|
155
159
|
success = code.call(value, success) if code
|
156
160
|
success
|
157
|
-
end
|
161
|
+
end
|
158
162
|
end
|
159
|
-
|
163
|
+
|
160
164
|
#---
|
161
|
-
|
165
|
+
|
162
166
|
def register_plugins(namespace, type, name, default = nil, locale = nil, &code)
|
163
167
|
name = name.to_sym
|
164
|
-
|
168
|
+
|
165
169
|
option_locale, validation_locale = split_locales(locale)
|
166
|
-
|
170
|
+
|
167
171
|
register_array(name, default, option_locale) do |values|
|
168
172
|
success = validate_plugins(namespace, type, name, values, validation_locale)
|
169
173
|
success = code.call(values, success) if code
|
170
174
|
success
|
171
|
-
end
|
175
|
+
end
|
172
176
|
end
|
173
|
-
|
177
|
+
|
174
178
|
#---
|
175
|
-
|
179
|
+
|
176
180
|
def register_project_provider(name, default = nil, locale = nil, &code)
|
177
181
|
register_plugin_provider(:nucleon, :project, name.to_sym, default, locale, &code)
|
178
182
|
end
|
179
|
-
|
183
|
+
|
180
184
|
#---
|
181
|
-
|
185
|
+
|
182
186
|
def register_project_providers(name, default = nil, locale = nil, &code)
|
183
187
|
register_plugin_providers(:nucleon, :project, name.to_sym, default, locale, &code)
|
184
188
|
end
|
185
|
-
|
189
|
+
|
186
190
|
#---
|
187
|
-
|
191
|
+
|
188
192
|
def register_project(name, default = nil, locale = nil, &code)
|
189
193
|
register_plugin(:nucleon, :project, name.to_sym, default, locale, &code)
|
190
194
|
end
|
191
|
-
|
195
|
+
|
192
196
|
#---
|
193
|
-
|
197
|
+
|
194
198
|
def register_projects(name, default = nil, locale = nil, &code)
|
195
|
-
register_plugins(:nucleon, :project, name.to_sym, default, locale, &code)
|
199
|
+
register_plugins(:nucleon, :project, name.to_sym, default, locale, &code)
|
196
200
|
end
|
197
|
-
|
201
|
+
|
198
202
|
#---
|
199
|
-
|
203
|
+
|
200
204
|
def register_translator_provider(name, default = nil, locale = nil, &code)
|
201
205
|
register_plugin_provider(:nucleon, :translator, name.to_sym, default, locale, &code)
|
202
206
|
end
|
203
|
-
|
207
|
+
|
204
208
|
#---
|
205
|
-
|
209
|
+
|
206
210
|
def register_translator_providers(name, default = nil, locale = nil, &code)
|
207
211
|
register_plugin_providers(:nucleon, :translator, name.to_sym, default, locale, &code)
|
208
212
|
end
|
209
|
-
|
213
|
+
|
210
214
|
#---
|
211
|
-
|
215
|
+
|
212
216
|
def register_translator(name, default = nil, locale = nil, &code)
|
213
217
|
register_plugin(:nucleon, :translator, name.to_sym, default, locale, &code)
|
214
218
|
end
|
215
|
-
|
219
|
+
|
216
220
|
#---
|
217
|
-
|
221
|
+
|
218
222
|
def register_translators(name, default = nil, locale = nil, &code)
|
219
|
-
register_plugins(:nucleon, :translators, name.to_sym, default, locale, &code)
|
223
|
+
register_plugins(:nucleon, :translators, name.to_sym, default, locale, &code)
|
220
224
|
end
|
221
|
-
|
225
|
+
|
222
226
|
#-----------------------------------------------------------------------------
|
223
227
|
# Validators
|
224
|
-
|
228
|
+
|
225
229
|
def validate_file(file_name, locale = nil)
|
226
230
|
success = file_name.nil? || File.exists?(file_name)
|
227
231
|
warn(locale, { :file => file_name }) unless success
|
228
|
-
success
|
232
|
+
success
|
229
233
|
end
|
230
|
-
|
234
|
+
|
231
235
|
#---
|
232
|
-
|
236
|
+
|
233
237
|
def validate_files(file_names, locale = nil)
|
234
238
|
success = true
|
235
|
-
|
239
|
+
|
236
240
|
array(file_names).each do |file_name|
|
237
241
|
test = validate_file(file_name, locale)
|
238
242
|
success = false unless test
|
239
243
|
end
|
240
|
-
success
|
244
|
+
success
|
241
245
|
end
|
242
|
-
|
246
|
+
|
243
247
|
#---
|
244
|
-
|
248
|
+
|
245
249
|
def validate_directory(dir_name, locale = nil)
|
246
250
|
success = dir_name.nil? || File.directory?(dir_name)
|
247
251
|
warn(locale, { :directory => dir_name }) unless success
|
248
|
-
success
|
252
|
+
success
|
249
253
|
end
|
250
|
-
|
254
|
+
|
251
255
|
#---
|
252
|
-
|
256
|
+
|
253
257
|
def validate_directories(dir_names, locale = nil)
|
254
258
|
success = true
|
255
|
-
|
259
|
+
|
256
260
|
array(dir_names).each do |dir_name|
|
257
261
|
test = validate_directory(dir_name, locale)
|
258
262
|
success = false unless test
|
259
263
|
end
|
260
|
-
success
|
264
|
+
success
|
261
265
|
end
|
262
|
-
|
266
|
+
|
263
267
|
#---
|
264
|
-
|
268
|
+
|
265
269
|
def validate_plugin_types(namespace, name, values, locale = nil)
|
266
270
|
loaded_plugin_types = Nucleon.loaded_plugins(namespace).keys
|
267
271
|
success = true
|
268
272
|
locale = "validation.#{name}" unless locale
|
269
|
-
|
273
|
+
|
270
274
|
array(values).each do |value|
|
271
275
|
if ! loaded_plugin_types.include?(value.to_sym)
|
272
276
|
warn(locale, { :value => value, :choices => loaded_plugin_types.join(", ") })
|
273
277
|
success = false
|
274
278
|
end
|
275
|
-
end
|
276
|
-
success
|
279
|
+
end
|
280
|
+
success
|
277
281
|
end
|
278
|
-
|
282
|
+
|
279
283
|
#---
|
280
|
-
|
284
|
+
|
281
285
|
def validate_plugin_providers(namespace, type, name, values, locale = nil)
|
282
286
|
loaded_plugin_providers = Nucleon.loaded_plugins(namespace, type).keys
|
283
287
|
success = true
|
284
288
|
locale = "validation.#{name}" unless locale
|
285
|
-
|
289
|
+
|
286
290
|
array(values).each do |value|
|
287
291
|
if ! loaded_plugin_providers.include?(value.to_sym)
|
288
292
|
warn(locale, { :value => value, :choices => loaded_plugin_providers.join(", ") })
|
289
293
|
success = false
|
290
294
|
end
|
291
|
-
end
|
292
|
-
success
|
295
|
+
end
|
296
|
+
success
|
293
297
|
end
|
294
|
-
|
298
|
+
|
295
299
|
#---
|
296
|
-
|
300
|
+
|
297
301
|
def validate_plugins(namespace, type, name, values, locale = nil)
|
298
302
|
plugin_class = Nucleon.plugin_class(namespace, type)
|
299
303
|
loaded_plugins = Nucleon.loaded_plugins(namespace, type)
|
300
|
-
success = true
|
304
|
+
success = true
|
301
305
|
locale = "validation.#{name}" unless locale
|
302
|
-
|
306
|
+
|
303
307
|
array(values).each do |value|
|
304
308
|
if info = plugin_class.translate_reference(value)
|
305
309
|
if ! loaded_plugins.keys.include?(info[:provider].to_sym)
|
@@ -307,17 +311,17 @@ module Registration
|
|
307
311
|
success = false
|
308
312
|
end
|
309
313
|
end
|
310
|
-
end
|
314
|
+
end
|
311
315
|
success
|
312
316
|
end
|
313
|
-
|
317
|
+
|
314
318
|
#-----------------------------------------------------------------------------
|
315
319
|
# Utilities
|
316
|
-
|
320
|
+
|
317
321
|
def split_locales(locale)
|
318
322
|
option_locale = nil
|
319
323
|
validation_locale = nil
|
320
|
-
|
324
|
+
|
321
325
|
if locale.is_a?(Array)
|
322
326
|
option_locale = locale[0]
|
323
327
|
validation_locale = locale[1] if locale.size > 1
|
@@ -32,7 +32,7 @@ module SubConfig
|
|
32
32
|
#-----------------------------------------------------------------------------
|
33
33
|
|
34
34
|
def _get(keys, default = nil, format = false)
|
35
|
-
return fetch(@properties, array(keys).flatten, default, format)
|
35
|
+
return fetch(@properties, symbol_array(array(keys).flatten), default, format)
|
36
36
|
end
|
37
37
|
protected :_get
|
38
38
|
|
@@ -53,7 +53,7 @@ module SubConfig
|
|
53
53
|
#---
|
54
54
|
|
55
55
|
def _set(keys, value = '', delete_nil = false)
|
56
|
-
modify(@properties, array(keys).flatten, value, delete_nil)
|
56
|
+
modify(@properties, symbol_array(array(keys).flatten), value, delete_nil)
|
57
57
|
end
|
58
58
|
protected :_set
|
59
59
|
|
@@ -67,7 +67,7 @@ module SubConfig
|
|
67
67
|
#---
|
68
68
|
|
69
69
|
def _delete(keys, default = nil)
|
70
|
-
existing = modify(@properties, array(keys).flatten, nil, true)
|
70
|
+
existing = modify(@properties, symbol_array(array(keys).flatten), nil, true)
|
71
71
|
return existing[:value] if existing[:value]
|
72
72
|
return default
|
73
73
|
end
|
data/lib/core/util/cli.rb
CHANGED
@@ -58,20 +58,39 @@ module CLI
|
|
58
58
|
#---
|
59
59
|
|
60
60
|
def self.split(args, banner, separator = '')
|
61
|
+
check_args = []
|
61
62
|
main_args = nil
|
62
63
|
sub_command = nil
|
63
64
|
sub_args = []
|
64
65
|
|
65
|
-
args
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
# Log level gets processed in main args so we can log executable init
|
67
|
+
parse_log_value = false
|
68
|
+
|
69
|
+
args.each do |arg|
|
70
|
+
if arg =~ /^\-\-log_level(?=\=(.*))?/
|
71
|
+
if $1
|
72
|
+
Nucleon.log_level = $1
|
73
|
+
else
|
74
|
+
parse_log_value = true
|
75
|
+
end
|
76
|
+
elsif parse_log_value
|
77
|
+
Nucleon.log_level = arg
|
78
|
+
parse_log_value = false
|
79
|
+
else
|
80
|
+
check_args << arg
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
check_args.each_index do |index|
|
85
|
+
if !check_args[index].start_with?('-')
|
86
|
+
main_args = check_args[0, index]
|
87
|
+
sub_command = check_args[index]
|
88
|
+
sub_args = check_args[index + 1, check_args.length - index + 1]
|
70
89
|
break
|
71
90
|
end
|
72
91
|
end
|
73
92
|
|
74
|
-
main_args =
|
93
|
+
main_args = check_args.dup if main_args.nil?
|
75
94
|
results = [ Parser.new(main_args, banner, separator, true) ]
|
76
95
|
|
77
96
|
if sub_command
|
@@ -121,14 +140,18 @@ module CLI
|
|
121
140
|
'--version',
|
122
141
|
'nucleon.core.util.cli.options.version'
|
123
142
|
)
|
124
|
-
option_bool(:color,
|
125
|
-
'--[no]
|
143
|
+
option_bool(:color, Util::Console.use_colors,
|
144
|
+
'--[no-]color',
|
126
145
|
'nucleon.core.util.cli.options.color'
|
127
146
|
)
|
128
147
|
option_str(:log_level, nil,
|
129
148
|
'--log_level STR',
|
130
149
|
'nucleon.core.util.cli.options.log_level'
|
131
150
|
)
|
151
|
+
option_str(:exec_dir, nil,
|
152
|
+
'--exec_dir STR',
|
153
|
+
'nucleon.core.util.cli.options.exec_dir'
|
154
|
+
)
|
132
155
|
option_str(:encoded_params, false,
|
133
156
|
'--encoded STR',
|
134
157
|
'nucleon.core.util.cli.options.encoded'
|
@@ -162,12 +185,14 @@ module CLI
|
|
162
185
|
exit 0
|
163
186
|
end
|
164
187
|
|
188
|
+
if options[:exec_dir]
|
189
|
+
Dir.chdir(options[:exec_dir])
|
190
|
+
end
|
191
|
+
|
165
192
|
return if options[:help]
|
166
193
|
|
167
194
|
parse_encoded
|
168
195
|
|
169
|
-
Nucleon.log_level = options[:log_level] if options[:log_level]
|
170
|
-
|
171
196
|
self.extra = normalize_extra_options(extra_args) unless extra_args.empty?
|
172
197
|
|
173
198
|
remaining_args = args.dup
|
data/lib/core/util/ssh.rb
CHANGED
@@ -255,13 +255,13 @@ class SSH < Core
|
|
255
255
|
end
|
256
256
|
|
257
257
|
channel.on_data do |ch, data|
|
258
|
+
data = yield(:output, command, data) if block_given?
|
258
259
|
result.append_output(data)
|
259
|
-
yield(:output, command, data) if block_given?
|
260
260
|
end
|
261
261
|
|
262
262
|
channel.on_extended_data do |ch, type, data|
|
263
|
+
data = yield(:error, command, data) if block_given?
|
263
264
|
result.append_errors(data)
|
264
|
-
yield(:error, command, data) if block_given?
|
265
265
|
end
|
266
266
|
|
267
267
|
channel.on_request('exit-status') do |ch, data|
|
data/locales/en.yml
CHANGED
@@ -17,7 +17,7 @@ en:
|
|
17
17
|
For help on any individual action run `%{command}`
|
18
18
|
errors:
|
19
19
|
missing_argument: |-
|
20
|
-
Argument <%{name}> must be specified
|
20
|
+
Argument <%{name}> must be specified
|
21
21
|
util:
|
22
22
|
cli:
|
23
23
|
options:
|
@@ -31,6 +31,8 @@ en:
|
|
31
31
|
Display a more extended breakdown of available options for this commands available actions
|
32
32
|
log_level: |-
|
33
33
|
Set the logging level for this execution run
|
34
|
+
exec_dir: |-
|
35
|
+
Change to a specified directory before this execution run
|
34
36
|
encoded: |-
|
35
37
|
Optional encoded parameter set that contains default action settings (machine use only)
|
36
38
|
parse:
|
@@ -69,11 +71,26 @@ en:
|
|
69
71
|
propogate_push: |-
|
70
72
|
Propogate pushes to the remote throughout the project tree (default %{default_value})
|
71
73
|
action:
|
72
|
-
unknown:
|
74
|
+
unknown:
|
73
75
|
description: |-
|
74
76
|
This Nucleon action has no description available
|
75
77
|
help: |-
|
76
78
|
There is no extended help information available for this Nucleon action.
|
79
|
+
extract:
|
80
|
+
description: |-
|
81
|
+
Extract an encoded package into a directory
|
82
|
+
help: |-
|
83
|
+
Extract an encoded package into a directory
|
84
|
+
options:
|
85
|
+
path: |-
|
86
|
+
Base path in which to extract the encoded data
|
87
|
+
encoded: |-
|
88
|
+
Encoded data to be extracted into the base path
|
89
|
+
errors:
|
90
|
+
path: |-
|
91
|
+
"Base path for extracted files must be an existing directory"
|
92
|
+
encoded: |-
|
93
|
+
"Data is either not properly encoded or is empty %{value}"
|
77
94
|
project:
|
78
95
|
create:
|
79
96
|
description: |-
|
@@ -100,7 +117,7 @@ en:
|
|
100
117
|
files: |-
|
101
118
|
Optional space separated list of files to save
|
102
119
|
start: |-
|
103
|
-
Saving project changes with provider %{project_provider} (ref: %{project_reference} rev: %{project_revision})
|
120
|
+
Saving project changes with provider %{project_provider} (ref: %{project_reference} rev: %{project_revision})
|
104
121
|
add:
|
105
122
|
description: |-
|
106
123
|
Add a new sub-project to this project
|
@@ -123,17 +140,3 @@ en:
|
|
123
140
|
Subproject path
|
124
141
|
start: |-
|
125
142
|
Removing existing subproject at %{sub_path}
|
126
|
-
extract:
|
127
|
-
description: |-
|
128
|
-
Extract an encoded package into a directory
|
129
|
-
options:
|
130
|
-
path: |-
|
131
|
-
Base path in which to extract the encoded data
|
132
|
-
encoded: |-
|
133
|
-
Encoded data to be extracted into the base path
|
134
|
-
errors:
|
135
|
-
path: |-
|
136
|
-
"Base path for extracted files must be an existing directory"
|
137
|
-
encoded: |-
|
138
|
-
"Data is either not properly encoded or is empty %{value}"
|
139
|
-
|
data/nucleon.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: nucleon 0.2.
|
5
|
+
# stub: nucleon 0.2.9 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "nucleon"
|
9
|
-
s.version = "0.2.
|
9
|
+
s.version = "0.2.9"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Adrian Webb"]
|
14
|
-
s.date = "2015-02-
|
14
|
+
s.date = "2015-02-19"
|
15
15
|
s.description = "\nA framework that provides a simple foundation for building Ruby applications that are:\n\n* Highly configurable (with both distributed and persistent configurations)\n* Extremely pluggable and extendable\n* Easily parallel\n\nNote: This framework is still very early in development!\n"
|
16
16
|
s.email = "adrian.webb@coralnexus.com"
|
17
17
|
s.executables = ["nucleon"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nucleon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Webb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: log4r
|