abundance 1.0.5 → 1.0.6

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.
Files changed (4) hide show
  1. data/lib/abundance.rb +17 -1
  2. data/lib/gardener.rb +19 -4
  3. data/lib/seed.rb +1 -1
  4. metadata +2 -2
data/lib/abundance.rb CHANGED
@@ -48,7 +48,7 @@ class Abundance
48
48
 
49
49
  # The +gardener+ class method initializes a gardener instance
50
50
  # with its garden supplied as a block. The invocation block must include
51
- # the +grow+ class method and a preceeding optional initialisation section.
51
+ # the +grow+ class method and a preceeding optional initialisation section that may include and +init_status+ return message.
52
52
  # === Parameters
53
53
  # * :seed_size = allowed seed size in bytes
54
54
  # * :rows = garden rows number, the number of concurent threads
@@ -57,6 +57,11 @@ class Abundance
57
57
  # gardener = Abundance.gardener( :block_size => 8192, :rows => 2, :init_timeout => 2) do
58
58
  #
59
59
  # processor = SpecialProcess.new
60
+ # if processor.started_successfully?
61
+ # Abundance.init_status(true, processor.init_message)
62
+ # else
63
+ # Abundance.init_status(false, processor.init_message)
64
+ # end
60
65
  #
61
66
  # Abundance.grow do |seed|
62
67
  # command = seed.sprout
@@ -92,5 +97,16 @@ class Abundance
92
97
  end
93
98
  end
94
99
 
100
+ # The +init_status+ class method can be used inside the gardener invocation to return an initialisation status message.
101
+ # The returned messages from all garden rows will then be accessible though the gardener's init_status instance method.
102
+ # === Parameters
103
+ # * _success_ = success of the initialisation, may be true or false
104
+ # * _message_ = a ruby expression or object
105
+ # === Example
106
+ # Abundance.init_status(true,'Initialisation Successfull!!!')
107
+ def Abundance.init_status(success,message)
108
+ $seed = {:id => Process.pid, :seed => 'init_status', :success => success, :message => message}
109
+ end
110
+
95
111
  end
96
112
 
data/lib/gardener.rb CHANGED
@@ -2,12 +2,13 @@
2
2
  #
3
3
  # The Gardener act as the client class for accessing and assessing the Garden ressources.
4
4
  # Its initialization occurs through the Abundance.gardener class method.
5
- # Its instance methods are fourthfold, following the 4 states of the garden.
6
- # Like the 4 seasons northern hemisphere gardening cycles:
7
- # * seed = the setting of your command cycle
5
+ #
6
+ # The Gardener's instance methods are:
7
+ # * init_status = the return message for the initialisation cycle, as set by the Abundance.init_status method.
8
+ # * seed = the setting of your command
8
9
  # * growth = the evolution of your command growing period
9
10
  # * harvest = the getting of your command results
10
- # * close = the closing and dying cycle
11
+ # * close = wrap everything up and does a legit close
11
12
  #
12
13
  # Author:: lp (mailto:lp@spiralix.org)
13
14
  # Copyright:: 2008 Louis-Philippe Perron - Released under the terms of the MIT license
@@ -39,6 +40,20 @@ class Gardener
39
40
  @socket_client_perm = Toolshed.socket_client_perm
40
41
  end
41
42
 
43
+ # The +init_status+ method for the Gardener instance allow to harvest an initialisation status message
44
+ # that would have been set by the Abundance.init_status method, inside the Abundance.gardener's block.
45
+ # It returns an array of hash, one hash for each garden rows.
46
+ # === Example
47
+ # puts gardener.init_status.inspect # => [{:message=>"init ok", :success=>true, :pid=>4760}, {:message=>"init failed", :success=>false, :pid=>4761}]
48
+ def init_status
49
+ status = []
50
+ @garden_rows.pids.each do |pid|
51
+ command, data = socket_client_perm_duplex(:harvest,pid)
52
+ status << {:success => data[:success], :message => data[:message], :pid => data[:id]}
53
+ end
54
+ return status
55
+ end
56
+
42
57
  # The +seed+ method for the Gardener instance allow to sow a command in the Gardener's Garden.
43
58
  # === Parameter
44
59
  # * _command_ = a ruby expression or object
data/lib/seed.rb CHANGED
@@ -11,7 +11,7 @@
11
11
  # :title:Seed
12
12
 
13
13
  class Seed
14
-
14
+ $seed = Hash.new
15
15
  # The +new+ class method initializes the class.
16
16
  # You don't have to initialize it inside of Abundance,
17
17
  # as it gets initialized automatically inside the +Abundance.grow+ method
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.5
4
+ version: 1.0.6
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-06 00:00:00 -05:00
12
+ date: 2008-12-12 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15