grumlin 0.12.4 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5ddac28eac1cb06e427f52d8639b8a75bdc9b4c867aa353199a05a51d847696
4
- data.tar.gz: 3ac77adec54d09b74ab1b620de484205cfbee52249cfa6e4529a5b988b228537
3
+ metadata.gz: e353294814ba425473eb717892ea994d686dd25eec4db78cd0c15102f68a7e53
4
+ data.tar.gz: 672458be5666e00f34386e632a8a902e3271ad91160b1b2d4bd2235d3789abd9
5
5
  SHA512:
6
- metadata.gz: f5ced6bb8aca8250daba19e059bcf36dc5fb3fe31ded7b552ca297f858edd82203b1b178196a1b448952819a112d44c40ab64e85aeb9f0f5469e44f728a5a539
7
- data.tar.gz: 6258168a26d952f31bb2087fef044914efb6c51d81355611954c3999d65a7e62f38bae0654da7f4213a40513093240acf673156547033bbf83de37f17313552f
6
+ metadata.gz: cc64a8dacf4dc2384e0d3da380cb0b62f534e603e49f67f537f0c1e46feb549c8098d8580c1d9d96edf0f3b145b777ae26206025086e52ee86ca37e526d53f8a
7
+ data.tar.gz: 4c2ae1909426dc7c89a41feecb2e7a917daa33f8adb7330229691fa7e49585b1b1e24fca7773026e998f7a738b701d8457e50fcaf8ca3c9e271a71b698ea26e6
@@ -22,7 +22,7 @@ jobs:
22
22
  runs-on: ubuntu-latest
23
23
  strategy:
24
24
  matrix:
25
- ruby: [2.6, 2.7, 3.0]
25
+ ruby: [2.7, 3.0]
26
26
  steps:
27
27
  - uses: actions/checkout@v2
28
28
 
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
- --format documentation
2
1
  --color
3
2
  --require spec_helper
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 2.7
3
3
  NewCops: enable
4
4
  SuggestExtensions: false
5
5
 
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 2.6.6
1
+ ruby 2.7.5
data/CHANGELOG.md CHANGED
@@ -1,4 +1,15 @@
1
- ## [Unreleased]
1
+ ## [0.14.0] - 2021-12-07
2
+
3
+ - Add initial support for [configuration steps](https://tinkerpop.apache.org/docs/current/reference/#configuration-steps)
4
+ - Add the `withSideEffect` configuration step
5
+ - Fix passing keyword arguments to regular steps
6
+ - *Drop support for ruby 2.6*
7
+
8
+ ## [0.13.0] - 2021-12-03
9
+
10
+ - Add `Shortcuts` and `Repository`
11
+ - Allow executing any gremlin steps by name using `Grumlin::AnonymousStep#step`
12
+ - Rename `Grumlin::Tools` to `Grumlin::Expressions`
2
13
 
3
14
  ## [0.1.0] - 2021-05-25
4
15
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grumlin (0.12.4)
4
+ grumlin (0.14.0)
5
5
  async-pool (~> 0.3)
6
6
  async-websocket (~> 0.19)
7
7
  oj (~> 3.12)
@@ -30,7 +30,7 @@ GEM
30
30
  protocol-http2 (~> 0.14.0)
31
31
  async-io (1.32.2)
32
32
  async
33
- async-pool (0.3.8)
33
+ async-pool (0.3.9)
34
34
  async (>= 1.25)
35
35
  async-rspec (1.16.0)
36
36
  rspec (~> 3.0)
@@ -44,7 +44,7 @@ GEM
44
44
  benchmark (0.1.1)
45
45
  childprocess (4.0.0)
46
46
  concurrent-ruby (1.1.8)
47
- console (1.13.1)
47
+ console (1.14.0)
48
48
  fiber-local
49
49
  diff-lcs (1.4.4)
50
50
  docile (1.4.0)
@@ -60,11 +60,15 @@ GEM
60
60
  rexml
61
61
  kramdown-parser-gfm (1.1.0)
62
62
  kramdown (~> 2.0)
63
+ mini_portile2 (2.5.3)
63
64
  minitest (5.14.4)
64
65
  nio4r (2.5.8)
66
+ nokogiri (1.11.7)
67
+ mini_portile2 (~> 2.5.0)
68
+ racc (~> 1.4)
65
69
  nokogiri (1.11.7-x86_64-linux)
66
70
  racc (~> 1.4)
67
- oj (3.13.7)
71
+ oj (3.13.9)
68
72
  overcommit (0.57.0)
69
73
  childprocess (>= 0.6.3, < 5)
70
74
  iniparse (~> 1.4)
@@ -154,6 +158,7 @@ GEM
154
158
  zeitwerk (2.4.2)
155
159
 
156
160
  PLATFORMS
161
+ ruby
157
162
  x86_64-linux
158
163
 
159
164
  DEPENDENCIES
data/README.md CHANGED
@@ -14,7 +14,7 @@ and gremlin-server.
14
14
  [async-websocket](https://github.com/socketry/async-websocket). Code using grumlin must be executed in an async
15
15
  event loop.
16
16
 
17
- **Warning:** Grumlin is in development, but ready for simple use cases
17
+ **Warning**: Grumlin is in development, but ready for simple use cases
18
18
 
19
19
  ## Table of contents
20
20
  - [Install](#install)
@@ -51,12 +51,12 @@ end
51
51
 
52
52
  ### Traversing graphs
53
53
 
54
- **Warning:** Not all steps and tools described in the standard are supported
54
+ **Warning**: Not all steps and tools described in the standard are supported
55
55
 
56
56
  #### Sugar
57
57
 
58
58
  Grumlin provides an easy to use module called `Grumlin::Sugar`. Once included in your class it injects some useful
59
- constants and methods turning your class into an entrypoint for traversals.
59
+ constants and methods turning your class into an entrypoint for traversals with pure gremlin experience.
60
60
 
61
61
  ```ruby
62
62
  class MyRepository
@@ -73,6 +73,109 @@ class MyRepository
73
73
  end
74
74
  ```
75
75
 
76
+ #### Shortcuts
77
+
78
+ **Shortcuts** is a way to share and organize gremlin code. They let developers define their own steps consisting of
79
+ sequences of standard gremlin steps, other shortcuts and even add new initially unsupported by Grumlin steps.
80
+ Remember ActiveRecord scopes? Shortcuts are very similar. `Grumlin::Shortcuts#with_shortcuts` wraps a given object into
81
+ a proxy object that simply proxies all methods existing in the wrapped object to it and handles shortcuts.
82
+
83
+ **Important**: if a shortcut's name matches a name of a method defined on the wrapped object, this shortcut will be
84
+ be ignored because methods have higher priority. You cannot override supported by Grumlin steps with shortcuts,
85
+ `Grumlin::Shortcuts.shortcut` will raise an `ArgumentError`. Please carefully choose names for your shortcuts.
86
+
87
+ Shortcuts are designed to be used with `Grumlin::Repository` but still can be used separately, with `Grumlin::Sugar`
88
+ for example.
89
+
90
+ **Defining**:
91
+ ```ruby
92
+
93
+ # Defining shortcuts
94
+ class ColorShortcut
95
+ extend Grumlin::Shortcuts
96
+
97
+ # Custom step
98
+ shortcut :hasColor do |color|
99
+ has(:color, color)
100
+ end
101
+ end
102
+
103
+ class ChooseShortcut
104
+ extend Grumlin::Shortcuts
105
+
106
+ # Standard Gremlin step
107
+ shortcut :choose do |*args|
108
+ step(:choose, *args)
109
+ end
110
+ end
111
+
112
+ class AllShortcuts
113
+ extend Grumlin::Shortcuts
114
+
115
+ # Adding shortcuts from other modules
116
+ shortcuts_from ColorShortcut
117
+ shortcuts_from ChooseShortcut
118
+ end
119
+ ```
120
+
121
+ **Using with Grumlin::Sugar**:
122
+ ```ruby
123
+ class MyRepository
124
+ include Grumlin::Sugar
125
+ extend Grumlin::Shortcuts
126
+
127
+ shortcuts_from AllShortcuts
128
+
129
+ # Wrapping a traversal
130
+ def red_triangles
131
+ with_shortcuts(g).V.hasLabel(:triangle)
132
+ .hasColor("red")
133
+ .toList
134
+ end
135
+
136
+ # Wrapping _
137
+ def something_else
138
+ with_shortcuts(g).V.hasColor("red")
139
+ .repeat(with_shortcuts(__)
140
+ .out(:has)
141
+ .hasColor("blue")).toList
142
+ end
143
+ end
144
+ ```
145
+
146
+ #### Grumlin::Repository
147
+ `Grumlin::Repository` combines functionality of `Grumlin::Sugar` and `Grumlin::Shortcuts` as well as adds a few useful
148
+ shortcuts to make gremlin code more rubyish. Can be used as a drop in replacement for `Grumlin::Sugar`. Remember that
149
+ `Grumlin::Sugar` needs to be included, but `Grumlin::Repository` - extended. **Classes extending `Grumlin::Repository`
150
+ or `Grumlin::Shortcuts` can be inherited**, successors don't need to extend them again and have access to shortcuts
151
+ defined in the ancestor.
152
+
153
+ **Using**:
154
+
155
+ ```ruby
156
+ class MyRepository
157
+ extend Grumlin::Repository
158
+
159
+ # Repository supports all Grumlin::Shortcut and Grumlin::Sugar features.
160
+ # It can add shortcuts from another repository or a shortcuts module
161
+ shortcuts_from ChooseShortcut
162
+
163
+ shortcut :red_triangles do |color|
164
+ # hasAll unwraps a hash of properties into a chain of `has` steps:
165
+ # hasAll(name1: :value, name2: :value) == has(:name1, :value).has(:name2, :value)
166
+ # the `props` shortcut does exactly the same but with `property` steps.
167
+ hasAll(T.label => :triangle, color: color)
168
+ end
169
+
170
+ # g and __ are already aware of shortcuts
171
+ def red_triangles
172
+ g.V.hasLabel(:triangle)
173
+ .hasColor("red")
174
+ .toList
175
+ end
176
+ end
177
+ ```
178
+
76
179
  #### IRB
77
180
 
78
181
  An example of how to start an IRB session with support for executing gremlin queries:
data/grumlin.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.homepage = "https://github.com/zhulik/grumlin"
18
18
  spec.license = "MIT"
19
- spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
19
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
20
20
 
21
21
  spec.metadata["homepage_uri"] = spec.homepage
22
22
  spec.metadata["source_code_uri"] = "https://github.com/zhulik/grumlin"
@@ -2,26 +2,32 @@
2
2
 
3
3
  module Grumlin
4
4
  class AnonymousStep
5
- attr_reader :name, :args, :previous_step
5
+ attr_reader :name, :previous_step, :configuration_steps
6
6
 
7
7
  # TODO: add other steps
8
- SUPPORTED_STEPS = %i[E V addE addV as both bothE by coalesce count dedup drop elementMap emit fold from group
9
- groupCount has hasId hasLabel hasNot id in inE inV is label limit not order out outE path
8
+ SUPPORTED_STEPS = %i[E V addE addV and as both bothE by coalesce count dedup drop elementMap emit fold from group
9
+ groupCount has hasId hasLabel hasNot id in inE inV is label limit not or order out outE path
10
10
  project property range repeat select sideEffect skip tail to unfold union until valueMap
11
11
  values where with].freeze
12
12
 
13
- def initialize(name, *args, previous_step: nil)
13
+ def initialize(name, *args, configuration_steps: [], previous_step: nil, **params)
14
14
  @name = name
15
15
  @previous_step = previous_step
16
16
  @args = args
17
+ @params = params
18
+ @configuration_steps = configuration_steps
17
19
  end
18
20
 
19
21
  SUPPORTED_STEPS.each do |step|
20
- define_method(step) do |*args|
21
- add_step(step, args)
22
+ define_method(step) do |*args, **params|
23
+ step(step, *args, **params)
22
24
  end
23
25
  end
24
26
 
27
+ def step(name, *args, **params)
28
+ self.class.new(name, *args, previous_step: self, configuration_steps: configuration_steps, **params)
29
+ end
30
+
25
31
  def inspect
26
32
  bytecode.inspect
27
33
  end
@@ -32,10 +38,8 @@ module Grumlin
32
38
  @bytecode ||= Bytecode.new(self, no_return: no_return)
33
39
  end
34
40
 
35
- private
36
-
37
- def add_step(step_name, args)
38
- self.class.new(step_name, *args, previous_step: self)
41
+ def args
42
+ [*@args, @params.any? ? arg.params : nil].compact
39
43
  end
40
44
  end
41
45
  end
@@ -20,7 +20,10 @@ module Grumlin
20
20
  end
21
21
 
22
22
  def inspect
23
- to_readable_bytecode.to_s
23
+ configuration_steps = @step.configuration_steps.map do |s|
24
+ serialize_arg(s, serialization_method: :to_readable_bytecode)
25
+ end
26
+ "#{configuration_steps.any? ? configuration_steps : nil}#{to_readable_bytecode}"
24
27
  end
25
28
  alias to_s inspect
26
29
 
@@ -29,21 +32,23 @@ module Grumlin
29
32
  end
30
33
 
31
34
  def value
32
- { step: (steps + (@no_return ? [NONE_STEP] : [])).map { |s| serialize_arg(s) } }
35
+ @value ||= { step: (steps + (@no_return ? [NONE_STEP] : [])).map { |s| serialize_arg(s) } }.tap do |v|
36
+ v.merge!(source: @step.configuration_steps.map { |s| serialize_arg(s) }) if @step.configuration_steps.any?
37
+ end
33
38
  end
34
39
 
35
40
  private
36
41
 
37
42
  # Serializes step or a step argument to either an executable query or a human readable string representation
38
- # depending on the `serialization_method` parameter. I should be either `:to_readable_bytecode` for human readable
43
+ # depending on the `serialization_method` parameter. It should be either `:to_readable_bytecode` for human readable
39
44
  # representation or `:to_bytecode` for query.
40
45
  def serialize_arg(arg, serialization_method: :to_bytecode)
41
- return arg.send(serialization_method) if arg.respond_to?(serialization_method)
46
+ return arg.public_send(serialization_method) if arg.respond_to?(serialization_method)
42
47
  return arg unless arg.is_a?(AnonymousStep)
43
48
 
44
49
  arg.args.flatten.each.with_object([arg.name.to_s]) do |a, res|
45
- res << if a.instance_of?(AnonymousStep)
46
- a.bytecode.send(serialization_method)
50
+ res << if a.respond_to?(:bytecode)
51
+ a.bytecode.public_send(serialization_method)
47
52
  else
48
53
  serialize_arg(a, serialization_method: serialization_method)
49
54
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grumlin
4
- module Tools
4
+ module Expressions
5
5
  module Order
6
6
  extend Tool
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grumlin
4
- module Tools
4
+ module Expressions
5
5
  module P
6
6
  class << self
7
7
  class Predicate < TypedValue
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grumlin
4
- module Tools
4
+ module Expressions
5
5
  module Pop
6
6
  extend Tool
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grumlin
4
- module Tools
4
+ module Expressions
5
5
  module Scope
6
6
  extend Tool
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grumlin
4
- module Tools
4
+ module Expressions
5
5
  module T
6
6
  extend Tool
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grumlin
4
- module Tools
4
+ module Expressions
5
5
  module Tool
6
6
  def define_steps(steps, tool_name)
7
7
  steps.each do |step|
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Grumlin
4
+ module Expressions
5
+ module U
6
+ # TODO: add other start steps
7
+ SUPPORTED_STEPS = %i[V addV count drop fold has hasLabel id in inE inV label out outE outV project repeat
8
+ timeLimit unfold valueMap values].freeze
9
+
10
+ class << self
11
+ SUPPORTED_STEPS.each do |step|
12
+ define_method step do |*args, **params|
13
+ AnonymousStep.new(step, *args, **params)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grumlin
4
- module Tools
4
+ module Expressions
5
5
  module WithOptions
6
6
  WITH_OPTIONS = {
7
7
  tokens: "~tinkerpop.valueMap.tokens",
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Grumlin
4
+ module Repository
5
+ module InstanceMethods
6
+ def __
7
+ with_shortcuts(Grumlin::Expressions::U)
8
+ end
9
+
10
+ def g
11
+ with_shortcuts(Grumlin::Traversal.new)
12
+ end
13
+ end
14
+
15
+ def self.extended(base)
16
+ base.extend(Grumlin::Shortcuts)
17
+ base.include(Grumlin::Expressions)
18
+ base.include(InstanceMethods)
19
+
20
+ base.shortcuts_from(Grumlin::Shortcuts::Properties)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Grumlin
4
+ class ShortcutProxy
5
+ extend Forwardable
6
+
7
+ attr_reader :object, :shortcuts
8
+
9
+ # shortcuts: {"name": ->(arg) {}}
10
+ def initialize(object, shortcuts, parent: nil)
11
+ @object = object
12
+ @shortcuts = shortcuts
13
+ @parent = parent
14
+ end
15
+
16
+ def method_missing(name, *args, **params)
17
+ return @parent.public_send(name, *args, **params) if %i[__ g].include?(name) && !@parent.nil?
18
+
19
+ return wrap_result(@object.public_send(name, *args, **params)) if @object.respond_to?(name)
20
+
21
+ return wrap_result(instance_exec(*args, **params, &@shortcuts[name])) if @shortcuts.key?(name)
22
+
23
+ super
24
+ end
25
+
26
+ # For some reason the interpreter thinks it's private
27
+ public def respond_to_missing?(name, include_private = false) # rubocop:disable Style/AccessModifierDeclarations
28
+ name = name.to_sym
29
+
30
+ (%i[__ g].include?(name) &&
31
+ @parent.respond_to?(name)) ||
32
+ @object.respond_to?(name) ||
33
+ @shortcuts.key?(name) ||
34
+ super
35
+ end
36
+
37
+ def_delegator :@object, :to_s
38
+
39
+ def inspect
40
+ @object.inspect
41
+ end
42
+
43
+ private
44
+
45
+ def wrap_result(result)
46
+ return self.class.new(result, @shortcuts, parent: @parent) if result.is_a?(AnonymousStep)
47
+
48
+ result
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Grumlin
4
+ module Shortcuts
5
+ module Properties
6
+ extend Grumlin::Shortcuts
7
+
8
+ shortcut :props do |*_args, **props|
9
+ props.reduce(self) do |tt, (prop, value)|
10
+ tt.property(prop, value)
11
+ end
12
+ end
13
+
14
+ shortcut :hasAll do |*, **props|
15
+ props.reduce(self) do |tt, (prop, value)|
16
+ tt.has(prop, value)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Grumlin
4
+ module Shortcuts
5
+ module InstanceMethods
6
+ def with_shortcuts(obj)
7
+ ShortcutProxy.new(obj, self.class.shortcuts, parent: self)
8
+ end
9
+ end
10
+
11
+ def self.extended(base)
12
+ base.include(InstanceMethods)
13
+ base.include(Grumlin::Expressions)
14
+ end
15
+
16
+ def inherited(subclass)
17
+ super
18
+ subclass.shortcuts_from(self)
19
+ end
20
+
21
+ def shortcut(name, &block)
22
+ name = name.to_sym
23
+ # TODO: blocklist of names to avoid conflicts with standard methods?
24
+ raise ArgumentError, "cannot use names of standard gremlin steps" if Grumlin.supported_steps.include?(name)
25
+
26
+ raise ArgumentError, "shortcut '#{name}' already exists" if shortcuts.key?(name)
27
+
28
+ shortcuts[name] = block
29
+ end
30
+
31
+ def shortcuts_from(other_shortcuts)
32
+ other_shortcuts.shortcuts.each do |name, block|
33
+ shortcut(name, &block)
34
+ end
35
+ end
36
+
37
+ def shortcuts
38
+ @shortcuts ||= {}
39
+ end
40
+ end
41
+ end
data/lib/grumlin/step.rb CHANGED
@@ -4,8 +4,8 @@ module Grumlin
4
4
  class Step < AnonymousStep
5
5
  attr_reader :client
6
6
 
7
- def initialize(pool, name, *args, previous_step: nil)
8
- super(name, *args, previous_step: previous_step)
7
+ def initialize(pool, name, *args, configuration_steps: [], previous_step: nil, **params)
8
+ super(name, *args, previous_step: previous_step, configuration_steps: configuration_steps, **params)
9
9
  @pool = pool
10
10
  end
11
11
 
@@ -36,10 +36,8 @@ module Grumlin
36
36
  end
37
37
  end
38
38
 
39
- private
40
-
41
- def add_step(step_name, args)
42
- self.class.new(@pool, step_name, *args, previous_step: self)
39
+ def step(step_name, *args, **params)
40
+ self.class.new(@pool, step_name, *args, previous_step: self, configuration_steps: @configuration_steps, **params)
43
41
  end
44
42
  end
45
43
  end
data/lib/grumlin/sugar.rb CHANGED
@@ -3,11 +3,11 @@
3
3
  module Grumlin
4
4
  module Sugar
5
5
  def self.included(base)
6
- base.include Grumlin::Tools
6
+ base.include(Grumlin::Expressions)
7
7
  end
8
8
 
9
9
  def __
10
- Grumlin::Tools::U
10
+ Grumlin::Expressions::U
11
11
  end
12
12
 
13
13
  def g
@@ -11,8 +11,8 @@ module Grumlin
11
11
  include Grumlin::Sugar
12
12
 
13
13
  before do
14
- Grumlin::Tools.constants.each do |tool|
15
- stub_const(tool.to_s, Grumlin::Tools.const_get(tool))
14
+ Grumlin::Expressions.constants.each do |tool|
15
+ stub_const(tool.to_s, Grumlin::Expressions.const_get(tool))
16
16
  end
17
17
  end
18
18
 
@@ -5,13 +5,26 @@ module Grumlin
5
5
  # TODO: add other start steps
6
6
  SUPPORTED_STEPS = %i[E V addE addV].freeze
7
7
 
8
- def initialize(pool = Grumlin.default_pool)
8
+ CONFIGURATION_STEPS = %i[withSideEffect].freeze
9
+
10
+ attr_reader :configuration_steps
11
+
12
+ def initialize(pool = Grumlin.default_pool, configuration_steps: [])
9
13
  @pool = pool
14
+ @configuration_steps = configuration_steps
15
+ end
16
+
17
+ alias inspect to_s
18
+
19
+ CONFIGURATION_STEPS.each do |step|
20
+ define_method step do |*args, **params|
21
+ self.class.new(@pool, configuration_steps: @configuration_steps + [AnonymousStep.new(step, *args, **params)])
22
+ end
10
23
  end
11
24
 
12
25
  SUPPORTED_STEPS.each do |step|
13
- define_method step do |*args|
14
- Step.new(@pool, step, *args)
26
+ define_method step do |*args, **params|
27
+ Step.new(@pool, step, *args, configuration_steps: @configuration_steps, **params)
15
28
  end
16
29
  end
17
30
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grumlin
4
- VERSION = "0.12.4"
4
+ VERSION = "0.14.0"
5
5
  end
data/lib/grumlin.rb CHANGED
@@ -106,6 +106,10 @@ module Grumlin
106
106
  end
107
107
  end
108
108
 
109
+ def self.supported_steps
110
+ @supported_steps ||= (Grumlin::AnonymousStep::SUPPORTED_STEPS + Grumlin::Expressions::U::SUPPORTED_STEPS).sort.uniq
111
+ end
112
+
109
113
  @pool_mutex = Mutex.new
110
114
 
111
115
  class << self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grumlin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.4
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Sinyavskiy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-10 00:00:00.000000000 Z
11
+ date: 2021-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-pool
@@ -101,21 +101,25 @@ files:
101
101
  - lib/grumlin/bytecode.rb
102
102
  - lib/grumlin/client.rb
103
103
  - lib/grumlin/edge.rb
104
+ - lib/grumlin/expressions/order.rb
105
+ - lib/grumlin/expressions/p.rb
106
+ - lib/grumlin/expressions/pop.rb
107
+ - lib/grumlin/expressions/scope.rb
108
+ - lib/grumlin/expressions/t.rb
109
+ - lib/grumlin/expressions/tool.rb
110
+ - lib/grumlin/expressions/u.rb
111
+ - lib/grumlin/expressions/with_options.rb
104
112
  - lib/grumlin/path.rb
113
+ - lib/grumlin/repository.rb
105
114
  - lib/grumlin/request_dispatcher.rb
115
+ - lib/grumlin/shortcut_proxy.rb
116
+ - lib/grumlin/shortcuts.rb
117
+ - lib/grumlin/shortcuts/properties.rb
106
118
  - lib/grumlin/step.rb
107
119
  - lib/grumlin/sugar.rb
108
120
  - lib/grumlin/test/rspec.rb
109
121
  - lib/grumlin/test/rspec/db_cleaner_context.rb
110
122
  - lib/grumlin/test/rspec/gremlin_context.rb
111
- - lib/grumlin/tools/order.rb
112
- - lib/grumlin/tools/p.rb
113
- - lib/grumlin/tools/pop.rb
114
- - lib/grumlin/tools/scope.rb
115
- - lib/grumlin/tools/t.rb
116
- - lib/grumlin/tools/tool.rb
117
- - lib/grumlin/tools/u.rb
118
- - lib/grumlin/tools/with_options.rb
119
123
  - lib/grumlin/transport.rb
120
124
  - lib/grumlin/traversal.rb
121
125
  - lib/grumlin/typed_value.rb
@@ -137,14 +141,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
137
141
  requirements:
138
142
  - - ">="
139
143
  - !ruby/object:Gem::Version
140
- version: 2.6.0
144
+ version: 2.7.0
141
145
  required_rubygems_version: !ruby/object:Gem::Requirement
142
146
  requirements:
143
147
  - - ">="
144
148
  - !ruby/object:Gem::Version
145
149
  version: '0'
146
150
  requirements: []
147
- rubygems_version: 3.2.22
151
+ rubygems_version: 3.2.32
148
152
  signing_key:
149
153
  specification_version: 4
150
154
  summary: Gremlin graph traversal language DSL and client for Ruby.
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Grumlin
4
- module Tools
5
- module U
6
- # TODO: add other start steps
7
- SUPPORTED_STEPS = %i[V addV count drop fold has id in inE inV label out outE outV project repeat timeLimit unfold
8
- valueMap values].freeze
9
-
10
- class << self
11
- SUPPORTED_STEPS.each do |step|
12
- define_method step do |*args|
13
- AnonymousStep.new(step, *args)
14
- end
15
- end
16
- end
17
- end
18
- end
19
- end