gauge-ruby 0.4.3 → 0.5.0

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
  SHA1:
3
- metadata.gz: 86bb6e44e272971e83b2bef3c38dd92106cae506
4
- data.tar.gz: cfdf3a81e93b61c3acc54da0a123630781043860
3
+ metadata.gz: 6ebee2ce6fc18711db236ce40d0d0020dfaad981
4
+ data.tar.gz: 84c36f79a8c0f8d34711e2838c4d1dcdfed1640b
5
5
  SHA512:
6
- metadata.gz: 36640d7d7936fc4600b7dc1040b922f893bd72ff4e1a514251fefba70a16459009c508031c57e328c59b87da07e4845622409f5da1c4539a66426fa074660042
7
- data.tar.gz: 220d4b472ee354d203bcbe35ab54f40f33be040d9eb8b664fc6e5001b0c5888f5000cd508fb4de196f6ed7a831641a2ee54f156247846a97af9846495016a341
6
+ metadata.gz: 81b059a9480123961f7deb12b3751a55c8be48441159dedd0b88e49fd7a8ebcf21d21b77f674bc8cbe208a4a2d92c5d8b3e74057dc6dea865163185d9576c95f
7
+ data.tar.gz: 4b5d87b25a69456bd2659cc0406afc58b12f2cdad7f89f699fee1c0b508ae1ac4c3420b3c20f8da5aadcb1fd5374b5e501d6a0d25ee123455a79c45b19a82593
@@ -0,0 +1,182 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: api.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'spec_pb'
7
+ Google::Protobuf::DescriptorPool.generated_pool.build do
8
+ add_message "gauge.messages.GetProjectRootRequest" do
9
+ end
10
+ add_message "gauge.messages.GetProjectRootResponse" do
11
+ optional :projectRoot, :string, 1
12
+ end
13
+ add_message "gauge.messages.GetInstallationRootRequest" do
14
+ end
15
+ add_message "gauge.messages.GetInstallationRootResponse" do
16
+ optional :installationRoot, :string, 1
17
+ end
18
+ add_message "gauge.messages.GetAllStepsRequest" do
19
+ end
20
+ add_message "gauge.messages.GetAllStepsResponse" do
21
+ repeated :allSteps, :message, 1, "gauge.messages.ProtoStepValue"
22
+ end
23
+ add_message "gauge.messages.SpecsRequest" do
24
+ repeated :specs, :string, 1
25
+ end
26
+ add_message "gauge.messages.SpecsResponse" do
27
+ repeated :details, :message, 1, "gauge.messages.SpecsResponse.SpecDetail"
28
+ end
29
+ add_message "gauge.messages.SpecsResponse.SpecDetail" do
30
+ optional :spec, :message, 1, "gauge.messages.ProtoSpec"
31
+ repeated :parseErrors, :message, 2, "gauge.messages.Error"
32
+ end
33
+ add_message "gauge.messages.GetAllConceptsRequest" do
34
+ end
35
+ add_message "gauge.messages.GetAllConceptsResponse" do
36
+ repeated :concepts, :message, 1, "gauge.messages.ConceptInfo"
37
+ end
38
+ add_message "gauge.messages.ConceptInfo" do
39
+ optional :stepValue, :message, 1, "gauge.messages.ProtoStepValue"
40
+ optional :filepath, :string, 2
41
+ optional :lineNumber, :int32, 3
42
+ end
43
+ add_message "gauge.messages.GetStepValueRequest" do
44
+ optional :stepText, :string, 1
45
+ optional :hasInlineTable, :bool, 2
46
+ end
47
+ add_message "gauge.messages.GetStepValueResponse" do
48
+ optional :stepValue, :message, 1, "gauge.messages.ProtoStepValue"
49
+ end
50
+ add_message "gauge.messages.GetLanguagePluginLibPathRequest" do
51
+ optional :language, :string, 1
52
+ end
53
+ add_message "gauge.messages.GetLanguagePluginLibPathResponse" do
54
+ optional :path, :string, 1
55
+ end
56
+ add_message "gauge.messages.ErrorResponse" do
57
+ optional :error, :string, 1
58
+ end
59
+ add_message "gauge.messages.PerformRefactoringRequest" do
60
+ optional :oldStep, :string, 1
61
+ optional :newStep, :string, 2
62
+ end
63
+ add_message "gauge.messages.PerformRefactoringResponse" do
64
+ optional :success, :bool, 1
65
+ repeated :errors, :string, 2
66
+ repeated :filesChanged, :string, 3
67
+ end
68
+ add_message "gauge.messages.ExtractConceptRequest" do
69
+ optional :conceptName, :message, 1, "gauge.messages.step"
70
+ repeated :steps, :message, 2, "gauge.messages.step"
71
+ optional :changeAcrossProject, :bool, 3
72
+ optional :conceptFileName, :string, 4
73
+ optional :selectedTextInfo, :message, 5, "gauge.messages.textInfo"
74
+ end
75
+ add_message "gauge.messages.textInfo" do
76
+ optional :fileName, :string, 1
77
+ optional :startingLineNo, :int32, 2
78
+ optional :endLineNo, :int32, 3
79
+ end
80
+ add_message "gauge.messages.step" do
81
+ optional :name, :string, 1
82
+ optional :table, :string, 2
83
+ optional :paramTableName, :string, 3
84
+ end
85
+ add_message "gauge.messages.ExtractConceptResponse" do
86
+ optional :isSuccess, :bool, 1
87
+ optional :error, :string, 2
88
+ repeated :filesChanged, :string, 3
89
+ end
90
+ add_message "gauge.messages.FormatSpecsRequest" do
91
+ repeated :specs, :string, 1
92
+ end
93
+ add_message "gauge.messages.FormatSpecsResponse" do
94
+ repeated :errors, :string, 1
95
+ repeated :warnings, :string, 2
96
+ end
97
+ add_message "gauge.messages.UnsupportedApiMessageResponse" do
98
+ end
99
+ add_message "gauge.messages.APIMessage" do
100
+ optional :messageType, :enum, 1, "gauge.messages.APIMessage.APIMessageType"
101
+ optional :messageId, :int64, 2
102
+ optional :projectRootRequest, :message, 3, "gauge.messages.GetProjectRootRequest"
103
+ optional :projectRootResponse, :message, 4, "gauge.messages.GetProjectRootResponse"
104
+ optional :installationRootRequest, :message, 5, "gauge.messages.GetInstallationRootRequest"
105
+ optional :installationRootResponse, :message, 6, "gauge.messages.GetInstallationRootResponse"
106
+ optional :allStepsRequest, :message, 7, "gauge.messages.GetAllStepsRequest"
107
+ optional :allStepsResponse, :message, 8, "gauge.messages.GetAllStepsResponse"
108
+ optional :specsRequest, :message, 9, "gauge.messages.SpecsRequest"
109
+ optional :specsResponse, :message, 10, "gauge.messages.SpecsResponse"
110
+ optional :stepValueRequest, :message, 11, "gauge.messages.GetStepValueRequest"
111
+ optional :stepValueResponse, :message, 12, "gauge.messages.GetStepValueResponse"
112
+ optional :libPathRequest, :message, 13, "gauge.messages.GetLanguagePluginLibPathRequest"
113
+ optional :libPathResponse, :message, 14, "gauge.messages.GetLanguagePluginLibPathResponse"
114
+ optional :error, :message, 15, "gauge.messages.ErrorResponse"
115
+ optional :allConceptsRequest, :message, 16, "gauge.messages.GetAllConceptsRequest"
116
+ optional :allConceptsResponse, :message, 17, "gauge.messages.GetAllConceptsResponse"
117
+ optional :performRefactoringRequest, :message, 18, "gauge.messages.PerformRefactoringRequest"
118
+ optional :performRefactoringResponse, :message, 19, "gauge.messages.PerformRefactoringResponse"
119
+ optional :extractConceptRequest, :message, 20, "gauge.messages.ExtractConceptRequest"
120
+ optional :extractConceptResponse, :message, 21, "gauge.messages.ExtractConceptResponse"
121
+ optional :formatSpecsRequest, :message, 22, "gauge.messages.FormatSpecsRequest"
122
+ optional :formatSpecsResponse, :message, 23, "gauge.messages.FormatSpecsResponse"
123
+ optional :unsupportedApiMessageResponse, :message, 24, "gauge.messages.UnsupportedApiMessageResponse"
124
+ end
125
+ add_enum "gauge.messages.APIMessage.APIMessageType" do
126
+ value :GetProjectRootRequest, 0
127
+ value :GetProjectRootResponse, 1
128
+ value :GetInstallationRootRequest, 2
129
+ value :GetInstallationRootResponse, 3
130
+ value :GetAllStepsRequest, 4
131
+ value :GetAllStepResponse, 5
132
+ value :SpecsRequest, 6
133
+ value :SpecsResponse, 7
134
+ value :GetStepValueRequest, 8
135
+ value :GetStepValueResponse, 9
136
+ value :GetLanguagePluginLibPathRequest, 10
137
+ value :GetLanguagePluginLibPathResponse, 11
138
+ value :ErrorResponse, 12
139
+ value :GetAllConceptsRequest, 13
140
+ value :GetAllConceptsResponse, 14
141
+ value :PerformRefactoringRequest, 15
142
+ value :PerformRefactoringResponse, 16
143
+ value :ExtractConceptRequest, 17
144
+ value :ExtractConceptResponse, 18
145
+ value :FormatSpecsRequest, 19
146
+ value :FormatSpecsResponse, 20
147
+ value :UnsupportedApiMessageResponse, 21
148
+ end
149
+ end
150
+
151
+ module Gauge
152
+ module Messages
153
+ GetProjectRootRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.GetProjectRootRequest").msgclass
154
+ GetProjectRootResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.GetProjectRootResponse").msgclass
155
+ GetInstallationRootRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.GetInstallationRootRequest").msgclass
156
+ GetInstallationRootResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.GetInstallationRootResponse").msgclass
157
+ GetAllStepsRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.GetAllStepsRequest").msgclass
158
+ GetAllStepsResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.GetAllStepsResponse").msgclass
159
+ SpecsRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.SpecsRequest").msgclass
160
+ SpecsResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.SpecsResponse").msgclass
161
+ SpecsResponse::SpecDetail = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.SpecsResponse.SpecDetail").msgclass
162
+ GetAllConceptsRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.GetAllConceptsRequest").msgclass
163
+ GetAllConceptsResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.GetAllConceptsResponse").msgclass
164
+ ConceptInfo = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.ConceptInfo").msgclass
165
+ GetStepValueRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.GetStepValueRequest").msgclass
166
+ GetStepValueResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.GetStepValueResponse").msgclass
167
+ GetLanguagePluginLibPathRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.GetLanguagePluginLibPathRequest").msgclass
168
+ GetLanguagePluginLibPathResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.GetLanguagePluginLibPathResponse").msgclass
169
+ ErrorResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.ErrorResponse").msgclass
170
+ PerformRefactoringRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.PerformRefactoringRequest").msgclass
171
+ PerformRefactoringResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.PerformRefactoringResponse").msgclass
172
+ ExtractConceptRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.ExtractConceptRequest").msgclass
173
+ TextInfo = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.textInfo").msgclass
174
+ Step = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.step").msgclass
175
+ ExtractConceptResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.ExtractConceptResponse").msgclass
176
+ FormatSpecsRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.FormatSpecsRequest").msgclass
177
+ FormatSpecsResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.FormatSpecsResponse").msgclass
178
+ UnsupportedApiMessageResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.UnsupportedApiMessageResponse").msgclass
179
+ APIMessage = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.APIMessage").msgclass
180
+ APIMessage::APIMessageType = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.APIMessage.APIMessageType").enummodule
181
+ end
182
+ end
@@ -16,13 +16,13 @@
16
16
  # along with Gauge-Ruby. If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
18
  require 'protocol_buffers'
19
- require_relative 'api.pb'
19
+ require_relative 'api_pb'
20
20
 
21
21
  module Gauge
22
22
  # @api private
23
23
  module Connector
24
24
  GAUGE_PORT_ENV = "GAUGE_INTERNAL_PORT"
25
- HOST_NAME = 'localhost'
25
+ HOST_NAME = '127.0.0.1'
26
26
  @@executionSocket = nil
27
27
 
28
28
 
@@ -17,7 +17,7 @@
17
17
  require 'ruby-debug-ide'
18
18
  require_relative 'gauge'
19
19
 
20
- ATTACH_DEBUGGER_EVENT = "Runner Ready for Debugging"
20
+ ATTACH_DEBUGGER_EVENT = 'Runner Ready for Debugging'
21
21
 
22
22
  module Gauge
23
23
  class DebugOptions
@@ -42,7 +42,7 @@ module Gauge
42
42
  if ENV['DEBUGGING']
43
43
  options = DebugOptions.new
44
44
  options.host = '127.0.0.1'
45
- options.port = ENV["DEBUG_PORT"].to_i
45
+ options.port = ENV['DEBUG_PORT'].to_i
46
46
  options.notify_dispatcher = false
47
47
  Gauge::Log.info ATTACH_DEBUGGER_EVENT
48
48
  Debugger.prepare_debugger(options)
@@ -59,22 +59,24 @@ module Gauge
59
59
  end
60
60
 
61
61
  def self.execute_hooks(hooks, currentExecutionInfo, should_filter)
62
- begin
63
- hooks.each do |hook|
64
- if !should_filter || hook[:options][:tags].length == 0
65
- next hook[:block].call(currentExecutionInfo)
66
- end
67
- tags = currentExecutionInfo.currentSpec.tags + currentExecutionInfo.currentScenario.tags
68
- intersection = (tags & hook[:options][:tags])
69
- if (hook[:options][:operator] == 'OR' && intersection.length > 0) ||
70
- (hook[:options][:operator] == 'AND' && intersection.length == hook[:options][:tags].length)
71
- hook[:block].call(currentExecutionInfo)
72
- end
62
+ hooks.each do |hook|
63
+ if !should_filter || hook[:options][:tags].empty?
64
+ next hook[:block].call(currentExecutionInfo)
65
+ end
66
+ tags = currentExecutionInfo.currentSpec.tags + get_scenario_tags(currentExecutionInfo)
67
+ intersection = (tags & hook[:options][:tags])
68
+ if (hook[:options][:operator] == 'OR' && !intersection.empty?) ||
69
+ (hook[:options][:operator] == 'AND' && intersection.length == hook[:options][:tags].length)
70
+ hook[:block].call(currentExecutionInfo)
73
71
  end
74
- return nil
75
- rescue Exception => e
76
- return e
77
72
  end
73
+ nil
74
+ rescue Exception => e
75
+ e
76
+ end
77
+
78
+ def self.get_scenario_tags(info)
79
+ !info.currentScenario.nil? ? info.currentScenario.tags : []
78
80
  end
79
81
  end
80
- end
82
+ end
@@ -17,15 +17,16 @@
17
17
 
18
18
  require 'socket'
19
19
  require 'protocol_buffers'
20
+ require 'grpc'
20
21
 
21
- require_relative 'messages.pb'
22
+ require_relative 'messages_pb'
22
23
  require_relative 'executor'
23
24
  require_relative 'static_loader'
24
25
  require_relative 'connector'
25
26
  require_relative 'message_processor'
26
27
  require_relative 'util'
27
28
  require_relative 'log'
28
-
29
+ require_relative 'lsp_server'
29
30
 
30
31
  module Gauge
31
32
  # @api private
@@ -33,24 +34,23 @@ module Gauge
33
34
  DEFAULT_IMPLEMENTATIONS_DIR_PATH = Util.get_step_implementation_dir
34
35
 
35
36
  def self.dispatch_messages(socket)
36
- while (!socket.eof?)
37
+ until socket.eof?
37
38
  len = Connector.message_length(socket)
38
39
  data = socket.read len
39
- message = Messages::Message.parse(data)
40
+ message = Messages::Message.decode(data)
40
41
  handle_message(socket, message)
41
- if message.messageType == Messages::Message::MessageType::KillProcessRequest || message.messageType == Messages::Message::MessageType::ExecutionEnding
42
+ if message.messageType == :KillProcessRequest || message.messageType == :ExecutionEnding
42
43
  socket.close
43
44
  return
44
45
  end
45
46
  end
46
47
  end
47
48
 
48
-
49
49
  def self.handle_message(socket, message)
50
50
  if !MessageProcessor.is_valid_message(message)
51
51
  Gauge::Log.error "Invalid message received : #{message}"
52
- execution_status_response = Messages::ExecutionStatusResponse.new(:executionResult => Messages::ProtoExecutionResult.new(:failed => true, :executionTime => 0))
53
- message = Messages::Message.new(:messageType => Messages::Message::MessageType::ExecutionStatusResponse, :messageId => message.messageId, :executionStatusResponse => execution_status_response)
52
+ execution_status_response = Messages::ExecutionStatusResponse.new(executionResult: Messages::ProtoExecutionResult.new(failed: true, executionTime: 0))
53
+ message = Messages::Message.new(messageType: :ExecutionStatusResponse, messageId: message.messageId, executionStatusResponse: execution_status_response)
54
54
  write_message(socket, message)
55
55
  else
56
56
  response = MessageProcessor.process_message message
@@ -59,7 +59,7 @@ module Gauge
59
59
  end
60
60
 
61
61
  def self.write_message(socket, message)
62
- serialized_message = message.to_s
62
+ serialized_message = Messages::Message.encode(message)
63
63
  size = serialized_message.bytesize
64
64
  ProtocolBuffers::Varint.encode(socket, size)
65
65
  socket.write serialized_message
@@ -67,17 +67,23 @@ module Gauge
67
67
 
68
68
  def self.port_from_env_variable(env_variable)
69
69
  port = ENV[env_variable]
70
- if port.nil?
71
- raise RuntimeError, "Could not find Env variable :#{env_variable}"
72
- end
73
- return port
70
+ raise "Could not find Env variable :#{env_variable}" if port.nil?
71
+ port
74
72
  end
75
73
 
76
74
  STDOUT.sync = true
77
75
  GaugeLog.init
78
- Connector.make_connection
79
76
  StaticLoader.load_files(DEFAULT_IMPLEMENTATIONS_DIR_PATH)
80
- dispatch_messages(Connector.execution_socket)
77
+ if ENV.key? 'GAUGE_LSP_GRPC'
78
+ server = GRPC::RpcServer.new
79
+ p = server.add_http2_port('127.0.0.1:0', :this_port_is_insecure)
80
+ server.handle(Gauge::LSPServer.new(server))
81
+ puts "Listening on port:#{p}"
82
+ server.run_till_terminated
83
+ else
84
+ Connector.make_connection
85
+ dispatch_messages(Connector.execution_socket)
86
+ end
81
87
  exit(0)
82
88
  end
83
89
  end
@@ -0,0 +1,16 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: lsp.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'messages_pb'
7
+ Google::Protobuf::DescriptorPool.generated_pool.build do
8
+ add_message "gauge.messages.Empty" do
9
+ end
10
+ end
11
+
12
+ module Gauge
13
+ module Messages
14
+ Empty = Google::Protobuf::DescriptorPool.generated_pool.lookup("gauge.messages.Empty").msgclass
15
+ end
16
+ end
@@ -0,0 +1,78 @@
1
+ # Copyright 2018 ThoughtWorks, Inc.
2
+
3
+ # This file is part of Gauge-Ruby.
4
+
5
+ # Gauge-Ruby is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+
10
+ # Gauge-Ruby is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with Gauge-Ruby. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require_relative 'lsp_services_pb'
19
+ require_relative 'processors/step_positions_request_processor'
20
+ require_relative 'processors/cache_file_processor'
21
+ require_relative 'processors/step_names_request_processor'
22
+ require_relative 'processors/stub_implementation_processor'
23
+ require_relative 'processors/implementation_file_list_processor'
24
+ require_relative 'processors/step_validation_request_processor'
25
+ require_relative 'processors/refactor_step_request_processor'
26
+ require_relative 'processors/step_name_request_processor'
27
+ require_relative 'processors/implementation_glob_pattern_processor'
28
+
29
+ module Gauge
30
+ class LSPServer < Gauge::Messages::LspService::Service
31
+ include Gauge::Processors
32
+
33
+ def initialize(server)
34
+ @server = server
35
+ end
36
+
37
+ def get_step_names(_request, _call)
38
+ step_names_response
39
+ end
40
+
41
+ def cache_file(request, _call)
42
+ cache_file_response(request)
43
+ end
44
+
45
+ def get_step_positions(request, _call)
46
+ step_positions(request)
47
+ end
48
+
49
+ def get_implementation_files(_request, _call)
50
+ implementation_files
51
+ end
52
+
53
+ def implement_stub(request, _call)
54
+ implement_stub_response(request)
55
+ end
56
+
57
+ def validate_step(request, _call)
58
+ step_validate_response(request)
59
+ end
60
+
61
+ def refactor(request, _call)
62
+ refactor_response(request)
63
+ end
64
+
65
+ def get_step_name(request, _call)
66
+ step_name_response(request)
67
+ end
68
+
69
+ def get_glob_patterns(_request, _call)
70
+ implementation_glob_pattern_response
71
+ end
72
+
73
+ def kill_process(_request, _call)
74
+ @server.stop
75
+ exit(0)
76
+ end
77
+ end
78
+ end