grumlin 0.14.3 → 0.15.1

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: f1574fb6f69111d6a738cdbb1e19fb085c234ade887483e1b2c45644104cc40b
4
- data.tar.gz: 2910b648435d662b8e1bebfb6646b838e71912807379aa04205efdcc0a8b8a05
3
+ metadata.gz: a8080c53730173eb1569dffffa521fddace42c531ae3487e86e19ee3f65e2950
4
+ data.tar.gz: 5307c15aadc7ee30306b8c5f38977aa7348ced9c9a28f2f44c0095348f0140d3
5
5
  SHA512:
6
- metadata.gz: 41cadcd8b01c0ef3af860942eb6d187e5acfafdfd5e7c7cd9a052bb5f261ecd9773912ebe8a6da039188b1a81519fc20a7c7c19706c915f7550787345b936ac8
7
- data.tar.gz: fcbc59501668d19e08305a08158ed63ac73a6a94d375d71af0975f8a4a556f900a2dadd611da66e5b306679580e586ee1a23bdfea1d058bf9c86e77a4f7ee2fa
6
+ metadata.gz: 81ea5b30d65205ae9b418c2caef9f4210a5850d3dd6c022e282d35e880916b35f4c916084c1af3ebb8842256647dbf44a099f61a37d4a21e2ac43ca3cc228c1f
7
+ data.tar.gz: e35049b5ac62ac624e46554a59f5350887e231ae18df29b0042ae56804939e3a9968a9bea8e597822826cf858cb0664e197a8b618be976151916e35ca633dbf6
@@ -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,24 @@
1
+ ## [0.15.1] - 2022-01-17
2
+
3
+ - Fix passing arrays as step arguments
4
+
5
+ ## [0.15.0] - 2022-01-11
6
+
7
+ - Add `properties` step
8
+ - Add proper support for bulked results
9
+ - Add support for `Property` objects
10
+
11
+ ## [0.14.5] - 2021-12-27
12
+
13
+ - Fix params handling
14
+ - Add `aggregate` step
15
+ - Add `Order.shuffle`
16
+
17
+ ## [0.14.4] - 2021-12-17
18
+
19
+ - `Grumlin::Repository.shorcuts_from` do not raise `ArgumentError` when importing an already existing shortcut
20
+ pointing to the same block. This fixes importing shortcuts from another repository.
21
+
1
22
  ## [0.14.2] - 2021-12-13
2
23
 
3
24
  - Fix `Module` bloating
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grumlin (0.14.3)
4
+ grumlin (0.15.1)
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
 
@@ -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 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
@@ -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
@@ -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
@@ -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.3"
4
+ VERSION = "0.15.1"
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.3
4
+ version: 0.15.1
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-13 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