grumlin 0.12.3 → 0.12.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +46 -0
- data/bin/console +3 -6
- data/lib/grumlin/anonymous_step.rb +4 -4
- data/lib/grumlin/sugar.rb +1 -14
- data/lib/grumlin/test/rspec/gremlin_context.rb +2 -3
- data/lib/grumlin/tools/u.rb +2 -3
- data/lib/grumlin/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5ddac28eac1cb06e427f52d8639b8a75bdc9b4c867aa353199a05a51d847696
|
4
|
+
data.tar.gz: 3ac77adec54d09b74ab1b620de484205cfbee52249cfa6e4529a5b988b228537
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5ced6bb8aca8250daba19e059bcf36dc5fb3fe31ded7b552ca297f858edd82203b1b178196a1b448952819a112d44c40ab64e85aeb9f0f5469e44f728a5a539
|
7
|
+
data.tar.gz: 6258168a26d952f31bb2087fef044914efb6c51d81355611954c3999d65a7e62f38bae0654da7f4213a40513093240acf673156547033bbf83de37f17313552f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -73,6 +73,52 @@ class MyRepository
|
|
73
73
|
end
|
74
74
|
```
|
75
75
|
|
76
|
+
#### IRB
|
77
|
+
|
78
|
+
An example of how to start an IRB session with support for executing gremlin queries:
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
Async do
|
82
|
+
include Grumlin::Sugar
|
83
|
+
|
84
|
+
IRB.start
|
85
|
+
ensure
|
86
|
+
Grumlin.close
|
87
|
+
end
|
88
|
+
```
|
89
|
+
|
90
|
+
Please check out [bin/console](bin/console) for full source. A similar trick may be applied to PRY.
|
91
|
+
|
92
|
+
#### Rails console
|
93
|
+
|
94
|
+
In order to make it possible to execute gremlin queries from the rails console you need to define
|
95
|
+
a custom console class. It should look somehow like
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
class MyRailsConsole
|
99
|
+
def self.start
|
100
|
+
IRB::WorkSpace.prepend(Rails::Console::BacktraceCleaner)
|
101
|
+
IRB::ExtendCommandBundle.include(Rails::ConsoleMethods)
|
102
|
+
|
103
|
+
Async do
|
104
|
+
include Grumlin::Sugar
|
105
|
+
|
106
|
+
IRB.setup(binding.source_location[0], argv: [])
|
107
|
+
workspace = IRB::WorkSpace.new(binding)
|
108
|
+
|
109
|
+
IRB::Irb.new(workspace).run(IRB.conf)
|
110
|
+
ensure
|
111
|
+
Grumlin.close
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
```
|
116
|
+
|
117
|
+
Then you need to reference it in your application.rb:
|
118
|
+
```ruby
|
119
|
+
config.console = MyRailsConsole
|
120
|
+
```
|
121
|
+
|
76
122
|
#### Testing
|
77
123
|
|
78
124
|
Grumlin provides a couple of helpers to simplify testing code written with it.
|
data/bin/console
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
|
4
4
|
require "bundler/setup"
|
5
5
|
require "grumlin"
|
6
|
+
|
6
7
|
require "irb"
|
8
|
+
require "irb/completion"
|
7
9
|
|
8
10
|
Grumlin.configure do |config|
|
9
11
|
config.url = ENV["GREMLIN_URL"] || "ws://localhost:8182/gremlin"
|
@@ -12,12 +14,7 @@ end
|
|
12
14
|
Async do
|
13
15
|
include Grumlin::Sugar
|
14
16
|
|
15
|
-
IRB.
|
16
|
-
workspace = IRB::WorkSpace.new(binding)
|
17
|
-
irb = IRB::Irb.new(workspace)
|
18
|
-
irb.eval_input
|
19
|
-
rescue StandardError
|
20
|
-
raise
|
17
|
+
IRB.start
|
21
18
|
ensure
|
22
19
|
Grumlin.close
|
23
20
|
end
|
@@ -5,10 +5,10 @@ module Grumlin
|
|
5
5
|
attr_reader :name, :args, :previous_step
|
6
6
|
|
7
7
|
# TODO: add other steps
|
8
|
-
SUPPORTED_STEPS = %i[E V addE addV as both by coalesce count dedup drop elementMap emit fold from group
|
9
|
-
has hasId hasLabel hasNot id in inE inV label limit not order out outE path
|
10
|
-
range repeat select sideEffect skip tail to unfold union until valueMap
|
11
|
-
with].freeze
|
8
|
+
SUPPORTED_STEPS = %i[E V addE addV as both bothE by coalesce count dedup drop elementMap emit fold from group
|
9
|
+
groupCount has hasId hasLabel hasNot id in inE inV is label limit not order out outE path
|
10
|
+
project property range repeat select sideEffect skip tail to unfold union until valueMap
|
11
|
+
values where with].freeze
|
12
12
|
|
13
13
|
def initialize(name, *args, previous_step: nil)
|
14
14
|
@name = name
|
data/lib/grumlin/sugar.rb
CHANGED
@@ -2,21 +2,8 @@
|
|
2
2
|
|
3
3
|
module Grumlin
|
4
4
|
module Sugar
|
5
|
-
HELPERS = [
|
6
|
-
Grumlin::Tools::Order,
|
7
|
-
Grumlin::Tools::P,
|
8
|
-
Grumlin::Tools::Pop,
|
9
|
-
Grumlin::Tools::Scope,
|
10
|
-
Grumlin::Tools::T,
|
11
|
-
Grumlin::Tools::U,
|
12
|
-
Grumlin::Tools::WithOptions
|
13
|
-
].freeze
|
14
|
-
|
15
5
|
def self.included(base)
|
16
|
-
|
17
|
-
name = helper.name.split("::").last
|
18
|
-
base.const_set(name, helper)
|
19
|
-
end
|
6
|
+
base.include Grumlin::Tools
|
20
7
|
end
|
21
8
|
|
22
9
|
def __
|
@@ -11,9 +11,8 @@ module Grumlin
|
|
11
11
|
include Grumlin::Sugar
|
12
12
|
|
13
13
|
before do
|
14
|
-
Grumlin::
|
15
|
-
|
16
|
-
stub_const(name, helper)
|
14
|
+
Grumlin::Tools.constants.each do |tool|
|
15
|
+
stub_const(tool.to_s, Grumlin::Tools.const_get(tool))
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
data/lib/grumlin/tools/u.rb
CHANGED
@@ -4,9 +4,8 @@ module Grumlin
|
|
4
4
|
module Tools
|
5
5
|
module U
|
6
6
|
# TODO: add other start steps
|
7
|
-
SUPPORTED_STEPS = %i[V addV count drop fold has id inE inV label out outE outV project repeat timeLimit unfold
|
8
|
-
valueMap
|
9
|
-
values].freeze
|
7
|
+
SUPPORTED_STEPS = %i[V addV count drop fold has id in inE inV label out outE outV project repeat timeLimit unfold
|
8
|
+
valueMap values].freeze
|
10
9
|
|
11
10
|
class << self
|
12
11
|
SUPPORTED_STEPS.each do |step|
|
data/lib/grumlin/version.rb
CHANGED
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.12.
|
4
|
+
version: 0.12.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: 2021-10-
|
11
|
+
date: 2021-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-pool
|