grumlin 0.12.5 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +1 -1
- data/.rspec +0 -1
- data/.rubocop.yml +1 -1
- data/.tool-versions +1 -1
- data/CHANGELOG.md +12 -1
- data/Gemfile.lock +6 -1
- data/README.md +106 -3
- data/grumlin.gemspec +1 -1
- data/lib/grumlin/anonymous_step.rb +12 -8
- data/lib/grumlin/bytecode.rb +11 -6
- data/lib/grumlin/{tools → expressions}/order.rb +1 -1
- data/lib/grumlin/{tools → expressions}/p.rb +1 -1
- data/lib/grumlin/{tools → expressions}/pop.rb +1 -1
- data/lib/grumlin/{tools → expressions}/scope.rb +1 -1
- data/lib/grumlin/{tools → expressions}/t.rb +1 -1
- data/lib/grumlin/{tools → expressions}/tool.rb +1 -1
- data/lib/grumlin/{tools → expressions}/u.rb +3 -3
- data/lib/grumlin/{tools → expressions}/with_options.rb +1 -1
- data/lib/grumlin/repository.rb +23 -0
- data/lib/grumlin/shortcut_proxy.rb +53 -0
- data/lib/grumlin/shortcuts/properties.rb +21 -0
- data/lib/grumlin/shortcuts.rb +41 -0
- data/lib/grumlin/step.rb +4 -6
- data/lib/grumlin/sugar.rb +2 -2
- data/lib/grumlin/test/rspec/gremlin_context.rb +2 -2
- data/lib/grumlin/traversal.rb +16 -3
- data/lib/grumlin/version.rb +1 -1
- data/lib/grumlin.rb +4 -0
- metadata +16 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4889d5002539dc86922c58967a95a9d65da0e93b0b953626f17b59e1296f24bc
|
4
|
+
data.tar.gz: d2f9cf32f1d2d41ba65ac610c08167333e13eb26a98da6569b4b05c41c78aa6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72503ca022ceb7f38a9b8444cd711ef5aed9a0c3b37121c93009b9cbf2e1000d318e9e720c8d6ce4c1882a09d0ce24a823df7e06b15e359c0d46388baf06fc8d
|
7
|
+
data.tar.gz: 073aaa56b7a15a0cb6cc149629f744c82892a902f68cc7e7c2df052cd4d0c053942cdb9a2625310bc7d6afc24433a97ba753bc4ea8bd54f8ddb681cba3075dbc
|
data/.github/workflows/main.yml
CHANGED
data/.rspec
CHANGED
data/.rubocop.yml
CHANGED
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 2.
|
1
|
+
ruby 2.7.5
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,15 @@
|
|
1
|
-
## [
|
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.
|
4
|
+
grumlin (0.14.1)
|
5
5
|
async-pool (~> 0.3)
|
6
6
|
async-websocket (~> 0.19)
|
7
7
|
oj (~> 3.12)
|
@@ -60,8 +60,12 @@ 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
71
|
oj (3.13.9)
|
@@ -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
|
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
|
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.
|
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,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Grumlin
|
4
4
|
class AnonymousStep
|
5
|
-
attr_reader :name, :
|
5
|
+
attr_reader :name, :previous_step, :configuration_steps
|
6
6
|
|
7
7
|
# TODO: add other steps
|
8
8
|
SUPPORTED_STEPS = %i[E V addE addV and as both bothE by coalesce count dedup drop elementMap emit fold from group
|
@@ -10,18 +10,24 @@ module Grumlin
|
|
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
|
-
|
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
|
-
|
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
|
data/lib/grumlin/bytecode.rb
CHANGED
@@ -20,7 +20,10 @@ module Grumlin
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def inspect
|
23
|
-
|
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.
|
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.
|
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.
|
46
|
-
a.bytecode.
|
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
|
4
|
+
module Expressions
|
5
5
|
module U
|
6
6
|
# TODO: add other start steps
|
7
7
|
SUPPORTED_STEPS = %i[V addV count drop fold has hasLabel id in inE inV label out outE outV project repeat
|
@@ -9,8 +9,8 @@ module Grumlin
|
|
9
9
|
|
10
10
|
class << self
|
11
11
|
SUPPORTED_STEPS.each do |step|
|
12
|
-
define_method step do |*args|
|
13
|
-
AnonymousStep.new(step, *args)
|
12
|
+
define_method step do |*args, **params|
|
13
|
+
AnonymousStep.new(step, *args, **params)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -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,53 @@
|
|
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
|
+
if result.is_a?(AnonymousStep) || result.is_a?(Traversal)
|
47
|
+
return self.class.new(result, @shortcuts, parent: @parent)
|
48
|
+
end
|
49
|
+
|
50
|
+
result
|
51
|
+
end
|
52
|
+
end
|
53
|
+
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
|
-
|
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
@@ -11,8 +11,8 @@ module Grumlin
|
|
11
11
|
include Grumlin::Sugar
|
12
12
|
|
13
13
|
before do
|
14
|
-
Grumlin::
|
15
|
-
stub_const(tool.to_s, Grumlin::
|
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
|
|
data/lib/grumlin/traversal.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/grumlin/version.rb
CHANGED
data/lib/grumlin.rb
CHANGED
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.
|
4
|
+
version: 0.14.1
|
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-
|
11
|
+
date: 2021-12-09 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.
|
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.
|
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.
|