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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00ef8073cd7041cc5387001f87b0df929061a08d04cd574557cdcad46e6691ea
4
- data.tar.gz: e9a4489348809e9d4c04732c5e0b25e0596c24d6bda0a47bb1d702c2aa91ba9d
3
+ metadata.gz: d5ddac28eac1cb06e427f52d8639b8a75bdc9b4c867aa353199a05a51d847696
4
+ data.tar.gz: 3ac77adec54d09b74ab1b620de484205cfbee52249cfa6e4529a5b988b228537
5
5
  SHA512:
6
- metadata.gz: 88f52ea660162bc3fde8694ab100da0f334272017199b16b5221bbe90a35901afec72e870338e7541e402f5af0f2b9a8db7c6e867aacd78fa6af9c57bdef04e2
7
- data.tar.gz: a72ffa18448d460e48ce320c7952f42a3c7f774dc17624650f8094b2107cba1bdb8b129f783f0de6c89ea02e17700796842f6fc3d0cb10db9c86c93161ccb387
6
+ metadata.gz: f5ced6bb8aca8250daba19e059bcf36dc5fb3fe31ded7b552ca297f858edd82203b1b178196a1b448952819a112d44c40ab64e85aeb9f0f5469e44f728a5a539
7
+ data.tar.gz: 6258168a26d952f31bb2087fef044914efb6c51d81355611954c3999d65a7e62f38bae0654da7f4213a40513093240acf673156547033bbf83de37f17313552f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grumlin (0.12.3)
4
+ grumlin (0.12.4)
5
5
  async-pool (~> 0.3)
6
6
  async-websocket (~> 0.19)
7
7
  oj (~> 3.12)
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,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 groupCount
9
- has hasId hasLabel hasNot id in inE inV label limit not order out outE path project property
10
- range repeat select sideEffect skip tail to unfold union until valueMap values where
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
- 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,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|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grumlin
4
- VERSION = "0.12.3"
4
+ VERSION = "0.12.4"
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.3
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-04 00:00:00.000000000 Z
11
+ date: 2021-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-pool