grumlin 0.14.5 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f286174f46acd657ca106d29b2b5aa981c7b8b6f78d5e5e0ccffc8c844991510
4
- data.tar.gz: f810075cd2f7ac036dd292f03b626b8033ff79070299a6c9356ac72a15604292
3
+ metadata.gz: e6bc5993ec07bf70b93c7f7b73e2e3716c14b3457ddedbbda0e6f38d5f2c19ff
4
+ data.tar.gz: b23c85808cacf2585fbc7c47f60d093049c1976ca13acd0317d0c71bf9871a5d
5
5
  SHA512:
6
- metadata.gz: 80fdbe5667fe93115a8d5dc817bf6d3f4bf6869c5f739a0d2ea36d53c06cf10fcff74c6384a4b796272b265e3fa392000b41954ab89c5400c017d5f40aabff81
7
- data.tar.gz: 2b4d6f0b34194c91d8bef2a64f7dd9f98d458a3156a4edeaf2e4e9a5044133af45ed2e946584c2fe8d433ed24c13d2e3619fefdfca926682a39619a30656f17e
6
+ metadata.gz: b752f3c20878758524da9d31de2114bca8d6585c9a9038989acef2ec21a888bbd667fe9ece033f257c67751eb87c33025c2876f80f80e3a983f25fb09c1e4b37
7
+ data.tar.gz: 9ac44ccf984d626cbb8254185534c75061d139934a613fae13c45cfd0cdbdf1d4d35ca088e0ff2a1073196294d8b38a5c4eff8a5b2a8a3258327537ad66daab6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
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
+
1
7
  ## [0.14.5] - 2021-12-27
2
8
 
3
9
  - 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.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.10)
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
 
@@ -7,8 +7,8 @@ module Grumlin
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
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
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
@@ -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.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.5
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-27 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
@@ -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