grumlin 0.12.1 → 0.12.5

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: db469922637c573a4c3d4a63308cd8481ad7d7b9f552d28c3c84ebec939e7e89
4
- data.tar.gz: 0a01bea74acc5e30535c6b0e589c67ac770c97cfa5f0e22a3c4915455a5f49a3
3
+ metadata.gz: 3fa9540000384bf515945dcb4ca15731e8b71d0d0d162bdde304c9c653e36de1
4
+ data.tar.gz: 7078ea9b27f96f6384b9b9918a0b49fe325075790b98b4367b153312670bd7be
5
5
  SHA512:
6
- metadata.gz: 900ba073a02947c8a4477feee2eb8bab9d9cf8e307d0c717e26b41d18fa7ca2ef4364660679608d23a9c278ddcc54e43f973c20d041149c87d8f00c0929fec82
7
- data.tar.gz: ada4730b53e54e19b72e584a939cbb04bf6273856c2fbeba1209e9856dba3a24cba36c4b7a19d5c7d09fd3c2c929067303d40dff48134da017e5eb675a3b4d54
6
+ metadata.gz: b32ac2a9ac09843ec5aa0ac8da79e9712bb98002df20689ea53c19f23b9209a58bd2850c203c67b7ed40c8b18059fa589243d5330cd5052f9637428043d0949b
7
+ data.tar.gz: ffdda90d2a81d59f4c8baa8d9cc0413d5caa2dbc418bbce3c64958202a22089122889ab41e67962d6de6e1bc5afff7824361a3c6265cd79328e4912fcada92cc
@@ -48,7 +48,7 @@ jobs:
48
48
  needs:
49
49
  - lint
50
50
  - test
51
- # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
51
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
52
52
  steps:
53
53
  - uses: actions/checkout@v2
54
54
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grumlin (0.12.1)
4
+ grumlin (0.12.5)
5
5
  async-pool (~> 0.3)
6
6
  async-websocket (~> 0.19)
7
7
  oj (~> 3.12)
@@ -30,7 +30,7 @@ GEM
30
30
  protocol-http2 (~> 0.14.0)
31
31
  async-io (1.32.2)
32
32
  async
33
- async-pool (0.3.8)
33
+ async-pool (0.3.9)
34
34
  async (>= 1.25)
35
35
  async-rspec (1.16.0)
36
36
  rspec (~> 3.0)
@@ -44,7 +44,7 @@ GEM
44
44
  benchmark (0.1.1)
45
45
  childprocess (4.0.0)
46
46
  concurrent-ruby (1.1.8)
47
- console (1.13.1)
47
+ console (1.14.0)
48
48
  fiber-local
49
49
  diff-lcs (1.4.4)
50
50
  docile (1.4.0)
@@ -64,7 +64,7 @@ GEM
64
64
  nio4r (2.5.8)
65
65
  nokogiri (1.11.7-x86_64-linux)
66
66
  racc (~> 1.4)
67
- oj (3.13.7)
67
+ oj (3.13.9)
68
68
  overcommit (0.57.0)
69
69
  childprocess (>= 0.6.3, < 5)
70
70
  iniparse (~> 1.4)
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.setup(nil)
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,9 +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 groupCount
9
- has hasId hasLabel hasNot id in inE inV label limit not order out outE path project property
10
- range repeat select skip tail to unfold union until valueMap values where with].freeze
8
+ SUPPORTED_STEPS = %i[E V addE addV and 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 or order out outE path
10
+ project property range repeat select sideEffect skip tail to unfold union until valueMap
11
+ values where with].freeze
11
12
 
12
13
  def initialize(name, *args, previous_step: nil)
13
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
- HELPERS.each do |helper|
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::Sugar::HELPERS.each do |helper|
15
- name = helper.name.split("::").last
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
 
@@ -4,8 +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 fold has id inE inV label out outV project repeat timeLimit unfold valueMap
8
- values].freeze
7
+ SUPPORTED_STEPS = %i[V addV count drop fold has hasLabel id in inE inV label out outE outV project repeat
8
+ timeLimit unfold valueMap values].freeze
9
9
 
10
10
  class << self
11
11
  SUPPORTED_STEPS.each do |step|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grumlin
4
- VERSION = "0.12.1"
4
+ VERSION = "0.12.5"
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.12.1
4
+ version: 0.12.5
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-09-29 00:00:00.000000000 Z
11
+ date: 2021-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-pool