grumlin 0.15.3 → 0.15.4

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: b44c62fb657fac1ce08d4a4dcb05456a2750284dddcd5adbbd20f56bb2b9ef9c
4
- data.tar.gz: eccc2648799e68be2225ce606a06411b49953ce586e4b8249156dc680fc3522e
3
+ metadata.gz: e796fc1b5bff2cb474d068ad2a05a2b8a195df1981842745d5c90798ab5e02b7
4
+ data.tar.gz: 39cd9ac6bbedfb6a8707d306c6a6e0223856028162778bb665865e387dcf2bc3
5
5
  SHA512:
6
- metadata.gz: dfc9f36a53d49749425df0014005e18ddd47b91e5c35bdc4dd4c7dfc0ec3309ba15df4e8a3367a8dba4c92494a2f70cab9fe4a846ded833100dc09937bf4ff9b
7
- data.tar.gz: d315dfb2945c27091f76a21af2e30f77eb8753042519cf2bd7813ef544cb805f4970808158a550e5abdc1891c1526d4c3441bda46334bae67e2bf49a8ff9bd87
6
+ metadata.gz: 072df70e88f7192272cad5c6127740ef10d52b5057f42a557e9f4ea722e55f53d222025e7b4d7607666d4c5038d3e630abb55faec7f05c640efed53d442a2b57
7
+ data.tar.gz: 32ac57244365458e56c9b2c2705500c87254ba523454817b67f88637e07444d5e0b2abfa361540693f0dedf578b7e5f346c8a2515e536c69ad86e5ee09fa7bf3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
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
+
1
6
  ## [0.15.3] - 2022-01-18
2
7
 
3
8
  - Fix passing nils as step arguments. Even if they are not supported by the server, they should not be omitted.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grumlin (0.15.3)
4
+ grumlin (0.15.4)
5
5
  async-pool (~> 0.3)
6
6
  async-websocket (~> 0.19)
7
7
  oj (~> 3.12)
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 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
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
@@ -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 identity in inE inV is label
8
- out outE 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.3"
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.3
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-18 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