grumlin 0.20.0 → 0.21.0
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/Gemfile.lock +2 -2
- data/README.md +8 -3
- data/gremlin_server/Dockerfile +1 -1
- data/grumlin.gemspec +1 -1
- data/lib/definitions.yml +1 -0
- data/lib/grumlin/repository/instance_methods.rb +5 -5
- data/lib/grumlin/repository.rb +7 -0
- data/lib/grumlin/shortcuts/properties.rb +5 -4
- data/lib/grumlin/shortcuts/storage.rb +0 -6
- data/lib/grumlin/shortcuts/upserts.rb +2 -2
- data/lib/grumlin/steppable.rb +1 -2
- data/lib/grumlin/traversal_start.rb +2 -0
- data/lib/grumlin/traversal_strategies/options_strategy.rb +11 -0
- data/lib/grumlin/version.rb +1 -1
- data/lib/grumlin/with_extension.rb +28 -0
- metadata +5 -4
- data/CHANGELOG.md +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb67bbe2eff3a7fd02cce19c6052fa70e3f54f3ec2cb06102667f69e43d07e8d
|
4
|
+
data.tar.gz: 1ecf0285f60fab6fd93bd0b36bfe58c39b94eebf0ead055f6f3cc4f2e9f8b19d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '05263993fc271810fd493ae3d5fdd8d84b6b698a8d9a4e4a4c336b09858571b156971b6f3def4bdb2d9c3743b07bebeb40eb1c426e4c316a8aa4a87b264f15b5'
|
7
|
+
data.tar.gz: 78fc706c4694146ff2b5fedc75b1d0186dca152fc9f2731c1b6936ea906e6410077c95871fba8b4c302f375cc8b28afffa37ccb59097a88470e266c4f26e6c51
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
grumlin (0.
|
4
|
+
grumlin (0.21.0)
|
5
5
|
async-pool (~> 0.3)
|
6
6
|
async-websocket (~> 0.19)
|
7
7
|
oj (~> 3.13)
|
@@ -72,7 +72,7 @@ GEM
|
|
72
72
|
racc (~> 1.4)
|
73
73
|
nokogiri (1.13.6-x86_64-linux)
|
74
74
|
racc (~> 1.4)
|
75
|
-
oj (3.13.
|
75
|
+
oj (3.13.18)
|
76
76
|
overcommit (0.59.1)
|
77
77
|
childprocess (>= 0.6.3, < 5)
|
78
78
|
iniparse (~> 1.4)
|
data/README.md
CHANGED
@@ -80,8 +80,7 @@ sequences of standard gremlin steps, other shortcuts and even add new initially
|
|
80
80
|
Remember ActiveRecord scopes? Shortcuts are very similar.
|
81
81
|
|
82
82
|
**Important**: if a shortcut's name matches a name of a method defined on the wrapped object, this shortcut will be
|
83
|
-
be ignored because methods have higher priority.
|
84
|
-
`Grumlin::Shortcuts.shortcut` will raise an `ArgumentError`. Please carefully choose names for your shortcuts.
|
83
|
+
be ignored because methods have higher priority.
|
85
84
|
|
86
85
|
Shortcuts are designed to be used with `Grumlin::Repository` but still can be used separately, with `Grumlin::Sugar`
|
87
86
|
for example.
|
@@ -143,7 +142,7 @@ class MyRepository
|
|
143
142
|
end
|
144
143
|
```
|
145
144
|
|
146
|
-
##### Overriding standard steps
|
145
|
+
##### Overriding standard steps and shortcuts
|
147
146
|
|
148
147
|
Sometimes it may be useful to override standard steps. Grumlin does not allow it by default, but one
|
149
148
|
is still able to override standard steps if they know what they are doing:
|
@@ -157,6 +156,8 @@ end
|
|
157
156
|
This will create a new shortcut that overrides the standard step `addV` and adds default properties to all vertices
|
158
157
|
created by the repository that uses this shortcut.
|
159
158
|
|
159
|
+
Shortcuts also can be overridden, but super() is not available.
|
160
|
+
|
160
161
|
#### Grumlin::Repository
|
161
162
|
`Grumlin::Repository` combines functionality of `Grumlin::Sugar` and `Grumlin::Shortcuts` as well as adds a few useful
|
162
163
|
shortcuts to make gremlin code more rubyish. Can be used as a drop in replacement for `Grumlin::Sugar`. Remember that
|
@@ -230,6 +231,10 @@ All of them support 3 different modes for error handling: `:retry`, `:ignore` an
|
|
230
231
|
with [retryable](https://github.com/nfedyashev/retryable). **params will be merged to the default config for upserts
|
231
232
|
and passed to `Retryable.retryable`. In case if you want to modify retryable behaviour you are to do so.
|
232
233
|
|
234
|
+
If you don't want to define you own repository, simply use
|
235
|
+
|
236
|
+
`Grumlin::Repository.new` returns an instance of an anonymous class extending `Grumlin::Repository`.
|
237
|
+
|
233
238
|
**Usage**
|
234
239
|
|
235
240
|
To execute the query defined in a query block one simply needs to call a method with the same name:
|
data/gremlin_server/Dockerfile
CHANGED
data/grumlin.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.metadata["homepage_uri"] = spec.homepage
|
22
22
|
spec.metadata["source_code_uri"] = "https://github.com/zhulik/grumlin"
|
23
|
-
spec.metadata["changelog_uri"] = "https://github.com/
|
23
|
+
spec.metadata["changelog_uri"] = "https://github.com/babbel/grumlin/releases"
|
24
24
|
spec.metadata["rubygems_mfa_required"] = "true"
|
25
25
|
|
26
26
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
data/lib/definitions.yml
CHANGED
@@ -56,7 +56,7 @@ module Grumlin
|
|
56
56
|
with_upsert_error_handling(on_failure, params) do
|
57
57
|
create_properties, update_properties = cleanup_properties(create_properties, update_properties)
|
58
58
|
|
59
|
-
g.upsertV(label, id, create_properties, update_properties).next
|
59
|
+
g.upsertV(label, id, create_properties, update_properties).id.next
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -70,7 +70,7 @@ module Grumlin
|
|
70
70
|
create_properties, update_properties = cleanup_properties(create_properties, update_properties)
|
71
71
|
|
72
72
|
t.upsertV(label, id, create_properties, update_properties)
|
73
|
-
end.iterate
|
73
|
+
end.id.iterate
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
@@ -80,12 +80,12 @@ module Grumlin
|
|
80
80
|
def upsert_edge(label, from:, to:, create_properties: {}, update_properties: {}, on_failure: :retry, **params) # rubocop:disable Metrics/ParameterLists
|
81
81
|
with_upsert_error_handling(on_failure, params) do
|
82
82
|
create_properties, update_properties = cleanup_properties(create_properties, update_properties, T.label)
|
83
|
-
g.upsertE(label, from, to, create_properties, update_properties).next
|
83
|
+
g.upsertE(label, from, to, create_properties, update_properties).id.next
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
87
|
# edges:
|
88
|
-
# [["label", "
|
88
|
+
# [["label", "from", "to", {create: :properties}, {update: properties}]]
|
89
89
|
# params can override Retryable config from UPSERT_RETRY_PARAMS
|
90
90
|
def upsert_edges(edges, batch_size: 100, on_failure: :retry, **params)
|
91
91
|
edges.each_slice(batch_size) do |slice|
|
@@ -94,7 +94,7 @@ module Grumlin
|
|
94
94
|
create_properties, update_properties = cleanup_properties(create_properties, update_properties, T.label)
|
95
95
|
|
96
96
|
t.upsertE(label, from, to, create_properties, update_properties)
|
97
|
-
end.iterate
|
97
|
+
end.id.iterate
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
data/lib/grumlin/repository.rb
CHANGED
@@ -10,6 +10,7 @@ module Grumlin
|
|
10
10
|
}.freeze
|
11
11
|
|
12
12
|
def self.extended(base)
|
13
|
+
super
|
13
14
|
base.extend(Grumlin::Shortcuts)
|
14
15
|
base.include(Repository::InstanceMethods)
|
15
16
|
|
@@ -17,6 +18,12 @@ module Grumlin
|
|
17
18
|
base.shortcuts_from(Grumlin::Shortcuts::Upserts)
|
18
19
|
end
|
19
20
|
|
21
|
+
def self.new
|
22
|
+
@repository ||= Class.new do # rubocop:disable Naming/MemoizedInstanceVariableName
|
23
|
+
extend Grumlin::Repository
|
24
|
+
end.new
|
25
|
+
end
|
26
|
+
|
20
27
|
def query(name, return_mode: :list, postprocess_with: nil, &query_block) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
21
28
|
return_mode = validate_return_mode!(return_mode)
|
22
29
|
postprocess_with = validate_postprocess_with!(postprocess_with)
|
@@ -5,11 +5,12 @@ module Grumlin
|
|
5
5
|
module Properties
|
6
6
|
extend Grumlin::Shortcuts
|
7
7
|
|
8
|
-
shortcut :props do
|
9
|
-
props.reduce(self) do |tt, (prop, value)|
|
10
|
-
next tt
|
8
|
+
shortcut :props do |cardinality = nil, **props|
|
9
|
+
props.reduce(self) do |tt, (prop, value)|
|
10
|
+
next tt if value.nil? # nils are not supported
|
11
|
+
next tt.property(prop, value) if cardinality.nil?
|
11
12
|
|
12
|
-
tt
|
13
|
+
tt.property(cardinality, prop, value)
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
@@ -31,12 +31,6 @@ module Grumlin
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def add(name, shortcut)
|
34
|
-
# not lazy shortcuts are allowed to be overridden
|
35
|
-
if known?(name) && @storage[name] != shortcut && shortcut.lazy?
|
36
|
-
raise ArgumentError,
|
37
|
-
"shortcut '#{name}' already exists"
|
38
|
-
end
|
39
|
-
|
40
34
|
@storage[name] = shortcut
|
41
35
|
|
42
36
|
ac = action_class
|
@@ -10,8 +10,8 @@ module Grumlin
|
|
10
10
|
.fold
|
11
11
|
.coalesce(
|
12
12
|
__.unfold,
|
13
|
-
__.addV(label).props(**create_properties.merge(T.id => id))
|
14
|
-
).props(**update_properties)
|
13
|
+
__.addV(label).props(Cardinality.single, **create_properties.merge(T.id => id))
|
14
|
+
).props(Cardinality.single, **update_properties)
|
15
15
|
end
|
16
16
|
|
17
17
|
shortcut :upsertE do |label, from, to, create_properties = {}, update_properties = {}|
|
data/lib/grumlin/steppable.rb
CHANGED
@@ -13,8 +13,7 @@ module Grumlin
|
|
13
13
|
def initialize
|
14
14
|
return if respond_to?(:shortcuts)
|
15
15
|
|
16
|
-
raise
|
17
|
-
"steppable must not be initialized directly, use Grumlin::Shortcuts::Storage#g or #__ instead"
|
16
|
+
raise "steppable must not be initialized directly, use Grumlin::Shortcuts::Storage#g or #__ instead"
|
18
17
|
end
|
19
18
|
|
20
19
|
ALL_STEPS.each do |step|
|
data/lib/grumlin/version.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Grumlin
|
4
|
+
module WithExtension
|
5
|
+
def with(name, value)
|
6
|
+
prev = self
|
7
|
+
strategy = if is_a?(with_action_class)
|
8
|
+
prev = previous_step
|
9
|
+
TraversalStrategies::OptionsStrategy.new(args.first.value.merge(name => value))
|
10
|
+
else
|
11
|
+
TraversalStrategies::OptionsStrategy.new({ name => value })
|
12
|
+
end
|
13
|
+
with_action_class.new(:withStrategies, args: [strategy], previous_step: prev)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def with_action_class
|
19
|
+
@with_action_class ||= Class.new(shortcuts.action_class) do
|
20
|
+
include WithExtension
|
21
|
+
|
22
|
+
def with_action_class
|
23
|
+
self.class
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
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.21.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: 2022-07-
|
11
|
+
date: 2022-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-pool
|
@@ -96,7 +96,6 @@ files:
|
|
96
96
|
- ".rspec"
|
97
97
|
- ".rubocop.yml"
|
98
98
|
- ".tool-versions"
|
99
|
-
- CHANGELOG.md
|
100
99
|
- CODE_OF_CONDUCT.md
|
101
100
|
- Gemfile
|
102
101
|
- Gemfile.lock
|
@@ -154,11 +153,13 @@ files:
|
|
154
153
|
- lib/grumlin/test/rspec/gremlin_context.rb
|
155
154
|
- lib/grumlin/transport.rb
|
156
155
|
- lib/grumlin/traversal_start.rb
|
156
|
+
- lib/grumlin/traversal_strategies/options_strategy.rb
|
157
157
|
- lib/grumlin/traverser.rb
|
158
158
|
- lib/grumlin/typed_value.rb
|
159
159
|
- lib/grumlin/typing.rb
|
160
160
|
- lib/grumlin/version.rb
|
161
161
|
- lib/grumlin/vertex.rb
|
162
|
+
- lib/grumlin/with_extension.rb
|
162
163
|
- lib/tasks/benchmark.rake
|
163
164
|
homepage: https://github.com/zhulik/grumlin
|
164
165
|
licenses:
|
@@ -166,7 +167,7 @@ licenses:
|
|
166
167
|
metadata:
|
167
168
|
homepage_uri: https://github.com/zhulik/grumlin
|
168
169
|
source_code_uri: https://github.com/zhulik/grumlin
|
169
|
-
changelog_uri: https://github.com/
|
170
|
+
changelog_uri: https://github.com/babbel/grumlin/releases
|
170
171
|
rubygems_mfa_required: 'true'
|
171
172
|
post_install_message:
|
172
173
|
rdoc_options: []
|
data/CHANGELOG.md
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
## [0.16.0] - 2022-03-11
|
2
|
-
|
3
|
-
- Query building is rewritten from scratch. No public APIs were changed. [Details](https://github.com/babbel/grumlin/pull/64)
|
4
|
-
- Add support for [TextP](https://tinkerpop.apache.org/javadocs/current/core/org/apache/tinkerpop/gremlin/process/traversal/TextP.html)
|
5
|
-
|
6
|
-
## [0.15.4] - 2022-01-20
|
7
|
-
|
8
|
-
- Move step and expression definitions to a yaml file for better diffs
|
9
|
-
- Add `definitions:format` rake task
|
10
|
-
|
11
|
-
## [0.15.3] - 2022-01-18
|
12
|
-
|
13
|
-
- Fix passing nils as step arguments. Even if they are not supported by the server, they should not be omitted.
|
14
|
-
|
15
|
-
## [0.15.2] - 2022-01-17
|
16
|
-
|
17
|
-
- New steps: `map` and `identity`
|
18
|
-
|
19
|
-
## [0.15.1] - 2022-01-17
|
20
|
-
|
21
|
-
- Fix passing arrays as step arguments
|
22
|
-
|
23
|
-
## [0.15.0] - 2022-01-11
|
24
|
-
|
25
|
-
- Add `properties` step
|
26
|
-
- Add proper support for bulked results
|
27
|
-
- Add support for `Property` objects
|
28
|
-
|
29
|
-
## [0.14.5] - 2021-12-27
|
30
|
-
|
31
|
-
- Fix params handling
|
32
|
-
- Add `aggregate` step
|
33
|
-
- Add `Order.shuffle`
|
34
|
-
|
35
|
-
## [0.14.4] - 2021-12-17
|
36
|
-
|
37
|
-
- `Grumlin::Repository.shorcuts_from` do not raise `ArgumentError` when importing an already existing shortcut
|
38
|
-
pointing to the same block. This fixes importing shortcuts from another repository.
|
39
|
-
|
40
|
-
## [0.14.2] - 2021-12-13
|
41
|
-
|
42
|
-
- Fix `Module` bloating
|
43
|
-
- Add `Operator` expressions
|
44
|
-
- Add `__.coalesce` and `__.constant`
|
45
|
-
- Add steps: `sum`, `sack`
|
46
|
-
- Add configuration steps: `withSack`
|
47
|
-
- Rename `Grumlin::Expressions::Tool` to `Grumlin::Expressions::Expression`
|
48
|
-
|
49
|
-
|
50
|
-
## [0.14.2] - 2021-12-12
|
51
|
-
|
52
|
-
- Better exceptions
|
53
|
-
- Add `choose` step
|
54
|
-
- Add `__.hasNot`, `__.is`, `__.select`
|
55
|
-
|
56
|
-
## [0.14.0] - 2021-12-07
|
57
|
-
|
58
|
-
- Add initial support for [configuration steps](https://tinkerpop.apache.org/docs/current/reference/#configuration-steps)
|
59
|
-
- Add the `withSideEffect` configuration step
|
60
|
-
- Fix passing keyword arguments to regular steps
|
61
|
-
- *Drop support for ruby 2.6*
|
62
|
-
|
63
|
-
## [0.13.0] - 2021-12-03
|
64
|
-
|
65
|
-
- Add `Shortcuts` and `Repository`
|
66
|
-
- Allow executing any gremlin steps by name using `Grumlin::AnonymousStep#step`
|
67
|
-
- Rename `Grumlin::Tools` to `Grumlin::Expressions`
|
68
|
-
|
69
|
-
## [0.1.0] - 2021-05-25
|
70
|
-
|
71
|
-
- Initial release
|