grumlin 0.14.4 → 0.15.2

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: 02a213b95f80992accf37eecb32684369e2e8a1582d10be4014e5c59b8381ec3
4
- data.tar.gz: ddf854b45f388d9a1c6e4a557e715c9d4363f2ae1c44503969e7d4c819537c1e
3
+ metadata.gz: a7027bddd19689f2886286b1bcd099c7c8dbf764502f77b5469434cd243387e5
4
+ data.tar.gz: b5a3e1e1db75e2a7378f77246c9b3bbbc066d5b32c575d15c88d38917d4658be
5
5
  SHA512:
6
- metadata.gz: 812636c84d1cffaf7bfb5b9c549b3d5c2fca7999b98c395e3cc9fa95701fe73ad0d91e159ba70c672e9bc5671119efd2f6ba65313e6c1e3c8d98e96e64cedc41
7
- data.tar.gz: 1863a834265130e9f14cc48d720f638825d86f1a12c70f3d77da4dd18fe835bf7ab0eedcc374ab51bdc0ec007b4c1af8e2f0798b03bd6d2c1fde71d5d544f9bb
6
+ metadata.gz: b116b30db9eeaf3255793843caa191b6942de7c16a5765b00aa0b803c5e7ae7a1e35d4da4372fd9e2ebe485555f9b895b0fb527cbb37ff89636824197e3a9821
7
+ data.tar.gz: 11647d93fe2b33814a5356607bca81f2d30edf3992cbae4c52a2191cc34db8632e65bd672ac61030ed27a3c7a7387316d0522188b53e83cef63af2171d5a8494
@@ -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", "3.1"]
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,23 @@
1
+ ## [0.15.2] - 2022-01-17
2
+
3
+ - New steps: `map` and `identity`
4
+
5
+ ## [0.15.1] - 2022-01-17
6
+
7
+ - Fix passing arrays as step arguments
8
+
9
+ ## [0.15.0] - 2022-01-11
10
+
11
+ - Add `properties` step
12
+ - Add proper support for bulked results
13
+ - Add support for `Property` objects
14
+
15
+ ## [0.14.5] - 2021-12-27
16
+
17
+ - Fix params handling
18
+ - Add `aggregate` step
19
+ - Add `Order.shuffle`
20
+
1
21
  ## [0.14.4] - 2021-12-17
2
22
 
3
23
  - `Grumlin::Repository.shorcuts_from` do not raise `ArgumentError` when importing an already existing shortcut
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grumlin (0.14.4)
4
+ grumlin (0.15.2)
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
 
@@ -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 sack select sideEffect skip sum tail to unfold union until
11
- valueMap 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 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,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
@@ -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
@@ -3,7 +3,7 @@
3
3
  module Grumlin
4
4
  module Expressions
5
5
  module Order
6
- SUPPORTED_STEPS = %i[asc desc].freeze
6
+ SUPPORTED_STEPS = %i[asc desc shuffle].freeze
7
7
 
8
8
  class << self
9
9
  extend Expression
@@ -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,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.4"
4
+ VERSION = "0.15.2"
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.4
4
+ version: 0.15.2
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-17 00:00:00.000000000 Z
11
+ date: 2022-01-17 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