deadly_serious 0.5.3 → 0.6.0
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.
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: e2660edb3604e3dd346527a39f1534c4b16911e1
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: e37197eb3b3a5baaa731a6be7ab9a5a664a264f0
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: bcbee1a6698414cb4ca2b05fda4f77521c011092fe49ca3cb9ee212c7f2fcf8a8d621e8bedc48f89929c0478adfbe9b79143fffbaa2140f80fd4d9e33e3af298
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 706924bd1b8a6343b0e7c494f0933431fe3c7bc06d977132710100f4882e55011d6ecb2e805c77126e54913a333cd640bc169b797e4d2627ca2386eca198423f
         
     | 
| 
         @@ -5,12 +5,13 @@ module DeadlySerious 
     | 
|
| 
       5 
5 
     | 
    
         
             
                    reader = readers.first
         
     | 
| 
       6 
6 
     | 
    
         
             
                    @writer = writers.first
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
                    reader 
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
                    if reader
         
     | 
| 
      
 9 
     | 
    
         
            +
                      reader.each { |packet| super(packet.chomp) }
         
     | 
| 
      
 10 
     | 
    
         
            +
                    else
         
     | 
| 
      
 11 
     | 
    
         
            +
                      super()
         
     | 
| 
      
 12 
     | 
    
         
            +
                    end
         
     | 
| 
      
 13 
     | 
    
         
            +
                  rescue Errno::EPIPE
         
     | 
| 
      
 14 
     | 
    
         
            +
                    # Ignore it. We expect that sometimes =)
         
     | 
| 
       14 
15 
     | 
    
         
             
                  end
         
     | 
| 
       15 
16 
     | 
    
         | 
| 
       16 
17 
     | 
    
         
             
                  # Send a packet to the next process
         
     | 
| 
         @@ -19,6 +20,8 @@ module DeadlySerious 
     | 
|
| 
       19 
20 
     | 
    
         
             
                    flush_buffer
         
     | 
| 
       20 
21 
     | 
    
         
             
                  end
         
     | 
| 
       21 
22 
     | 
    
         | 
| 
      
 23 
     | 
    
         
            +
                  alias :emit :send
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
       22 
25 
     | 
    
         
             
                  # Send a packet to the next process,
         
     | 
| 
       23 
26 
     | 
    
         
             
                  # however, accumulate some of them
         
     | 
| 
       24 
27 
     | 
    
         
             
                  # before send to gain a little
         
     | 
| 
         @@ -0,0 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'deadly_serious/engine/json_io'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module DeadlySerious
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Engine
         
     | 
| 
      
 5 
     | 
    
         
            +
                module SimpleJsonProcess
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                  def run(readers: [], writers: [])
         
     | 
| 
      
 8 
     | 
    
         
            +
                    reader = JsonIo.new(readers.first) unless readers.empty?
         
     | 
| 
      
 9 
     | 
    
         
            +
                    @writer = JsonIo.new(writers.first) unless writers.empty?
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                    if reader
         
     | 
| 
      
 12 
     | 
    
         
            +
                      reader.each do |packet|
         
     | 
| 
      
 13 
     | 
    
         
            +
                        super(*packet)
         
     | 
| 
      
 14 
     | 
    
         
            +
                      end
         
     | 
| 
      
 15 
     | 
    
         
            +
                    else
         
     | 
| 
      
 16 
     | 
    
         
            +
                      super()
         
     | 
| 
      
 17 
     | 
    
         
            +
                    end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  rescue Errno::EPIPE
         
     | 
| 
      
 19 
     | 
    
         
            +
                    # Ignore it. We expect that sometimes =)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  # Send a packet to the next process
         
     | 
| 
      
 23 
     | 
    
         
            +
                  def send(*packet)
         
     | 
| 
      
 24 
     | 
    
         
            +
                    raise 'No "writer" defined' unless @writer
         
     | 
| 
      
 25 
     | 
    
         
            +
                    @writer << packet unless packet.empty?
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  alias :emit :send
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
         @@ -26,9 +26,15 @@ module DeadlySerious 
     | 
|
| 
       26 
26 
     | 
    
         
             
                  def spawn_process(a_class, *args, process_name: a_class.name, readers: [], writers: [])
         
     | 
| 
       27 
27 
     | 
    
         
             
                    writers.each { |writer| create_pipe(writer) }
         
     | 
| 
       28 
28 
     | 
    
         
             
                    fork_it do
         
     | 
| 
       29 
     | 
    
         
            -
                       
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 29 
     | 
    
         
            +
                      begin
         
     | 
| 
      
 30 
     | 
    
         
            +
                        set_process_name(process_name)
         
     | 
| 
      
 31 
     | 
    
         
            +
                        append_open_io_if_needed(a_class)
         
     | 
| 
      
 32 
     | 
    
         
            +
                        the_object = a_class.new
         
     | 
| 
      
 33 
     | 
    
         
            +
                        the_object.run(*args, readers: readers, writers: writers)
         
     | 
| 
      
 34 
     | 
    
         
            +
                      rescue => e
         
     | 
| 
      
 35 
     | 
    
         
            +
                        the_object.finalize if the_object.respond_to?(:finalize)
         
     | 
| 
      
 36 
     | 
    
         
            +
                        raise e
         
     | 
| 
      
 37 
     | 
    
         
            +
                      end
         
     | 
| 
       32 
38 
     | 
    
         
             
                    end
         
     | 
| 
       33 
39 
     | 
    
         
             
                  end
         
     | 
| 
       34 
40 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: deadly_serious
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.6.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Ronie Uliana
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2014-01- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-01-09 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -74,6 +74,7 @@ files: 
     | 
|
| 
       74 
74 
     | 
    
         
             
            - lib/deadly_serious/engine/open_io.rb
         
     | 
| 
       75 
75 
     | 
    
         
             
            - lib/deadly_serious/engine/push_pop.rb
         
     | 
| 
       76 
76 
     | 
    
         
             
            - lib/deadly_serious/engine/push_pop_send.rb
         
     | 
| 
      
 77 
     | 
    
         
            +
            - lib/deadly_serious/engine/simple_json_process.rb
         
     | 
| 
       77 
78 
     | 
    
         
             
            - lib/deadly_serious/engine/spawner.rb
         
     | 
| 
       78 
79 
     | 
    
         
             
            - lib/deadly_serious/processes/db_source.rb
         
     | 
| 
       79 
80 
     | 
    
         
             
            - lib/deadly_serious/processes/joiner.rb
         
     |