radar-app 0.1.2 → 0.1.3

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
  SHA1:
3
- metadata.gz: 3fb6b20d6df8f4cc3b56d91408d22aae3e84128b
4
- data.tar.gz: 33a551fca948d6c5892308c9aa314a06baa632e2
3
+ metadata.gz: 87275c99ccf595f790ed41ea17368244a0ecf547
4
+ data.tar.gz: d8e60964e55ec23b1781890268d3c4144d793613
5
5
  SHA512:
6
- metadata.gz: f2845a1c8fb8eaf8741ecdcbff2c7e2dbc83f648697d4091f0940ec2acca0f3240698fe8490176b3061a8bba6bf591219166fc2cddab3239c257e11e48ba0f93
7
- data.tar.gz: f1313c072a94e6b88328503cfbd6729026801de924c0bced71e9f6015d09c195885b090e7f075266378dec9a9926621004a2de231c6e8e58bffbc282d9c1a660
6
+ metadata.gz: 4a966936887953e9172fb1de38a3d093060eebf0556846142287e23f73ee519898314b71606f26828f3f72c594e7bb708b868a9956dcfa711e61f18267363b17
7
+ data.tar.gz: 03f11106ab18446b278d671bfea31322cb0747094e9fdc3c30d50694c8263938fbf26ced0a5515671efcaad9ecce00b0fbaa67ffb40ea9bad30208f38a1dc60f
@@ -7,6 +7,7 @@ require 'radar/app/analyzer_controller'
7
7
  require 'radar/app/server'
8
8
  require 'radar/app/bootstrap'
9
9
  require 'radar/app/analyzer'
10
+ require 'radar/app/processor_factory'
10
11
 
11
12
  require 'radar-api'
12
13
  require 'connection_pool'
@@ -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
@@ -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}..." }
@@ -1,5 +1,5 @@
1
1
  module Radar
2
2
  module App
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
@@ -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.2
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.2.5
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