nucleon 0.1.12 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/Gemfile.lock +27 -1
- data/VERSION +1 -1
- data/lib/core/config.rb +1 -1
- data/lib/core/config/collection.rb +24 -11
- data/lib/core/facade.rb +70 -0
- data/lib/core/manager.rb +25 -45
- data/lib/core/mixin/macro/plugin_interface.rb +2 -2
- data/lib/core/plugin/base.rb +11 -4
- data/lib/core/plugin/project.rb +19 -8
- data/lib/core/plugin/template.rb +7 -0
- data/lib/core/util/cache.rb +7 -2
- data/lib/core/util/shell.rb +7 -11
- data/lib/nucleon/project/git.rb +5 -2
- data/lib/nucleon_base.rb +139 -29
- data/nucleon.gemspec +12 -3
- metadata +44 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f70ed4e699ce46380540f987964c6dc765f542a0
|
4
|
+
data.tar.gz: 291ade54e0558e342f349adc551b0ebd7d0bf492
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19ba8e9c5ccfb4bbbcc44115ceda60d0af1f11879e65e10d81b4ce4b5ff11e69da0d03648a899c236197a7fb1e8e1944145965e8228213c8f9623956ebf8cdd4
|
7
|
+
data.tar.gz: 970bef07364f59149c7c87cd20b598b1cb9372709e04a10aad3d3a7187818d7fb85423be7d0fb86cc4602bc1398d1ced493815f62ab3b5a6c4381fde730f9c80
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,11 +2,22 @@ GEM
|
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
4
|
addressable (2.3.6)
|
5
|
+
binding_of_caller (0.7.2)
|
6
|
+
debug_inspector (>= 0.0.1)
|
5
7
|
builder (3.2.2)
|
6
8
|
celluloid (0.15.2)
|
7
9
|
timers (~> 1.1.0)
|
8
10
|
childprocess (0.5.2)
|
9
11
|
ffi (~> 1.0, >= 1.0.11)
|
12
|
+
coderay (1.1.0)
|
13
|
+
columnize (0.3.6)
|
14
|
+
debug_inspector (0.0.2)
|
15
|
+
debugger (1.6.6)
|
16
|
+
columnize (>= 0.3.1)
|
17
|
+
debugger-linecache (~> 1.2.0)
|
18
|
+
debugger-ruby_core_source (~> 1.3.2)
|
19
|
+
debugger-linecache (1.2.0)
|
20
|
+
debugger-ruby_core_source (1.3.2)
|
10
21
|
deep_merge (1.0.1)
|
11
22
|
descendants_tracker (0.0.4)
|
12
23
|
thread_safe (~> 0.3, >= 0.3.1)
|
@@ -23,7 +34,7 @@ GEM
|
|
23
34
|
multi_json (>= 1.7.5, < 2.0)
|
24
35
|
nokogiri (~> 1.6.0)
|
25
36
|
oauth2
|
26
|
-
hashie (2.1.
|
37
|
+
hashie (2.1.1)
|
27
38
|
highline (1.6.21)
|
28
39
|
i18n (0.6.9)
|
29
40
|
jeweler (2.0.1)
|
@@ -39,6 +50,7 @@ GEM
|
|
39
50
|
jwt (0.1.11)
|
40
51
|
multi_json (>= 1.5)
|
41
52
|
log4r (1.1.10)
|
53
|
+
method_source (0.8.2)
|
42
54
|
mini_portile (0.5.3)
|
43
55
|
multi_json (1.9.2)
|
44
56
|
multi_xml (0.5.5)
|
@@ -54,6 +66,16 @@ GEM
|
|
54
66
|
rack (~> 1.2)
|
55
67
|
octokit (2.7.2)
|
56
68
|
sawyer (~> 0.5.2)
|
69
|
+
pry (0.9.12.6)
|
70
|
+
coderay (~> 1.0)
|
71
|
+
method_source (~> 0.8)
|
72
|
+
slop (~> 3.4)
|
73
|
+
pry-debugger (0.2.2)
|
74
|
+
debugger (~> 1.3)
|
75
|
+
pry (~> 0.9.10)
|
76
|
+
pry-stack_explorer (0.4.9.1)
|
77
|
+
binding_of_caller (>= 0.7)
|
78
|
+
pry (>= 0.9.11)
|
57
79
|
rack (1.5.2)
|
58
80
|
rake (10.2.2)
|
59
81
|
rdoc (3.12.2)
|
@@ -70,6 +92,7 @@ GEM
|
|
70
92
|
sawyer (0.5.4)
|
71
93
|
addressable (~> 2.3.5)
|
72
94
|
faraday (~> 0.8, < 0.10)
|
95
|
+
slop (3.5.0)
|
73
96
|
sshkey (1.6.1)
|
74
97
|
thread_safe (0.3.3)
|
75
98
|
timers (1.1.0)
|
@@ -89,6 +112,9 @@ DEPENDENCIES
|
|
89
112
|
multi_json (~> 1.7)
|
90
113
|
netrc (~> 0.7)
|
91
114
|
octokit (~> 2.7)
|
115
|
+
pry (~> 0.9)
|
116
|
+
pry-debugger (~> 0.2)
|
117
|
+
pry-stack_explorer (~> 0.4)
|
92
118
|
rdoc (~> 3.12)
|
93
119
|
rspec (~> 2.10)
|
94
120
|
rugged (~> 0.19)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.13
|
data/lib/core/config.rb
CHANGED
@@ -6,50 +6,63 @@ class Collection
|
|
6
6
|
#-----------------------------------------------------------------------------
|
7
7
|
# Property accessor / modifiers
|
8
8
|
|
9
|
+
@@lock = Mutex.new
|
9
10
|
@@properties = {}
|
10
11
|
|
11
12
|
#---
|
12
13
|
|
13
14
|
def self.all
|
14
|
-
|
15
|
+
@@properties
|
15
16
|
end
|
16
17
|
|
17
18
|
#---
|
18
19
|
|
19
20
|
def self.get(name)
|
20
|
-
|
21
|
+
value = nil
|
22
|
+
@@lock.synchronize do
|
23
|
+
value = @@properties[name.to_sym]
|
24
|
+
end
|
25
|
+
value
|
21
26
|
end
|
22
27
|
|
23
28
|
#---
|
24
29
|
|
25
30
|
def self.set(name, value)
|
26
|
-
@@
|
31
|
+
@@lock.synchronize do
|
32
|
+
@@properties[name.to_sym] = value
|
33
|
+
end
|
27
34
|
end
|
28
35
|
|
29
36
|
#---
|
30
37
|
|
31
38
|
def self.delete(name)
|
32
|
-
@@
|
39
|
+
@@lock.synchronize do
|
40
|
+
@@properties.delete(name.to_sym)
|
41
|
+
end
|
33
42
|
end
|
34
43
|
|
35
44
|
#---
|
36
45
|
|
37
46
|
def self.clear
|
38
|
-
@@
|
47
|
+
@@lock.synchronize do
|
48
|
+
@@properties = {}
|
49
|
+
end
|
39
50
|
end
|
40
51
|
|
41
52
|
#---
|
42
53
|
|
43
54
|
def self.save(options = {})
|
44
55
|
unless Util::Data.empty?(options[:log_dir])
|
45
|
-
|
56
|
+
@@lock.synchronize do
|
57
|
+
log_dir = options[:log_dir]
|
46
58
|
|
47
|
-
|
48
|
-
|
49
|
-
|
59
|
+
if options[:config_store]
|
60
|
+
unless File.directory?(log_dir)
|
61
|
+
FileUtils.mkdir_p(log_dir)
|
62
|
+
end
|
63
|
+
Util::Disk.write(File.join(log_dir, "properties.json"), Util::Data.to_json(@@properties, true))
|
64
|
+
Util::Disk.write(File.join(log_dir, "properties.yaml"), Util::Data.to_yaml(Util::Data.string_map(@@properties)))
|
50
65
|
end
|
51
|
-
Util::Disk.write(File.join(log_dir, "common.json"), Util::Data.to_json(@@properties, true))
|
52
|
-
Util::Disk.write(File.join(log_dir, "common.yaml"), Util::Data.to_yaml(Util::Data.string_map(@@properties)))
|
53
66
|
end
|
54
67
|
end
|
55
68
|
end
|
data/lib/core/facade.rb
CHANGED
@@ -1,5 +1,33 @@
|
|
1
1
|
|
2
2
|
module Nucleon
|
3
|
+
#-------------------------------------------------------------------------------
|
4
|
+
# Parallel interface (include Parallel)
|
5
|
+
|
6
|
+
module Parallel
|
7
|
+
|
8
|
+
def self.included(klass)
|
9
|
+
if Nucleon.parallel?
|
10
|
+
klass.send :include, Celluloid
|
11
|
+
end
|
12
|
+
klass.extend ClassMethods
|
13
|
+
end
|
14
|
+
|
15
|
+
#---
|
16
|
+
|
17
|
+
module ClassMethods
|
18
|
+
def external_block_exec(*methods)
|
19
|
+
if Nucleon.parallel?
|
20
|
+
methods.each do |method|
|
21
|
+
execute_block_on_receiver method.to_sym
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
#-------------------------------------------------------------------------------
|
29
|
+
# Core Nucleon facade (extend Facade)
|
30
|
+
|
3
31
|
module Facade
|
4
32
|
|
5
33
|
include Mixin::Colors
|
@@ -34,6 +62,48 @@ module Facade
|
|
34
62
|
|
35
63
|
#-----------------------------------------------------------------------------
|
36
64
|
|
65
|
+
def handle(klass)
|
66
|
+
if parallel? && klass.respond_to?(:current_actor)
|
67
|
+
myself = klass.current_actor
|
68
|
+
else
|
69
|
+
myself = klass
|
70
|
+
end
|
71
|
+
myself
|
72
|
+
end
|
73
|
+
|
74
|
+
#---
|
75
|
+
|
76
|
+
def manager(collection, name, klass)
|
77
|
+
name = name.to_sym
|
78
|
+
|
79
|
+
if collection.has_key?(name)
|
80
|
+
manager = collection[name]
|
81
|
+
else
|
82
|
+
if parallel?
|
83
|
+
klass.supervise_as name
|
84
|
+
manager = Celluloid::Actor[name]
|
85
|
+
else
|
86
|
+
manager = klass.new # Managers should not have initialization parameters
|
87
|
+
end
|
88
|
+
collection[name] = manager
|
89
|
+
end
|
90
|
+
test_connection(manager)
|
91
|
+
manager
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_connection(manager)
|
95
|
+
if parallel?
|
96
|
+
begin
|
97
|
+
# Raise error if no test method found but retry for dead actors
|
98
|
+
manager.test_connection
|
99
|
+
rescue Celluloid::DeadActorError
|
100
|
+
retry
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
#-----------------------------------------------------------------------------
|
106
|
+
|
37
107
|
def admin?
|
38
108
|
is_admin = ( ENV['USER'] == 'root' )
|
39
109
|
ext_admin = exec(:check_admin) do |op, results|
|
data/lib/core/manager.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
module Nucleon
|
3
3
|
class Manager
|
4
4
|
|
5
|
-
include
|
6
|
-
|
5
|
+
include Parallel
|
6
|
+
|
7
7
|
#-----------------------------------------------------------------------------
|
8
8
|
|
9
9
|
@@supervisors = {}
|
@@ -11,26 +11,8 @@ class Manager
|
|
11
11
|
#-----------------------------------------------------------------------------
|
12
12
|
# Plugin manager interface
|
13
13
|
|
14
|
-
def self.init_manager(name)
|
15
|
-
name = name.to_sym
|
16
|
-
|
17
|
-
Manager.supervise_as name
|
18
|
-
@@supervisors[name] = Celluloid::Actor[name]
|
19
|
-
end
|
20
|
-
|
21
|
-
#---
|
22
|
-
|
23
14
|
def self.connection(name = :core)
|
24
|
-
name
|
25
|
-
|
26
|
-
init_manager(name) unless @@supervisors.has_key?(name)
|
27
|
-
|
28
|
-
#begin
|
29
|
-
@@supervisors[name].test_connection
|
30
|
-
#rescue Celluloid::DeadActorError
|
31
|
-
# retry
|
32
|
-
#end
|
33
|
-
@@supervisors[name]
|
15
|
+
Nucleon.manager(@@supervisors, name, self)
|
34
16
|
end
|
35
17
|
|
36
18
|
#---
|
@@ -52,7 +34,7 @@ class Manager
|
|
52
34
|
#---
|
53
35
|
|
54
36
|
def myself
|
55
|
-
|
37
|
+
Nucleon.handle(self)
|
56
38
|
end
|
57
39
|
|
58
40
|
#---
|
@@ -132,8 +114,8 @@ class Manager
|
|
132
114
|
def reload(core = false, &code)
|
133
115
|
logger.info("Loading Nucleon plugins at #{Time.now}")
|
134
116
|
|
135
|
-
if core
|
136
|
-
Celluloid.logger = logger
|
117
|
+
if core
|
118
|
+
Celluloid.logger = logger if Nucleon.parallel?
|
137
119
|
|
138
120
|
define_namespace :nucleon
|
139
121
|
|
@@ -292,27 +274,26 @@ class Manager
|
|
292
274
|
def load_base(type, provider, options = {})
|
293
275
|
logger.info("Fetching plugin #{type} provider #{provider} at #{Time.now}")
|
294
276
|
|
295
|
-
options
|
296
|
-
config
|
297
|
-
name
|
298
|
-
|
299
|
-
logger.debug("Plugin options: #{config.export.inspect}")
|
277
|
+
options = translate_type(type, options)
|
278
|
+
config = Config.ensure(options)
|
279
|
+
name = config.get(:name, nil)
|
280
|
+
ensure_new = config.delete(:new, false)
|
300
281
|
|
301
|
-
if name
|
282
|
+
if name
|
302
283
|
logger.debug("Looking up existing instance of #{name}")
|
303
284
|
|
304
|
-
existing_instance = get(type, name)
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
285
|
+
if existing_instance = get(type, name)
|
286
|
+
unless ensure_new
|
287
|
+
config.export.each do |property_name, value|
|
288
|
+
unless [ :name, :meta ].include?(property_name)
|
289
|
+
existing_instance[property_name] = value
|
290
|
+
end
|
310
291
|
end
|
311
|
-
|
312
|
-
existing_instance.normalize(true)
|
292
|
+
existing_instance.normalize(true)
|
313
293
|
|
314
|
-
|
315
|
-
|
294
|
+
logger.debug("Using existing instance of #{type}, #{name}")
|
295
|
+
return existing_instance
|
296
|
+
end
|
316
297
|
end
|
317
298
|
end
|
318
299
|
create(type, provider, options)
|
@@ -340,8 +321,6 @@ class Manager
|
|
340
321
|
klass = plugin_class(type)
|
341
322
|
data = klass.build_info(type, data) if klass.respond_to?(:build_info)
|
342
323
|
|
343
|
-
logger.debug("Translated plugin data: #{data.inspect}")
|
344
|
-
|
345
324
|
data.each do |options|
|
346
325
|
if plugin = load(type, options[:provider], options)
|
347
326
|
if build_hash
|
@@ -369,7 +348,7 @@ class Manager
|
|
369
348
|
info = @load_info[type][provider] if Util::Data.exists?(@load_info, [ type, provider ])
|
370
349
|
|
371
350
|
if info
|
372
|
-
logger.debug("Plugin information for #{provider} #{type} found.
|
351
|
+
logger.debug("Plugin information for #{provider} #{type} found.")
|
373
352
|
|
374
353
|
instance_name = "#{provider}_" + Nucleon.sha1(options)
|
375
354
|
options = translate(info[:namespace], type, provider, options)
|
@@ -380,7 +359,7 @@ class Manager
|
|
380
359
|
info[:instance_name] = instance_name
|
381
360
|
options[:meta] = Config.new(info).import(Util::Data.hash(options[:meta]))
|
382
361
|
|
383
|
-
logger.info("Creating new plugin #{provider} #{type}
|
362
|
+
logger.info("Creating new plugin #{provider} #{type}")
|
384
363
|
|
385
364
|
plugin = info[:class].new(type, provider, options)
|
386
365
|
|
@@ -416,7 +395,8 @@ class Manager
|
|
416
395
|
if plugin && plugin.respond_to?(:plugin_type) && @plugins.has_key?(plugin.plugin_type)
|
417
396
|
logger.debug("Removing #{plugin.plugin_type} #{plugin.plugin_name}")
|
418
397
|
@plugins[plugin.plugin_type].delete(plugin.plugin_instance_name)
|
419
|
-
plugin.
|
398
|
+
plugin.remove_plugin
|
399
|
+
plugin.terminate if plugin.respond_to?(:terminate) # For Celluloid plugins
|
420
400
|
else
|
421
401
|
logger.warn("Cannot remove plugin: #{plugin.inspect}")
|
422
402
|
end
|
@@ -57,8 +57,8 @@ module PluginInterface
|
|
57
57
|
code.call(type, provider, name, plugin)
|
58
58
|
end
|
59
59
|
else
|
60
|
-
logger.debug("Processing plugin: #{plugin.
|
61
|
-
code.call(type, provider, plugin.
|
60
|
+
logger.debug("Processing plugin: #{plugin.plugin_name}")
|
61
|
+
code.call(type, provider, plugin.plugin_name, plugin)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
data/lib/core/plugin/base.rb
CHANGED
@@ -29,6 +29,12 @@ class Base < Core
|
|
29
29
|
return nil
|
30
30
|
end
|
31
31
|
|
32
|
+
#---
|
33
|
+
|
34
|
+
def remove_plugin
|
35
|
+
# Implement in sub classes if needed for cleanup
|
36
|
+
end
|
37
|
+
|
32
38
|
#-----------------------------------------------------------------------------
|
33
39
|
# Checks
|
34
40
|
|
@@ -40,8 +46,7 @@ class Base < Core
|
|
40
46
|
# Property accessor / modifiers
|
41
47
|
|
42
48
|
def myself
|
43
|
-
|
44
|
-
self
|
49
|
+
Nucleon.handle(self)
|
45
50
|
end
|
46
51
|
alias_method :me, :myself
|
47
52
|
|
@@ -269,10 +274,12 @@ class Base < Core
|
|
269
274
|
|
270
275
|
#---
|
271
276
|
|
272
|
-
def self.init_plugin_collection
|
277
|
+
def self.init_plugin_collection(*external_block_methods)
|
273
278
|
logger.debug("Initializing plugin collection interface at #{Time.now}")
|
274
279
|
|
275
|
-
include
|
280
|
+
include Parallel
|
281
|
+
external_block_exec(*external_block_methods)
|
282
|
+
|
276
283
|
include Mixin::Settings
|
277
284
|
include Mixin::SubConfig
|
278
285
|
|
data/lib/core/plugin/project.rb
CHANGED
@@ -767,12 +767,11 @@ class Project < Base
|
|
767
767
|
# Remote operations
|
768
768
|
|
769
769
|
def pull(remote = :edit, options = {})
|
770
|
+
config = Config.ensure(options).import({ :remote => remote })
|
770
771
|
success = false
|
771
772
|
|
772
773
|
if can_persist?
|
773
|
-
localize do
|
774
|
-
config = Config.ensure(options).import({ :remote => remote })
|
775
|
-
|
774
|
+
localize do
|
776
775
|
if extension_check(:pull, { :directory => directory, :config => config })
|
777
776
|
remote = config.delete(:remote)
|
778
777
|
|
@@ -806,18 +805,30 @@ class Project < Base
|
|
806
805
|
#---
|
807
806
|
|
808
807
|
def push(remote = :edit, options = {})
|
808
|
+
config = Config.ensure(options).import({ :remote => remote })
|
809
809
|
success = false
|
810
810
|
|
811
|
+
push_project = lambda do |push_remote|
|
812
|
+
logger.info("Pushing to #{push_remote} from #{directory}")
|
813
|
+
success = yield(config, push_remote) if block_given? && pull(push_remote, config)
|
814
|
+
end
|
815
|
+
|
811
816
|
if can_persist?
|
812
|
-
localize do
|
813
|
-
config = Config.ensure(options).import({ :remote => remote })
|
814
|
-
|
817
|
+
localize do
|
815
818
|
if extension_check(:push, { :directory => directory, :config => config })
|
816
819
|
remote = config.delete(:remote)
|
820
|
+
tries = config.delete(:tries, 5)
|
817
821
|
|
822
|
+
# TODO: Figure out a better way through specialized exception handling
|
818
823
|
if remote(remote)
|
819
|
-
|
820
|
-
|
824
|
+
begin
|
825
|
+
success = push_project.call(remote)
|
826
|
+
raise unless success
|
827
|
+
|
828
|
+
rescue
|
829
|
+
tries -= 1
|
830
|
+
retry if tries > 0
|
831
|
+
end
|
821
832
|
end
|
822
833
|
|
823
834
|
if success
|
data/lib/core/plugin/template.rb
CHANGED
@@ -75,6 +75,13 @@ class Template < Base
|
|
75
75
|
logger.debug("Completed rendering of #{plugin_provider} data: #{output}")
|
76
76
|
return output
|
77
77
|
end
|
78
|
+
|
79
|
+
#-----------------------------------------------------------------------------
|
80
|
+
# Utilities
|
81
|
+
|
82
|
+
def self.translate(data)
|
83
|
+
return data
|
84
|
+
end
|
78
85
|
end
|
79
86
|
end
|
80
87
|
end
|
data/lib/core/util/cache.rb
CHANGED
@@ -60,12 +60,13 @@ class Cache < Core
|
|
60
60
|
#---
|
61
61
|
|
62
62
|
def get(keys, default = nil, format = false)
|
63
|
-
result = super
|
63
|
+
result = super(keys, nil)
|
64
64
|
|
65
65
|
if result.nil?
|
66
66
|
load
|
67
|
-
result = super
|
67
|
+
result = super(keys, nil)
|
68
68
|
end
|
69
|
+
result = filter(default, format) if result.nil?
|
69
70
|
result
|
70
71
|
end
|
71
72
|
|
@@ -119,6 +120,8 @@ class Cache < Core
|
|
119
120
|
logger.debug("Cache file contents: #{raw}")
|
120
121
|
parse_properties = Data.hash(parser.parse(raw))
|
121
122
|
|
123
|
+
Nucleon.remove_plugin(parser)
|
124
|
+
|
122
125
|
import(parse_properties, { :no_save => true }) unless parse_properties.empty?
|
123
126
|
success = true
|
124
127
|
end
|
@@ -135,6 +138,8 @@ class Cache < Core
|
|
135
138
|
@@cache_lock.synchronize do
|
136
139
|
if renderer = CORL.translator({}, translator)
|
137
140
|
rendering = renderer.generate(export)
|
141
|
+
|
142
|
+
Nucleon.remove_plugin(renderer)
|
138
143
|
|
139
144
|
if Disk.write(file, rendering)
|
140
145
|
success = true
|
data/lib/core/util/shell.rb
CHANGED
@@ -3,7 +3,8 @@ module Nucleon
|
|
3
3
|
module Util
|
4
4
|
class Shell < Core
|
5
5
|
|
6
|
-
include
|
6
|
+
include Parallel
|
7
|
+
external_block_exec :exec
|
7
8
|
|
8
9
|
#-----------------------------------------------------------------------------
|
9
10
|
|
@@ -48,21 +49,16 @@ class Shell < Core
|
|
48
49
|
# Shell interface
|
49
50
|
|
50
51
|
def self.connection(name = :core)
|
51
|
-
name
|
52
|
-
init_shell(name) unless @@supervisors.has_key?(name)
|
53
|
-
@@supervisors[name]
|
52
|
+
Nucleon.manager(@@supervisors, name, self)
|
54
53
|
end
|
55
54
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
@@supervisors[name] = Celluloid::Actor[name]
|
55
|
+
#---
|
56
|
+
|
57
|
+
def test_connection
|
58
|
+
true
|
61
59
|
end
|
62
60
|
|
63
61
|
#---
|
64
|
-
|
65
|
-
execute_block_on_receiver :exec
|
66
62
|
|
67
63
|
def exec(command, options = {}, &code)
|
68
64
|
config = Config.ensure(options)
|
data/lib/nucleon/project/git.rb
CHANGED
@@ -527,7 +527,7 @@ class Git < Plugin::Project
|
|
527
527
|
command_provider = get(:command_provider, Nucleon.type_default(:command))
|
528
528
|
quiet = get(:quiet, true)
|
529
529
|
|
530
|
-
|
530
|
+
command = Nucleon.command({
|
531
531
|
:command => :git,
|
532
532
|
:data => { 'git-dir=' => repo.path },
|
533
533
|
:subcommand => {
|
@@ -536,9 +536,12 @@ class Git < Plugin::Project
|
|
536
536
|
:data => data,
|
537
537
|
:args => processed_args
|
538
538
|
}
|
539
|
-
}, command_provider)
|
539
|
+
}, command_provider)
|
540
|
+
|
541
|
+
result = command.exec({ :quiet => quiet }) do |op, cli_command, cli_data|
|
540
542
|
block_given? ? yield(op, cli_command, cli_data) : true
|
541
543
|
end
|
544
|
+
Nucleon.remove_plugin(command)
|
542
545
|
end
|
543
546
|
end
|
544
547
|
result
|
data/lib/nucleon_base.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
#*******************************************************************************
|
3
2
|
# Nucleon
|
4
3
|
#
|
@@ -71,6 +70,108 @@ macro_dir = File.join(mixin_dir, 'macro')
|
|
71
70
|
util_dir = File.join(core_dir, 'util')
|
72
71
|
mod_dir = File.join(core_dir, 'mod')
|
73
72
|
plugin_dir = File.join(core_dir, 'plugin')
|
73
|
+
|
74
|
+
#-------------------------------------------------------------------------------
|
75
|
+
# Environment checks and debugging
|
76
|
+
|
77
|
+
module Nucleon
|
78
|
+
|
79
|
+
def self.VERSION
|
80
|
+
File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
|
81
|
+
end
|
82
|
+
|
83
|
+
#-----------------------------------------------------------------------------
|
84
|
+
|
85
|
+
def self.debugging?
|
86
|
+
ENV["NUCLEON_DEBUG"] ? true : false
|
87
|
+
end
|
88
|
+
|
89
|
+
#---
|
90
|
+
|
91
|
+
def self.debug_break(condition = true)
|
92
|
+
if debugging?
|
93
|
+
#-------------------------------------------------------------------------------
|
94
|
+
# Nucleon Pry powered development console
|
95
|
+
#
|
96
|
+
# Usage:
|
97
|
+
#
|
98
|
+
# * Execute nucleon (or derivative executable, ex; corl) with the NUCLEON_DEBUG
|
99
|
+
# environment variable set
|
100
|
+
#
|
101
|
+
# :> [ sudo ] NUCLEON_DEBUG=1 nucleon <args>...
|
102
|
+
#
|
103
|
+
# * Call the debug_break method anywhere in the code to start a debugging
|
104
|
+
# session.
|
105
|
+
#
|
106
|
+
# :> Nucleon.debug_break or :> Nucleon.debug_break <test?>
|
107
|
+
#
|
108
|
+
# * Since the debugging tools don't work in parallel, parallel operations are
|
109
|
+
# serialized when NUCLEON_DEBUG environment variable is found.
|
110
|
+
#
|
111
|
+
#-------------------------------------------------------------------------------
|
112
|
+
# General information
|
113
|
+
#
|
114
|
+
# For more information on Pry: http://pryrepl.org
|
115
|
+
# ( https://github.com/pry/pry )
|
116
|
+
#
|
117
|
+
# Loaded plugins: stack explorer ( https://github.com/pry/pry-stack_explorer )
|
118
|
+
# debugger ( https://github.com/nixme/pry-debugger )
|
119
|
+
#
|
120
|
+
# For available commands and help information: [ help ]
|
121
|
+
# For command specific help: [ <command> --help ]
|
122
|
+
#
|
123
|
+
#-------------------------------------------------------------------------------
|
124
|
+
# General commands:
|
125
|
+
#
|
126
|
+
# :> cd <Class> Change to inspect class (class constant)
|
127
|
+
# :> show-method <method> Show source for class method
|
128
|
+
# :> .<CLI command> <args>... Execute a CLI command (always starts with dot)
|
129
|
+
#
|
130
|
+
#-------------------------------------------------------------------------------
|
131
|
+
# Breakpoints
|
132
|
+
#
|
133
|
+
# :> breakpoints List all defined breakpoints
|
134
|
+
# :> break Same as breakpoints command
|
135
|
+
#
|
136
|
+
# :> break <Class>#<method> Break at start of `Class#method`.
|
137
|
+
# :> break <Class>#<method> if <test?> Break at `Class#method` if `test?`.
|
138
|
+
# :> break <path>/<ruby file>:<line> Break at line in ruby file.
|
139
|
+
# :> break <line> Break at line in current file.
|
140
|
+
#
|
141
|
+
# :> break --condition <breakpoint> <test?> Change condition on breakpoint.
|
142
|
+
# :> break --condition <breakpoint> Remove condition on breakpoint.
|
143
|
+
#
|
144
|
+
# :> break --delete <breakpoint> Delete breakpoint.
|
145
|
+
# :> break --disable-all Disable all breakpoints.
|
146
|
+
#
|
147
|
+
# :> break --show <breakpoint> Show details about breakpoint.
|
148
|
+
#
|
149
|
+
#-------------------------------------------------------------------------------
|
150
|
+
# Stack inspection / traversal
|
151
|
+
#
|
152
|
+
# :> show-stack Show all accessible frames in the call stack.
|
153
|
+
# :> frame <number> Move to a specific frame.
|
154
|
+
# :> up Move up one frame in the call stack.
|
155
|
+
# :> down Move down one frame in the call stack.
|
156
|
+
#
|
157
|
+
#-------------------------------------------------------------------------------
|
158
|
+
# Debugging execution flow:
|
159
|
+
#
|
160
|
+
# :> s = [ step | step <times> ] Step execution into the next line or method.
|
161
|
+
# :> n = [ next | next <times> ] Step over to the next line within same frame.
|
162
|
+
# :> f = [ finish ] Execute until current stack frame returns.
|
163
|
+
# :> c = [ continue ] Continue program execution (end Pry session).
|
164
|
+
#
|
165
|
+
binding.pry if condition
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
#-----------------------------------------------------------------------------
|
170
|
+
|
171
|
+
def self.parallel?
|
172
|
+
debugging? || ENV['NUCLEON_NO_PARALLEL'] ? false : true
|
173
|
+
end
|
174
|
+
end
|
74
175
|
|
75
176
|
#-------------------------------------------------------------------------------
|
76
177
|
# Coral requirements
|
@@ -79,13 +180,25 @@ $:.unshift(lib_dir) unless $:.include?(lib_dir) || $:.include?(File.expand_path(
|
|
79
180
|
|
80
181
|
#---
|
81
182
|
|
183
|
+
if Nucleon.debugging?
|
184
|
+
require 'pry'
|
185
|
+
require 'pry-stack_explorer'
|
186
|
+
require 'pry-debugger'
|
187
|
+
|
188
|
+
if defined?(PryDebugger)
|
189
|
+
Pry.commands.alias_command 'c', 'continue'
|
190
|
+
Pry.commands.alias_command 's', 'step'
|
191
|
+
Pry.commands.alias_command 'n', 'next'
|
192
|
+
Pry.commands.alias_command 'f', 'finish'
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
#---
|
197
|
+
|
82
198
|
# TODO: Reduce the number of dependencies loaded in this load script (for performance).
|
83
199
|
# Decentralize!
|
84
|
-
|
85
|
-
require 'rubygems'
|
86
200
|
|
87
201
|
require 'optparse'
|
88
|
-
require 'pp'
|
89
202
|
require 'i18n'
|
90
203
|
require 'log4r'
|
91
204
|
require 'log4r/configurator'
|
@@ -101,10 +214,12 @@ require 'tmpdir'
|
|
101
214
|
require 'sshkey'
|
102
215
|
|
103
216
|
require 'childprocess'
|
217
|
+
require 'thread'
|
104
218
|
|
105
|
-
|
106
|
-
require 'celluloid'
|
107
|
-
require 'celluloid/autostart'
|
219
|
+
if Nucleon.parallel?
|
220
|
+
require 'celluloid'
|
221
|
+
require 'celluloid/autostart'
|
222
|
+
end
|
108
223
|
|
109
224
|
#---
|
110
225
|
|
@@ -115,13 +230,6 @@ I18n.load_path << File.expand_path(File.join('..', 'locales', 'en.yml'), lib_dir
|
|
115
230
|
|
116
231
|
#---
|
117
232
|
|
118
|
-
if nucleon_locate('git')
|
119
|
-
require 'rugged'
|
120
|
-
nucleon_require(util_dir, :git)
|
121
|
-
end
|
122
|
-
|
123
|
-
#---
|
124
|
-
|
125
233
|
# Make sure logger is at the top of our load order priorities
|
126
234
|
nucleon_require(util_dir, :logger)
|
127
235
|
|
@@ -150,6 +258,14 @@ end
|
|
150
258
|
|
151
259
|
#---
|
152
260
|
|
261
|
+
nucleon_require(core_dir, :facade)
|
262
|
+
|
263
|
+
module Nucleon
|
264
|
+
extend Facade
|
265
|
+
end
|
266
|
+
|
267
|
+
#---
|
268
|
+
|
153
269
|
# Include bootstrap classes
|
154
270
|
nucleon_require(core_dir, :errors)
|
155
271
|
nucleon_require(core_dir, :codes)
|
@@ -172,23 +288,17 @@ nucleon_require(core_dir, :core)
|
|
172
288
|
nucleon_require(util_dir, name)
|
173
289
|
end
|
174
290
|
|
291
|
+
#---
|
292
|
+
|
293
|
+
if nucleon_locate('git')
|
294
|
+
require 'rugged'
|
295
|
+
nucleon_require(util_dir, :git)
|
296
|
+
end
|
297
|
+
|
298
|
+
#---
|
299
|
+
|
175
300
|
# Include plugin system
|
176
|
-
nucleon_require(core_dir, :facade)
|
177
301
|
nucleon_require(core_dir, :gems)
|
178
302
|
nucleon_require(core_dir, :manager)
|
179
303
|
nucleon_require(plugin_dir, :base)
|
180
304
|
nucleon_require(core_dir, :plugin)
|
181
|
-
|
182
|
-
#-------------------------------------------------------------------------------
|
183
|
-
# Core interface
|
184
|
-
|
185
|
-
module Nucleon
|
186
|
-
|
187
|
-
def self.VERSION
|
188
|
-
File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
|
189
|
-
end
|
190
|
-
|
191
|
-
#-----------------------------------------------------------------------------
|
192
|
-
|
193
|
-
extend Facade
|
194
|
-
end
|
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.1.
|
5
|
+
# stub: nucleon 0.1.13 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "nucleon"
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.13"
|
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 = "2014-04-
|
14
|
+
s.date = "2014-04-14"
|
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"]
|
@@ -118,6 +118,9 @@ Gem::Specification.new do |s|
|
|
118
118
|
s.add_development_dependency(%q<rspec>, ["~> 2.10"])
|
119
119
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
120
120
|
s.add_development_dependency(%q<yard>, ["~> 0.8"])
|
121
|
+
s.add_development_dependency(%q<pry>, ["~> 0.9"])
|
122
|
+
s.add_development_dependency(%q<pry-stack_explorer>, ["~> 0.4"])
|
123
|
+
s.add_development_dependency(%q<pry-debugger>, ["~> 0.2"])
|
121
124
|
else
|
122
125
|
s.add_dependency(%q<log4r>, ["~> 1.1"])
|
123
126
|
s.add_dependency(%q<i18n>, ["~> 0.6"])
|
@@ -134,6 +137,9 @@ Gem::Specification.new do |s|
|
|
134
137
|
s.add_dependency(%q<rspec>, ["~> 2.10"])
|
135
138
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
136
139
|
s.add_dependency(%q<yard>, ["~> 0.8"])
|
140
|
+
s.add_dependency(%q<pry>, ["~> 0.9"])
|
141
|
+
s.add_dependency(%q<pry-stack_explorer>, ["~> 0.4"])
|
142
|
+
s.add_dependency(%q<pry-debugger>, ["~> 0.2"])
|
137
143
|
end
|
138
144
|
else
|
139
145
|
s.add_dependency(%q<log4r>, ["~> 1.1"])
|
@@ -151,6 +157,9 @@ Gem::Specification.new do |s|
|
|
151
157
|
s.add_dependency(%q<rspec>, ["~> 2.10"])
|
152
158
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
153
159
|
s.add_dependency(%q<yard>, ["~> 0.8"])
|
160
|
+
s.add_dependency(%q<pry>, ["~> 0.9"])
|
161
|
+
s.add_dependency(%q<pry-stack_explorer>, ["~> 0.4"])
|
162
|
+
s.add_dependency(%q<pry-debugger>, ["~> 0.2"])
|
154
163
|
end
|
155
164
|
end
|
156
165
|
|
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.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Webb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: log4r
|
@@ -220,6 +220,48 @@ dependencies:
|
|
220
220
|
- - "~>"
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0.8'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: pry
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - "~>"
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0.9'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - "~>"
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0.9'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: pry-stack_explorer
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - "~>"
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '0.4'
|
244
|
+
type: :development
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - "~>"
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0.4'
|
251
|
+
- !ruby/object:Gem::Dependency
|
252
|
+
name: pry-debugger
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - "~>"
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: '0.2'
|
258
|
+
type: :development
|
259
|
+
prerelease: false
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - "~>"
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: '0.2'
|
223
265
|
description: |2
|
224
266
|
|
225
267
|
A framework that provides a simple foundation for building Ruby applications that are:
|