grumlin 0.4.0 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11e434ab0f5cd463d357e69dd3cbf5083f85a1bdd32e4d2c96023ce262704020
4
- data.tar.gz: f24dd70f8b0abe9b370f77587d590802b32aa3e7b8a20380b9518004868cc6c7
3
+ metadata.gz: ea9263ebc4f6303d3dc02ccd39c8dd04f2b46b434456edad4466a19ebe7dede2
4
+ data.tar.gz: 84205bc8a2568987933d6cce5c576cbbf298700659b31d7435ecac1fde030029
5
5
  SHA512:
6
- metadata.gz: 5bfbd0d4db9ef46d35839b8ca5654cdc1f5038ee2c4ca004b678471380095d1fb587fa89a8df0c5a4769e3943ceb4e0b88734b701593ccf1047a05ab85baaaf5
7
- data.tar.gz: a7d87e630e6b2076bedd079365e709018b3fc61f1577564c504593ffdeb4deab88f56d8785c30877489171b6c9d7fd245982475a75f4c639647c923e2ca296ef
6
+ metadata.gz: 1fc512adc3e110cc6a6ed2f348a24b888b5f5443d566eb1f57bb3b56dad60529390f1c4c52b1391296f75a1ea4cd79dc70eb427c3f57b4bf4f4c6417e54bbe95
7
+ data.tar.gz: 36029a741e2d89654cbb5a9ecd28213c7122e3ecc35cd030baa320af71bd238560d1e671a8b9d2aa1f4b40938d1787679b2166733b0ebc429d5a5a113142d3b2
@@ -1,6 +1,6 @@
1
1
  name: Ruby
2
2
 
3
- on: [push, pull_request]
3
+ on: [push]
4
4
 
5
5
  jobs:
6
6
  lint:
data/.rubocop.yml CHANGED
@@ -7,24 +7,44 @@ require:
7
7
  - rubocop-performance
8
8
  - rubocop-rspec
9
9
 
10
- Style/StringLiterals:
11
- Enabled: true
12
- EnforcedStyle: double_quotes
13
-
14
- Style/StringLiteralsInInterpolation:
15
- Enabled: true
16
- EnforcedStyle: double_quotes
17
-
18
- Style/Documentation:
19
- Enabled: false
20
-
21
10
  Layout/LineLength:
22
11
  Max: 120
12
+ Exclude:
13
+ - spec/**/*_spec.rb
23
14
 
24
15
  Metrics/BlockLength:
25
16
  Exclude:
26
17
  - spec/**/*_spec.rb
27
18
 
19
+ Metrics/MethodLength:
20
+ Max: 20
21
+
22
+ Metrics/ParameterLists:
23
+ Max: 6
24
+
25
+ Naming/MethodName:
26
+ IgnoredPatterns:
27
+ - toList
28
+ - inVLabel
29
+ - outVLabel
30
+ - inV
31
+ - outV
32
+
33
+ Naming/VariableName:
34
+ AllowedIdentifiers:
35
+ - inV
36
+ - outV
37
+ - inVLabel
38
+ - outVLabel
39
+
40
+ Naming/MethodParameterName:
41
+ AllowedNames:
42
+ - id
43
+ - inV
44
+ - outV
45
+ - inVLabel
46
+ - outVLabel
47
+
28
48
  RSpec/NamedSubject:
29
49
  Enabled: false
30
50
 
@@ -34,5 +54,26 @@ RSpec/NestedGroups:
34
54
  RSpec/ExampleLength:
35
55
  Enabled: false
36
56
 
57
+ RSpec/MultipleExpectations:
58
+ Enabled: false
59
+
60
+ RSpec/DescribeClass:
61
+ Enabled: false
62
+
63
+ Style/WordArray:
64
+ Exclude:
65
+ - spec/**/*_spec.rb
66
+
67
+ Style/StringLiterals:
68
+ Enabled: true
69
+ EnforcedStyle: double_quotes
70
+
71
+ Style/StringLiteralsInInterpolation:
72
+ Enabled: true
73
+ EnforcedStyle: double_quotes
74
+
75
+ Style/Documentation:
76
+ Enabled: false
77
+
37
78
  Style/MultilineBlockChain:
38
- Enabled: false
79
+ Enabled: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grumlin (0.4.0)
4
+ grumlin (0.5.0)
5
5
  async-pool (~> 0.3)
6
6
  async-websocket (~> 0.19)
7
7
 
data/lib/async/channel.rb CHANGED
@@ -45,7 +45,7 @@ module Async
45
45
  end
46
46
  end
47
47
 
48
- def each # rubocop:disable Metrics/MethodLength
48
+ def each
49
49
  raise(ChannelClosedError, "Cannot receive from a closed channel") if closed?
50
50
 
51
51
  @queue.each do |type, payload|
@@ -60,7 +60,7 @@ module Grumlin
60
60
  end
61
61
 
62
62
  # TODO: support yielding
63
- def write(*args) # rubocop:disable Metrics/MethodLength
63
+ def write(*args)
64
64
  raise NotConnectedError unless connected?
65
65
 
66
66
  request_id = SecureRandom.uuid
data/lib/grumlin/edge.rb CHANGED
@@ -1,11 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # rubocop:disable Naming/VariableName,Naming/MethodParameterName,Naming/MethodName
4
3
  module Grumlin
5
4
  class Edge
6
5
  attr_reader :label, :id, :inVLabel, :outVLabel, :inV, :outV
7
6
 
8
- def initialize(label:, id:, inVLabel:, outVLabel:, inV:, outV:) # rubocop:disable Metrics/ParameterLists
7
+ def initialize(label:, id:, inVLabel:, outVLabel:, inV:, outV:)
9
8
  @label = label
10
9
  @id = Typing.cast(id)
11
10
  @inVLabel = inVLabel
@@ -24,4 +23,3 @@ module Grumlin
24
23
  alias to_s inspect
25
24
  end
26
25
  end
27
- # rubocop:enable Naming/MethodParameterName,Naming/VariableName,Naming/MethodName
data/lib/grumlin/order.rb CHANGED
@@ -2,12 +2,10 @@
2
2
 
3
3
  module Grumlin
4
4
  module Order
5
- module Order
5
+ class << self
6
6
  DESC = { "@type": "g:Order", "@value": "desc" }.freeze
7
7
  ASC = { "@type": "g:Order", "@value": "desc" }.freeze
8
8
 
9
- extend self # rubocop:disable Style/ModuleFunction
10
-
11
9
  def asc
12
10
  ASC
13
11
  end
@@ -16,7 +14,5 @@ module Grumlin
16
14
  DESC
17
15
  end
18
16
  end
19
-
20
- extend Order
21
17
  end
22
18
  end
data/lib/grumlin/pop.rb CHANGED
@@ -2,9 +2,7 @@
2
2
 
3
3
  module Grumlin
4
4
  module Pop
5
- module Pop
6
- extend self # rubocop:disable Style/ModuleFunction
7
-
5
+ class << self
8
6
  FIRST = { "@type": "g:Pop", "@value": "first" }.freeze
9
7
  LAST = { "@type": "g:Pop", "@value": "last" }.freeze
10
8
  ALL = { "@type": "g:Pop", "@value": "all" }.freeze
@@ -26,7 +24,5 @@ module Grumlin
26
24
  MIXED
27
25
  end
28
26
  end
29
-
30
- extend Pop
31
27
  end
32
28
  end
@@ -36,7 +36,7 @@ module Grumlin
36
36
 
37
37
  # builds a response object, when it's ready sends it to the client via a channel
38
38
  # TODO: sometimes response does not include requestID, no idea how to handle it so far.
39
- def add_response(response) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
39
+ def add_response(response) # rubocop:disable Metrics/AbcSize
40
40
  request_id = response[:requestId]
41
41
  raise "ERROR" unless ongoing_request?(request_id)
42
42
 
data/lib/grumlin/step.rb CHANGED
@@ -14,7 +14,7 @@ module Grumlin
14
14
  @enum.next
15
15
  end
16
16
 
17
- def toList # rubocop:disable Naming/MethodName
17
+ def toList
18
18
  @pool.acquire do |client|
19
19
  client.write(*steps)
20
20
  end
data/lib/grumlin/sugar.rb CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  module Grumlin
4
4
  module Sugar
5
- # TODO: how to use it in specs?
6
5
  HELPERS = [
7
6
  Grumlin::U,
8
7
  Grumlin::T,
@@ -12,25 +11,12 @@ module Grumlin
12
11
  ].freeze
13
12
 
14
13
  def self.included(base)
15
- base.extend ClassMethods
16
- end
17
-
18
- module ClassMethods
19
- def const_missing(name)
20
- helper = HELPERS.find { |h| h.const_defined?(name) }
21
- super if helper.nil?
22
-
23
- const_set(name, helper)
14
+ HELPERS.each do |helper|
15
+ name = helper.name.split("::").last
16
+ base.const_set(name, helper)
24
17
  end
25
18
  end
26
19
 
27
- def const_missing(name)
28
- helper = HELPERS.find { |h| h.const_defined?(name) }
29
- super if helper.nil?
30
-
31
- const_set(name, helper)
32
- end
33
-
34
20
  def __
35
21
  Grumlin::U
36
22
  end
data/lib/grumlin/t.rb CHANGED
@@ -2,12 +2,10 @@
2
2
 
3
3
  module Grumlin
4
4
  module T
5
- module T
5
+ class << self
6
6
  T_ID = { :@type => "g:T", :@value => "id" }.freeze # TODO: replace with a class?
7
7
  T_LABEL = { :@type => "g:T", :@value => "label" }.freeze # TODO: replace with a class?
8
8
 
9
- extend self # rubocop:disable Style/ModuleFunction
10
-
11
9
  def id
12
10
  T_ID
13
11
  end
@@ -16,7 +14,5 @@ module Grumlin
16
14
  T_LABEL
17
15
  end
18
16
  end
19
-
20
- extend T
21
17
  end
22
18
  end
@@ -8,8 +8,14 @@ module Grumlin
8
8
 
9
9
  ::RSpec.shared_context GremlinContext do
10
10
  include GremlinContext
11
+ include Grumlin::Sugar
11
12
 
12
- let(:g) { Grumlin::Traversal.new }
13
+ before do
14
+ Grumlin::Sugar::HELPERS.each do |helper|
15
+ name = helper.name.split("::").last
16
+ stub_const(name, helper)
17
+ end
18
+ end
13
19
 
14
20
  after do
15
21
  Grumlin.config.default_pool.close
@@ -20,7 +20,7 @@ module Grumlin
20
20
  @connected
21
21
  end
22
22
 
23
- def connect # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
23
+ def connect # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
24
24
  raise AlreadyConnectedError if connected?
25
25
 
26
26
  @connection = Async::WebSocket::Client.connect(Async::HTTP::Endpoint.parse(@url), **@client_options)
@@ -56,7 +56,7 @@ module Grumlin
56
56
  @request_channel << message
57
57
  end
58
58
 
59
- def close # rubocop:disable Metrics/MethodLength
59
+ def close
60
60
  return unless connected?
61
61
 
62
62
  @request_channel.close
data/lib/grumlin/u.rb CHANGED
@@ -2,17 +2,12 @@
2
2
 
3
3
  module Grumlin
4
4
  module U
5
- module U
6
- extend self # rubocop:disable Style/ModuleFunction
7
-
5
+ class << self
8
6
  %w[addV V has count out values unfold].each do |step|
9
7
  define_method step do |*args|
10
8
  AnonymousStep.new(step, *args)
11
9
  end
12
10
  end
13
11
  end
14
-
15
- # TODO: add alias __
16
- extend U
17
12
  end
18
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grumlin
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
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.4.0
4
+ version: 0.5.0
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-08-20 00:00:00.000000000 Z
11
+ date: 2021-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-pool