grumlin 0.13.1 → 0.14.3
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 +23 -0
- data/Gemfile.lock +17 -13
- data/README.md +2 -1
- data/grumlin.gemspec +4 -1
- data/lib/grumlin/anonymous_step.rb +19 -11
- data/lib/grumlin/bytecode.rb +12 -4
- data/lib/grumlin/client.rb +5 -2
- data/lib/grumlin/edge.rb +4 -1
- data/lib/grumlin/expressions/{tool.rb → expression.rb} +2 -2
- data/lib/grumlin/expressions/operator.rb +15 -0
- data/lib/grumlin/expressions/order.rb +5 -3
- data/lib/grumlin/expressions/pop.rb +5 -3
- data/lib/grumlin/expressions/scope.rb +5 -3
- data/lib/grumlin/expressions/t.rb +5 -3
- data/lib/grumlin/expressions/u.rb +4 -4
- data/lib/grumlin/path.rb +4 -1
- data/lib/grumlin/request_dispatcher.rb +8 -4
- data/lib/grumlin/shortcut_proxy.rb +7 -5
- data/lib/grumlin/shortcuts/properties.rb +2 -2
- data/lib/grumlin/step.rb +4 -4
- data/lib/grumlin/transport.rb +1 -1
- data/lib/grumlin/traversal.rb +22 -3
- data/lib/grumlin/typed_value.rb +8 -2
- data/lib/grumlin/version.rb +1 -1
- data/lib/grumlin/vertex.rb +4 -1
- data/lib/grumlin.rb +2 -0
- metadata +6 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f1574fb6f69111d6a738cdbb1e19fb085c234ade887483e1b2c45644104cc40b
|
|
4
|
+
data.tar.gz: 2910b648435d662b8e1bebfb6646b838e71912807379aa04205efdcc0a8b8a05
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 41cadcd8b01c0ef3af860942eb6d187e5acfafdfd5e7c7cd9a052bb5f261ecd9773912ebe8a6da039188b1a81519fc20a7c7c19706c915f7550787345b936ac8
|
|
7
|
+
data.tar.gz: fcbc59501668d19e08305a08158ed63ac73a6a94d375d71af0975f8a4a556f900a2dadd611da66e5b306679580e586ee1a23bdfea1d058bf9c86e77a4f7ee2fa
|
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,3 +1,26 @@
|
|
|
1
|
+
## [0.14.2] - 2021-12-13
|
|
2
|
+
|
|
3
|
+
- Fix `Module` bloating
|
|
4
|
+
- Add `Operator` expressions
|
|
5
|
+
- Add `__.coalesce` and `__.constant`
|
|
6
|
+
- Add steps: `sum`, `sack`
|
|
7
|
+
- Add configuration steps: `withSack`
|
|
8
|
+
- Rename `Grumlin::Expressions::Tool` to `Grumlin::Expressions::Expression`
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## [0.14.2] - 2021-12-12
|
|
12
|
+
|
|
13
|
+
- Better exceptions
|
|
14
|
+
- Add `choose` step
|
|
15
|
+
- Add `__.hasNot`, `__.is`, `__.select`
|
|
16
|
+
|
|
17
|
+
## [0.14.0] - 2021-12-07
|
|
18
|
+
|
|
19
|
+
- Add initial support for [configuration steps](https://tinkerpop.apache.org/docs/current/reference/#configuration-steps)
|
|
20
|
+
- Add the `withSideEffect` configuration step
|
|
21
|
+
- Fix passing keyword arguments to regular steps
|
|
22
|
+
- *Drop support for ruby 2.6*
|
|
23
|
+
|
|
1
24
|
## [0.13.0] - 2021-12-03
|
|
2
25
|
|
|
3
26
|
- Add `Shortcuts` and `Repository`
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
grumlin (0.
|
|
4
|
+
grumlin (0.14.3)
|
|
5
5
|
async-pool (~> 0.3)
|
|
6
6
|
async-websocket (~> 0.19)
|
|
7
7
|
oj (~> 3.12)
|
|
@@ -60,16 +60,20 @@ 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.
|
|
71
|
+
oj (3.13.10)
|
|
68
72
|
overcommit (0.57.0)
|
|
69
73
|
childprocess (>= 0.6.3, < 5)
|
|
70
74
|
iniparse (~> 1.4)
|
|
71
|
-
parallel (1.
|
|
72
|
-
parser (3.0.
|
|
75
|
+
parallel (1.21.0)
|
|
76
|
+
parser (3.0.3.2)
|
|
73
77
|
ast (~> 2.4.1)
|
|
74
78
|
protocol-hpack (1.4.2)
|
|
75
79
|
protocol-http (0.22.5)
|
|
@@ -84,7 +88,7 @@ GEM
|
|
|
84
88
|
racc (1.5.2)
|
|
85
89
|
rainbow (3.0.0)
|
|
86
90
|
rake (13.0.3)
|
|
87
|
-
regexp_parser (2.
|
|
91
|
+
regexp_parser (2.2.0)
|
|
88
92
|
reverse_markdown (2.0.0)
|
|
89
93
|
nokogiri
|
|
90
94
|
rexml (3.2.5)
|
|
@@ -105,23 +109,22 @@ GEM
|
|
|
105
109
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
106
110
|
rspec-support (~> 3.10.0)
|
|
107
111
|
rspec-support (3.10.2)
|
|
108
|
-
rubocop (1.
|
|
112
|
+
rubocop (1.23.0)
|
|
109
113
|
parallel (~> 1.10)
|
|
110
114
|
parser (>= 3.0.0.0)
|
|
111
115
|
rainbow (>= 2.2.2, < 4.0)
|
|
112
116
|
regexp_parser (>= 1.8, < 3.0)
|
|
113
117
|
rexml
|
|
114
|
-
rubocop-ast (>= 1.
|
|
118
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
|
115
119
|
ruby-progressbar (~> 1.7)
|
|
116
120
|
unicode-display_width (>= 1.4.0, < 3.0)
|
|
117
|
-
rubocop-ast (1.
|
|
121
|
+
rubocop-ast (1.14.0)
|
|
118
122
|
parser (>= 3.0.1.1)
|
|
119
|
-
rubocop-performance (1.
|
|
123
|
+
rubocop-performance (1.12.0)
|
|
120
124
|
rubocop (>= 1.7.0, < 2.0)
|
|
121
125
|
rubocop-ast (>= 0.4.0)
|
|
122
|
-
rubocop-rspec (2.
|
|
123
|
-
rubocop (~> 1.
|
|
124
|
-
rubocop-ast (>= 1.1.0)
|
|
126
|
+
rubocop-rspec (2.6.0)
|
|
127
|
+
rubocop (~> 1.19)
|
|
125
128
|
ruby-progressbar (1.11.0)
|
|
126
129
|
simplecov (0.21.2)
|
|
127
130
|
docile (~> 1.1)
|
|
@@ -149,11 +152,12 @@ GEM
|
|
|
149
152
|
timers (4.3.3)
|
|
150
153
|
tzinfo (2.0.4)
|
|
151
154
|
concurrent-ruby (~> 1.0)
|
|
152
|
-
unicode-display_width (2.
|
|
155
|
+
unicode-display_width (2.1.0)
|
|
153
156
|
yard (0.9.26)
|
|
154
157
|
zeitwerk (2.4.2)
|
|
155
158
|
|
|
156
159
|
PLATFORMS
|
|
160
|
+
ruby
|
|
157
161
|
x86_64-linux
|
|
158
162
|
|
|
159
163
|
DEPENDENCIES
|
data/README.md
CHANGED
|
@@ -241,7 +241,8 @@ config.include_context(Grumlin::Test::RSpec::DBCleanerContext) # Cleans the data
|
|
|
241
241
|
...
|
|
242
242
|
```
|
|
243
243
|
|
|
244
|
-
It is highly recommended to use `Grumlin::Sugar` and not trying to use lower level APIs
|
|
244
|
+
It is highly recommended to use `Grumlin::Sugar` or `Grumlin::Repository` and not trying to use lower level APIs
|
|
245
|
+
as they are subject to change.
|
|
245
246
|
|
|
246
247
|
## Development
|
|
247
248
|
|
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"
|
|
@@ -31,4 +31,7 @@ Gem::Specification.new do |spec|
|
|
|
31
31
|
spec.add_dependency "async-websocket", "~> 0.19"
|
|
32
32
|
spec.add_dependency "oj", "~> 3.12"
|
|
33
33
|
spec.add_dependency "zeitwerk", "~> 2.4"
|
|
34
|
+
spec.metadata = {
|
|
35
|
+
"rubygems_mfa_required" => "true"
|
|
36
|
+
}
|
|
34
37
|
end
|
|
@@ -2,38 +2,46 @@
|
|
|
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
|
-
SUPPORTED_STEPS = %i[E V addE addV and as both bothE by coalesce count dedup drop elementMap emit fold from
|
|
9
|
-
groupCount has hasId hasLabel hasNot id in inE inV is label limit not or order out outE
|
|
10
|
-
project property range repeat select sideEffect skip tail to unfold union until
|
|
11
|
-
values where with].freeze
|
|
8
|
+
SUPPORTED_STEPS = %i[E V addE addV and as both bothE by choose coalesce count dedup drop elementMap emit fold from
|
|
9
|
+
group groupCount has hasId hasLabel hasNot id in inE inV is label limit not or order out outE
|
|
10
|
+
path project property range repeat sack select sideEffect skip sum tail to unfold union until
|
|
11
|
+
valueMap 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
|
-
step(step, args)
|
|
22
|
+
define_method(step) do |*args, **params|
|
|
23
|
+
step(step, *args, **params)
|
|
22
24
|
end
|
|
23
25
|
end
|
|
24
26
|
|
|
25
|
-
def step(name, args)
|
|
26
|
-
self.class.new(name, *args, previous_step: self)
|
|
27
|
+
def step(name, *args, **params)
|
|
28
|
+
self.class.new(name, *args, previous_step: self, configuration_steps: configuration_steps, **params)
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
def inspect
|
|
30
32
|
bytecode.inspect
|
|
31
33
|
end
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
def to_s
|
|
36
|
+
inspect
|
|
37
|
+
end
|
|
34
38
|
|
|
35
39
|
def bytecode(no_return: false)
|
|
36
40
|
@bytecode ||= Bytecode.new(self, no_return: no_return)
|
|
37
41
|
end
|
|
42
|
+
|
|
43
|
+
def args
|
|
44
|
+
[*@args, @params.any? ? arg.params : nil].compact
|
|
45
|
+
end
|
|
38
46
|
end
|
|
39
47
|
end
|
data/lib/grumlin/bytecode.rb
CHANGED
|
@@ -20,22 +20,30 @@ 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}"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def to_s
|
|
30
|
+
inspect
|
|
24
31
|
end
|
|
25
|
-
alias to_s inspect
|
|
26
32
|
|
|
27
33
|
def to_readable_bytecode
|
|
28
34
|
@to_readable_bytecode ||= steps.map { |s| serialize_arg(s, serialization_method: :to_readable_bytecode) }
|
|
29
35
|
end
|
|
30
36
|
|
|
31
37
|
def value
|
|
32
|
-
{ step: (steps + (@no_return ? [NONE_STEP] : [])).map { |s| serialize_arg(s) } }
|
|
38
|
+
@value ||= { step: (steps + (@no_return ? [NONE_STEP] : [])).map { |s| serialize_arg(s) } }.tap do |v|
|
|
39
|
+
v.merge!(source: @step.configuration_steps.map { |s| serialize_arg(s) }) if @step.configuration_steps.any?
|
|
40
|
+
end
|
|
33
41
|
end
|
|
34
42
|
|
|
35
43
|
private
|
|
36
44
|
|
|
37
45
|
# Serializes step or a step argument to either an executable query or a human readable string representation
|
|
38
|
-
# depending on the `serialization_method` parameter.
|
|
46
|
+
# depending on the `serialization_method` parameter. It should be either `:to_readable_bytecode` for human readable
|
|
39
47
|
# representation or `:to_bytecode` for query.
|
|
40
48
|
def serialize_arg(arg, serialization_method: :to_bytecode)
|
|
41
49
|
return arg.public_send(serialization_method) if arg.respond_to?(serialization_method)
|
data/lib/grumlin/client.rb
CHANGED
|
@@ -51,7 +51,7 @@ module Grumlin
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def connect
|
|
54
|
-
raise
|
|
54
|
+
raise ClientClosedError if @closed
|
|
55
55
|
|
|
56
56
|
@transport = build_transport
|
|
57
57
|
response_channel = @transport.connect
|
|
@@ -113,10 +113,13 @@ module Grumlin
|
|
|
113
113
|
"<#{self.class} url=#{@url} connected=#{connected?}>"
|
|
114
114
|
end
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
def to_s
|
|
117
|
+
inspect
|
|
118
|
+
end
|
|
117
119
|
|
|
118
120
|
private
|
|
119
121
|
|
|
122
|
+
# This might be overridden in successors
|
|
120
123
|
def build_transport
|
|
121
124
|
Transport.new(@url, parent: @parent, **@client_options)
|
|
122
125
|
end
|
data/lib/grumlin/edge.rb
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
module Grumlin
|
|
4
4
|
module Expressions
|
|
5
|
-
module
|
|
5
|
+
module Expression
|
|
6
6
|
def define_steps(steps, tool_name)
|
|
7
7
|
steps.each do |step|
|
|
8
|
-
|
|
8
|
+
define_method step do
|
|
9
9
|
name = "@#{step}"
|
|
10
10
|
return instance_variable_get(name) if instance_variable_defined?(name)
|
|
11
11
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Grumlin
|
|
4
|
+
module Expressions
|
|
5
|
+
module Operator
|
|
6
|
+
SUPPORTED_STEPS = %i[addAll and assign div max min minus mult or sum].freeze
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
extend Expression
|
|
10
|
+
|
|
11
|
+
define_steps(SUPPORTED_STEPS, "Operator")
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
module Grumlin
|
|
4
4
|
module Expressions
|
|
5
5
|
module Order
|
|
6
|
-
extend Tool
|
|
7
|
-
|
|
8
6
|
SUPPORTED_STEPS = %i[asc desc].freeze
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
class << self
|
|
9
|
+
extend Expression
|
|
10
|
+
|
|
11
|
+
define_steps(SUPPORTED_STEPS, "Order")
|
|
12
|
+
end
|
|
11
13
|
end
|
|
12
14
|
end
|
|
13
15
|
end
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
module Grumlin
|
|
4
4
|
module Expressions
|
|
5
5
|
module Pop
|
|
6
|
-
extend Tool
|
|
7
|
-
|
|
8
6
|
SUPPORTED_STEPS = %i[all first last mixed].freeze
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
class << self
|
|
9
|
+
extend Expression
|
|
10
|
+
|
|
11
|
+
define_steps(SUPPORTED_STEPS, "Pop")
|
|
12
|
+
end
|
|
11
13
|
end
|
|
12
14
|
end
|
|
13
15
|
end
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
module Grumlin
|
|
4
4
|
module Expressions
|
|
5
5
|
module Scope
|
|
6
|
-
extend Tool
|
|
7
|
-
|
|
8
6
|
SUPPORTED_STEPS = %i[local].freeze
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
class << self
|
|
9
|
+
extend Expression
|
|
10
|
+
|
|
11
|
+
define_steps(SUPPORTED_STEPS, "Scope")
|
|
12
|
+
end
|
|
11
13
|
end
|
|
12
14
|
end
|
|
13
15
|
end
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
module Grumlin
|
|
4
4
|
module Expressions
|
|
5
5
|
module T
|
|
6
|
-
extend Tool
|
|
7
|
-
|
|
8
6
|
SUPPORTED_STEPS = %i[id label].freeze
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
class << self
|
|
9
|
+
extend Expression
|
|
10
|
+
|
|
11
|
+
define_steps(SUPPORTED_STEPS, "T")
|
|
12
|
+
end
|
|
11
13
|
end
|
|
12
14
|
end
|
|
13
15
|
end
|
|
@@ -4,13 +4,13 @@ module Grumlin
|
|
|
4
4
|
module Expressions
|
|
5
5
|
module U
|
|
6
6
|
# TODO: add other start steps
|
|
7
|
-
SUPPORTED_STEPS = %i[V addV count drop fold has hasLabel id in inE inV label out outE
|
|
8
|
-
timeLimit unfold valueMap values].freeze
|
|
7
|
+
SUPPORTED_STEPS = %i[V addV coalesce constant count drop fold has hasLabel hasNot id in inE inV is label out outE
|
|
8
|
+
outV project repeat select timeLimit unfold valueMap values].freeze
|
|
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
|
data/lib/grumlin/path.rb
CHANGED
|
@@ -22,14 +22,18 @@ module Grumlin
|
|
|
22
22
|
498 => ClientSideError
|
|
23
23
|
}.freeze
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
class DispatcherError < Grumlin::Error; end
|
|
26
|
+
|
|
27
|
+
class RequestAlreadyAddedError < DispatcherError; end
|
|
28
|
+
|
|
29
|
+
class UnknownRequestError < DispatcherError; end
|
|
26
30
|
|
|
27
31
|
def initialize
|
|
28
32
|
@requests = {}
|
|
29
33
|
end
|
|
30
34
|
|
|
31
35
|
def add_request(request)
|
|
32
|
-
raise
|
|
36
|
+
raise RequestAlreadyAddedError if @requests.key?(request[:requestId])
|
|
33
37
|
|
|
34
38
|
Async::Channel.new.tap do |channel|
|
|
35
39
|
@requests[request[:requestId]] = { request: request, result: [], channel: channel }
|
|
@@ -40,7 +44,7 @@ module Grumlin
|
|
|
40
44
|
# TODO: sometimes response does not include requestID, no idea how to handle it so far.
|
|
41
45
|
def add_response(response) # rubocop:disable Metrics/AbcSize
|
|
42
46
|
request_id = response[:requestId]
|
|
43
|
-
raise
|
|
47
|
+
raise UnknownRequestError unless ongoing_request?(request_id)
|
|
44
48
|
|
|
45
49
|
request = @requests[request_id]
|
|
46
50
|
|
|
@@ -61,7 +65,7 @@ module Grumlin
|
|
|
61
65
|
end
|
|
62
66
|
|
|
63
67
|
def close_request(request_id)
|
|
64
|
-
raise
|
|
68
|
+
raise UnknownRequestError unless ongoing_request?(request_id)
|
|
65
69
|
|
|
66
70
|
request = @requests.delete(request_id)
|
|
67
71
|
request[:channel].close
|
|
@@ -13,12 +13,12 @@ module Grumlin
|
|
|
13
13
|
@parent = parent
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
def method_missing(name, *args)
|
|
17
|
-
return @parent.public_send(name, *args) if %i[__ g].include?(name) && !@parent.nil?
|
|
16
|
+
def method_missing(name, *args, **params)
|
|
17
|
+
return @parent.public_send(name, *args, **params) if %i[__ g].include?(name) && !@parent.nil?
|
|
18
18
|
|
|
19
|
-
return wrap_result(@object.public_send(name, *args)) if @object.respond_to?(name)
|
|
19
|
+
return wrap_result(@object.public_send(name, *args, **params)) if @object.respond_to?(name)
|
|
20
20
|
|
|
21
|
-
return wrap_result(instance_exec(*args, &@shortcuts[name])) if @shortcuts.key?(name)
|
|
21
|
+
return wrap_result(instance_exec(*args, **params, &@shortcuts[name])) if @shortcuts.key?(name)
|
|
22
22
|
|
|
23
23
|
super
|
|
24
24
|
end
|
|
@@ -43,7 +43,9 @@ module Grumlin
|
|
|
43
43
|
private
|
|
44
44
|
|
|
45
45
|
def wrap_result(result)
|
|
46
|
-
|
|
46
|
+
if result.is_a?(AnonymousStep) || result.is_a?(Traversal)
|
|
47
|
+
return self.class.new(result, @shortcuts, parent: @parent)
|
|
48
|
+
end
|
|
47
49
|
|
|
48
50
|
result
|
|
49
51
|
end
|
|
@@ -5,13 +5,13 @@ module Grumlin
|
|
|
5
5
|
module Properties
|
|
6
6
|
extend Grumlin::Shortcuts
|
|
7
7
|
|
|
8
|
-
shortcut :props do
|
|
8
|
+
shortcut :props do |*_args, **props|
|
|
9
9
|
props.reduce(self) do |tt, (prop, value)|
|
|
10
10
|
tt.property(prop, value)
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
shortcut :hasAll do
|
|
14
|
+
shortcut :hasAll do |*, **props|
|
|
15
15
|
props.reduce(self) do |tt, (prop, value)|
|
|
16
16
|
tt.has(prop, value)
|
|
17
17
|
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,8 +36,8 @@ module Grumlin
|
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
def step(step_name, args)
|
|
40
|
-
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)
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
end
|
data/lib/grumlin/transport.rb
CHANGED
|
@@ -23,7 +23,7 @@ module Grumlin
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def connect
|
|
26
|
-
raise
|
|
26
|
+
raise ClientClosedError if @closed
|
|
27
27
|
raise AlreadyConnectedError if connected?
|
|
28
28
|
|
|
29
29
|
@connection = Async::WebSocket::Client.connect(Async::HTTP::Endpoint.parse(@url), **@client_options)
|
data/lib/grumlin/traversal.rb
CHANGED
|
@@ -5,13 +5,32 @@ 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[withSack 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
|
+
def inspect
|
|
18
|
+
"#<#{self.class}>"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def to_s
|
|
22
|
+
inspect
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
CONFIGURATION_STEPS.each do |step|
|
|
26
|
+
define_method step do |*args, **params|
|
|
27
|
+
self.class.new(@pool, configuration_steps: @configuration_steps + [AnonymousStep.new(step, *args, **params)])
|
|
28
|
+
end
|
|
10
29
|
end
|
|
11
30
|
|
|
12
31
|
SUPPORTED_STEPS.each do |step|
|
|
13
|
-
define_method step do |*args|
|
|
14
|
-
Step.new(@pool, step, *args)
|
|
32
|
+
define_method step do |*args, **params|
|
|
33
|
+
Step.new(@pool, step, *args, configuration_steps: @configuration_steps, **params)
|
|
15
34
|
end
|
|
16
35
|
end
|
|
17
36
|
end
|
data/lib/grumlin/typed_value.rb
CHANGED
data/lib/grumlin/version.rb
CHANGED
data/lib/grumlin/vertex.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.3
|
|
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-12-
|
|
11
|
+
date: 2021-12-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: async-pool
|
|
@@ -101,12 +101,13 @@ files:
|
|
|
101
101
|
- lib/grumlin/bytecode.rb
|
|
102
102
|
- lib/grumlin/client.rb
|
|
103
103
|
- lib/grumlin/edge.rb
|
|
104
|
+
- lib/grumlin/expressions/expression.rb
|
|
105
|
+
- lib/grumlin/expressions/operator.rb
|
|
104
106
|
- lib/grumlin/expressions/order.rb
|
|
105
107
|
- lib/grumlin/expressions/p.rb
|
|
106
108
|
- lib/grumlin/expressions/pop.rb
|
|
107
109
|
- lib/grumlin/expressions/scope.rb
|
|
108
110
|
- lib/grumlin/expressions/t.rb
|
|
109
|
-
- lib/grumlin/expressions/tool.rb
|
|
110
111
|
- lib/grumlin/expressions/u.rb
|
|
111
112
|
- lib/grumlin/expressions/with_options.rb
|
|
112
113
|
- lib/grumlin/path.rb
|
|
@@ -130,9 +131,7 @@ homepage: https://github.com/zhulik/grumlin
|
|
|
130
131
|
licenses:
|
|
131
132
|
- MIT
|
|
132
133
|
metadata:
|
|
133
|
-
|
|
134
|
-
source_code_uri: https://github.com/zhulik/grumlin
|
|
135
|
-
changelog_uri: https://github.com/zhulik/grumlin/blob/master/CHANGELOG.md
|
|
134
|
+
rubygems_mfa_required: 'true'
|
|
136
135
|
post_install_message:
|
|
137
136
|
rdoc_options: []
|
|
138
137
|
require_paths:
|
|
@@ -141,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
141
140
|
requirements:
|
|
142
141
|
- - ">="
|
|
143
142
|
- !ruby/object:Gem::Version
|
|
144
|
-
version: 2.
|
|
143
|
+
version: 2.7.0
|
|
145
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
145
|
requirements:
|
|
147
146
|
- - ">="
|