abundance 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/garden.rb +12 -1
- data/lib/gardener.rb +1 -0
- metadata +1 -1
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
|
34
|
+
@quit = false; @full_crop = false
|
35
35
|
@harvest = []
|
36
36
|
@rows_port = []
|
37
37
|
@seeds = []; @sprouts = []; @crops = []; @id = 0
|
@@ -77,6 +77,9 @@ class Garden
|
|
77
77
|
if @harvest[data[:id]]
|
78
78
|
socket_server_send(command,data, @harvest[data[:id]][:clientaddr], @harvest[data[:id]][:clientport])
|
79
79
|
@crops[data[:id]] = @harvest[data[:id]] = nil
|
80
|
+
elsif @full_crop && @seeds.compact.empty? && @sprouts.compact.empty?
|
81
|
+
socket_server_send(command,@crops.compact,@mem_addr,@mem_port)
|
82
|
+
@crops.clear; @full_crop = false
|
80
83
|
end
|
81
84
|
when :growth
|
82
85
|
case data
|
@@ -104,6 +107,14 @@ class Garden
|
|
104
107
|
when :crop
|
105
108
|
socket_server_send(command,@crops.compact,clientaddr,clientport)
|
106
109
|
@crops.clear
|
110
|
+
when :full_crop
|
111
|
+
if @seeds.compact.empty? && @sprouts.compact.empty?
|
112
|
+
socket_server_send(command,@crops.compact,clientaddr,clientport)
|
113
|
+
@crops.clear
|
114
|
+
else
|
115
|
+
@full_crop = true
|
116
|
+
@mem_addr = clientaddr; @mem_port = clientport
|
117
|
+
end
|
107
118
|
else
|
108
119
|
if data.is_a? Integer
|
109
120
|
if @crops[data]
|
data/lib/gardener.rb
CHANGED
@@ -76,6 +76,7 @@ class Gardener
|
|
76
76
|
# * :sprout = return an array of seed actually processing
|
77
77
|
# * :seed = return an array of seed waiting to be processed
|
78
78
|
# * :all = return a hash of respective arrays for crops, sprouts and seeds
|
79
|
+
# * :full_crop = wait for all seeds to be done processing, then returns as in :crop.
|
79
80
|
# === Example
|
80
81
|
# seed1_result = gardener.harvest(id_seed_1)
|
81
82
|
|