radar-app 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/radar/app.rb +1 -0
- data/lib/radar/app/processor_factory.rb +16 -0
- data/lib/radar/app/server.rb +1 -1
- data/lib/radar/app/version.rb +1 -1
- data/spec/lib/radar/app/processor_factory_spec.rb +51 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87275c99ccf595f790ed41ea17368244a0ecf547
|
4
|
+
data.tar.gz: d8e60964e55ec23b1781890268d3c4144d793613
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a966936887953e9172fb1de38a3d093060eebf0556846142287e23f73ee519898314b71606f26828f3f72c594e7bb708b868a9956dcfa711e61f18267363b17
|
7
|
+
data.tar.gz: 03f11106ab18446b278d671bfea31322cb0747094e9fdc3c30d50694c8263938fbf26ced0a5515671efcaad9ecce00b0fbaa67ffb40ea9bad30208f38a1dc60f
|
data/lib/radar/app.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'thrift/exceptions'
|
2
|
+
|
3
|
+
module Radar
|
4
|
+
module App
|
5
|
+
module ProcessorFactory
|
6
|
+
def self.create_processor(superclass)
|
7
|
+
Class.new(superclass) do
|
8
|
+
def write_error(err, oprot, name, seqid)
|
9
|
+
super
|
10
|
+
raise if err.type == Thrift::ApplicationException::INTERNAL_ERROR
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/radar/app/server.rb
CHANGED
@@ -8,7 +8,7 @@ module Radar
|
|
8
8
|
|
9
9
|
def start
|
10
10
|
handler = Radar::App::AnalyzerController.new
|
11
|
-
processor = Radar::API::AnalyzerController::Processor.new(handler)
|
11
|
+
processor = ProcessorFactory.create_processor(Radar::API::AnalyzerController::Processor.new(handler))
|
12
12
|
transport = Thrift::ServerSocket.new(port)
|
13
13
|
server = Thrift::NonblockingServer.new(processor, transport, Thrift::FramedTransportFactory.new)
|
14
14
|
logger.info { "Starting app on port #{port}..." }
|
data/lib/radar/app/version.rb
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'radar/app/processor_factory'
|
2
|
+
|
3
|
+
describe Radar::App::ProcessorFactory do
|
4
|
+
|
5
|
+
let(:parent_processor_class) do
|
6
|
+
Class.new do
|
7
|
+
attr_reader :write_error_called
|
8
|
+
|
9
|
+
def process_an_error
|
10
|
+
begin
|
11
|
+
raise 'an error'
|
12
|
+
rescue => e
|
13
|
+
x = Thrift::ApplicationException.new(Thrift::ApplicationException::INTERNAL_ERROR, 'Internal error')
|
14
|
+
write_error(x, nil, nil, nil)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def process_unknown_method
|
19
|
+
x = Thrift::ApplicationException.new(Thrift::ApplicationException::UNKNOWN_METHOD, 'Unknown function')
|
20
|
+
write_error(x, nil, nil, nil)
|
21
|
+
end
|
22
|
+
|
23
|
+
def write_error(err, oprot, name, seqid)
|
24
|
+
@write_error_called = true
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#create_processor' do
|
31
|
+
describe 'it creates a processor that' do
|
32
|
+
let(:processor) { Radar::App::ProcessorFactory.create_processor(parent_processor_class).new }
|
33
|
+
it 'raises the exception on error' do
|
34
|
+
expect { processor.process_an_error }.to raise_error 'an error'
|
35
|
+
end
|
36
|
+
it 'calls #write_error from super' do
|
37
|
+
begin
|
38
|
+
processor.process_an_error
|
39
|
+
rescue => e
|
40
|
+
# not testing exception
|
41
|
+
end
|
42
|
+
expect(processor.write_error_called).to eq true
|
43
|
+
end
|
44
|
+
context 'when err is not INTERNAL_ERROR' do
|
45
|
+
it 'does not raise any exception' do
|
46
|
+
expect { processor.process_unknown_method }.not_to raise_error
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radar-app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonardo Mendonca
|
@@ -176,6 +176,7 @@ files:
|
|
176
176
|
- lib/radar/app/core_ext.rb
|
177
177
|
- lib/radar/app/core_ext/date.rb
|
178
178
|
- lib/radar/app/logger.rb
|
179
|
+
- lib/radar/app/processor_factory.rb
|
179
180
|
- lib/radar/app/runner.rb
|
180
181
|
- lib/radar/app/server.rb
|
181
182
|
- lib/radar/app/session.rb
|
@@ -190,6 +191,7 @@ files:
|
|
190
191
|
- spec/gen-rb/example_constants.rb
|
191
192
|
- spec/gen-rb/example_types.rb
|
192
193
|
- spec/lib/radar/app/analyzer_spec.rb
|
194
|
+
- spec/lib/radar/app/processor_factory_spec.rb
|
193
195
|
- spec/lib/radar/app/tasks/generate_spec.rb
|
194
196
|
- spec/lib/thrift/builder_spec.rb
|
195
197
|
- templates/.webhook
|
@@ -218,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
218
220
|
version: '0'
|
219
221
|
requirements: []
|
220
222
|
rubyforge_project:
|
221
|
-
rubygems_version: 2.
|
223
|
+
rubygems_version: 2.5.1
|
222
224
|
signing_key:
|
223
225
|
specification_version: 4
|
224
226
|
summary: radar-app generator
|
@@ -227,5 +229,6 @@ test_files:
|
|
227
229
|
- spec/gen-rb/example_constants.rb
|
228
230
|
- spec/gen-rb/example_types.rb
|
229
231
|
- spec/lib/radar/app/analyzer_spec.rb
|
232
|
+
- spec/lib/radar/app/processor_factory_spec.rb
|
230
233
|
- spec/lib/radar/app/tasks/generate_spec.rb
|
231
234
|
- spec/lib/thrift/builder_spec.rb
|