grumlin 0.14.5 → 0.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f286174f46acd657ca106d29b2b5aa981c7b8b6f78d5e5e0ccffc8c844991510
4
- data.tar.gz: f810075cd2f7ac036dd292f03b626b8033ff79070299a6c9356ac72a15604292
3
+ metadata.gz: b44c62fb657fac1ce08d4a4dcb05456a2750284dddcd5adbbd20f56bb2b9ef9c
4
+ data.tar.gz: eccc2648799e68be2225ce606a06411b49953ce586e4b8249156dc680fc3522e
5
5
  SHA512:
6
- metadata.gz: 80fdbe5667fe93115a8d5dc817bf6d3f4bf6869c5f739a0d2ea36d53c06cf10fcff74c6384a4b796272b265e3fa392000b41954ab89c5400c017d5f40aabff81
7
- data.tar.gz: 2b4d6f0b34194c91d8bef2a64f7dd9f98d458a3156a4edeaf2e4e9a5044133af45ed2e946584c2fe8d433ed24c13d2e3619fefdfca926682a39619a30656f17e
6
+ metadata.gz: dfc9f36a53d49749425df0014005e18ddd47b91e5c35bdc4dd4c7dfc0ec3309ba15df4e8a3367a8dba4c92494a2f70cab9fe4a846ded833100dc09937bf4ff9b
7
+ data.tar.gz: d315dfb2945c27091f76a21af2e30f77eb8753042519cf2bd7813ef544cb805f4970808158a550e5abdc1891c1526d4c3441bda46334bae67e2bf49a8ff9bd87
@@ -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", "3.1"]
26
26
  steps:
27
27
  - uses: actions/checkout@v2
28
28
 
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## [0.15.3] - 2022-01-18
2
+
3
+ - Fix passing nils as step arguments. Even if they are not supported by the server, they should not be omitted.
4
+
5
+ ## [0.15.2] - 2022-01-17
6
+
7
+ - New steps: `map` and `identity`
8
+
9
+ ## [0.15.1] - 2022-01-17
10
+
11
+ - Fix passing arrays as step arguments
12
+
13
+ ## [0.15.0] - 2022-01-11
14
+
15
+ - Add `properties` step
16
+ - Add proper support for bulked results
17
+ - Add support for `Property` objects
18
+
1
19
  ## [0.14.5] - 2021-12-27
2
20
 
3
21
  - Fix params handling
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grumlin (0.14.5)
4
+ grumlin (0.15.3)
5
5
  async-pool (~> 0.3)
6
6
  async-websocket (~> 0.19)
7
7
  oj (~> 3.12)
@@ -60,15 +60,15 @@ GEM
60
60
  rexml
61
61
  kramdown-parser-gfm (1.1.0)
62
62
  kramdown (~> 2.0)
63
- mini_portile2 (2.5.3)
63
+ mini_portile2 (2.7.1)
64
64
  minitest (5.14.4)
65
65
  nio4r (2.5.8)
66
- nokogiri (1.11.7)
67
- mini_portile2 (~> 2.5.0)
66
+ nokogiri (1.13.1)
67
+ mini_portile2 (~> 2.7.0)
68
68
  racc (~> 1.4)
69
- nokogiri (1.11.7-x86_64-linux)
69
+ nokogiri (1.13.1-x86_64-linux)
70
70
  racc (~> 1.4)
71
- oj (3.13.10)
71
+ oj (3.13.11)
72
72
  overcommit (0.57.0)
73
73
  childprocess (>= 0.6.3, < 5)
74
74
  iniparse (~> 1.4)
@@ -85,7 +85,7 @@ GEM
85
85
  protocol-websocket (0.7.5)
86
86
  protocol-http (~> 0.2)
87
87
  protocol-http1 (~> 0.2)
88
- racc (1.5.2)
88
+ racc (1.6.0)
89
89
  rainbow (3.0.0)
90
90
  rake (13.0.3)
91
91
  regexp_parser (2.2.0)
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
 
@@ -6,9 +6,9 @@ module Grumlin
6
6
 
7
7
  # TODO: add other steps
8
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 property range repeat sack select sideEffect skip sum tail to unfold
11
- union until valueMap values where with].freeze
9
+ fold from group groupCount has hasId hasLabel hasNot id identity in inE inV is label limit
10
+ map not or order out outE path project properties property range repeat sack select sideEffect
11
+ skip sum tail to 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,9 @@ module Grumlin
41
41
  end
42
42
 
43
43
  def args
44
- [*@args, @params.any? ? @params : nil].compact
44
+ [*@args].tap do |args|
45
+ args << @params if @params.any?
46
+ end
45
47
  end
46
48
  end
47
49
  end
@@ -14,7 +14,6 @@ module Grumlin
14
14
 
15
15
  def initialize(step, no_return: false)
16
16
  super(type: "Bytecode")
17
-
18
17
  @step = step
19
18
  @no_return = no_return
20
19
  end
@@ -49,7 +48,7 @@ module Grumlin
49
48
  return arg.public_send(serialization_method) if arg.respond_to?(serialization_method)
50
49
  return arg unless arg.is_a?(AnonymousStep)
51
50
 
52
- arg.args.flatten.each.with_object([arg.name.to_s]) do |a, res|
51
+ arg.args.each.with_object([arg.name.to_s]) do |a, res|
53
52
  res << if a.respond_to?(:bytecode)
54
53
  a.bytecode.public_send(serialization_method)
55
54
  else
@@ -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 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
7
+ SUPPORTED_STEPS = %i[V addV coalesce constant count drop fold has hasLabel hasNot id identity in inE inV is label
8
+ out outE 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
@@ -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,16 +3,17 @@
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 },
17
18
  # "g:VertexProperty"=> ->(value) { value }, # TODO: implement me
18
19
  "g:T" => ->(value) { value.to_sym }
@@ -73,6 +74,15 @@ module Grumlin
73
74
  rescue ArgumentError
74
75
  raise TypeError, "#{value} cannot be casted to Hash"
75
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
76
86
  end
77
87
  end
78
88
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grumlin
4
- VERSION = "0.14.5"
4
+ VERSION = "0.15.3"
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.5
4
+ version: 0.15.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-27 00:00:00.000000000 Z
11
+ date: 2022-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-pool
@@ -111,6 +111,7 @@ files:
111
111
  - lib/grumlin/expressions/u.rb
112
112
  - lib/grumlin/expressions/with_options.rb
113
113
  - lib/grumlin/path.rb
114
+ - lib/grumlin/property.rb
114
115
  - lib/grumlin/repository.rb
115
116
  - lib/grumlin/request_dispatcher.rb
116
117
  - lib/grumlin/shortcut_proxy.rb
@@ -123,6 +124,7 @@ files:
123
124
  - lib/grumlin/test/rspec/gremlin_context.rb
124
125
  - lib/grumlin/transport.rb
125
126
  - lib/grumlin/traversal.rb
127
+ - lib/grumlin/traverser.rb
126
128
  - lib/grumlin/typed_value.rb
127
129
  - lib/grumlin/typing.rb
128
130
  - lib/grumlin/version.rb