grumlin 0.22.4 → 1.0.0.rc1
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 +0 -1
 - data/.rubocop.yml +9 -9
 - data/Gemfile.lock +10 -8
 - data/README.md +102 -141
 - data/Rakefile +1 -1
 - data/bin/console +18 -3
 - data/doc/middlewares.md +97 -0
 - data/grumlin.gemspec +1 -0
 - data/lib/async/channel.rb +54 -56
 - data/lib/grumlin/benchmark/repository.rb +10 -14
 - data/lib/grumlin/client.rb +92 -112
 - data/lib/grumlin/config.rb +30 -15
 - data/lib/grumlin/dummy_transaction.rb +13 -15
 - data/lib/grumlin/edge.rb +18 -20
 - data/lib/grumlin/expressions/cardinality.rb +5 -9
 - data/lib/grumlin/expressions/column.rb +5 -9
 - data/lib/grumlin/expressions/expression.rb +7 -11
 - data/lib/grumlin/expressions/operator.rb +5 -9
 - data/lib/grumlin/expressions/order.rb +5 -9
 - data/lib/grumlin/expressions/p.rb +27 -31
 - data/lib/grumlin/expressions/pop.rb +5 -9
 - data/lib/grumlin/expressions/scope.rb +5 -9
 - data/lib/grumlin/expressions/t.rb +5 -9
 - data/lib/grumlin/expressions/text_p.rb +5 -9
 - data/lib/grumlin/expressions/with_options.rb +17 -21
 - data/lib/grumlin/features/feature_list.rb +8 -12
 - data/lib/grumlin/features/neptune_features.rb +5 -9
 - data/lib/grumlin/features/tinkergraph_features.rb +5 -9
 - data/lib/grumlin/features.rb +8 -10
 - data/lib/grumlin/middlewares/apply_shortcuts.rb +8 -0
 - data/lib/grumlin/middlewares/build_query.rb +20 -0
 - data/lib/grumlin/middlewares/builder.rb +15 -0
 - data/lib/grumlin/middlewares/cast_results.rb +7 -0
 - data/lib/grumlin/middlewares/find_blocklisted_steps.rb +14 -0
 - data/lib/grumlin/middlewares/find_mutating_steps.rb +9 -0
 - data/lib/grumlin/middlewares/middleware.rb +11 -0
 - data/lib/grumlin/middlewares/run_query.rb +7 -0
 - data/lib/grumlin/middlewares/serialize_to_bytecode.rb +9 -0
 - data/lib/grumlin/middlewares/serialize_to_steps.rb +8 -0
 - data/lib/grumlin/path.rb +11 -13
 - data/lib/grumlin/property.rb +14 -16
 - data/lib/grumlin/query_validators/blocklisted_steps_validator.rb +22 -0
 - data/lib/grumlin/query_validators/validator.rb +36 -0
 - data/lib/grumlin/repository/error_handling_strategy.rb +36 -40
 - data/lib/grumlin/repository/instance_methods.rb +115 -118
 - data/lib/grumlin/repository.rb +82 -58
 - data/lib/grumlin/request_dispatcher.rb +55 -57
 - data/lib/grumlin/request_error_factory.rb +53 -55
 - data/lib/grumlin/shortcut.rb +19 -21
 - data/lib/grumlin/shortcuts/properties.rb +12 -16
 - data/lib/grumlin/shortcuts/storage.rb +67 -74
 - data/lib/grumlin/shortcuts/upserts.rb +18 -22
 - data/lib/grumlin/shortcuts.rb +23 -25
 - data/lib/grumlin/shortcuts_applyer.rb +27 -29
 - data/lib/grumlin/step.rb +92 -0
 - data/lib/grumlin/step_data.rb +12 -14
 - data/lib/grumlin/steppable.rb +24 -22
 - data/lib/grumlin/steps.rb +51 -54
 - data/lib/grumlin/steps_serializers/bytecode.rb +53 -56
 - data/lib/grumlin/steps_serializers/human_readable_bytecode.rb +17 -21
 - data/lib/grumlin/steps_serializers/serializer.rb +7 -11
 - data/lib/grumlin/steps_serializers/string.rb +26 -30
 - data/lib/grumlin/test/rspec/db_cleaner_context.rb +8 -12
 - data/lib/grumlin/test/rspec/gremlin_context.rb +18 -16
 - data/lib/grumlin/test/rspec.rb +1 -5
 - data/lib/grumlin/transaction.rb +26 -27
 - data/lib/grumlin/transport.rb +71 -73
 - data/lib/grumlin/traversal_start.rb +31 -33
 - data/lib/grumlin/traversal_strategies/options_strategy.rb +3 -7
 - data/lib/grumlin/traverser.rb +5 -7
 - data/lib/grumlin/typed_value.rb +11 -13
 - data/lib/grumlin/typing.rb +70 -72
 - data/lib/grumlin/version.rb +1 -1
 - data/lib/grumlin/vertex.rb +14 -16
 - data/lib/grumlin/vertex_property.rb +14 -16
 - data/lib/grumlin/with_extension.rb +17 -19
 - data/lib/grumlin.rb +23 -19
 - metadata +32 -6
 - data/lib/grumlin/action.rb +0 -92
 - data/lib/grumlin/sugar.rb +0 -15
 
    
        data/lib/grumlin/step_data.rb
    CHANGED
    
    | 
         @@ -1,20 +1,18 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
                attr_reader :name, :args, :params
         
     | 
| 
      
 3 
     | 
    
         
            +
            class Grumlin::StepData
         
     | 
| 
      
 4 
     | 
    
         
            +
              attr_reader :name, :args, :params
         
     | 
| 
       6 
5 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 6 
     | 
    
         
            +
              def initialize(name, args: [], params: {})
         
     | 
| 
      
 7 
     | 
    
         
            +
                @name = name
         
     | 
| 
      
 8 
     | 
    
         
            +
                @args = args
         
     | 
| 
      
 9 
     | 
    
         
            +
                @params = params
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
       12 
11 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
              def ==(other)
         
     | 
| 
      
 13 
     | 
    
         
            +
                self.class == other.class &&
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @name == other.name &&
         
     | 
| 
      
 15 
     | 
    
         
            +
                  @args == other.args &&
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @params == other.params
         
     | 
| 
       19 
17 
     | 
    
         
             
              end
         
     | 
| 
       20 
18 
     | 
    
         
             
            end
         
     | 
    
        data/lib/grumlin/steppable.rb
    CHANGED
    
    | 
         @@ -1,36 +1,38 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
                extend Forwardable
         
     | 
| 
      
 3 
     | 
    
         
            +
            class Grumlin::Steppable
         
     | 
| 
      
 4 
     | 
    
         
            +
              extend Forwardable
         
     | 
| 
       6 
5 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
      
 6 
     | 
    
         
            +
              attr_reader :session_id
         
     | 
| 
       8 
7 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
              START_STEPS = Grumlin.definitions.dig(:steps, :start).map(&:to_sym).freeze
         
     | 
| 
      
 9 
     | 
    
         
            +
              REGULAR_STEPS = Grumlin.definitions.dig(:steps, :regular).map(&:to_sym).freeze
         
     | 
| 
      
 10 
     | 
    
         
            +
              CONFIGURATION_STEPS = Grumlin.definitions.dig(:steps, :configuration).map(&:to_sym).freeze
         
     | 
| 
       12 
11 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 12 
     | 
    
         
            +
              ALL_STEPS = START_STEPS + CONFIGURATION_STEPS + REGULAR_STEPS
         
     | 
| 
       14 
13 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 14 
     | 
    
         
            +
              def initialize(pool: nil, session_id: nil, middlewares: Grumlin.default_middlewares)
         
     | 
| 
      
 15 
     | 
    
         
            +
                @pool = pool
         
     | 
| 
      
 16 
     | 
    
         
            +
                @session_id = session_id
         
     | 
| 
       18 
17 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
      
 18 
     | 
    
         
            +
                @middlewares = middlewares
         
     | 
| 
       20 
19 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
                return if respond_to?(:shortcuts)
         
     | 
| 
       23 
21 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                 
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                    shortcuts.action_class.new(step, args: args, params: params, previous_step: self, session_id: @session_id)
         
     | 
| 
       27 
     | 
    
         
            -
                  end
         
     | 
| 
       28 
     | 
    
         
            -
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
                raise "steppable must not be initialized directly, use Grumlin::Shortcuts::Storage#g or #__ instead"
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
       29 
24 
     | 
    
         | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 25 
     | 
    
         
            +
              ALL_STEPS.each do |step|
         
     | 
| 
      
 26 
     | 
    
         
            +
                define_method step do |*args, **params|
         
     | 
| 
      
 27 
     | 
    
         
            +
                  shortcuts.step_class.new(step, args: args, params: params, previous_step: self,
         
     | 
| 
      
 28 
     | 
    
         
            +
                                                 session_id: @session_id, pool: @pool, middlewares: @middlewares)
         
     | 
| 
       32 
29 
     | 
    
         
             
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
       33 
31 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
      
 32 
     | 
    
         
            +
              def step(name, *args, **params)
         
     | 
| 
      
 33 
     | 
    
         
            +
                shortcuts.step_class.new(name, args: args, params: params, previous_step: self,
         
     | 
| 
      
 34 
     | 
    
         
            +
                                               session_id: @session_id, pool: @pool, middlewares: @middlewares)
         
     | 
| 
       35 
35 
     | 
    
         
             
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              def_delegator :shortcuts, :__
         
     | 
| 
       36 
38 
     | 
    
         
             
            end
         
     | 
    
        data/lib/grumlin/steps.rb
    CHANGED
    
    | 
         @@ -1,79 +1,76 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
                ALL_STEPS = Action::ALL_STEPS
         
     | 
| 
      
 3 
     | 
    
         
            +
            class Grumlin::Steps
         
     | 
| 
      
 4 
     | 
    
         
            +
              CONFIGURATION_STEPS = Grumlin::Step::CONFIGURATION_STEPS
         
     | 
| 
      
 5 
     | 
    
         
            +
              ALL_STEPS = Grumlin::Step::ALL_STEPS
         
     | 
| 
       7 
6 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
              def self.from(step)
         
     | 
| 
      
 8 
     | 
    
         
            +
                raise ArgumentError, "expected: #{Grumlin::Step}, given: #{step.class}" unless step.is_a?(Grumlin::Step)
         
     | 
| 
       10 
9 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                   
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
                    actions.unshift(action)
         
     | 
| 
       16 
     | 
    
         
            -
                    action = action.previous_step
         
     | 
| 
       17 
     | 
    
         
            -
                  end
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                  new(shortcuts).tap do |chain|
         
     | 
| 
       20 
     | 
    
         
            -
                    actions.each do |act|
         
     | 
| 
       21 
     | 
    
         
            -
                      chain.add(act.name, args: act.args, params: act.params)
         
     | 
| 
       22 
     | 
    
         
            -
                    end
         
     | 
| 
      
 10 
     | 
    
         
            +
                new(step.shortcuts).tap do |chain|
         
     | 
| 
      
 11 
     | 
    
         
            +
                  until step.nil? || step.is_a?(Grumlin::TraversalStart)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    chain.add(step.name, args: step.args, params: step.params, to: :begin)
         
     | 
| 
      
 13 
     | 
    
         
            +
                    step = step.previous_step
         
     | 
| 
       23 
14 
     | 
    
         
             
                  end
         
     | 
| 
       24 
15 
     | 
    
         
             
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
       25 
17 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 18 
     | 
    
         
            +
              attr_reader :configuration_steps, :steps, :shortcuts
         
     | 
| 
       27 
19 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 20 
     | 
    
         
            +
              def initialize(shortcuts, configuration_steps: [], steps: [])
         
     | 
| 
      
 21 
     | 
    
         
            +
                @shortcuts = shortcuts
         
     | 
| 
      
 22 
     | 
    
         
            +
                @configuration_steps = configuration_steps
         
     | 
| 
      
 23 
     | 
    
         
            +
                @steps = steps
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              def add(name, args: [], params: {}, to: :end)
         
     | 
| 
      
 27 
     | 
    
         
            +
                if CONFIGURATION_STEPS.include?(name) || name.to_sym == :tx
         
     | 
| 
      
 28 
     | 
    
         
            +
                  return add_configuration_step(name, args: args, params: params, to: to)
         
     | 
| 
       32 
29 
     | 
    
         
             
                end
         
     | 
| 
       33 
30 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
                 
     | 
| 
       35 
     | 
    
         
            -
                   
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
                  end
         
     | 
| 
      
 31 
     | 
    
         
            +
                Grumlin::StepData.new(name, args: cast_arguments(args), params: params).tap do |step|
         
     | 
| 
      
 32 
     | 
    
         
            +
                  next @steps << step if to == :end
         
     | 
| 
      
 33 
     | 
    
         
            +
                  next @steps.unshift(step) if to == :begin
         
     | 
| 
       38 
34 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
                   
     | 
| 
       40 
     | 
    
         
            -
                    @steps << step
         
     | 
| 
       41 
     | 
    
         
            -
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
                  raise ArgumentError, "'to:' must be either :begin or :end, given: '#{to}'"
         
     | 
| 
       42 
36 
     | 
    
         
             
                end
         
     | 
| 
      
 37 
     | 
    
         
            +
              end
         
     | 
| 
       43 
38 
     | 
    
         | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
      
 39 
     | 
    
         
            +
              def uses_shortcuts?
         
     | 
| 
      
 40 
     | 
    
         
            +
                shortcuts?(@configuration_steps) || shortcuts?(@steps)
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
       47 
42 
     | 
    
         | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
      
 43 
     | 
    
         
            +
              def ==(other)
         
     | 
| 
      
 44 
     | 
    
         
            +
                self.class == other.class &&
         
     | 
| 
      
 45 
     | 
    
         
            +
                  @shortcuts == other.shortcuts &&
         
     | 
| 
      
 46 
     | 
    
         
            +
                  @configuration_steps == other.configuration_steps &&
         
     | 
| 
      
 47 
     | 
    
         
            +
                  @steps == other.steps
         
     | 
| 
      
 48 
     | 
    
         
            +
              end
         
     | 
| 
       54 
49 
     | 
    
         | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
      
 50 
     | 
    
         
            +
              # TODO: add #bytecode, to_s, inspect
         
     | 
| 
       56 
51 
     | 
    
         | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
      
 52 
     | 
    
         
            +
              private
         
     | 
| 
       58 
53 
     | 
    
         | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
                    end
         
     | 
| 
      
 54 
     | 
    
         
            +
              def shortcuts?(steps_ary)
         
     | 
| 
      
 55 
     | 
    
         
            +
                steps_ary.any? do |step|
         
     | 
| 
      
 56 
     | 
    
         
            +
                  @shortcuts.known?(step.name) || step.args.any? do |arg|
         
     | 
| 
      
 57 
     | 
    
         
            +
                    arg.is_a?(Grumlin::Steps) ? arg.uses_shortcuts? : false
         
     | 
| 
       64 
58 
     | 
    
         
             
                  end
         
     | 
| 
       65 
59 
     | 
    
         
             
                end
         
     | 
| 
      
 60 
     | 
    
         
            +
              end
         
     | 
| 
       66 
61 
     | 
    
         | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
      
 62 
     | 
    
         
            +
              def add_configuration_step(name, args: [], params: {}, to: :end)
         
     | 
| 
      
 63 
     | 
    
         
            +
                raise ArgumentError, "cannot use configuration steps after start step was used" if @steps.any? && to == :end
         
     | 
| 
       69 
64 
     | 
    
         | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
                   
     | 
| 
       73 
     | 
    
         
            -
                end
         
     | 
| 
      
 65 
     | 
    
         
            +
                Grumlin::StepData.new(name, args: cast_arguments(args), params: params).tap do |step|
         
     | 
| 
      
 66 
     | 
    
         
            +
                  next @configuration_steps << step if to == :end
         
     | 
| 
      
 67 
     | 
    
         
            +
                  next @configuration_steps.unshift(step) if to == :begin
         
     | 
| 
       74 
68 
     | 
    
         | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
                  arguments.map { |arg| arg.is_a?(Action) ? Steps.from(arg) : arg }
         
     | 
| 
      
 69 
     | 
    
         
            +
                  raise ArgumentError, "to must be either :begin or :end, given: '#{to}'"
         
     | 
| 
       77 
70 
     | 
    
         
             
                end
         
     | 
| 
       78 
71 
     | 
    
         
             
              end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
              def cast_arguments(arguments)
         
     | 
| 
      
 74 
     | 
    
         
            +
                arguments.map { |arg| arg.is_a?(Grumlin::Step) ? Grumlin::Steps.from(arg) : arg }
         
     | 
| 
      
 75 
     | 
    
         
            +
              end
         
     | 
| 
       79 
76 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,72 +1,69 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
                  # constructor params: no_return: true|false, default false
         
     | 
| 
       7 
     | 
    
         
            -
                  # TODO: add pretty
         
     | 
| 
      
 3 
     | 
    
         
            +
            class Grumlin::StepsSerializers::Bytecode < Grumlin::StepsSerializers::Serializer
         
     | 
| 
      
 4 
     | 
    
         
            +
              # constructor params: no_return: true|false, default false
         
     | 
| 
      
 5 
     | 
    
         
            +
              # TODO: add pretty
         
     | 
| 
       8 
6 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
              NONE_STEP = Grumlin::StepData.new("none")
         
     | 
| 
       10 
8 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
      
 9 
     | 
    
         
            +
              def serialize
         
     | 
| 
      
 10 
     | 
    
         
            +
                steps = Grumlin::ShortcutsApplyer.call(@steps)
         
     | 
| 
      
 11 
     | 
    
         
            +
                no_return = @params.fetch(:no_return, false)
         
     | 
| 
      
 12 
     | 
    
         
            +
                {}.tap do |result|
         
     | 
| 
      
 13 
     | 
    
         
            +
                  result[:step] = serialize_steps(steps.steps + (no_return ? [NONE_STEP] : [])) if steps.steps.any?
         
     | 
| 
      
 14 
     | 
    
         
            +
                  result[:source] = serialize_steps(steps.configuration_steps) if steps.configuration_steps.any?
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
       19 
17 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 18 
     | 
    
         
            +
              private
         
     | 
| 
       21 
19 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
      
 20 
     | 
    
         
            +
              def serialize_steps(steps)
         
     | 
| 
      
 21 
     | 
    
         
            +
                steps.map { |s| serialize_step(s) }
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
       25 
23 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                      end
         
     | 
| 
       31 
     | 
    
         
            -
                      result << step.params if step.params.any?
         
     | 
| 
       32 
     | 
    
         
            -
                    end
         
     | 
| 
      
 24 
     | 
    
         
            +
              def serialize_step(step)
         
     | 
| 
      
 25 
     | 
    
         
            +
                [step.name].tap do |result|
         
     | 
| 
      
 26 
     | 
    
         
            +
                  step.args.each do |arg|
         
     | 
| 
      
 27 
     | 
    
         
            +
                    result << serialize_arg(arg)
         
     | 
| 
       33 
28 
     | 
    
         
             
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
                  result << step.params if step.params.any?
         
     | 
| 
      
 30 
     | 
    
         
            +
                end
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
       34 
32 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
      
 33 
     | 
    
         
            +
              def serialize_arg(arg)
         
     | 
| 
      
 34 
     | 
    
         
            +
                return serialize_typed_value(arg) if arg.is_a?(Grumlin::TypedValue)
         
     | 
| 
      
 35 
     | 
    
         
            +
                return serialize_predicate(arg) if arg.is_a?(Grumlin::Expressions::P::Predicate)
         
     | 
| 
      
 36 
     | 
    
         
            +
                return arg.value if arg.is_a?(Grumlin::Expressions::WithOptions)
         
     | 
| 
       39 
37 
     | 
    
         | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
      
 38 
     | 
    
         
            +
                return arg unless arg.is_a?(Grumlin::Steps)
         
     | 
| 
       41 
39 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
                   
     | 
| 
      
 40 
     | 
    
         
            +
                { :@type => "g:Bytecode",
         
     | 
| 
      
 41 
     | 
    
         
            +
                  :@value => Grumlin::StepsSerializers::Bytecode.new(arg, **@params.merge(no_return: false)).serialize }
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
       44 
43 
     | 
    
         | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
      
 44 
     | 
    
         
            +
              def serialize_typed_value(value)
         
     | 
| 
      
 45 
     | 
    
         
            +
                return value.value if value.type.nil?
         
     | 
| 
       47 
46 
     | 
    
         | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
      
 47 
     | 
    
         
            +
                {
         
     | 
| 
      
 48 
     | 
    
         
            +
                  "@type": "g:#{value.type}",
         
     | 
| 
      
 49 
     | 
    
         
            +
                  "@value": value.value
         
     | 
| 
      
 50 
     | 
    
         
            +
                }
         
     | 
| 
      
 51 
     | 
    
         
            +
              end
         
     | 
| 
       53 
52 
     | 
    
         | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
                  end
         
     | 
| 
       70 
     | 
    
         
            -
                end
         
     | 
| 
      
 53 
     | 
    
         
            +
              def serialize_predicate(value)
         
     | 
| 
      
 54 
     | 
    
         
            +
                {
         
     | 
| 
      
 55 
     | 
    
         
            +
                  "@type": "g:#{value.namespace}",
         
     | 
| 
      
 56 
     | 
    
         
            +
                  "@value": {
         
     | 
| 
      
 57 
     | 
    
         
            +
                    predicate: value.name,
         
     | 
| 
      
 58 
     | 
    
         
            +
                    value: if value.type.nil?
         
     | 
| 
      
 59 
     | 
    
         
            +
                             value.value
         
     | 
| 
      
 60 
     | 
    
         
            +
                           else
         
     | 
| 
      
 61 
     | 
    
         
            +
                             {
         
     | 
| 
      
 62 
     | 
    
         
            +
                               "@type": "g:#{value.type}",
         
     | 
| 
      
 63 
     | 
    
         
            +
                               "@value": value.value
         
     | 
| 
      
 64 
     | 
    
         
            +
                             }
         
     | 
| 
      
 65 
     | 
    
         
            +
                           end
         
     | 
| 
      
 66 
     | 
    
         
            +
                  }
         
     | 
| 
      
 67 
     | 
    
         
            +
                }
         
     | 
| 
       71 
68 
     | 
    
         
             
              end
         
     | 
| 
       72 
69 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,30 +1,26 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
                 
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                    end
         
     | 
| 
       11 
     | 
    
         
            -
                  end
         
     | 
| 
      
 3 
     | 
    
         
            +
            class Grumlin::StepsSerializers::HumanReadableBytecode < Grumlin::StepsSerializers::Bytecode
         
     | 
| 
      
 4 
     | 
    
         
            +
              def serialize
         
     | 
| 
      
 5 
     | 
    
         
            +
                steps = Grumlin::ShortcutsApplyer.call(@steps)
         
     | 
| 
      
 6 
     | 
    
         
            +
                [steps.configuration_steps, steps.steps].map do |stps|
         
     | 
| 
      
 7 
     | 
    
         
            +
                  stps.map { |s| serialize_step(s) }
         
     | 
| 
      
 8 
     | 
    
         
            +
                end
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
       12 
10 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 11 
     | 
    
         
            +
              private
         
     | 
| 
       14 
12 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
      
 13 
     | 
    
         
            +
              def serialize_arg(arg)
         
     | 
| 
      
 14 
     | 
    
         
            +
                return arg.to_s if arg.is_a?(Grumlin::TypedValue)
         
     | 
| 
      
 15 
     | 
    
         
            +
                return serialize_predicate(arg) if arg.is_a?(Grumlin::Expressions::P::Predicate)
         
     | 
| 
      
 16 
     | 
    
         
            +
                return arg.value if arg.is_a?(Grumlin::Expressions::WithOptions)
         
     | 
| 
       19 
17 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 18 
     | 
    
         
            +
                return arg unless arg.is_a?(Grumlin::Steps)
         
     | 
| 
       21 
19 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
      
 20 
     | 
    
         
            +
                Grumlin::StepsSerializers::HumanReadableBytecode.new(arg, **@params.merge(no_return: false)).serialize[1]
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
       24 
22 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                  end
         
     | 
| 
       28 
     | 
    
         
            -
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
              def serialize_predicate(arg)
         
     | 
| 
      
 24 
     | 
    
         
            +
                "#{arg.name}(#{arg.value})"
         
     | 
| 
       29 
25 
     | 
    
         
             
              end
         
     | 
| 
       30 
26 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,16 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
                 
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
                    @params = params
         
     | 
| 
       9 
     | 
    
         
            -
                  end
         
     | 
| 
      
 3 
     | 
    
         
            +
            class Grumlin::StepsSerializers::Serializer
         
     | 
| 
      
 4 
     | 
    
         
            +
              def initialize(steps, **params)
         
     | 
| 
      
 5 
     | 
    
         
            +
                @steps = steps
         
     | 
| 
      
 6 
     | 
    
         
            +
                @params = params
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
       10 
8 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                  end
         
     | 
| 
       14 
     | 
    
         
            -
                end
         
     | 
| 
      
 9 
     | 
    
         
            +
              def serialize
         
     | 
| 
      
 10 
     | 
    
         
            +
                raise NotImplementedError
         
     | 
| 
       15 
11 
     | 
    
         
             
              end
         
     | 
| 
       16 
12 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,43 +1,39 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
                  # constructor params: anonymous: true|false, default: false
         
     | 
| 
       8 
     | 
    
         
            -
                  # TODO: add pretty
         
     | 
| 
      
 3 
     | 
    
         
            +
            class Grumlin::StepsSerializers::String < Grumlin::StepsSerializers::Serializer
         
     | 
| 
      
 4 
     | 
    
         
            +
              # constructor params: apply_shortcuts: true|false, default: false
         
     | 
| 
      
 5 
     | 
    
         
            +
              # constructor params: anonymous: true|false, default: false
         
     | 
| 
      
 6 
     | 
    
         
            +
              # TODO: add pretty
         
     | 
| 
       9 
7 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
              def serialize
         
     | 
| 
      
 9 
     | 
    
         
            +
                steps = @params[:apply_shortcuts] ? Grumlin::ShortcutsApplyer.call(@steps) : @steps
         
     | 
| 
       12 
10 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 11 
     | 
    
         
            +
                steps = [steps.configuration_steps, steps.steps].map do |stps|
         
     | 
| 
      
 12 
     | 
    
         
            +
                  stps.map { |step| serialize_step(step) }
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
       16 
14 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
                "#{prefix}.#{(steps[0] + steps[1]).join(".")}"
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
       19 
17 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 18 
     | 
    
         
            +
              private
         
     | 
| 
       21 
19 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 20 
     | 
    
         
            +
              def serialize_step(step)
         
     | 
| 
      
 21 
     | 
    
         
            +
                "#{step.name}(#{(step.args + [step.params.any? ? step.params : nil].compact).map do |a|
         
     | 
| 
      
 22 
     | 
    
         
            +
                                  serialize_arg(a)
         
     | 
| 
      
 23 
     | 
    
         
            +
                                end.join(", ")})"
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
       27 
25 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
      
 26 
     | 
    
         
            +
              def prefix
         
     | 
| 
      
 27 
     | 
    
         
            +
                @prefix ||= @params[:anonymous] ? "__" : "g"
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
       31 
29 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
      
 30 
     | 
    
         
            +
              def serialize_arg(arg)
         
     | 
| 
      
 31 
     | 
    
         
            +
                return "\"#{arg}\"" if arg.is_a?(::String) || arg.is_a?(Symbol)
         
     | 
| 
      
 32 
     | 
    
         
            +
                return "#{arg.type}.#{arg.value}" if arg.is_a?(Grumlin::TypedValue)
         
     | 
| 
      
 33 
     | 
    
         
            +
                return arg.to_s if arg.is_a?(Grumlin::Expressions::WithOptions)
         
     | 
| 
       36 
34 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
      
 35 
     | 
    
         
            +
                return arg unless arg.is_a?(Grumlin::Steps)
         
     | 
| 
       38 
36 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                  end
         
     | 
| 
       41 
     | 
    
         
            -
                end
         
     | 
| 
      
 37 
     | 
    
         
            +
                Grumlin::StepsSerializers::String.new(arg, anonymous: true, **@params).serialize
         
     | 
| 
       42 
38 
     | 
    
         
             
              end
         
     | 
| 
       43 
39 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,19 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            module Grumlin
         
     | 
| 
       4 
     | 
    
         
            -
              module  
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
                  module DBCleanerContext
         
     | 
| 
       7 
     | 
    
         
            -
                  end
         
     | 
| 
      
 3 
     | 
    
         
            +
            module Grumlin::Test::RSpec
         
     | 
| 
      
 4 
     | 
    
         
            +
              module DBCleanerContext
         
     | 
| 
      
 5 
     | 
    
         
            +
              end
         
     | 
| 
       8 
6 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
              ::RSpec.shared_context DBCleanerContext do
         
     | 
| 
      
 8 
     | 
    
         
            +
                include DBCleanerContext
         
     | 
| 
       11 
9 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
                    end
         
     | 
| 
       16 
     | 
    
         
            -
                  end
         
     | 
| 
      
 10 
     | 
    
         
            +
                before do
         
     | 
| 
      
 11 
     | 
    
         
            +
                  g.E.drop.iterate
         
     | 
| 
      
 12 
     | 
    
         
            +
                  g.V.drop.iterate
         
     | 
| 
       17 
13 
     | 
    
         
             
                end
         
     | 
| 
       18 
14 
     | 
    
         
             
              end
         
     | 
| 
       19 
15 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,25 +1,27 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            module Grumlin
         
     | 
| 
       4 
     | 
    
         
            -
              module  
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
                  module GremlinContext
         
     | 
| 
       7 
     | 
    
         
            -
                  end
         
     | 
| 
      
 3 
     | 
    
         
            +
            module Grumlin::Test::RSpec
         
     | 
| 
      
 4 
     | 
    
         
            +
              module GremlinContext
         
     | 
| 
      
 5 
     | 
    
         
            +
              end
         
     | 
| 
       8 
6 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
              ::RSpec.shared_context GremlinContext do
         
     | 
| 
      
 8 
     | 
    
         
            +
                include GremlinContext
         
     | 
| 
      
 9 
     | 
    
         
            +
                include Grumlin::Expressions
         
     | 
| 
       12 
10 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 11 
     | 
    
         
            +
                [:__, :g].each do |name|
         
     | 
| 
      
 12 
     | 
    
         
            +
                  define_method(name) do |cuts = Grumlin::Shortcuts::Storage.empty|
         
     | 
| 
      
 13 
     | 
    
         
            +
                    cuts.send(name)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
       18 
16 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                     
     | 
| 
      
 17 
     | 
    
         
            +
                before do
         
     | 
| 
      
 18 
     | 
    
         
            +
                  Grumlin::Expressions.constants.each do |tool|
         
     | 
| 
      
 19 
     | 
    
         
            +
                    stub_const(tool.to_s, Grumlin::Expressions.const_get(tool))
         
     | 
| 
       22 
20 
     | 
    
         
             
                  end
         
     | 
| 
       23 
21 
     | 
    
         
             
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                after do
         
     | 
| 
      
 24 
     | 
    
         
            +
                  Grumlin.close
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
       24 
26 
     | 
    
         
             
              end
         
     | 
| 
       25 
27 
     | 
    
         
             
            end
         
     | 
    
        data/lib/grumlin/test/rspec.rb
    CHANGED
    
    
    
        data/lib/grumlin/transaction.rb
    CHANGED
    
    | 
         @@ -1,39 +1,38 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
                attr_reader :session_id
         
     | 
| 
      
 3 
     | 
    
         
            +
            class Grumlin::Transaction
         
     | 
| 
      
 4 
     | 
    
         
            +
              attr_reader :session_id
         
     | 
| 
       6 
5 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
      
 6 
     | 
    
         
            +
              include Console
         
     | 
| 
       8 
7 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
              COMMIT = Grumlin::Repository.new.g.step(:tx, :commit)
         
     | 
| 
      
 9 
     | 
    
         
            +
              ROLLBACK = Grumlin::Repository.new.g.step(:tx, :rollback)
         
     | 
| 
       11 
10 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 11 
     | 
    
         
            +
              def initialize(traversal_start_class, pool:, middlewares:)
         
     | 
| 
      
 12 
     | 
    
         
            +
                @traversal_start_class = traversal_start_class
         
     | 
| 
      
 13 
     | 
    
         
            +
                @pool = pool
         
     | 
| 
      
 14 
     | 
    
         
            +
                @session_id = SecureRandom.uuid
         
     | 
| 
      
 15 
     | 
    
         
            +
                @middlewares = middlewares
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
       18 
17 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 18 
     | 
    
         
            +
              def begin
         
     | 
| 
      
 19 
     | 
    
         
            +
                @traversal_start_class.new(session_id: @session_id)
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
       22 
21 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
              def commit
         
     | 
| 
      
 23 
     | 
    
         
            +
                finalize(COMMIT)
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
       26 
25 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
      
 26 
     | 
    
         
            +
              def rollback
         
     | 
| 
      
 27 
     | 
    
         
            +
                finalize(ROLLBACK)
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
       30 
29 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 30 
     | 
    
         
            +
              private
         
     | 
| 
       32 
31 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
      
 32 
     | 
    
         
            +
              def finalize(step)
         
     | 
| 
      
 33 
     | 
    
         
            +
                @middlewares.call(traversal: step,
         
     | 
| 
      
 34 
     | 
    
         
            +
                                  need_results: false,
         
     | 
| 
      
 35 
     | 
    
         
            +
                                  session_id: @session_id,
         
     | 
| 
      
 36 
     | 
    
         
            +
                                  pool: @pool)
         
     | 
| 
       38 
37 
     | 
    
         
             
              end
         
     | 
| 
       39 
38 
     | 
    
         
             
            end
         
     |