abundance 1.0.6 → 1.0.7
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 +25 -9
- data/lib/gardener.rb +1 -1
- data/lib/seed.rb +0 -1
- metadata +2 -2
    
        data/lib/abundance.rb
    CHANGED
    
    
    
        data/lib/garden.rb
    CHANGED
    
    | @@ -31,9 +31,8 @@ class Garden | |
| 31 31 |  | 
| 32 32 | 
             
              def initialize
         | 
| 33 33 | 
             
                @pid = fork do
         | 
| 34 | 
            -
                  @quit = false; @full_crop = false
         | 
| 35 | 
            -
                  @harvest = []
         | 
| 36 | 
            -
                  @rows_port = []
         | 
| 34 | 
            +
                  @quit = false; @full_crop = false; @do_init = false
         | 
| 35 | 
            +
                  @harvest = []; @rows_port = []; @init_done = []
         | 
| 37 36 | 
             
                  @seeds = []; @sprouts = []; @crops = []; @id = 0
         | 
| 38 37 | 
             
                  @socket_server = Toolshed.socket_server(Toolshed::garden_port)
         | 
| 39 38 | 
             
                  @socket_client_temp = Toolshed.socket_client_temp
         | 
| @@ -49,6 +48,12 @@ class Garden | |
| 49 48 | 
             
                          seed = nil
         | 
| 50 49 | 
             
                          row_port = @rows_port.shift
         | 
| 51 50 | 
             
                          socket_client_temp(:quit,seed,row_port)
         | 
| 51 | 
            +
                        elsif @do_init && ! @rows_port.empty?
         | 
| 52 | 
            +
                          row_port = @rows_port.shift
         | 
| 53 | 
            +
                          unless @init_done.include?( row_port )
         | 
| 54 | 
            +
                            socket_client_temp(:init,seed,row_port)
         | 
| 55 | 
            +
                            @init_done << row_port; @do_init = nil
         | 
| 56 | 
            +
                          end
         | 
| 52 57 | 
             
                        else
         | 
| 53 58 | 
             
                          throw :fill_rows
         | 
| 54 59 | 
             
                        end               
         | 
| @@ -56,7 +61,7 @@ class Garden | |
| 56 61 | 
             
                    end
         | 
| 57 62 | 
             
                    command, data, clientport, clientname, clientaddr = socket_server_recv
         | 
| 58 63 | 
             
                    case command
         | 
| 59 | 
            -
                    when :seed | 
| 64 | 
            +
                    when :seed
         | 
| 60 65 | 
             
                      @id += 1; @seeds << {:id => @id , :seed => data}
         | 
| 61 66 | 
             
                      socket_server_send(command,@id,clientaddr,clientport)
         | 
| 62 67 | 
             
                    when :row
         | 
| @@ -71,7 +76,7 @@ class Garden | |
| 71 76 | 
             
                        @sprouts[seed[:id]] = seed
         | 
| 72 77 | 
             
                      end
         | 
| 73 78 | 
             
                      socket_server_send(command,seed,clientaddr,clientport)  
         | 
| 74 | 
            -
                    when :crop | 
| 79 | 
            +
                    when :crop
         | 
| 75 80 | 
             
                      @sprouts[data[:id]] = nil
         | 
| 76 81 | 
             
                      @crops[data[:id]] = data; socket_server_send(command,true,clientaddr,clientport)
         | 
| 77 82 | 
             
                      if @harvest[data[:id]]
         | 
| @@ -127,6 +132,12 @@ class Garden | |
| 127 132 | 
             
                          socket_server_send(command,false,clientaddr,clientport)
         | 
| 128 133 | 
             
                        end
         | 
| 129 134 | 
             
                      end
         | 
| 135 | 
            +
                    when :init
         | 
| 136 | 
            +
                      @do_init = true;
         | 
| 137 | 
            +
                      @init_return = {:clientaddr => clientaddr, :clientport => clientport}
         | 
| 138 | 
            +
                    when :init_crop
         | 
| 139 | 
            +
                      socket_server_send(command,true,clientaddr,clientport)
         | 
| 140 | 
            +
                      socket_server_send(command,data, @init_return[:clientaddr], @init_return[:clientport])
         | 
| 130 141 | 
             
                    when :close
         | 
| 131 142 | 
             
                      if data[:level] == :garden
         | 
| 132 143 | 
             
                        @seeds_pid = data[:pid]
         | 
| @@ -185,6 +196,7 @@ class Garden | |
| 185 196 | 
             
                  @pids = []
         | 
| 186 197 | 
             
                  rows.times do
         | 
| 187 198 | 
             
                    row_port = Toolshed.available_port
         | 
| 199 | 
            +
                    @socket_client_perm = Toolshed.socket_client_perm
         | 
| 188 200 | 
             
                    @pids << fork do
         | 
| 189 201 | 
             
                      @socket_server = Toolshed.socket_server(row_port)
         | 
| 190 202 | 
             
                      t1 = Thread.new do
         | 
| @@ -192,7 +204,6 @@ class Garden | |
| 192 204 | 
             
                      end
         | 
| 193 205 |  | 
| 194 206 | 
             
                      t2 = Thread.new do
         | 
| 195 | 
            -
                        @socket_client_perm = Toolshed.socket_client_perm
         | 
| 196 207 | 
             
                        loop do
         | 
| 197 208 | 
             
                          if $seed.nil?
         | 
| 198 209 | 
             
                            command, data = socket_client_perm_duplex(:row,row_port)
         | 
| @@ -204,15 +215,20 @@ class Garden | |
| 204 215 | 
             
                            $seed = data
         | 
| 205 216 | 
             
                            if $seed.nil?
         | 
| 206 217 | 
             
                              command, data, clientport, clientname, clientaddr = socket_server_recv
         | 
| 207 | 
            -
                               | 
| 218 | 
            +
                              case command
         | 
| 219 | 
            +
                              when :sprout
         | 
| 220 | 
            +
                                $seed = data
         | 
| 221 | 
            +
                              when :init
         | 
| 222 | 
            +
                                command, data = socket_client_perm_duplex(:init_crop,$seed)
         | 
| 223 | 
            +
                                $seed = nil;
         | 
| 224 | 
            +
                              end
         | 
| 208 225 | 
             
                            end
         | 
| 209 226 | 
             
                          elsif $seed.include?(:success)
         | 
| 210 227 | 
             
                            command, data = socket_client_perm_duplex(:crop,$seed)
         | 
| 211 | 
            -
                            $seed = nil
         | 
| 228 | 
            +
                            $seed = nil;
         | 
| 212 229 | 
             
                          else
         | 
| 213 230 | 
             
                            t1.run
         | 
| 214 231 | 
             
                          end
         | 
| 215 | 
            -
             | 
| 216 232 | 
             
                        end
         | 
| 217 233 | 
             
                      end
         | 
| 218 234 | 
             
                      t2.join
         | 
    
        data/lib/gardener.rb
    CHANGED
    
    | @@ -48,7 +48,7 @@ class Gardener | |
| 48 48 | 
             
              def init_status
         | 
| 49 49 | 
             
                status = []
         | 
| 50 50 | 
             
                @garden_rows.pids.each do |pid|
         | 
| 51 | 
            -
                  command, data = socket_client_perm_duplex(: | 
| 51 | 
            +
                  command, data = socket_client_perm_duplex(:init,pid)
         | 
| 52 52 | 
             
                  status << {:success => data[:success], :message => data[:message], :pid => data[:id]}
         | 
| 53 53 | 
             
                end
         | 
| 54 54 | 
             
                return status
         | 
    
        data/lib/seed.rb
    CHANGED
    
    
    
        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.7
         | 
| 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-14 00:00:00 -05:00
         | 
| 13 13 | 
             
            default_executable: 
         | 
| 14 14 | 
             
            dependencies: []
         | 
| 15 15 |  |