grumlin 0.15.4 → 0.15.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile.lock +2 -2
- data/lib/definitions.yml +4 -0
- data/lib/grumlin/shortcut.rb +27 -0
- data/lib/grumlin/shortcut_proxy.rb +1 -1
- data/lib/grumlin/shortcuts.rb +11 -5
- data/lib/grumlin/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 195f614a2cbebbe43f6dd2aedb3aeb54891c4377f50f85f21f44ee3325c87f58
|
4
|
+
data.tar.gz: 0f0a3c0b5aa8f03fb4d613c406b08497685ee9fb4cbea2e8a0b99385f749ebf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21a7d91e9ce0a9e143f4bba9bb15d4bd31f6337f72500038bf09cd471ab05535d9d3ade4cfba6d6b6d779e09600b6352ed83b3e4bd70aeadd1417e51ba663937
|
7
|
+
data.tar.gz: 9cd14a8f18b856eca87d3b51b48c3f3c0d8d454b76fae92466bd7aee370019bbbb0b398236187acfcfed2322520aa4a3aa68a0e6bfb8b02a073e27f0db3cf525
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
grumlin (0.15.
|
4
|
+
grumlin (0.15.6)
|
5
5
|
async-pool (~> 0.3)
|
6
6
|
async-websocket (~> 0.19)
|
7
7
|
oj (~> 3.12)
|
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
protocol-http (~> 0.22.0)
|
29
29
|
protocol-http1 (~> 0.14.0)
|
30
30
|
protocol-http2 (~> 0.14.0)
|
31
|
-
async-io (1.
|
31
|
+
async-io (1.33.0)
|
32
32
|
async
|
33
33
|
async-pool (0.3.9)
|
34
34
|
async (>= 1.25)
|
data/lib/definitions.yml
CHANGED
@@ -32,11 +32,14 @@ steps:
|
|
32
32
|
- in
|
33
33
|
- inE
|
34
34
|
- inV
|
35
|
+
- inject
|
35
36
|
- is
|
36
37
|
- label
|
37
38
|
- limit
|
38
39
|
- map
|
40
|
+
- none
|
39
41
|
- not
|
42
|
+
- option
|
40
43
|
- or
|
41
44
|
- order
|
42
45
|
- out
|
@@ -68,6 +71,7 @@ steps:
|
|
68
71
|
- V
|
69
72
|
- addE
|
70
73
|
- addV
|
74
|
+
- inject
|
71
75
|
configuration:
|
72
76
|
- withSack
|
73
77
|
- withSideEffect
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Grumlin
|
4
|
+
class Shortcut
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
attr_reader :name, :block
|
8
|
+
|
9
|
+
def_delegator :@block, :arity
|
10
|
+
def_delegator :@block, :source_location
|
11
|
+
|
12
|
+
def initialize(name, &block)
|
13
|
+
@name = name
|
14
|
+
@block = block
|
15
|
+
end
|
16
|
+
|
17
|
+
def ==(other)
|
18
|
+
@name == other.name && @block == other.block
|
19
|
+
end
|
20
|
+
|
21
|
+
# TODO: to_s, inspect, preview
|
22
|
+
|
23
|
+
def apply(object, *args, **params)
|
24
|
+
object.instance_exec(*args, **params, &@block)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -18,7 +18,7 @@ module Grumlin
|
|
18
18
|
|
19
19
|
return wrap_result(@object.public_send(name, *args, **params)) if @object.respond_to?(name)
|
20
20
|
|
21
|
-
return wrap_result(
|
21
|
+
return wrap_result(@shortcuts[name].apply(self, *args, **params)) if @shortcuts.key?(name)
|
22
22
|
|
23
23
|
super
|
24
24
|
end
|
data/lib/grumlin/shortcuts.rb
CHANGED
@@ -18,7 +18,7 @@ module Grumlin
|
|
18
18
|
subclass.shortcuts_from(self)
|
19
19
|
end
|
20
20
|
|
21
|
-
def shortcut(name, &block)
|
21
|
+
def shortcut(name, shortcut = nil, &block) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
22
22
|
name = name.to_sym
|
23
23
|
# TODO: blocklist of names to avoid conflicts with standard methods?
|
24
24
|
if Grumlin::AnonymousStep::SUPPORTED_STEPS.include?(name)
|
@@ -26,14 +26,20 @@ module Grumlin
|
|
26
26
|
"cannot use names of standard gremlin steps"
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
if (shortcut.nil? && block.nil?) || (shortcut && block)
|
30
|
+
raise ArgumentError, "either shortcut or block must be passed"
|
31
|
+
end
|
32
|
+
|
33
|
+
shortcut ||= Shortcut.new(name, &block)
|
34
|
+
|
35
|
+
raise ArgumentError, "shortcut '#{name}' already exists" if shortcuts.key?(name) && shortcuts[name] != shortcut
|
30
36
|
|
31
|
-
shortcuts[name] =
|
37
|
+
shortcuts[name] = shortcut
|
32
38
|
end
|
33
39
|
|
34
40
|
def shortcuts_from(other_shortcuts)
|
35
|
-
other_shortcuts.shortcuts.each do |name,
|
36
|
-
shortcut(name,
|
41
|
+
other_shortcuts.shortcuts.each do |name, shortcut|
|
42
|
+
shortcut(name, shortcut)
|
37
43
|
end
|
38
44
|
end
|
39
45
|
|
data/lib/grumlin/version.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.15.
|
4
|
+
version: 0.15.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gleb Sinyavskiy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-pool
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- lib/grumlin/property.rb
|
116
116
|
- lib/grumlin/repository.rb
|
117
117
|
- lib/grumlin/request_dispatcher.rb
|
118
|
+
- lib/grumlin/shortcut.rb
|
118
119
|
- lib/grumlin/shortcut_proxy.rb
|
119
120
|
- lib/grumlin/shortcuts.rb
|
120
121
|
- lib/grumlin/shortcuts/properties.rb
|