grumlin 0.14.2 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +3 -3
- data/CHANGELOG.md +27 -0
- data/Gemfile.lock +2 -2
- data/README.md +1 -1
- data/lib/grumlin/anonymous_step.rb +5 -5
- 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 +2 -2
- data/lib/grumlin/property.rb +24 -0
- data/lib/grumlin/shortcuts.rb +1 -1
- data/lib/grumlin/traversal.rb +1 -1
- data/lib/grumlin/traverser.rb +12 -0
- data/lib/grumlin/typing.rb +14 -3
- data/lib/grumlin/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6bc5993ec07bf70b93c7f7b73e2e3716c14b3457ddedbbda0e6f38d5f2c19ff
|
4
|
+
data.tar.gz: b23c85808cacf2585fbc7c47f60d093049c1976ca13acd0317d0c71bf9871a5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b752f3c20878758524da9d31de2114bca8d6585c9a9038989acef2ec21a888bbd667fe9ece033f257c67751eb87c33025c2876f80f80e3a983f25fb09c1e4b37
|
7
|
+
data.tar.gz: 9ac44ccf984d626cbb8254185534c75061d139934a613fae13c45cfd0cdbdf1d4d35ca088e0ff2a1073196294d8b38a5c4eff8a5b2a8a3258327537ad66daab6
|
data/.github/workflows/main.yml
CHANGED
@@ -10,7 +10,7 @@ jobs:
|
|
10
10
|
|
11
11
|
- uses: ruby/setup-ruby@v1
|
12
12
|
with:
|
13
|
-
ruby-version: 3.0
|
13
|
+
ruby-version: "3.0"
|
14
14
|
bundler-cache: true
|
15
15
|
|
16
16
|
- name: Run the default task
|
@@ -22,7 +22,7 @@ jobs:
|
|
22
22
|
runs-on: ubuntu-latest
|
23
23
|
strategy:
|
24
24
|
matrix:
|
25
|
-
ruby: [2.7, 3.0]
|
25
|
+
ruby: ["2.7", "3.0"]
|
26
26
|
steps:
|
27
27
|
- uses: actions/checkout@v2
|
28
28
|
|
@@ -54,7 +54,7 @@ jobs:
|
|
54
54
|
|
55
55
|
- uses: ruby/setup-ruby@v1
|
56
56
|
with:
|
57
|
-
ruby-version: 3.0
|
57
|
+
ruby-version: "3.0"
|
58
58
|
bundler-cache: true
|
59
59
|
|
60
60
|
- name: Build gem
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,30 @@
|
|
1
|
+
## [0.15.0] - 2022-01-11
|
2
|
+
|
3
|
+
- Add `properties` step
|
4
|
+
- Add proper support for bulked results
|
5
|
+
- Add support for `Property` objects
|
6
|
+
|
7
|
+
## [0.14.5] - 2021-12-27
|
8
|
+
|
9
|
+
- Fix params handling
|
10
|
+
- Add `aggregate` step
|
11
|
+
- Add `Order.shuffle`
|
12
|
+
|
13
|
+
## [0.14.4] - 2021-12-17
|
14
|
+
|
15
|
+
- `Grumlin::Repository.shorcuts_from` do not raise `ArgumentError` when importing an already existing shortcut
|
16
|
+
pointing to the same block. This fixes importing shortcuts from another repository.
|
17
|
+
|
18
|
+
## [0.14.2] - 2021-12-13
|
19
|
+
|
20
|
+
- Fix `Module` bloating
|
21
|
+
- Add `Operator` expressions
|
22
|
+
- Add `__.coalesce` and `__.constant`
|
23
|
+
- Add steps: `sum`, `sack`
|
24
|
+
- Add configuration steps: `withSack`
|
25
|
+
- Rename `Grumlin::Expressions::Tool` to `Grumlin::Expressions::Expression`
|
26
|
+
|
27
|
+
|
1
28
|
## [0.14.2] - 2021-12-12
|
2
29
|
|
3
30
|
- Better exceptions
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
grumlin (0.
|
4
|
+
grumlin (0.15.0)
|
5
5
|
async-pool (~> 0.3)
|
6
6
|
async-websocket (~> 0.19)
|
7
7
|
oj (~> 3.12)
|
@@ -68,7 +68,7 @@ GEM
|
|
68
68
|
racc (~> 1.4)
|
69
69
|
nokogiri (1.11.7-x86_64-linux)
|
70
70
|
racc (~> 1.4)
|
71
|
-
oj (3.13.
|
71
|
+
oj (3.13.11)
|
72
72
|
overcommit (0.57.0)
|
73
73
|
childprocess (>= 0.6.3, < 5)
|
74
74
|
iniparse (~> 1.4)
|
data/README.md
CHANGED
@@ -5,10 +5,10 @@ module Grumlin
|
|
5
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 choose coalesce count dedup drop elementMap emit
|
9
|
-
group groupCount has hasId hasLabel hasNot id in inE inV is label limit not or order
|
10
|
-
path project property range repeat select sideEffect skip tail to
|
11
|
-
values where with].freeze
|
8
|
+
SUPPORTED_STEPS = %i[E V addE addV aggregate and as both bothE by choose coalesce count dedup drop elementMap emit
|
9
|
+
fold from group groupCount has hasId hasLabel hasNot id in inE inV is label limit not or order
|
10
|
+
out outE path project properties property range repeat sack select sideEffect skip sum tail to
|
11
|
+
unfold union until valueMap values where with].freeze
|
12
12
|
|
13
13
|
def initialize(name, *args, configuration_steps: [], previous_step: nil, **params)
|
14
14
|
@name = name
|
@@ -41,7 +41,7 @@ module Grumlin
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def args
|
44
|
-
[*@args, @params.any? ?
|
44
|
+
[*@args, @params.any? ? @params : nil].compact
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -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
|
-
|
6
|
+
SUPPORTED_STEPS = %i[asc desc shuffle].freeze
|
7
7
|
|
8
|
-
|
8
|
+
class << self
|
9
|
+
extend Expression
|
9
10
|
|
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,8 +4,8 @@ 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 hasNot id in inE inV is label out outE
|
8
|
-
repeat select 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|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Grumlin
|
4
|
+
class Property
|
5
|
+
attr_reader :key, :value
|
6
|
+
|
7
|
+
def initialize(value)
|
8
|
+
@key = value[:key]
|
9
|
+
@value = Typing.cast(value[:value])
|
10
|
+
end
|
11
|
+
|
12
|
+
def inspect
|
13
|
+
"p[#{key}->#{value}]"
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_s
|
17
|
+
inspect
|
18
|
+
end
|
19
|
+
|
20
|
+
def ==(other)
|
21
|
+
self.class == other.class && @key == other.key && @value == other.value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/grumlin/shortcuts.rb
CHANGED
@@ -23,7 +23,7 @@ module Grumlin
|
|
23
23
|
# TODO: blocklist of names to avoid conflicts with standard methods?
|
24
24
|
raise ArgumentError, "cannot use names of standard gremlin steps" if Grumlin.supported_steps.include?(name)
|
25
25
|
|
26
|
-
raise ArgumentError, "shortcut '#{name}' already exists" if shortcuts.key?(name)
|
26
|
+
raise ArgumentError, "shortcut '#{name}' already exists" if shortcuts.key?(name) && shortcuts[name] != block
|
27
27
|
|
28
28
|
shortcuts[name] = block
|
29
29
|
end
|
data/lib/grumlin/traversal.rb
CHANGED
data/lib/grumlin/typing.rb
CHANGED
@@ -3,17 +3,19 @@
|
|
3
3
|
module Grumlin
|
4
4
|
module Typing
|
5
5
|
TYPES = {
|
6
|
-
"g:List" => ->(value) { value
|
7
|
-
"g:Set" => ->(value) {
|
6
|
+
"g:List" => ->(value) { cast_list(value) },
|
7
|
+
"g:Set" => ->(value) { cast_list(value).to_set },
|
8
8
|
"g:Map" => ->(value) { cast_map(value) },
|
9
9
|
"g:Vertex" => ->(value) { cast_entity(Grumlin::Vertex, value) },
|
10
10
|
"g:Edge" => ->(value) { cast_entity(Grumlin::Edge, value) },
|
11
11
|
"g:Path" => ->(value) { cast_entity(Grumlin::Path, value) },
|
12
|
+
"g:Traverser" => ->(value) { cast_entity(Traverser, value) },
|
13
|
+
"g:Property" => ->(value) { cast_entity(Property, value) },
|
12
14
|
"g:Int64" => ->(value) { cast_int(value) },
|
13
15
|
"g:Int32" => ->(value) { cast_int(value) },
|
14
16
|
"g:Double" => ->(value) { cast_double(value) },
|
15
|
-
"g:Traverser" => ->(value) { cast(value[:value]) }, # TODO: wtf is bulk?
|
16
17
|
"g:Direction" => ->(value) { value },
|
18
|
+
# "g:VertexProperty"=> ->(value) { value }, # TODO: implement me
|
17
19
|
"g:T" => ->(value) { value.to_sym }
|
18
20
|
}.freeze
|
19
21
|
|
@@ -72,6 +74,15 @@ module Grumlin
|
|
72
74
|
rescue ArgumentError
|
73
75
|
raise TypeError, "#{value} cannot be casted to Hash"
|
74
76
|
end
|
77
|
+
|
78
|
+
def cast_list(value)
|
79
|
+
value.each_with_object([]) do |item, result|
|
80
|
+
casted_value = cast(item)
|
81
|
+
next (result << casted_value) unless casted_value.instance_of?(Traverser)
|
82
|
+
|
83
|
+
casted_value.bulk.times { result << casted_value.value }
|
84
|
+
end
|
85
|
+
end
|
75
86
|
end
|
76
87
|
end
|
77
88
|
end
|
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.
|
4
|
+
version: 0.15.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:
|
11
|
+
date: 2022-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-pool
|
@@ -101,15 +101,17 @@ 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
|
114
|
+
- lib/grumlin/property.rb
|
113
115
|
- lib/grumlin/repository.rb
|
114
116
|
- lib/grumlin/request_dispatcher.rb
|
115
117
|
- lib/grumlin/shortcut_proxy.rb
|
@@ -122,6 +124,7 @@ files:
|
|
122
124
|
- lib/grumlin/test/rspec/gremlin_context.rb
|
123
125
|
- lib/grumlin/transport.rb
|
124
126
|
- lib/grumlin/traversal.rb
|
127
|
+
- lib/grumlin/traverser.rb
|
125
128
|
- lib/grumlin/typed_value.rb
|
126
129
|
- lib/grumlin/typing.rb
|
127
130
|
- lib/grumlin/version.rb
|