trailblazer-operation 0.6.1 → 0.6.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +10 -13
- data/CHANGES.md +21 -0
- data/README.md +1 -1
- data/lib/trailblazer/operation.rb +2 -14
- data/lib/trailblazer/operation/class_dependencies.rb +5 -5
- data/lib/trailblazer/operation/public_call.rb +22 -7
- data/lib/trailblazer/operation/railway.rb +4 -0
- data/lib/trailblazer/operation/trace.rb +4 -1
- data/lib/trailblazer/operation/version.rb +1 -1
- data/test/docs/operation_test.rb +57 -2
- data/test/docs/wiring_test.rb +5 -8
- data/test/operation_test.rb +43 -0
- data/test/step_test.rb +3 -2
- data/test/test_helper.rb +3 -1
- data/test/trace_test.rb +4 -9
- data/trailblazer-operation.gemspec +3 -3
- metadata +9 -12
- data/lib/trailblazer/operation/container.rb +0 -14
- data/test/dry_container_test.rb +0 -25
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: bf82f1aa3080dfea1c9165859fdd6de207c9333cc3af7fb8c2e52fff55811ba2
         | 
| 4 | 
            +
              data.tar.gz: c53369fe71b53e3ac3be42746d438c648b312a4d03956f483abd2d1e7e39cebb
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 98b29781915fdb5b40921dfd621a59dc580ce708e7ddaaf44b3123ee5a838ffde6a96cbe9b2d0cb24b15b60db3d2f5e166339253612786b96ebf5c5073e28fe6
         | 
| 7 | 
            +
              data.tar.gz: 1481d504865240aeeee2bd254cfbc927156da7d465a408e42fc8936579984a95a80926356e6b5757d67ce8d814879f6aa22fc1678cd869345ac7be38b40d2e68
         | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/.travis.yml
    CHANGED
    
    | @@ -1,16 +1,13 @@ | |
| 1 1 | 
             
            language: ruby
         | 
| 2 2 | 
             
            before_install:
         | 
| 3 3 | 
             
              - gem install bundler -v 1.17.3
         | 
| 4 | 
            -
             | 
| 5 | 
            -
               | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
                - rvm:  | 
| 13 | 
            -
             | 
| 14 | 
            -
                - rvm: 2.5.0
         | 
| 15 | 
            -
                  gemfile: Gemfile
         | 
| 16 | 
            -
                  script: bundle exec rake test
         | 
| 4 | 
            +
            rvm:
         | 
| 5 | 
            +
              - ruby-head
         | 
| 6 | 
            +
              - 2.7
         | 
| 7 | 
            +
              - 2.6
         | 
| 8 | 
            +
              - 2.5
         | 
| 9 | 
            +
              - 2.4
         | 
| 10 | 
            +
            jobs:
         | 
| 11 | 
            +
              allow_failures:
         | 
| 12 | 
            +
                - rvm: ruby-head
         | 
| 13 | 
            +
                - rvm: 2.7
         | 
    
        data/CHANGES.md
    CHANGED
    
    | @@ -1,3 +1,24 @@ | |
| 1 | 
            +
            ## 0.6.6
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            * Rename `Operation.flow_options` to `Operation.flow_options_for_public_call`.
         | 
| 4 | 
            +
            * Operations can also accept `flow_options` at run-time now :beers:, giving them precedence over `Operation.flow_options_for_public_call`.
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            ## 0.6.5
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            * Upgrade `trailblazer-activity` & `trailblazer-activity-dsl-linear` versions to utilise new `trailblazer-context` :drum:
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            ## 0.6.4
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            * Remove container support. Containers should be part of `ctx` itself
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            ## 0.6.3
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            * Require forwardable module from standard lib.
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            ## 0.6.2
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            * Fix Trace so it works with Ruby <= 2.4
         | 
| 21 | 
            +
             | 
| 1 22 | 
             
            ## 0.6.1
         | 
| 2 23 |  | 
| 3 24 | 
             
            * Reintroduce `ClassDependencies` by leveraging `State.fields`.
         | 
    
        data/README.md
    CHANGED
    
    | @@ -15,6 +15,6 @@ An operation can be used exaclty like an activity, including nesting, tracing, e | |
| 15 15 |  | 
| 16 16 | 
             
            ## Copyright
         | 
| 17 17 |  | 
| 18 | 
            -
            Copyright (c) 2016 Nick Sutterer <apotonick@gmail.com>
         | 
| 18 | 
            +
            Copyright (c) 2016-2020 Nick Sutterer <apotonick@gmail.com>
         | 
| 19 19 |  | 
| 20 20 | 
             
            `trailblazer-operation` is released under the [MIT License](http://www.opensource.org/licenses/MIT).
         | 
| @@ -1,10 +1,10 @@ | |
| 1 | 
            +
            require 'forwardable'
         | 
| 2 | 
            +
            require 'trailblazer/operation/version'
         | 
| 1 3 | 
             
            require "trailblazer/option"
         | 
| 2 4 | 
             
            require "trailblazer/context"
         | 
| 3 | 
            -
            require "trailblazer/container_chain"
         | 
| 4 5 |  | 
| 5 6 | 
             
            require "trailblazer/activity/dsl/linear"
         | 
| 6 7 |  | 
| 7 | 
            -
             | 
| 8 8 | 
             
            module Trailblazer
         | 
| 9 9 | 
             
              # DISCUSS: I don't know where else to put this. It's not part of the {Activity} concept
         | 
| 10 10 | 
             
              class Activity
         | 
| @@ -51,13 +51,6 @@ module Trailblazer | |
| 51 51 |  | 
| 52 52 | 
             
                require "trailblazer/operation/trace"
         | 
| 53 53 | 
             
                extend Trace                   # ::trace
         | 
| 54 | 
            -
             | 
| 55 | 
            -
                module Railway
         | 
| 56 | 
            -
                  def self.fail!     ; Activity::Left  end
         | 
| 57 | 
            -
                  def self.pass!     ; Activity::Right end
         | 
| 58 | 
            -
                  def self.fail_fast!; Activity::FastTrack::FailFast end
         | 
| 59 | 
            -
                  def self.pass_fast!; Activity::FastTrack::PassFast end
         | 
| 60 | 
            -
                end
         | 
| 61 54 | 
             
              end
         | 
| 62 55 | 
             
            end
         | 
| 63 56 |  | 
| @@ -67,9 +60,4 @@ require "trailblazer/operation/deprecated_macro" # TODO: remove in 2.2. | |
| 67 60 | 
             
            require "trailblazer/operation/result"
         | 
| 68 61 | 
             
            require "trailblazer/operation/railway"
         | 
| 69 62 |  | 
| 70 | 
            -
            require "trailblazer/developer"
         | 
| 71 | 
            -
            require "trailblazer/operation/trace"
         | 
| 72 | 
            -
             | 
| 73 63 | 
             
            require "trailblazer/operation/railway/macaroni"
         | 
| 74 | 
            -
             | 
| 75 | 
            -
            require "trailblazer/operation/container"
         | 
| @@ -12,21 +12,21 @@ class Trailblazer::Operation | |
| 12 12 | 
             
                  @state.update_options(options)
         | 
| 13 13 | 
             
                end
         | 
| 14 14 |  | 
| 15 | 
            -
                def options_for_public_call(options,  | 
| 15 | 
            +
                def options_for_public_call(options, **flow_options)
         | 
| 16 16 | 
             
                  ctx = super
         | 
| 17 | 
            -
                  context_for_fields(class_fields, ctx)
         | 
| 17 | 
            +
                  context_for_fields(class_fields, [ctx, flow_options], {})
         | 
| 18 18 | 
             
                end
         | 
| 19 19 |  | 
| 20 20 | 
             
                private def class_fields
         | 
| 21 21 | 
             
                  @state.to_h[:fields]
         | 
| 22 22 | 
             
                end
         | 
| 23 23 |  | 
| 24 | 
            -
                private def context_for_fields(fields, ctx)
         | 
| 25 | 
            -
                  ctx_with_fields = Trailblazer::Context | 
| 24 | 
            +
                private def context_for_fields(fields, (ctx, flow_options), **)
         | 
| 25 | 
            +
                  ctx_with_fields = Trailblazer::Context(fields, ctx, flow_options[:context_options]) # TODO: redundant to otions_for_public_call.
         | 
| 26 26 | 
             
                end
         | 
| 27 27 |  | 
| 28 28 | 
             
                def call_with_circuit_interface((ctx, flow_options), **circuit_options)
         | 
| 29 | 
            -
                  ctx_with_fields = context_for_fields(class_fields, ctx)
         | 
| 29 | 
            +
                  ctx_with_fields = context_for_fields(class_fields, [ctx, flow_options], circuit_options)
         | 
| 30 30 |  | 
| 31 31 | 
             
                  super([ctx_with_fields, flow_options], circuit_options) # FIXME: should we unwrap here?
         | 
| 32 32 | 
             
                end
         | 
| @@ -19,15 +19,23 @@ module Trailblazer | |
| 19 19 | 
             
                  call_with_public_interface(options, *args)
         | 
| 20 20 | 
             
                end
         | 
| 21 21 |  | 
| 22 | 
            -
                 | 
| 23 | 
            -
             | 
| 22 | 
            +
                # Default {@activity} call interface which doesn't accept {circuit_options}
         | 
| 23 | 
            +
                #
         | 
| 24 | 
            +
                # @param [Array] args => [ctx, flow_options]
         | 
| 25 | 
            +
                #
         | 
| 26 | 
            +
                # @return [Operation::Railway::Result]
         | 
| 27 | 
            +
                #
         | 
| 28 | 
            +
                # @private
         | 
| 29 | 
            +
                def call_with_public_interface(options, flow_options = {})
         | 
| 30 | 
            +
                  flow_options  = flow_options_for_public_call(flow_options)
         | 
| 31 | 
            +
                  ctx           = options_for_public_call(options, flow_options)
         | 
| 24 32 |  | 
| 25 33 | 
             
                  # call the activity.
         | 
| 26 34 | 
             
                  # This will result in invoking {::call_with_circuit_interface}.
         | 
| 27 35 | 
             
                  # last_signal, (options, flow_options) = Activity::TaskWrap.invoke(self, [ctx, {}], {})
         | 
| 28 36 | 
             
                  signal, (ctx, flow_options) = Activity::TaskWrap.invoke(
         | 
| 29 37 | 
             
                    @activity,
         | 
| 30 | 
            -
                    [ctx, flow_options | 
| 38 | 
            +
                    [ctx, flow_options],
         | 
| 31 39 | 
             
                    exec_context: new
         | 
| 32 40 | 
             
                  )
         | 
| 33 41 |  | 
| @@ -36,6 +44,13 @@ module Trailblazer | |
| 36 44 | 
             
                end
         | 
| 37 45 |  | 
| 38 46 | 
             
                # This interface is used for all nested OPs (and the outer-most, too).
         | 
| 47 | 
            +
                #
         | 
| 48 | 
            +
                # @param [Array] args - Contains [ctx, flow_options]
         | 
| 49 | 
            +
                # @param [Hash]  circuit_options - Options to configure activity circuit
         | 
| 50 | 
            +
                #
         | 
| 51 | 
            +
                # @return [signal, [ctx, flow_options]]
         | 
| 52 | 
            +
                #
         | 
| 53 | 
            +
                # @private
         | 
| 39 54 | 
             
                def call_with_circuit_interface(args, circuit_options)
         | 
| 40 55 | 
             
                  strategy_call(args, circuit_options) # FastTrack#call
         | 
| 41 56 | 
             
                end
         | 
| @@ -46,13 +61,13 @@ module Trailblazer | |
| 46 61 |  | 
| 47 62 | 
             
                # Compile a Context object to be passed into the Activity::call.
         | 
| 48 63 | 
             
                # @private
         | 
| 49 | 
            -
                def self.options_for_public_call(options,  | 
| 50 | 
            -
                  Trailblazer::Context | 
| 64 | 
            +
                def self.options_for_public_call(options, flow_options = {})
         | 
| 65 | 
            +
                  Trailblazer::Context(options, {}, flow_options[:context_options])
         | 
| 51 66 | 
             
                end
         | 
| 52 67 |  | 
| 53 68 | 
             
                # @semi=public
         | 
| 54 | 
            -
                def  | 
| 55 | 
            -
                   | 
| 69 | 
            +
                def flow_options_for_public_call(options = {})
         | 
| 70 | 
            +
                  options
         | 
| 56 71 | 
             
                end
         | 
| 57 72 | 
             
              end
         | 
| 58 73 | 
             
            end
         | 
| @@ -5,6 +5,10 @@ module Trailblazer | |
| 5 5 | 
             
              class Operation
         | 
| 6 6 | 
             
                # End event: All subclasses of End:::Success are interpreted as "success".
         | 
| 7 7 | 
             
                module Railway
         | 
| 8 | 
            +
                  def self.fail!     ; Activity::Left  end
         | 
| 9 | 
            +
                  def self.pass!     ; Activity::Right end
         | 
| 10 | 
            +
                  def self.fail_fast!; Activity::FastTrack::FailFast end
         | 
| 11 | 
            +
                  def self.pass_fast!; Activity::FastTrack::PassFast end
         | 
| 8 12 | 
             
                  # @param options Context
         | 
| 9 13 | 
             
                  # @param end_event The last emitted signal in a circuit is usually the end event.
         | 
| 10 14 | 
             
                  def self.Result(end_event, options, *)
         | 
| @@ -1,3 +1,6 @@ | |
| 1 | 
            +
            require 'delegate'
         | 
| 2 | 
            +
            require "trailblazer/developer"
         | 
| 3 | 
            +
             | 
| 1 4 | 
             
            module Trailblazer
         | 
| 2 5 | 
             
              class Operation
         | 
| 3 6 | 
             
                module Trace
         | 
| @@ -31,7 +34,7 @@ module Trailblazer | |
| 31 34 | 
             
                    end
         | 
| 32 35 |  | 
| 33 36 | 
             
                    def wtf
         | 
| 34 | 
            -
                       | 
| 37 | 
            +
                      Developer::Trace::Present.(@stack)
         | 
| 35 38 | 
             
                    end
         | 
| 36 39 |  | 
| 37 40 | 
             
                    def wtf?
         | 
    
        data/test/docs/operation_test.rb
    CHANGED
    
    | @@ -24,7 +24,6 @@ class DocsActivityTest < Minitest::Spec | |
| 24 24 | 
             
                signal.inspect.must_equal %{#<Trailblazer::Activity::Railway::End::Success semantic=:success>}
         | 
| 25 25 | 
             
              end
         | 
| 26 26 |  | 
| 27 | 
            -
              #:describe
         | 
| 28 27 | 
             
              describe Memo::Create do
         | 
| 29 28 | 
             
                it "creates a sane Memo instance" do
         | 
| 30 29 | 
             
                  #:call-public
         | 
| @@ -39,8 +38,64 @@ class DocsActivityTest < Minitest::Spec | |
| 39 38 | 
             
                  result.success?.must_equal true
         | 
| 40 39 | 
             
                  result[:model].text.must_equal "Enjoy an IPA"
         | 
| 41 40 | 
             
                end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                it "allows indifferent access for ctx keys" do
         | 
| 43 | 
            +
                  #:ctx-indifferent-access
         | 
| 44 | 
            +
                  result = Memo::Create.(params: { text: "Enjoy an IPA" })
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                  result[:params]     # => { text: "Enjoy an IPA" }
         | 
| 47 | 
            +
                  result['params']    # => { text: "Enjoy an IPA" }
         | 
| 48 | 
            +
                  #:ctx-indifferent-access end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                  result.success?.must_equal true
         | 
| 51 | 
            +
                  result[:params].must_equal({ text: "Enjoy an IPA" })
         | 
| 52 | 
            +
                  result['params'].must_equal({ text: "Enjoy an IPA" })
         | 
| 53 | 
            +
                end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                it "allows defining aliases for ctx keys" do
         | 
| 56 | 
            +
                  module AliasesExample
         | 
| 57 | 
            +
                    Memo = Struct.new(:text)
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                    module Memo::Contract
         | 
| 60 | 
            +
                      Create = Struct.new(:sync)
         | 
| 61 | 
            +
                    end
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                    #:ctx-aliases-step
         | 
| 64 | 
            +
                    class Memo::Create < Trailblazer::Operation
         | 
| 65 | 
            +
                      #~flow
         | 
| 66 | 
            +
                      step ->(ctx, **) { ctx[:'contract.default'] = Memo::Contract::Create.new }
         | 
| 67 | 
            +
                      #~flow end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                      pass :sync
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                      def sync(ctx, contract:, **)
         | 
| 72 | 
            +
                        # ctx['contract.default'] == ctx[:contract]
         | 
| 73 | 
            +
                        contract.sync
         | 
| 74 | 
            +
                      end
         | 
| 75 | 
            +
                    end
         | 
| 76 | 
            +
                    #:ctx-aliases-step end
         | 
| 77 | 
            +
                  end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                  #:ctx-aliases
         | 
| 80 | 
            +
                  options = { params: { text: "Enjoy an IPA" } }
         | 
| 81 | 
            +
                  flow_options = {
         | 
| 82 | 
            +
                    context_options: {
         | 
| 83 | 
            +
                      aliases: { 'contract.default': :contract, 'policy.default': :policy },
         | 
| 84 | 
            +
                      container_class: Trailblazer::Context::Container::WithAliases,
         | 
| 85 | 
            +
                    }
         | 
| 86 | 
            +
                  }
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                  result = AliasesExample::Memo::Create.(options, flow_options)
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                  result['contract.default']  # => Memo::Contract::Create
         | 
| 91 | 
            +
                  result[:contract]           # => Memo::Contract::Create
         | 
| 92 | 
            +
                  #:ctx-aliases end
         | 
| 93 | 
            +
             | 
| 94 | 
            +
                  result.success?.must_equal true
         | 
| 95 | 
            +
                  _(result[:contract].class).must_equal AliasesExample::Memo::Contract::Create
         | 
| 96 | 
            +
                  _(result['contract.default']).must_equal result[:contract]
         | 
| 97 | 
            +
                end
         | 
| 42 98 | 
             
              end
         | 
| 43 | 
            -
              #:describe end
         | 
| 44 99 |  | 
| 45 100 | 
             
              it do
         | 
| 46 101 | 
             
                module J
         | 
    
        data/test/docs/wiring_test.rb
    CHANGED
    
    | @@ -245,9 +245,8 @@ describe all options :pass_fast, :fast_track and emiting signals directly, like | |
| 245 245 | 
             
              end
         | 
| 246 246 |  | 
| 247 247 | 
             
              it "runs #create_model, only" do
         | 
| 248 | 
            -
                Memo = FastTrack::Memo
         | 
| 249 248 | 
             
                #:ft-call
         | 
| 250 | 
            -
                result = Memo::Create.(create_empty_model: true)
         | 
| 249 | 
            +
                result = FastTrack::Memo::Create.(create_empty_model: true)
         | 
| 251 250 | 
             
                puts result.success?        #=> true
         | 
| 252 251 | 
             
                puts result[:model].inspect #=> #<Memo text=nil>
         | 
| 253 252 | 
             
                #:ft-call end
         | 
| @@ -257,9 +256,8 @@ describe all options :pass_fast, :fast_track and emiting signals directly, like | |
| 257 256 | 
             
              end
         | 
| 258 257 |  | 
| 259 258 | 
             
              it "fast-tracks in #assign_errors" do
         | 
| 260 | 
            -
                Memo = FastTrack::Memo
         | 
| 261 259 | 
             
                #:ft-call-err
         | 
| 262 | 
            -
                result = Memo::Create.({})
         | 
| 260 | 
            +
                result = FastTrack::Memo::Create.({})
         | 
| 263 261 | 
             
                puts result.success?          #=> false
         | 
| 264 262 | 
             
                puts result[:model].inspect   #=> #<Memo text=nil>
         | 
| 265 263 | 
             
                puts result[:errors].inspect  #=> "Something went wrong!"
         | 
| @@ -271,16 +269,15 @@ describe all options :pass_fast, :fast_track and emiting signals directly, like | |
| 271 269 | 
             
              end
         | 
| 272 270 |  | 
| 273 271 | 
             
              it "goes till #save by emitting signals directly" do
         | 
| 274 | 
            -
                 | 
| 275 | 
            -
                result = Memo::Create.(params: {text: "Punk is not dead!"})
         | 
| 272 | 
            +
                result = FastTrack::Memo::Create.(params: {text: "Punk is not dead!"})
         | 
| 276 273 | 
             
                result.success?.must_equal true
         | 
| 277 274 | 
             
                result[:model].id.must_equal 1
         | 
| 278 275 | 
             
                result[:errors].must_be_nil
         | 
| 279 276 | 
             
              end
         | 
| 280 277 |  | 
| 278 | 
            +
             | 
| 281 279 | 
             
              it "goes till #save by using signal helper" do
         | 
| 282 | 
            -
                 | 
| 283 | 
            -
                result = Memo::Create2.(params: {text: "Punk is not dead!"})
         | 
| 280 | 
            +
                result = FastTrack::Memo::Create2.(params: {text: "Punk is not dead!"})
         | 
| 284 281 | 
             
                result.success?.must_equal true
         | 
| 285 282 | 
             
                result[:model].id.must_equal 1
         | 
| 286 283 | 
             
                result[:errors].must_be_nil
         | 
    
        data/test/operation_test.rb
    CHANGED
    
    | @@ -79,8 +79,51 @@ class DeclarativeApiTest < Minitest::Spec | |
| 79 79 | 
             
                step ->(options, **) { options["e"] = 2 }
         | 
| 80 80 | 
             
              end
         | 
| 81 81 |  | 
| 82 | 
            +
              class Aliases < Update
         | 
| 83 | 
            +
                def self.flow_options_for_public_call(*)
         | 
| 84 | 
            +
                  {
         | 
| 85 | 
            +
                    context_options: {
         | 
| 86 | 
            +
                      aliases: { 'b' => :settle },
         | 
| 87 | 
            +
                      container_class: Trailblazer::Context::Container::WithAliases,
         | 
| 88 | 
            +
                    }
         | 
| 89 | 
            +
                  }
         | 
| 90 | 
            +
                end
         | 
| 91 | 
            +
              end
         | 
| 92 | 
            +
             | 
| 82 93 | 
             
              it "allows to inherit" do
         | 
| 83 94 | 
             
                Upsert.("params" => {decide: true}).inspect("a", "b", "c", "d", "e").must_equal %{<Result:true [false, true, nil, 1, nil] >}
         | 
| 84 95 | 
             
                Unset. ("params" => {decide: true}).inspect("a", "b", "c", "d", "e").must_equal %{<Result:true [false, true, nil, 1, 2] >}
         | 
| 85 96 | 
             
              end
         | 
| 97 | 
            +
             | 
| 98 | 
            +
              #---
         | 
| 99 | 
            +
              #- ctx container
         | 
| 100 | 
            +
              it do
         | 
| 101 | 
            +
                options = { "params" => {decide: true} }
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                # Default call
         | 
| 104 | 
            +
                result = Update.(options)
         | 
| 105 | 
            +
                result.inspect("a", "b", "c").must_equal %{<Result:true [false, true, nil] >}
         | 
| 106 | 
            +
             | 
| 107 | 
            +
                # Circuit interface call
         | 
| 108 | 
            +
                signal, (ctx, _) = Update.([Update.options_for_public_call(options), {}], {})
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                signal.inspect.must_equal %{#<Trailblazer::Activity::Railway::End::Success semantic=:success>}
         | 
| 111 | 
            +
                ctx.inspect.must_equal %{#<Trailblazer::Context::Container wrapped_options={\"params\"=>{:decide=>true}} mutable_options={\"a\"=>false, \"b\"=>true}>}
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                # Call by passing aliases as an argument.
         | 
| 114 | 
            +
                result = Update.(
         | 
| 115 | 
            +
                  options,
         | 
| 116 | 
            +
                  {
         | 
| 117 | 
            +
                    context_options: {
         | 
| 118 | 
            +
                      aliases: { 'b' => :settle },
         | 
| 119 | 
            +
                      container_class: Trailblazer::Context::Container::WithAliases,
         | 
| 120 | 
            +
                    }
         | 
| 121 | 
            +
                  }
         | 
| 122 | 
            +
                )
         | 
| 123 | 
            +
                result[:settle].must_equal true
         | 
| 124 | 
            +
             | 
| 125 | 
            +
                # Set aliases by overriding `flow_options` at the compile time.
         | 
| 126 | 
            +
                result = Aliases.(options)
         | 
| 127 | 
            +
                result[:settle].must_equal true
         | 
| 128 | 
            +
              end
         | 
| 86 129 | 
             
            end
         | 
    
        data/test/step_test.rb
    CHANGED
    
    | @@ -173,11 +173,12 @@ class StepTest < Minitest::Spec | |
| 173 173 | 
             
              #-
         | 
| 174 174 | 
             
              # not existent :name
         | 
| 175 175 | 
             
              it do
         | 
| 176 | 
            -
                assert_raises Trailblazer::Activity::DSL::Linear::Sequence::IndexError do
         | 
| 176 | 
            +
                op = assert_raises Trailblazer::Activity::DSL::Linear::Sequence::IndexError do
         | 
| 177 177 | 
             
                  Class.new(Trailblazer::Operation) do
         | 
| 178 178 | 
             
                    step :a, before: "I don't exist!"
         | 
| 179 179 | 
             
                  end
         | 
| 180 | 
            -
                end | 
| 180 | 
            +
                end
         | 
| 181 | 
            +
                assert_match /<Trailblazer::Activity::DSL::Linear::Sequence::IndexError: "I don't exist!" is not a valid step ID. Did you mean any of these ?/, op.inspect
         | 
| 181 182 | 
             
              end
         | 
| 182 183 |  | 
| 183 184 | 
             
              #---
         | 
    
        data/test/test_helper.rb
    CHANGED
    
    
    
        data/test/trace_test.rb
    CHANGED
    
    | @@ -14,18 +14,13 @@ class TraceTest < Minitest::Spec | |
| 14 14 | 
             
              end
         | 
| 15 15 | 
             
              # raise Create["__task_wraps__"].inspect
         | 
| 16 16 |  | 
| 17 | 
            -
              it "allows using low-level  | 
| 18 | 
            -
                 | 
| 19 | 
            -
             | 
| 20 | 
            -
                stack, = Trailblazer::Developer::Trace.(
         | 
| 17 | 
            +
              it "allows using low-level Operation::Trace" do
         | 
| 18 | 
            +
                result = Trailblazer::Operation::Trace.(
         | 
| 21 19 | 
             
                  Create,
         | 
| 22 | 
            -
                   | 
| 23 | 
            -
                    {a_return: true, params: {}},
         | 
| 24 | 
            -
                    {}
         | 
| 25 | 
            -
                  ]
         | 
| 20 | 
            +
                  { a_return: true, params: {} },
         | 
| 26 21 | 
             
                )
         | 
| 27 22 |  | 
| 28 | 
            -
                 | 
| 23 | 
            +
                output = result.wtf
         | 
| 29 24 |  | 
| 30 25 | 
             
                output.gsub(/0x\w+/, "").gsub(/@.+_test/, "").must_equal %{`-- TraceTest::Create
         | 
| 31 26 | 
             
                |-- Start.default
         | 
| @@ -14,11 +14,11 @@ Gem::Specification.new do |spec| | |
| 14 14 |  | 
| 15 15 | 
             
              spec.files         = `git ls-files`.split($/)
         | 
| 16 16 | 
             
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         | 
| 17 | 
            -
              spec.test_files    = spec.files.grep(%r{^(test | 
| 17 | 
            +
              spec.test_files    = spec.files.grep(%r{^(test)/})
         | 
| 18 18 | 
             
              spec.require_paths = ["lib"]
         | 
| 19 19 |  | 
| 20 | 
            -
              spec.add_dependency "trailblazer-activity-dsl-linear", ">= 0.2 | 
| 21 | 
            -
              spec.add_dependency "trailblazer-activity", ">= 0. | 
| 20 | 
            +
              spec.add_dependency "trailblazer-activity-dsl-linear", ">= 0.3.2", "< 1.0.0"
         | 
| 21 | 
            +
              spec.add_dependency "trailblazer-activity", ">= 0.11.2", "< 1.0.0"
         | 
| 22 22 | 
             
              spec.add_dependency "trailblazer-developer", ">= 0.0.8"
         | 
| 23 23 |  | 
| 24 24 | 
             
              spec.add_development_dependency "bundler"
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: trailblazer-operation
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.6. | 
| 4 | 
            +
              version: 0.6.6
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Nick Sutterer
         | 
| 8 | 
            -
            autorequire: | 
| 8 | 
            +
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2021-01-27 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: trailblazer-activity-dsl-linear
         | 
| @@ -16,7 +16,7 @@ dependencies: | |
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - ">="
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version: 0.2 | 
| 19 | 
            +
                    version: 0.3.2
         | 
| 20 20 | 
             
                - - "<"
         | 
| 21 21 | 
             
                  - !ruby/object:Gem::Version
         | 
| 22 22 | 
             
                    version: 1.0.0
         | 
| @@ -26,7 +26,7 @@ dependencies: | |
| 26 26 | 
             
                requirements:
         | 
| 27 27 | 
             
                - - ">="
         | 
| 28 28 | 
             
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            -
                    version: 0.2 | 
| 29 | 
            +
                    version: 0.3.2
         | 
| 30 30 | 
             
                - - "<"
         | 
| 31 31 | 
             
                  - !ruby/object:Gem::Version
         | 
| 32 32 | 
             
                    version: 1.0.0
         | 
| @@ -36,7 +36,7 @@ dependencies: | |
| 36 36 | 
             
                requirements:
         | 
| 37 37 | 
             
                - - ">="
         | 
| 38 38 | 
             
                  - !ruby/object:Gem::Version
         | 
| 39 | 
            -
                    version: 0. | 
| 39 | 
            +
                    version: 0.11.2
         | 
| 40 40 | 
             
                - - "<"
         | 
| 41 41 | 
             
                  - !ruby/object:Gem::Version
         | 
| 42 42 | 
             
                    version: 1.0.0
         | 
| @@ -46,7 +46,7 @@ dependencies: | |
| 46 46 | 
             
                requirements:
         | 
| 47 47 | 
             
                - - ">="
         | 
| 48 48 | 
             
                  - !ruby/object:Gem::Version
         | 
| 49 | 
            -
                    version: 0. | 
| 49 | 
            +
                    version: 0.11.2
         | 
| 50 50 | 
             
                - - "<"
         | 
| 51 51 | 
             
                  - !ruby/object:Gem::Version
         | 
| 52 52 | 
             
                    version: 1.0.0
         | 
| @@ -138,7 +138,6 @@ files: | |
| 138 138 | 
             
            - lib/trailblazer/operation.rb
         | 
| 139 139 | 
             
            - lib/trailblazer/operation/callable.rb
         | 
| 140 140 | 
             
            - lib/trailblazer/operation/class_dependencies.rb
         | 
| 141 | 
            -
            - lib/trailblazer/operation/container.rb
         | 
| 142 141 | 
             
            - lib/trailblazer/operation/deprecated_macro.rb
         | 
| 143 142 | 
             
            - lib/trailblazer/operation/public_call.rb
         | 
| 144 143 | 
             
            - lib/trailblazer/operation/railway.rb
         | 
| @@ -155,7 +154,6 @@ files: | |
| 155 154 | 
             
            - test/docs/macaroni_test.rb
         | 
| 156 155 | 
             
            - test/docs/operation_test.rb
         | 
| 157 156 | 
             
            - test/docs/wiring_test.rb
         | 
| 158 | 
            -
            - test/dry_container_test.rb
         | 
| 159 157 | 
             
            - test/fast_track_test.rb
         | 
| 160 158 | 
             
            - test/gemfiles/Gemfile.ruby-1.9
         | 
| 161 159 | 
             
            - test/gemfiles/Gemfile.ruby-2.0
         | 
| @@ -179,7 +177,7 @@ homepage: http://trailblazer.to | |
| 179 177 | 
             
            licenses:
         | 
| 180 178 | 
             
            - MIT
         | 
| 181 179 | 
             
            metadata: {}
         | 
| 182 | 
            -
            post_install_message: | 
| 180 | 
            +
            post_install_message:
         | 
| 183 181 | 
             
            rdoc_options: []
         | 
| 184 182 | 
             
            require_paths:
         | 
| 185 183 | 
             
            - lib
         | 
| @@ -195,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 195 193 | 
             
                  version: '0'
         | 
| 196 194 | 
             
            requirements: []
         | 
| 197 195 | 
             
            rubygems_version: 3.0.8
         | 
| 198 | 
            -
            signing_key: | 
| 196 | 
            +
            signing_key:
         | 
| 199 197 | 
             
            specification_version: 4
         | 
| 200 198 | 
             
            summary: Trailblazer's operation object with railway flow and integrated error handling.
         | 
| 201 199 | 
             
            test_files:
         | 
| @@ -208,7 +206,6 @@ test_files: | |
| 208 206 | 
             
            - test/docs/macaroni_test.rb
         | 
| 209 207 | 
             
            - test/docs/operation_test.rb
         | 
| 210 208 | 
             
            - test/docs/wiring_test.rb
         | 
| 211 | 
            -
            - test/dry_container_test.rb
         | 
| 212 209 | 
             
            - test/fast_track_test.rb
         | 
| 213 210 | 
             
            - test/gemfiles/Gemfile.ruby-1.9
         | 
| 214 211 | 
             
            - test/gemfiles/Gemfile.ruby-2.0
         | 
| @@ -1,14 +0,0 @@ | |
| 1 | 
            -
            module Trailblazer
         | 
| 2 | 
            -
              module Operation::Container
         | 
| 3 | 
            -
                def options_for_public_call(options={}, *containers)
         | 
| 4 | 
            -
                  # generate the skill hash that embraces runtime options plus potential containers, the so called Runtime options.
         | 
| 5 | 
            -
                  # This wrapping is supposed to happen once in the entire system.
         | 
| 6 | 
            -
             | 
| 7 | 
            -
                  hash_transformer = ->(containers) { containers[0].to_hash } # FIXME: don't transform any containers into kw args.
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                  immutable_options = Trailblazer::Context::ContainerChain.new([options, *containers], to_hash: hash_transformer)
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                  Trailblazer::Context(immutable_options)
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
              end
         | 
| 14 | 
            -
            end
         | 
    
        data/test/dry_container_test.rb
    DELETED
    
    | @@ -1,25 +0,0 @@ | |
| 1 | 
            -
            require "test_helper"
         | 
| 2 | 
            -
            require "dry/container"
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            class DryContainerTest < Minitest::Spec
         | 
| 5 | 
            -
              my_container = Dry::Container.new
         | 
| 6 | 
            -
              my_container.register("user_repository", -> { Object })
         | 
| 7 | 
            -
              my_container.namespace("contract") do
         | 
| 8 | 
            -
                register("create") { Array }
         | 
| 9 | 
            -
              end
         | 
| 10 | 
            -
             | 
| 11 | 
            -
              class Create < Trailblazer::Operation
         | 
| 12 | 
            -
                extend Trailblazer::Operation::Container
         | 
| 13 | 
            -
              end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
              it "allows 2.2 call style" do
         | 
| 16 | 
            -
                Create.({}, my_container)["user_repository"].must_equal Object
         | 
| 17 | 
            -
              end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
              it { Create.({}, {}, my_container)["user_repository"].must_equal Object }
         | 
| 20 | 
            -
              it { Create.({}, {}, my_container)["contract.create"].must_equal Array }
         | 
| 21 | 
            -
              # also allows our own options PLUS containers.
         | 
| 22 | 
            -
              it { Create.({}, {"model" => String}, my_container)["model"].must_equal String }
         | 
| 23 | 
            -
              it { Create.({}, {"model" => String}, my_container)["user_repository"].must_equal Object }
         | 
| 24 | 
            -
              it { Create.({}, {"user_repository" => Integer}, my_container)["user_repository"].must_equal Integer }
         | 
| 25 | 
            -
            end
         |