rsence 2.0.0.9.pre → 2.0.0.10.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/http/broker.rb +4 -3
- data/lib/plugins/dependencies.rb +4 -3
- data/lib/plugins/pluginmanager.rb +80 -64
- metadata +4 -5
- data/lib/plugins/dependencies.rbc +0 -2103
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0.
|
1
|
+
2.0.0.10.pre
|
data/lib/http/broker.rb
CHANGED
@@ -84,11 +84,12 @@ class Broker
|
|
84
84
|
end
|
85
85
|
Thread.new do
|
86
86
|
Thread.pass
|
87
|
-
puts "
|
87
|
+
puts "Testing if #{host}:#{port} responds.." if ::RSence.args[:debug]
|
88
88
|
until RSence.argv.test_port( port, host )
|
89
|
-
puts "port
|
90
|
-
sleep 0.
|
89
|
+
puts "..#{host}:#{port} doesn't respond yet.." if ::RSence.args[:debug]
|
90
|
+
sleep 0.2
|
91
91
|
end
|
92
|
+
puts "..#{host}:#{port} responds!" if ::RSence.args[:debug]
|
92
93
|
@@transporter.online = true
|
93
94
|
end
|
94
95
|
|
data/lib/plugins/dependencies.rb
CHANGED
@@ -64,7 +64,8 @@ module RSence
|
|
64
64
|
# Don't use Dependencies for external projects yet. It's subject to change
|
65
65
|
# without deprecation warnings.
|
66
66
|
# +resolved+ and +categories+ are optional.
|
67
|
-
def initialize( resolved = [], categories = {} )
|
67
|
+
def initialize( resolved = [], categories = {}, quiet=true )
|
68
|
+
@quiet = quiet
|
68
69
|
@pre_resolved = resolved.clone
|
69
70
|
@depends_on = {
|
70
71
|
# :name => [ :dep1, :dep2, :dep3, ... ]
|
@@ -256,9 +257,9 @@ module RSence
|
|
256
257
|
end
|
257
258
|
if len == resolved.length
|
258
259
|
if same_len
|
259
|
-
warn "impossible dependencies:"
|
260
|
+
warn "impossible dependencies:" unless @quiet
|
260
261
|
(depends_on.keys - resolved).each do |unsatisfied|
|
261
|
-
warn " #{unsatisfied.inspect} => #{depends_on[unsatisfied].inspect}"
|
262
|
+
warn " #{unsatisfied.inspect} => #{depends_on[unsatisfied].inspect}" unless @quiet
|
262
263
|
unresolved.push( unsatisfied )
|
263
264
|
end
|
264
265
|
break
|
@@ -402,12 +402,12 @@ module RSence
|
|
402
402
|
end
|
403
403
|
|
404
404
|
# Returns true, if the bundle is disabled
|
405
|
-
def
|
405
|
+
def disabled?( bundle_path )
|
406
406
|
File.exists?( File.join( bundle_path, 'disabled' ) )
|
407
407
|
end
|
408
408
|
|
409
409
|
# Returns true, if the bundle is loaded.
|
410
|
-
def
|
410
|
+
def loaded?( bundle_name )
|
411
411
|
@registry.has_key?( bundle_name )
|
412
412
|
end
|
413
413
|
|
@@ -417,39 +417,20 @@ module RSence
|
|
417
417
|
# - Skips bundles without a ruby source file with the same
|
418
418
|
# name as the directory (plus '.rb').
|
419
419
|
# - Skips bundles containing a file or directory named 'disabled'
|
420
|
-
def
|
420
|
+
def find_bundles( path )
|
421
421
|
bundles_found = []
|
422
422
|
Dir.entries(path).each do |bundle_name|
|
423
423
|
bundle_status = valid_plugindir?( path, bundle_name )
|
424
424
|
if bundle_status
|
425
425
|
(bundle_path, src_file) = bundle_status
|
426
|
-
|
426
|
+
unless disabled?( bundle_path )
|
427
|
+
bundles_found.push( [bundle_path, bundle_name.to_sym, src_file] )
|
428
|
+
end
|
427
429
|
end
|
428
430
|
end
|
429
431
|
return bundles_found
|
430
432
|
end
|
431
433
|
|
432
|
-
# Top-level method for scanning all plugin directories.
|
433
|
-
# Clears previously loaded plugins.
|
434
|
-
def scan_plugins
|
435
|
-
@registry = {} # bundle_name => bundle_instance mapping
|
436
|
-
@info = {} # bundle_name => bundle_info mapping
|
437
|
-
@aliases = {} # bundle_alias => bundle_name mapping
|
438
|
-
@servlets = [] # bundle_name list of Servlet class instances
|
439
|
-
bundles_found = []
|
440
|
-
@plugin_paths.each do |path|
|
441
|
-
next unless File.directory? path
|
442
|
-
bundles_found += scan_plugindir( path )
|
443
|
-
end
|
444
|
-
bundles_found.each do |bundle_path, bundle_name, src_file|
|
445
|
-
unless is_disabled?( bundle_path )
|
446
|
-
bundle_found( bundle_path, bundle_name, src_file )
|
447
|
-
end
|
448
|
-
end
|
449
|
-
load_bundles
|
450
|
-
delegate( :open )
|
451
|
-
end
|
452
|
-
|
453
434
|
# Unloads the plugin bundle named +bundle_name+
|
454
435
|
def unload_bundle( bundle_name )
|
455
436
|
if @registry.has_key?( bundle_name )
|
@@ -476,19 +457,20 @@ module RSence
|
|
476
457
|
@info.delete( bundle_name )
|
477
458
|
end
|
478
459
|
@transporter.online = online_status
|
460
|
+
return unload_order
|
479
461
|
end
|
480
462
|
end
|
481
463
|
|
482
464
|
# Returns true, if a plugin bundle has changed.
|
483
465
|
# Only compares timestamp, not checksum.
|
484
|
-
def
|
466
|
+
def changed?( plugin_name )
|
485
467
|
info = @info[plugin_name]
|
486
468
|
last_changed = info[:last_changed]
|
487
469
|
newest_change = most_recent( info[:path], last_changed )
|
488
470
|
return last_changed < newest_change
|
489
471
|
end
|
490
472
|
|
491
|
-
# Logs and speaks the message
|
473
|
+
# Logs and speaks the message, if the speech synthesis command "say" exists.
|
492
474
|
def say( message )
|
493
475
|
puts message
|
494
476
|
if RSence.args[:say]
|
@@ -500,45 +482,79 @@ module RSence
|
|
500
482
|
end
|
501
483
|
|
502
484
|
# Checks for changed plugin bundles and unloads/loads/reloads them accordingly.
|
503
|
-
def
|
504
|
-
|
485
|
+
def update_bundles!
|
486
|
+
(are_found, to_load, to_unload, to_reload) = [[],[],[],[]]
|
487
|
+
found_map = {}
|
505
488
|
@plugin_paths.each do |path|
|
506
|
-
|
507
|
-
end
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
is_loaded =
|
512
|
-
if is_loaded and
|
513
|
-
|
514
|
-
unload_bundle( bundle_name )
|
515
|
-
say( "Unloaded #{bundle_name}." )
|
516
|
-
elsif is_loaded and plugin_changed?( bundle_name )
|
517
|
-
# bundle changed, should be reloaded:
|
518
|
-
unload_bundle( bundle_name )
|
519
|
-
unless @info.has_key?( bundle_name ) and not plugin_changed?( bundle_name )
|
520
|
-
@info[bundle_name] = bundle_info( bundle_path, bundle_name, src_file )
|
521
|
-
end
|
522
|
-
if @deps.resolved?( bundle_name )
|
523
|
-
load_bundle( bundle_name )
|
524
|
-
say( "Reloaded #{bundle_name}." )
|
525
|
-
end
|
489
|
+
are_found += find_bundles( path )
|
490
|
+
end
|
491
|
+
are_found.each do |item|
|
492
|
+
(path, name, src_file) = item
|
493
|
+
found_map[name] = item
|
494
|
+
is_loaded = loaded?( name )
|
495
|
+
if is_loaded and changed?( name )
|
496
|
+
to_reload.push( name )
|
526
497
|
elsif not is_loaded
|
527
|
-
|
528
|
-
unless @info.has_key?( bundle_name ) and not plugin_changed?( bundle_name )
|
529
|
-
@info[bundle_name] = bundle_info( bundle_path, bundle_name, src_file )
|
530
|
-
end
|
531
|
-
if @deps.resolved?( bundle_name )
|
532
|
-
load_bundle( bundle_name )
|
533
|
-
say( "Loaded #{bundle_name}." )
|
534
|
-
end
|
498
|
+
to_load.push( name )
|
535
499
|
end
|
536
500
|
end
|
537
|
-
|
538
|
-
|
539
|
-
say( "#{bundle_name} deleted, unloading.." )
|
540
|
-
unload_bundle( bundle_name )
|
501
|
+
@registry.keys.each do |name|
|
502
|
+
to_unload.push( name ) if not found_map.has_key?( name )
|
541
503
|
end
|
504
|
+
to_unload.each do |name|
|
505
|
+
puts "Unloading #{name.inspect}"
|
506
|
+
unload_bundle( name )
|
507
|
+
end
|
508
|
+
to_reload.each do |name|
|
509
|
+
puts "Unloading #{name.inspect}"
|
510
|
+
unload_order = unload_bundle( name )
|
511
|
+
to_load += unload_order
|
512
|
+
end
|
513
|
+
info_map = {}
|
514
|
+
to_load.each do |name|
|
515
|
+
info_map[name] = bundle_info( *found_map[name] )
|
516
|
+
end
|
517
|
+
no_deps = {}
|
518
|
+
to_load.dup.each do |name|
|
519
|
+
if @deps.unresolved?( name )
|
520
|
+
no_deps[ name ] = @deps.deps_on( name )
|
521
|
+
@deps.del_item( name )
|
522
|
+
to_load.delete( name )
|
523
|
+
end
|
524
|
+
end
|
525
|
+
to_open = []
|
526
|
+
@deps.list.each do |name|
|
527
|
+
next unless to_load.include?( name )
|
528
|
+
info = info_map[name]
|
529
|
+
if to_reload.include?( name )
|
530
|
+
puts "Reloading #{name.inspect}"
|
531
|
+
else
|
532
|
+
puts "Loading #{name.inspect}"
|
533
|
+
end
|
534
|
+
@info[name] = info
|
535
|
+
load_bundle( name )
|
536
|
+
to_open.push( name )
|
537
|
+
end
|
538
|
+
unless no_deps.empty?
|
539
|
+
warn "Warning! Unable to load the following bundles; missing dependencies:"
|
540
|
+
no_deps.each do |name,deps|
|
541
|
+
warn " #{name} depends on: #{deps.join(', ')}"
|
542
|
+
end
|
543
|
+
end
|
544
|
+
to_open.each do |name|
|
545
|
+
puts "Opening #{name.inspect}"
|
546
|
+
call( name, :open )
|
547
|
+
end
|
548
|
+
end
|
549
|
+
|
550
|
+
# Top-level method for scanning all plugin directories.
|
551
|
+
# Clears previously loaded plugins.
|
552
|
+
def init_bundles!
|
553
|
+
@registry = {} # bundle_name => bundle_instance mapping
|
554
|
+
@info = {} # bundle_name => bundle_info mapping
|
555
|
+
@aliases = {} # bundle_alias => bundle_name mapping
|
556
|
+
@servlets = [] # bundle_name list of Servlet class instances
|
557
|
+
update_bundles!
|
542
558
|
end
|
543
559
|
|
544
560
|
# Initialize with a list of directories as plugin_paths.
|
@@ -554,16 +570,16 @@ module RSence
|
|
554
570
|
@plugin_paths = plugin_paths
|
555
571
|
@deps = Dependencies.new( resolved_deps, resolved_categories )
|
556
572
|
puts "Loading #{name_prefix+' ' if name_prefix}plugins..." if RSence.args[:verbose]
|
557
|
-
|
573
|
+
init_bundles!
|
558
574
|
puts %{Plugins #{"of #{name_prefix} " if name_prefix}loaded.} if RSence.args[:verbose]
|
559
575
|
if autoreload
|
560
576
|
@thr = Thread.new do
|
561
577
|
Thread.pass
|
562
578
|
while true
|
563
579
|
begin
|
564
|
-
|
580
|
+
update_bundles!
|
565
581
|
rescue => e
|
566
|
-
|
582
|
+
plugin_error( e, "PluginManager#update_bundles!", "An error occurred while reloading bundles" )
|
567
583
|
end
|
568
584
|
sleep 3
|
569
585
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsence
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 961916124
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
9
|
- 0
|
10
|
-
-
|
10
|
+
- 10
|
11
11
|
- pre
|
12
|
-
version: 2.0.0.
|
12
|
+
version: 2.0.0.10.pre
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Riassence Inc.
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-05-
|
20
|
+
date: 2010-05-29 00:00:00 +03:00
|
21
21
|
default_executable: rsence
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -63,7 +63,6 @@ files:
|
|
63
63
|
- lib/http/request.rb
|
64
64
|
- lib/http/response.rb
|
65
65
|
- lib/plugins/dependencies.rb
|
66
|
-
- lib/plugins/dependencies.rbc
|
67
66
|
- lib/plugins/gui_plugin.rb
|
68
67
|
- lib/plugins/guiparser.rb
|
69
68
|
- lib/plugins/plugin.rb
|