grumlin 0.14.2 → 0.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d54992de5df5f10f004557bc7a7d86ec5558c104663bf36904838e843d38b4d
4
- data.tar.gz: e2e5cca5ad4cc034b991760db13c9a41d780609895ea38e236ef384bfa9df8f4
3
+ metadata.gz: e6bc5993ec07bf70b93c7f7b73e2e3716c14b3457ddedbbda0e6f38d5f2c19ff
4
+ data.tar.gz: b23c85808cacf2585fbc7c47f60d093049c1976ca13acd0317d0c71bf9871a5d
5
5
  SHA512:
6
- metadata.gz: 9a1f23141609f072193fa4a624ae63263200daebb72b4f2c0759e738325409546365f962117d36dbb8baf1c6df5ebd9a60f5c53453f7827cfd8cc90d450afa0e
7
- data.tar.gz: c6bd3b5f1f0b02173931f8189c0dca7fdcb5c11bfc6c4f8fdb34065a8d90a55ecb4118cf50f080c3c490ed1e2afda9035716fafc4679c6f606ad74ccc955d5f3
6
+ metadata.gz: b752f3c20878758524da9d31de2114bca8d6585c9a9038989acef2ec21a888bbd667fe9ece033f257c67751eb87c33025c2876f80f80e3a983f25fb09c1e4b37
7
+ data.tar.gz: 9ac44ccf984d626cbb8254185534c75061d139934a613fae13c45cfd0cdbdf1d4d35ca088e0ff2a1073196294d8b38a5c4eff8a5b2a8a3258327537ad66daab6
@@ -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.14.2)
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.9)
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
@@ -51,7 +51,7 @@ end
51
51
 
52
52
  ### Traversing graphs
53
53
 
54
- **Warning**: Not all steps and tools described in the standard are supported
54
+ **Warning**: Not all steps and expressions defined in the reference documentation are supported.
55
55
 
56
56
  #### Sugar
57
57
 
@@ -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 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 select sideEffect skip tail to unfold union until valueMap
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? ? arg.params : nil].compact
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 Tool
5
+ module Expression
6
6
  def define_steps(steps, tool_name)
7
7
  steps.each do |step|
8
- self.class.define_method step do
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
6
+ SUPPORTED_STEPS = %i[asc desc shuffle].freeze
7
7
 
8
- SUPPORTED_STEPS = %i[asc desc].freeze
8
+ class << self
9
+ extend Expression
9
10
 
10
- define_steps(SUPPORTED_STEPS, "Order")
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
- define_steps(SUPPORTED_STEPS, "Pop")
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
- define_steps(SUPPORTED_STEPS, "Scope")
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
- define_steps(SUPPORTED_STEPS, "T")
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 outV project
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
@@ -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
@@ -5,7 +5,7 @@ module Grumlin
5
5
  # TODO: add other start steps
6
6
  SUPPORTED_STEPS = %i[E V addE addV].freeze
7
7
 
8
- CONFIGURATION_STEPS = %i[withSideEffect].freeze
8
+ CONFIGURATION_STEPS = %i[withSack withSideEffect].freeze
9
9
 
10
10
  attr_reader :configuration_steps
11
11
 
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Grumlin
4
+ class Traverser
5
+ attr_reader :bulk, :value
6
+
7
+ def initialize(value)
8
+ @bulk = value.dig(:bulk, :@value) || 1
9
+ @value = Typing.cast(value[:value])
10
+ end
11
+ end
12
+ end
@@ -3,17 +3,19 @@
3
3
  module Grumlin
4
4
  module Typing
5
5
  TYPES = {
6
- "g:List" => ->(value) { value.map { |item| cast(item) } },
7
- "g:Set" => ->(value) { Set.new(value.map { |item| cast(item) }) },
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grumlin
4
- VERSION = "0.14.2"
4
+ VERSION = "0.15.0"
5
5
  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.14.2
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: 2021-12-11 00:00:00.000000000 Z
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