trailblazer-developer 0.0.9 → 0.0.10
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 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: e6a577980533d74f29b616b2b5d3d85026a8d7ca20f096a9d9af463e30994fe3
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: '03894756cc87b350bd9d0c71ee7c22cc951e7302869e20a95c8facd21d585c84'
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: b03caa6b40f5e45acc588999dc43b891b9f0f4d9ced50261acbe3919c1d89d4feb24c7ba9a4dd7924b10f72b87fb32d775d8a1ed000d8a6dea33da02b15fd5b6
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 6a8aa191f8132ffb968cdf0256985a4bbc5ea916a6240d94baac3a50a621e8b9a0b8e38aec84cf4ba336f32cecdafa5c31bd1a271da2074ce32c64d09e778e72
         
     | 
| 
         @@ -1,4 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require "representable/hash"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "trailblazer/activity/dsl/linear" # Railway.
         
     | 
| 
       2 
3 
     | 
    
         | 
| 
       3 
4 
     | 
    
         
             
            module Trailblazer
         
     | 
| 
       4 
5 
     | 
    
         
             
              module Developer
         
     | 
| 
         @@ -30,21 +31,19 @@ module Trailblazer 
     | 
|
| 
       30 
31 
     | 
    
         
             
                  end
         
     | 
| 
       31 
32 
     | 
    
         | 
| 
       32 
33 
     | 
    
         
             
                  def call(hash)
         
     | 
| 
       33 
     | 
    
         
            -
                     
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                    compute_intermediate(elements)
         
     | 
| 
      
 34 
     | 
    
         
            +
                    signal, (ctx, _) = Activity::TaskWrap.invoke(Pipeline, hash: hash)
         
     | 
| 
      
 35 
     | 
    
         
            +
                    ctx[:intermediate]
         
     | 
| 
       36 
36 
     | 
    
         
             
                  end
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
     | 
    
         
            -
                  def transform_from_hash( 
     | 
| 
       39 
     | 
    
         
            -
                    parser.new(OpenStruct.new).from_hash(hash).elements
         
     | 
| 
      
 38 
     | 
    
         
            +
                  def transform_from_hash(ctx, hash:, parser: Representer::Activity, **)
         
     | 
| 
      
 39 
     | 
    
         
            +
                    ctx[:elements] = parser.new(OpenStruct.new).from_hash(hash).elements
         
     | 
| 
       40 
40 
     | 
    
         
             
                  end
         
     | 
| 
       41 
41 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
                  def find_start_events(elements)
         
     | 
| 
       43 
     | 
    
         
            -
                    elements.find_all { |el| el.type == "Event" }
         
     | 
| 
      
 42 
     | 
    
         
            +
                  def find_start_events(ctx, elements:, **)
         
     | 
| 
      
 43 
     | 
    
         
            +
                    ctx[:start_events] = elements.find_all { |el| el.type == "Event" }
         
     | 
| 
       44 
44 
     | 
    
         
             
                  end
         
     | 
| 
       45 
45 
     | 
    
         | 
| 
       46 
     | 
    
         
            -
                  def compute_intermediate( 
     | 
| 
       47 
     | 
    
         
            -
                    start_events = find_start_events.(elements)
         
     | 
| 
      
 46 
     | 
    
         
            +
                  def compute_intermediate(ctx, elements:, start_events:, **)
         
     | 
| 
       48 
47 
     | 
    
         
             
                    end_events   = elements.find_all { |el| el.type == "EndEventTerminate" } # DISCUSS: is it really called TERMINATE?
         
     | 
| 
       49 
48 
     | 
    
         | 
| 
       50 
49 
     | 
    
         
             
                    inter = Activity::Schema::Intermediate
         
     | 
| 
         @@ -66,7 +65,7 @@ module Trailblazer 
     | 
|
| 
       66 
65 
     | 
    
         
             
                    ])
         
     | 
| 
       67 
66 
     | 
    
         
             
                    # pp wiring
         
     | 
| 
       68 
67 
     | 
    
         | 
| 
       69 
     | 
    
         
            -
                    inter.new(wiring, end_events.collect(&:id), start_events.collect(&:id))
         
     | 
| 
      
 68 
     | 
    
         
            +
                    ctx[:intermediate] = inter.new(wiring, end_events.collect(&:id), start_events.collect(&:id))
         
     | 
| 
       70 
69 
     | 
    
         
             
                  end
         
     | 
| 
       71 
70 
     | 
    
         | 
| 
       72 
71 
     | 
    
         
             
                  # private
         
     | 
| 
         @@ -86,6 +85,12 @@ module Trailblazer 
     | 
|
| 
       86 
85 
     | 
    
         
             
                  def extract_semantic(label)
         
     | 
| 
       87 
86 
     | 
    
         
             
                    label.to_sym
         
     | 
| 
       88 
87 
     | 
    
         
             
                  end
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                  class Pipeline < Trailblazer::Activity::Railway
         
     | 
| 
      
 90 
     | 
    
         
            +
                    step Generate.method(:transform_from_hash),   id: :transform_from_hash
         
     | 
| 
      
 91 
     | 
    
         
            +
                    step Generate.method(:find_start_events),     id: :find_start_events
         
     | 
| 
      
 92 
     | 
    
         
            +
                    step Generate.method(:compute_intermediate),  id: :compute_intermediate
         
     | 
| 
      
 93 
     | 
    
         
            +
                  end
         
     | 
| 
       89 
94 
     | 
    
         
             
                end
         
     | 
| 
       90 
95 
     | 
    
         
             
              end
         
     | 
| 
       91 
96 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: trailblazer-developer
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.10
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Nick Sutterer
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2019- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2019-11-20 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -147,7 +147,6 @@ files: 
     | 
|
| 
       147 
147 
     | 
    
         
             
            - gems.local.rb
         
     | 
| 
       148 
148 
     | 
    
         
             
            - lib/trailblazer/developer.rb
         
     | 
| 
       149 
149 
     | 
    
         
             
            - lib/trailblazer/developer/CHANGES.md
         
     | 
| 
       150 
     | 
    
         
            -
            - lib/trailblazer/developer/activity.rb
         
     | 
| 
       151 
150 
     | 
    
         
             
            - lib/trailblazer/developer/client.rb
         
     | 
| 
       152 
151 
     | 
    
         
             
            - lib/trailblazer/developer/generate.rb
         
     | 
| 
       153 
152 
     | 
    
         
             
            - lib/trailblazer/developer/render/circuit.rb
         
     | 
| 
         @@ -1,51 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module Trailblazer
         
     | 
| 
       2 
     | 
    
         
            -
              module Developer
         
     | 
| 
       3 
     | 
    
         
            -
                # Transforms an {Activity::Graph} into an abstract data structure that represents the graph via a
         
     | 
| 
       4 
     | 
    
         
            -
                # well-defined API. The goal is to decouple graph internals from the presentation layer.
         
     | 
| 
       5 
     | 
    
         
            -
                # The {Model} is usually passed into Renderer and Layouter, to render the bpmn:Diagram XML or JSON.
         
     | 
| 
       6 
     | 
    
         
            -
                #
         
     | 
| 
       7 
     | 
    
         
            -
                # It returns {Model} with {Task}s and {Flow}s.
         
     | 
| 
       8 
     | 
    
         
            -
                module Activity
         
     | 
| 
       9 
     | 
    
         
            -
                  module Graph
         
     | 
| 
       10 
     | 
    
         
            -
                    class << self
         
     | 
| 
       11 
     | 
    
         
            -
                      Model = Struct.new(:id, :start_events, :end_events, :task, :sequence_flow)
         
     | 
| 
       12 
     | 
    
         
            -
                      Task  = Struct.new(:id, :name, :options, :incoming, :outgoing)
         
     | 
| 
       13 
     | 
    
         
            -
                      # DISCUSS: direction ATM is the "condition" for the BPMN rendering.
         
     | 
| 
       14 
     | 
    
         
            -
                      Flow  = Struct.new(:id, :sourceRef, :targetRef, :direction)
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                      # @param Graph an object implementing the Activity::Graph interface
         
     | 
| 
       17 
     | 
    
         
            -
                      # @return Model Generic representation of the graph, ready for rendering.
         
     | 
| 
       18 
     | 
    
         
            -
                      def self.to_model(graph, id: "some-process") # rubocop:disable Metrics/AbcSize
         
     | 
| 
       19 
     | 
    
         
            -
                        start_events = graph.find_all("Start.default") # FIXME. this is a static assumption.
         
     | 
| 
       20 
     | 
    
         
            -
                        end_events   = graph.find_all { |node| graph.successors(node).size.zero? }
         
     | 
| 
       21 
     | 
    
         
            -
                        tasks        = graph.find_all { |_node| true }
         
     | 
| 
       22 
     | 
    
         
            -
                        tasks       -= start_events
         
     | 
| 
       23 
     | 
    
         
            -
                        tasks       -= end_events
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
                        # transform nodes into BPMN elements.
         
     | 
| 
       26 
     | 
    
         
            -
                        start_events = start_events.collect do |evt|
         
     | 
| 
       27 
     | 
    
         
            -
                          Task.new(evt[:id], evt[:id], evt, Incomings(graph, evt), Outgoings(graph, evt))
         
     | 
| 
       28 
     | 
    
         
            -
                        end
         
     | 
| 
       29 
     | 
    
         
            -
                        end_events = end_events.collect do |evt|
         
     | 
| 
       30 
     | 
    
         
            -
                          Task.new(evt[:id], evt[:id], evt, Incomings(graph, evt), Outgoings(graph, evt))
         
     | 
| 
       31 
     | 
    
         
            -
                        end
         
     | 
| 
       32 
     | 
    
         
            -
                        tasks        = tasks.collect { |evt| Task.new(evt[:id], evt[:id], evt, Incomings(graph, evt), Outgoings(graph, evt)) }
         
     | 
| 
       33 
     | 
    
         
            -
                        edges        = (start_events + end_events + tasks).collect { |task| [task.incoming, task.outgoing] }.flatten(2).uniq
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                        Model.new(id, start_events, end_events, tasks, edges)
         
     | 
| 
       36 
     | 
    
         
            -
                      end
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                      private
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                      def Outgoings(graph, source)
         
     | 
| 
       41 
     | 
    
         
            -
                        graph.successors(source).collect { |target, edge| Flow.new(edge[:id], source[:id], target[:id], edge[:_wrapped]) }
         
     | 
| 
       42 
     | 
    
         
            -
                      end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
                      def Incomings(graph, target)
         
     | 
| 
       45 
     | 
    
         
            -
                        graph.predecessors(target).collect { |source, edge| Flow.new(edge[:id], source[:id], target[:id], edge[:_wrapped]) }
         
     | 
| 
       46 
     | 
    
         
            -
                      end
         
     | 
| 
       47 
     | 
    
         
            -
                    end
         
     | 
| 
       48 
     | 
    
         
            -
                  end
         
     | 
| 
       49 
     | 
    
         
            -
                end
         
     | 
| 
       50 
     | 
    
         
            -
              end
         
     | 
| 
       51 
     | 
    
         
            -
            end
         
     |