grumlin 0.15.0 → 0.15.4

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: e6bc5993ec07bf70b93c7f7b73e2e3716c14b3457ddedbbda0e6f38d5f2c19ff
4
- data.tar.gz: b23c85808cacf2585fbc7c47f60d093049c1976ca13acd0317d0c71bf9871a5d
3
+ metadata.gz: e796fc1b5bff2cb474d068ad2a05a2b8a195df1981842745d5c90798ab5e02b7
4
+ data.tar.gz: 39cd9ac6bbedfb6a8707d306c6a6e0223856028162778bb665865e387dcf2bc3
5
5
  SHA512:
6
- metadata.gz: b752f3c20878758524da9d31de2114bca8d6585c9a9038989acef2ec21a888bbd667fe9ece033f257c67751eb87c33025c2876f80f80e3a983f25fb09c1e4b37
7
- data.tar.gz: 9ac44ccf984d626cbb8254185534c75061d139934a613fae13c45cfd0cdbdf1d4d35ca088e0ff2a1073196294d8b38a5c4eff8a5b2a8a3258327537ad66daab6
6
+ metadata.gz: 072df70e88f7192272cad5c6127740ef10d52b5057f42a557e9f4ea722e55f53d222025e7b4d7607666d4c5038d3e630abb55faec7f05c640efed53d442a2b57
7
+ data.tar.gz: 32ac57244365458e56c9b2c2705500c87254ba523454817b67f88637e07444d5e0b2abfa361540693f0dedf578b7e5f346c8a2515e536c69ad86e5ee09fa7bf3
@@ -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,20 @@
1
+ ## [0.15.4] - 2022-01-20
2
+
3
+ - Move step and expression definitions to a yaml file for better diffs
4
+ - Add `definitions:format` rake task
5
+
6
+ ## [0.15.3] - 2022-01-18
7
+
8
+ - Fix passing nils as step arguments. Even if they are not supported by the server, they should not be omitted.
9
+
10
+ ## [0.15.2] - 2022-01-17
11
+
12
+ - New steps: `map` and `identity`
13
+
14
+ ## [0.15.1] - 2022-01-17
15
+
16
+ - Fix passing arrays as step arguments
17
+
1
18
  ## [0.15.0] - 2022-01-11
2
19
 
3
20
  - Add `properties` step
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grumlin (0.15.0)
4
+ grumlin (0.15.4)
5
5
  async-pool (~> 0.3)
6
6
  async-websocket (~> 0.19)
7
7
  oj (~> 3.12)
@@ -60,13 +60,13 @@ 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
71
  oj (3.13.11)
72
72
  overcommit (0.57.0)
@@ -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
@@ -258,6 +258,10 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
258
258
  the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
259
259
  push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
260
260
 
261
+ ### Adding new steps and expressions
262
+ To add a new step or an expression simple put it to the corresponding list in [definitions.yml](lib/definitions.yml)
263
+ and run `rake definitions:format`. You don't need to properly sort the lists manually, the rake task will do it for you.
264
+
261
265
  ## Contributing
262
266
 
263
267
  Bug reports and pull requests are welcome on GitHub at https://github.com/zhulik/grumlin. This project is intended to
data/Rakefile CHANGED
@@ -1,12 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "yaml"
4
+
3
5
  require "bundler/gem_tasks"
4
6
  require "rspec/core/rake_task"
7
+ require "rubocop/rake_task"
5
8
 
6
9
  RSpec::Core::RakeTask.new(:spec)
10
+ RuboCop::RakeTask.new
7
11
 
8
- require "rubocop/rake_task"
12
+ task default: %i[rubocop spec]
9
13
 
10
- RuboCop::RakeTask.new
14
+ namespace :definitions do
15
+ desc "Format definitions.yml"
16
+ task :format do
17
+ path = File.join(__dir__, "lib", "definitions.yml")
18
+ definitions = YAML.safe_load(File.read(path))
19
+
20
+ definitions.each_value do |kind|
21
+ kind.each do |name, list|
22
+ next if name == "with_options"
23
+
24
+ list.sort!
25
+ end
26
+ end
11
27
 
12
- task default: %i[spec rubocop]
28
+ File.write(path, YAML.dump(definitions))
29
+ end
30
+ end
@@ -0,0 +1,110 @@
1
+ ---
2
+ steps:
3
+ regular:
4
+ - E
5
+ - V
6
+ - addE
7
+ - addV
8
+ - aggregate
9
+ - and
10
+ - as
11
+ - both
12
+ - bothE
13
+ - by
14
+ - choose
15
+ - coalesce
16
+ - constant
17
+ - count
18
+ - dedup
19
+ - drop
20
+ - elementMap
21
+ - emit
22
+ - fold
23
+ - from
24
+ - group
25
+ - groupCount
26
+ - has
27
+ - hasId
28
+ - hasLabel
29
+ - hasNot
30
+ - id
31
+ - identity
32
+ - in
33
+ - inE
34
+ - inV
35
+ - is
36
+ - label
37
+ - limit
38
+ - map
39
+ - not
40
+ - or
41
+ - order
42
+ - out
43
+ - outE
44
+ - outV
45
+ - path
46
+ - project
47
+ - properties
48
+ - property
49
+ - range
50
+ - repeat
51
+ - sack
52
+ - select
53
+ - sideEffect
54
+ - skip
55
+ - sum
56
+ - tail
57
+ - timeLimit
58
+ - to
59
+ - unfold
60
+ - union
61
+ - until
62
+ - valueMap
63
+ - values
64
+ - where
65
+ - with
66
+ start:
67
+ - E
68
+ - V
69
+ - addE
70
+ - addV
71
+ configuration:
72
+ - withSack
73
+ - withSideEffect
74
+ expressions:
75
+ operator:
76
+ - addAll
77
+ - and
78
+ - assign
79
+ - div
80
+ - max
81
+ - min
82
+ - minus
83
+ - mult
84
+ - or
85
+ - sum
86
+ order:
87
+ - asc
88
+ - desc
89
+ - shuffle
90
+ pop:
91
+ - all
92
+ - first
93
+ - last
94
+ - mixed
95
+ scope:
96
+ - local
97
+ t:
98
+ - id
99
+ - label
100
+ with_options:
101
+ tokens: "~tinkerpop.valueMap.tokens"
102
+ none: 0
103
+ ids: 1
104
+ labels: 2
105
+ keys: 4
106
+ values: 8
107
+ all: 15
108
+ indexer: "~tinkerpop.index.indexer"
109
+ list: 0
110
+ map: 1
@@ -4,11 +4,7 @@ module Grumlin
4
4
  class AnonymousStep
5
5
  attr_reader :name, :previous_step, :configuration_steps
6
6
 
7
- # TODO: add other steps
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
7
+ SUPPORTED_STEPS = Grumlin.definitions.dig(:steps, :regular).map(&:to_sym).freeze
12
8
 
13
9
  def initialize(name, *args, configuration_steps: [], previous_step: nil, **params)
14
10
  @name = name
@@ -41,7 +37,9 @@ module Grumlin
41
37
  end
42
38
 
43
39
  def args
44
- [*@args, @params.any? ? @params : nil].compact
40
+ [*@args].tap do |args|
41
+ args << @params if @params.any?
42
+ end
45
43
  end
46
44
  end
47
45
  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 Operator
6
- SUPPORTED_STEPS = %i[addAll and assign div max min minus mult or sum].freeze
6
+ SUPPORTED_STEPS = Grumlin.definitions.dig(:expressions, :operator).map(&:to_sym).freeze
7
7
 
8
8
  class << self
9
9
  extend Expression
@@ -3,7 +3,7 @@
3
3
  module Grumlin
4
4
  module Expressions
5
5
  module Order
6
- SUPPORTED_STEPS = %i[asc desc shuffle].freeze
6
+ SUPPORTED_STEPS = Grumlin.definitions.dig(:expressions, :order).map(&:to_sym).freeze
7
7
 
8
8
  class << self
9
9
  extend Expression
@@ -3,7 +3,7 @@
3
3
  module Grumlin
4
4
  module Expressions
5
5
  module Pop
6
- SUPPORTED_STEPS = %i[all first last mixed].freeze
6
+ SUPPORTED_STEPS = Grumlin.definitions.dig(:expressions, :pop).map(&:to_sym).freeze
7
7
 
8
8
  class << self
9
9
  extend Expression
@@ -3,7 +3,7 @@
3
3
  module Grumlin
4
4
  module Expressions
5
5
  module Scope
6
- SUPPORTED_STEPS = %i[local].freeze
6
+ SUPPORTED_STEPS = Grumlin.definitions.dig(:expressions, :scope).map(&:to_sym).freeze
7
7
 
8
8
  class << self
9
9
  extend Expression
@@ -3,7 +3,7 @@
3
3
  module Grumlin
4
4
  module Expressions
5
5
  module T
6
- SUPPORTED_STEPS = %i[id label].freeze
6
+ SUPPORTED_STEPS = Grumlin.definitions.dig(:expressions, :t).map(&:to_sym).freeze
7
7
 
8
8
  class << self
9
9
  extend Expression
@@ -2,13 +2,10 @@
2
2
 
3
3
  module Grumlin
4
4
  module Expressions
5
+ # The module is called U because Underscore and implements __
5
6
  module U
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
9
-
10
7
  class << self
11
- SUPPORTED_STEPS.each do |step|
8
+ Grumlin::AnonymousStep::SUPPORTED_STEPS.each do |step|
12
9
  define_method step do |*args, **params|
13
10
  AnonymousStep.new(step, *args, **params)
14
11
  end
@@ -3,18 +3,7 @@
3
3
  module Grumlin
4
4
  module Expressions
5
5
  module WithOptions
6
- WITH_OPTIONS = {
7
- tokens: "~tinkerpop.valueMap.tokens",
8
- none: 0,
9
- ids: 1,
10
- labels: 2,
11
- keys: 4,
12
- values: 8,
13
- all: 15,
14
- indexer: "~tinkerpop.index.indexer",
15
- list: 0,
16
- map: 1
17
- }.freeze
6
+ WITH_OPTIONS = Grumlin.definitions.dig(:expressions, :with_options).freeze
18
7
 
19
8
  class << self
20
9
  WITH_OPTIONS.each do |k, v|
@@ -21,7 +21,10 @@ module Grumlin
21
21
  def shortcut(name, &block)
22
22
  name = name.to_sym
23
23
  # TODO: blocklist of names to avoid conflicts with standard methods?
24
- raise ArgumentError, "cannot use names of standard gremlin steps" if Grumlin.supported_steps.include?(name)
24
+ if Grumlin::AnonymousStep::SUPPORTED_STEPS.include?(name)
25
+ raise ArgumentError,
26
+ "cannot use names of standard gremlin steps"
27
+ end
25
28
 
26
29
  raise ArgumentError, "shortcut '#{name}' already exists" if shortcuts.key?(name) && shortcuts[name] != block
27
30
 
@@ -2,10 +2,9 @@
2
2
 
3
3
  module Grumlin
4
4
  class Traversal
5
- # TODO: add other start steps
6
- SUPPORTED_STEPS = %i[E V addE addV].freeze
5
+ SUPPORTED_STEPS = Grumlin.definitions.dig(:steps, :start).map(&:to_sym).freeze
7
6
 
8
- CONFIGURATION_STEPS = %i[withSack withSideEffect].freeze
7
+ CONFIGURATION_STEPS = Grumlin.definitions.dig(:steps, :configuration).map(&:to_sym).freeze
9
8
 
10
9
  attr_reader :configuration_steps
11
10
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grumlin
4
- VERSION = "0.15.0"
4
+ VERSION = "0.15.4"
5
5
  end
data/lib/grumlin.rb CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  require "securerandom"
4
4
  require "oj"
5
+ require "yaml"
5
6
 
7
+ # TODO: use Oj directly
6
8
  Oj.mimic_JSON
7
9
  Oj.add_to_json
8
10
 
@@ -108,10 +110,6 @@ module Grumlin
108
110
  end
109
111
  end
110
112
 
111
- def self.supported_steps
112
- @supported_steps ||= (Grumlin::AnonymousStep::SUPPORTED_STEPS + Grumlin::Expressions::U::SUPPORTED_STEPS).sort.uniq
113
- end
114
-
115
113
  @pool_mutex = Mutex.new
116
114
 
117
115
  class << self
@@ -145,6 +143,10 @@ module Grumlin
145
143
  Thread.current.thread_variable_set(:grumlin_default_pool, nil)
146
144
  end
147
145
  end
146
+
147
+ def definitions
148
+ @definitions ||= YAML.safe_load(File.read(File.join(__dir__, "definitions.yml")), symbolize_names: true)
149
+ end
148
150
  end
149
151
  end
150
152
 
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.15.0
4
+ version: 0.15.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Sinyavskiy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-12 00:00:00.000000000 Z
11
+ date: 2022-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-pool
@@ -96,6 +96,7 @@ files:
96
96
  - gremlin_server/tinkergraph-empty.properties
97
97
  - grumlin.gemspec
98
98
  - lib/async/channel.rb
99
+ - lib/definitions.yml
99
100
  - lib/grumlin.rb
100
101
  - lib/grumlin/anonymous_step.rb
101
102
  - lib/grumlin/bytecode.rb