abundance 1.0.8 → 1.0.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.
- data/lib/abundance.rb +1 -1
- data/lib/garden.rb +19 -16
- data/lib/gardener.rb +4 -5
- metadata +2 -2
data/lib/abundance.rb
CHANGED
@@ -105,7 +105,7 @@ class Abundance
|
|
105
105
|
# === Example
|
106
106
|
# Abundance.init_status(true,'Initialisation Successfull!!!')
|
107
107
|
def Abundance.init_status(success,message)
|
108
|
-
$
|
108
|
+
$init = {:id => Process.pid, :seed => 'init_status', :success => success, :message => message}
|
109
109
|
end
|
110
110
|
|
111
111
|
end
|
data/lib/garden.rb
CHANGED
@@ -31,7 +31,7 @@ class Garden
|
|
31
31
|
|
32
32
|
def initialize
|
33
33
|
@pid = fork do
|
34
|
-
@quit = false; @full_crop = false; @do_init =
|
34
|
+
@quit = false; @full_crop = false; @do_init = nil; @seed_all = nil; @init_all_crop = []
|
35
35
|
@harvest = []; @rows_port = []; @init_done = []; @seed_all_done = []; @seed_all_crop = []
|
36
36
|
@seeds = []; @sprouts = []; @crops = []; @id = 0
|
37
37
|
@socket_server = Toolshed.socket_server(Toolshed::garden_port)
|
@@ -47,6 +47,14 @@ class Garden
|
|
47
47
|
else
|
48
48
|
@rows_port << row_port
|
49
49
|
end
|
50
|
+
elsif ! @do_init.nil? && ! @rows_port.empty? && @init_done.size != @do_init
|
51
|
+
row_port = @rows_port.shift
|
52
|
+
unless @init_done.include?( row_port )
|
53
|
+
socket_client_temp(:init,'init_status',row_port)
|
54
|
+
@init_done << row_port
|
55
|
+
else
|
56
|
+
@rows_port << row_port
|
57
|
+
end
|
50
58
|
elsif ! @seeds.empty? && ! @rows_port.empty?
|
51
59
|
seed = @seeds.shift
|
52
60
|
@sprouts[seed[:id]] = seed
|
@@ -56,14 +64,6 @@ class Garden
|
|
56
64
|
seed = nil
|
57
65
|
row_port = @rows_port.shift
|
58
66
|
socket_client_temp(:quit,seed,row_port)
|
59
|
-
elsif @do_init && ! @rows_port.empty?
|
60
|
-
row_port = @rows_port.shift
|
61
|
-
unless @init_done.include?( row_port )
|
62
|
-
socket_client_temp(:init,seed,row_port)
|
63
|
-
@init_done << row_port; @do_init = nil
|
64
|
-
else
|
65
|
-
@rows_port << row_port
|
66
|
-
end
|
67
67
|
else
|
68
68
|
throw :fill_rows
|
69
69
|
end
|
@@ -143,12 +143,15 @@ class Garden
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
when :init
|
146
|
-
@do_init =
|
146
|
+
@do_init = data
|
147
147
|
@init_return = {:clientaddr => clientaddr, :clientport => clientport}
|
148
148
|
when :init_crop
|
149
149
|
socket_server_send(command,true,clientaddr,clientport)
|
150
|
-
|
151
|
-
@
|
150
|
+
@init_all_crop << data
|
151
|
+
if @init_all_crop.size == @do_init
|
152
|
+
socket_server_send(command,@init_all_crop, @init_return[:clientaddr], @init_return[:clientport])
|
153
|
+
@init_return = Hash.new; @init_done = Array.new; @do_init = nil; @init_all_crop = Array.new
|
154
|
+
end
|
152
155
|
when :seed_all
|
153
156
|
@seed_all = data
|
154
157
|
@seed_all_return = {:clientaddr => clientaddr, :clientport => clientport, :data => []}
|
@@ -244,15 +247,15 @@ class Garden
|
|
244
247
|
@seed_all = true
|
245
248
|
$seed = {:id => Process.pid, :seed => data}
|
246
249
|
when :init
|
247
|
-
|
248
|
-
|
250
|
+
$init = {:seed => 'init_status', :message => 'No Init Message', :id => Process.pid} if $init.nil?
|
251
|
+
command, data = socket_client_perm_duplex(:init_crop,$init)
|
249
252
|
end
|
250
253
|
end
|
251
|
-
elsif $seed.
|
254
|
+
elsif ! $seed[:success].nil?
|
252
255
|
if @seed_all
|
253
256
|
command, data = socket_client_perm_duplex(:seed_all_crop,$seed)
|
254
257
|
@seed_all = false
|
255
|
-
else
|
258
|
+
else
|
256
259
|
command, data = socket_client_perm_duplex(:crop,$seed)
|
257
260
|
end
|
258
261
|
$seed = nil;
|
data/lib/gardener.rb
CHANGED
@@ -46,12 +46,11 @@ class Gardener
|
|
46
46
|
# === Example
|
47
47
|
# puts gardener.init_status.inspect # => [{:message=>"init ok", :success=>true, :pid=>4760}, {:message=>"init failed", :success=>false, :pid=>4761}]
|
48
48
|
def init_status
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
status << {:success => data[:success], :message => data[:message], :pid => data[:id]}
|
49
|
+
command, data = socket_client_perm_duplex(:init,@garden_rows.pids.size)
|
50
|
+
data.map! do |row|
|
51
|
+
{:success => row[:success], :message => row[:message], :pid => row[:id]}
|
53
52
|
end
|
54
|
-
return
|
53
|
+
return data
|
55
54
|
end
|
56
55
|
|
57
56
|
# The +seed+ method for the Gardener instance allow to sow a command in the Gardener's Garden.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abundance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Louis-Philippe Perron
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-12-
|
12
|
+
date: 2008-12-15 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|