grumlin 0.15.3 → 0.16.0

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +10 -0
  3. data/CHANGELOG.md +10 -0
  4. data/Gemfile.lock +2 -2
  5. data/README.md +4 -0
  6. data/Rakefile +21 -3
  7. data/lib/definitions.yml +114 -0
  8. data/lib/grumlin/action.rb +124 -0
  9. data/lib/grumlin/client.rb +2 -2
  10. data/lib/grumlin/expressions/operator.rb +1 -1
  11. data/lib/grumlin/expressions/order.rb +1 -1
  12. data/lib/grumlin/expressions/p.rb +12 -17
  13. data/lib/grumlin/expressions/pop.rb +1 -1
  14. data/lib/grumlin/expressions/scope.rb +1 -1
  15. data/lib/grumlin/expressions/t.rb +1 -1
  16. data/lib/grumlin/expressions/text_p.rb +15 -0
  17. data/lib/grumlin/expressions/with_options.rb +17 -14
  18. data/lib/grumlin/repository.rb +2 -2
  19. data/lib/grumlin/shortcut.rb +27 -0
  20. data/lib/grumlin/shortcuts/properties.rb +6 -2
  21. data/lib/grumlin/shortcuts.rb +15 -13
  22. data/lib/grumlin/shortcuts_applyer.rb +48 -0
  23. data/lib/grumlin/step_data.rb +18 -0
  24. data/lib/grumlin/steps.rb +77 -0
  25. data/lib/grumlin/steps_serializers/bytecode.rb +65 -0
  26. data/lib/grumlin/steps_serializers/human_readable_bytecode.rb +36 -0
  27. data/lib/grumlin/steps_serializers/serializer.rb +16 -0
  28. data/lib/grumlin/steps_serializers/string.rb +42 -0
  29. data/lib/grumlin/sugar.rb +4 -4
  30. data/lib/grumlin/traversal_start.rb +51 -0
  31. data/lib/grumlin/typed_value.rb +0 -15
  32. data/lib/grumlin/version.rb +1 -1
  33. data/lib/grumlin.rb +6 -4
  34. metadata +14 -8
  35. data/lib/grumlin/anonymous_step.rb +0 -49
  36. data/lib/grumlin/bytecode.rb +0 -70
  37. data/lib/grumlin/expressions/u.rb +0 -19
  38. data/lib/grumlin/shortcut_proxy.rb +0 -53
  39. data/lib/grumlin/step.rb +0 -43
  40. data/lib/grumlin/traversal.rb +0 -37
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Grumlin
4
- class ShortcutProxy
5
- extend Forwardable
6
-
7
- attr_reader :object, :shortcuts
8
-
9
- # shortcuts: {"name": ->(arg) {}}
10
- def initialize(object, shortcuts, parent: nil)
11
- @object = object
12
- @shortcuts = shortcuts
13
- @parent = parent
14
- end
15
-
16
- def method_missing(name, *args, **params)
17
- return @parent.public_send(name, *args, **params) if %i[__ g].include?(name) && !@parent.nil?
18
-
19
- return wrap_result(@object.public_send(name, *args, **params)) if @object.respond_to?(name)
20
-
21
- return wrap_result(instance_exec(*args, **params, &@shortcuts[name])) if @shortcuts.key?(name)
22
-
23
- super
24
- end
25
-
26
- # For some reason the interpreter thinks it's private
27
- public def respond_to_missing?(name, include_private = false) # rubocop:disable Style/AccessModifierDeclarations
28
- name = name.to_sym
29
-
30
- (%i[__ g].include?(name) &&
31
- @parent.respond_to?(name)) ||
32
- @object.respond_to?(name) ||
33
- @shortcuts.key?(name) ||
34
- super
35
- end
36
-
37
- def_delegator :@object, :to_s
38
-
39
- def inspect
40
- @object.inspect
41
- end
42
-
43
- private
44
-
45
- def wrap_result(result)
46
- if result.is_a?(AnonymousStep) || result.is_a?(Traversal)
47
- return self.class.new(result, @shortcuts, parent: @parent)
48
- end
49
-
50
- result
51
- end
52
- end
53
- end
data/lib/grumlin/step.rb DELETED
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Grumlin
4
- class Step < AnonymousStep
5
- attr_reader :client
6
-
7
- def initialize(pool, name, *args, configuration_steps: [], previous_step: nil, **params)
8
- super(name, *args, previous_step: previous_step, configuration_steps: configuration_steps, **params)
9
- @pool = pool
10
- end
11
-
12
- def next
13
- to_enum.next
14
- end
15
-
16
- def hasNext # rubocop:disable Naming/MethodName
17
- to_enum.peek
18
- true
19
- rescue StopIteration
20
- false
21
- end
22
-
23
- def to_enum
24
- @to_enum ||= toList.to_enum
25
- end
26
-
27
- def toList
28
- @pool.acquire do |client|
29
- client.write(bytecode)
30
- end
31
- end
32
-
33
- def iterate
34
- @pool.acquire do |client|
35
- client.write(bytecode(no_return: true))
36
- end
37
- end
38
-
39
- def step(step_name, *args, **params)
40
- self.class.new(@pool, step_name, *args, previous_step: self, configuration_steps: @configuration_steps, **params)
41
- end
42
- end
43
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Grumlin
4
- class Traversal
5
- # TODO: add other start steps
6
- SUPPORTED_STEPS = %i[E V addE addV].freeze
7
-
8
- CONFIGURATION_STEPS = %i[withSack withSideEffect].freeze
9
-
10
- attr_reader :configuration_steps
11
-
12
- def initialize(pool = Grumlin.default_pool, configuration_steps: [])
13
- @pool = pool
14
- @configuration_steps = configuration_steps
15
- end
16
-
17
- def inspect
18
- "#<#{self.class}>"
19
- end
20
-
21
- def to_s
22
- inspect
23
- end
24
-
25
- CONFIGURATION_STEPS.each do |step|
26
- define_method step do |*args, **params|
27
- self.class.new(@pool, configuration_steps: @configuration_steps + [AnonymousStep.new(step, *args, **params)])
28
- end
29
- end
30
-
31
- SUPPORTED_STEPS.each do |step|
32
- define_method step do |*args, **params|
33
- Step.new(@pool, step, *args, configuration_steps: @configuration_steps, **params)
34
- end
35
- end
36
- end
37
- end