workflows 0.1.0 → 0.1.1
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 +4 -4
 - data/README.md +87 -5
 - data/lib/workflows/version.rb +1 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: f04dc0293e71b313565f3fd0ef0d7ed890e71daf
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 1383744ebe41d421c1d7a12a03716f7823bea67b
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 78534b357ba6f368f087799d0d9728b350d62ae5bfc4d2c7561e8f98fff482a438ec3d46dcca2e0ac8a60048d71ad4ca4434be7604e66c1442e11a3f349a13d4
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 859e56d98fac93caf713ed2afb9f85bcdd62fe9dba727ceb35bd190ce01f8c6ed40642b306be1dc1f82ffd38481f53c867852d02db3a8d764db5f299c09e2fbc
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,8 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Workflows
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
            Workflows is an attempt to create multiple-step services. each step of
         
     | 
| 
      
 4 
     | 
    
         
            +
            the workflow is service by itself that has a run method. it can fail or
         
     | 
| 
      
 5 
     | 
    
         
            +
            succeed and the status of the step will change to :fail or :ok
         
     | 
| 
      
 6 
     | 
    
         
            +
            respectively. each service in this model has two types of output. one
         
     | 
| 
      
 7 
     | 
    
         
            +
            that is called state and another that is called output. state will be
         
     | 
| 
      
 8 
     | 
    
         
            +
            passed to the next step of the workflow, so if there are objects that
         
     | 
| 
      
 9 
     | 
    
         
            +
            need to be passed between the steps, they should be kept in state.
         
     | 
| 
      
 10 
     | 
    
         
            +
            outputs are not passed between the steps and are only holding the output
         
     | 
| 
      
 11 
     | 
    
         
            +
            value of each executed step of the workflow.
         
     | 
| 
       6 
12 
     | 
    
         | 
| 
       7 
13 
     | 
    
         
             
            ## Installation
         
     | 
| 
       8 
14 
     | 
    
         | 
| 
         @@ -20,9 +26,85 @@ Or install it yourself as: 
     | 
|
| 
       20 
26 
     | 
    
         | 
| 
       21 
27 
     | 
    
         
             
                $ gem install workflows
         
     | 
| 
       22 
28 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
            ##  
     | 
| 
      
 29 
     | 
    
         
            +
            ## Example
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            You can find more examples in the example directory of the gem.
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            If you have a workflow such as the following:
         
     | 
| 
       24 
34 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 35 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 36 
     | 
    
         
            +
            class BarbieMakerFlow
         
     | 
| 
      
 37 
     | 
    
         
            +
              include Workflows
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              has_flow [
         
     | 
| 
      
 41 
     | 
    
         
            +
                {
         
     | 
| 
      
 42 
     | 
    
         
            +
                  name: 'design',
         
     | 
| 
      
 43 
     | 
    
         
            +
                  service: Design,
         
     | 
| 
      
 44 
     | 
    
         
            +
                  args: [:gender, :specification]
         
     | 
| 
      
 45 
     | 
    
         
            +
                },
         
     | 
| 
      
 46 
     | 
    
         
            +
                {
         
     | 
| 
      
 47 
     | 
    
         
            +
                  name: 'make',
         
     | 
| 
      
 48 
     | 
    
         
            +
                  service: Make,
         
     | 
| 
      
 49 
     | 
    
         
            +
                  args: [:outfit]
         
     | 
| 
      
 50 
     | 
    
         
            +
                }
         
     | 
| 
      
 51 
     | 
    
         
            +
              ]
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            class Design
         
     | 
| 
      
 56 
     | 
    
         
            +
              include Workflows::StepService
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
              def run
         
     | 
| 
      
 59 
     | 
    
         
            +
                set_state(
         
     | 
| 
      
 60 
     | 
    
         
            +
                  barbie: Barbie.new(args.gender, args.specification)
         
     | 
| 
      
 61 
     | 
    
         
            +
                )
         
     | 
| 
      
 62 
     | 
    
         
            +
              end
         
     | 
| 
      
 63 
     | 
    
         
            +
            end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
            class Make
         
     | 
| 
      
 66 
     | 
    
         
            +
              include Workflows::StepService
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
              def run
         
     | 
| 
      
 69 
     | 
    
         
            +
                barbie = get_state[:barbie]
         
     | 
| 
      
 70 
     | 
    
         
            +
                msg = barbie.dress_up(args.outfit)
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                set_output(msg)
         
     | 
| 
      
 73 
     | 
    
         
            +
                set_state(barbie: barbie)
         
     | 
| 
      
 74 
     | 
    
         
            +
              end
         
     | 
| 
      
 75 
     | 
    
         
            +
            end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
            class Barbie
         
     | 
| 
      
 78 
     | 
    
         
            +
              attr_reader :gender,
         
     | 
| 
      
 79 
     | 
    
         
            +
                          :specification,
         
     | 
| 
      
 80 
     | 
    
         
            +
                          :outfit
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
              def initialize(gender, specification)
         
     | 
| 
      
 83 
     | 
    
         
            +
                @gender = gender
         
     | 
| 
      
 84 
     | 
    
         
            +
                @specification = specification
         
     | 
| 
      
 85 
     | 
    
         
            +
              end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
              def dress_up(outfit)
         
     | 
| 
      
 88 
     | 
    
         
            +
                @outfit = outfit
         
     | 
| 
      
 89 
     | 
    
         
            +
                "#{@gender} #{@specification} barbie is wearing a #{outfit}"
         
     | 
| 
      
 90 
     | 
    
         
            +
              end
         
     | 
| 
      
 91 
     | 
    
         
            +
            end
         
     | 
| 
      
 92 
     | 
    
         
            +
            ```
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
            you can now run your flow by providing input arguments for each step:
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 97 
     | 
    
         
            +
            bmf = BarbieMakerFlow.new(
         
     | 
| 
      
 98 
     | 
    
         
            +
              design: { gender: 'female', specification: 'Software Engineer' },
         
     | 
| 
      
 99 
     | 
    
         
            +
              make: { outfit: 'white shirt and navy shorts' }
         
     | 
| 
      
 100 
     | 
    
         
            +
            )
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
            bmf.run  #=> runs the flow with provided inputs
         
     | 
| 
      
 103 
     | 
    
         
            +
            bmf.status #=> [:ok, :ok] | [:ok, :fail] | [:fail, :fail]
         
     | 
| 
      
 104 
     | 
    
         
            +
            bmf.output #=> ['output of design', 'output of make']
         
     | 
| 
      
 105 
     | 
    
         
            +
            bmf.state #=> Barbie.new(gender: 'female',
         
     | 
| 
      
 106 
     | 
    
         
            +
            specification: ....)
         
     | 
| 
      
 107 
     | 
    
         
            +
            ```
         
     | 
| 
       26 
108 
     | 
    
         | 
| 
       27 
109 
     | 
    
         
             
            ## Development
         
     | 
| 
       28 
110 
     | 
    
         | 
    
        data/lib/workflows/version.rb
    CHANGED