abundance 1.3.3 → 1.3.4

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/garden_cycles.rb CHANGED
@@ -177,13 +177,13 @@ class Garden
177
177
 
178
178
  case message_block[1]
179
179
  when :progress
180
- value = @crops.size.to_f / (@crops.size + @sprouts.compact.size + @seeds.size)
180
+ value = @crops.compact.size.to_f / (@crops.compact.size + @sprouts.compact.size + @seeds.size)
181
181
  value = 1 if value.nan?; progress = sprintf( "%.2f", value)
182
182
  message_block[2] = progress
183
183
  when :finished
184
- @seeds.empty? && @sprouts.empty? ? message_block[2] = true : message_block[2] = false
184
+ @seeds.empty? && @sprouts.compact.empty? ? message_block[2] = true : message_block[2] = false
185
185
  when :empty
186
- @seeds.empty? && @sprouts.empty? && @crops.empty? ? message_block[2] = true : message_block[2] = false
186
+ @seeds.empty? && @sprouts.compact.empty? && @crops.compact.empty? ? message_block[2] = true : message_block[2] = false
187
187
  when :seed
188
188
  message_block[2] = @seeds.size
189
189
  when :sprout
data/test/tc_high_api.rb CHANGED
@@ -50,7 +50,6 @@ 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)
54
53
  check_false
55
54
  check_seed_harvest # leaves no crops in the queue
56
55
  check_full_harvest # also leaves no crops in the queue
@@ -70,14 +69,6 @@ class TestHighAPI < Test::Unit::TestCase
70
69
  assert_equal(init[:message],init[:pid],"init :pid should be the row pid, it isn't")
71
70
  end
72
71
  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
81
72
 
82
73
  def check_false
83
74
  id = @g.seed(nil)
@@ -133,7 +124,7 @@ class TestHighAPI < Test::Unit::TestCase
133
124
  25.times do |num|
134
125
  queue_items[num] = @g.seed(num)
135
126
  end
136
- check_empty(false); check_finished(false)
127
+
137
128
  all = @g.harvest(:all)
138
129
  assert_kind_of(Hash,all, "the harvest :all method doesn't return a Hash as supposed")
139
130
  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")
data/test/tc_queue.rb ADDED
@@ -0,0 +1,54 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2
+ require 'test/unit'
3
+ require 'abundance'
4
+
5
+ class TestQueue < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @rows = 4
9
+ set_gardener
10
+ end
11
+
12
+ def test_queue
13
+ check_empty(true)
14
+ check_finished(true)
15
+ seed_lots
16
+ check_empty(false)
17
+ check_finished(false)
18
+ @g.harvest(:full_crop)
19
+ check_empty(true)
20
+ check_finished(true)
21
+ end
22
+
23
+ def teardown
24
+ @g.close
25
+ end
26
+
27
+ private
28
+
29
+ def set_gardener
30
+ @g = Abundance.gardener(:rows => @rows, :init_timeout => 3) do
31
+ Abundance.init_status(true,Process.pid)
32
+ Abundance.grow do |seed|
33
+ sprout = seed.sprout
34
+ Array.new(100000,01).join
35
+ seed.crop(true, "gardener1: #{sprout}")
36
+ end
37
+ end
38
+ end
39
+
40
+ def seed_lots
41
+ 20.times do |num|
42
+ @g.seed(num.to_s)
43
+ end
44
+ end
45
+
46
+ def check_empty(bool)
47
+ assert_equal(bool,@g.growth(:empty),"growth :empty does not return #{bool.to_s}")
48
+ end
49
+
50
+ def check_finished(bool)
51
+ assert_equal(bool,@g.growth(:finished),"growth :finished does not return #{bool.to_s}")
52
+ end
53
+
54
+ end
data/test/ts_abundance.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2
2
  require 'test/unit'
3
+
3
4
  require 'test/tc_high_api'
4
5
  require 'test/tc_robustness'
5
6
  require 'test/tc_multi_gardener'
6
- require 'test/tc_burst'
7
+ require 'test/tc_burst'
8
+ require 'test/tc_queue'
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.3
4
+ version: 1.3.4
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-05 00:00:00 -05:00
12
+ date: 2009-02-06 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -33,6 +33,7 @@ files:
33
33
  - test/tc_burst.rb
34
34
  - test/tc_high_api.rb
35
35
  - test/tc_multi_gardener.rb
36
+ - test/tc_queue.rb
36
37
  - test/tc_robustness.rb
37
38
  - test/ts_abundance.rb
38
39
  has_rdoc: true