abundance 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/garden_cycles.rb +6 -2
- data/lib/gardener.rb +2 -0
- data/test/tc_high_api.rb +10 -1
- metadata +2 -2
data/lib/garden_cycles.rb
CHANGED
@@ -180,14 +180,18 @@ class Garden
|
|
180
180
|
value = @crops.size.to_f / (@crops.size + @sprouts.compact.size + @seeds.size)
|
181
181
|
value = 1 if value.nan?; progress = sprintf( "%.2f", value)
|
182
182
|
message_block[2] = progress
|
183
|
+
when :finished
|
184
|
+
@seeds.empty? && @sprouts.empty? ? message_block[2] = true : message_block[2] = false
|
185
|
+
when :empty
|
186
|
+
@seeds.empty? && @sprouts.empty? && @crops.empty? ? message_block[2] = true : message_block[2] = false
|
183
187
|
when :seed
|
184
188
|
message_block[2] = @seeds.size
|
185
189
|
when :sprout
|
186
190
|
message_block[2] = @sprouts.compact.size
|
187
191
|
when :crop
|
188
|
-
message_block[2] = @crops.size
|
192
|
+
message_block[2] = @crops.compact.size
|
189
193
|
else
|
190
|
-
message_block[2] =
|
194
|
+
message_block[2] = "Unknow garden command: growth(#{message_block[1].to_s})"
|
191
195
|
end
|
192
196
|
|
193
197
|
add_writable(message_block)
|
data/lib/gardener.rb
CHANGED
@@ -92,6 +92,8 @@ class Gardener
|
|
92
92
|
# === Parameter
|
93
93
|
# The parameter given as a symbol specifies the level of growth report you wish to get:
|
94
94
|
# * :progress = return actual progress status, scaled between 0.00 and 1.00
|
95
|
+
# * :empty = return true when no seeds are in garden
|
96
|
+
# * :finished = return true when no seeds are waiting or processing
|
95
97
|
# * :seed = return total seeds waiting to be processed
|
96
98
|
# * :sprout = return total seeds actually in process
|
97
99
|
# * :crop = return total seeds for which process has completed
|
data/test/tc_high_api.rb
CHANGED
@@ -50,6 +50,7 @@ class TestHighAPI < Test::Unit::TestCase
|
|
50
50
|
assert_instance_of(Gardener,@g)
|
51
51
|
|
52
52
|
check_init
|
53
|
+
check_empty(true); check_finished(true)
|
53
54
|
check_false
|
54
55
|
check_seed_harvest # leaves no crops in the queue
|
55
56
|
check_full_harvest # also leaves no crops in the queue
|
@@ -69,6 +70,14 @@ class TestHighAPI < Test::Unit::TestCase
|
|
69
70
|
assert_equal(init[:message],init[:pid],"init :pid should be the row pid, it isn't")
|
70
71
|
end
|
71
72
|
end
|
73
|
+
|
74
|
+
def check_empty(bool)
|
75
|
+
assert_equal(bool,@g.growth(:empty),"growth :empty does not return #{bool.to_s}")
|
76
|
+
end
|
77
|
+
|
78
|
+
def check_finished(bool)
|
79
|
+
assert_equal(bool,@g.growth(:finished),"growth :finished does not return #{bool.to_s}")
|
80
|
+
end
|
72
81
|
|
73
82
|
def check_false
|
74
83
|
id = @g.seed(nil)
|
@@ -124,7 +133,7 @@ class TestHighAPI < Test::Unit::TestCase
|
|
124
133
|
25.times do |num|
|
125
134
|
queue_items[num] = @g.seed(num)
|
126
135
|
end
|
127
|
-
|
136
|
+
check_empty(false); check_finished(false)
|
128
137
|
all = @g.harvest(:all)
|
129
138
|
assert_kind_of(Hash,all, "the harvest :all method doesn't return a Hash as supposed")
|
130
139
|
assert_equal(25,all[:seeds].size + all[:sprouts].size + all[:crops].size, "the harvest :all method returns a total of items not coherent with amount of seeded items")
|
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.3.
|
4
|
+
version: 1.3.3
|
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: 2009-02-
|
12
|
+
date: 2009-02-05 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|