radar-app 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +1 -0
- data/bin/radar-app +2 -0
- data/lib/radar/app.rb +1 -0
- data/lib/radar/app/analyzer_controller.rb +8 -27
- data/lib/radar/app/controller.rb +38 -0
- data/lib/radar/app/server.rb +3 -2
- data/lib/radar/app/version.rb +1 -1
- data/radar-app.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfcce7a0a67d8975a90faf73b59dc307000b0e55
|
4
|
+
data.tar.gz: 01328620e14ea086a6bab6d3d13b62de656abefe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb6d33d4d82a1ca525e3b1e49c6a2e6212e5fbebb0dc3e1f6605967a268ba1adef437bfa61dac3e8d0a7debdf2f7b49ae56562aba540a470fd372b11107adb07
|
7
|
+
data.tar.gz: 3c0557d4fe258a9ad20c3aeece9ce8fef7468fd35ffcb13c0b0bc82379ea3470400e19e7a6e5ca823b4eb50578b4f5aeade1c1e3c81503ae14bb8f4999743ce1
|
data/Guardfile
CHANGED
data/bin/radar-app
CHANGED
@@ -42,6 +42,8 @@ class RadarApp < Thor
|
|
42
42
|
desc 'server', 'Starts the app server'
|
43
43
|
method_option :aliases => 's'
|
44
44
|
def server
|
45
|
+
require 'active_support/dependencies'
|
46
|
+
ActiveSupport::Dependencies.autoload_paths << './analyzers'
|
45
47
|
require './analyzers_registry'
|
46
48
|
Radar::App::Server.start
|
47
49
|
end
|
data/lib/radar/app.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
module Radar
|
2
2
|
module App
|
3
3
|
class AnalyzerController
|
4
|
+
include Radar::App::Controller
|
4
5
|
attr_reader :sessions
|
5
6
|
|
7
|
+
forward :on_each_month, :on_each_day, :on_finish, :on_cash_flow
|
8
|
+
|
6
9
|
def initialize
|
7
10
|
@sessions = {}
|
8
11
|
end
|
@@ -17,27 +20,9 @@ module Radar
|
|
17
20
|
(@@analyzers ||= {})[analyzer_id] = analyzer_class
|
18
21
|
end
|
19
22
|
|
20
|
-
def on_each_day(session_id, portfolio)
|
21
|
-
handle_error do
|
22
|
-
@sessions[session_id].on_each_day(portfolio)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def on_each_month(session_id, portfolio)
|
27
|
-
handle_error do
|
28
|
-
@sessions[session_id].on_each_month(portfolio)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def on_finish(session_id, portfolio)
|
33
|
-
handle_error do
|
34
|
-
@sessions[session_id].on_finish(portfolio)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
23
|
def create_session(session_id, analyzer_id)
|
39
24
|
handle_error do
|
40
|
-
analyzer = @@analyzers[analyzer_id].
|
25
|
+
analyzer = create_fresh_analyzer(@@analyzers[analyzer_id].name)
|
41
26
|
@sessions[session_id] = analyzer
|
42
27
|
analyzer.config
|
43
28
|
end
|
@@ -75,14 +60,10 @@ module Radar
|
|
75
60
|
|
76
61
|
protected
|
77
62
|
|
78
|
-
def
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
$stderr.puts "#{e.class}: #{e.message}"
|
83
|
-
$stderr.puts e.backtrace
|
84
|
-
$stderr.puts
|
85
|
-
end
|
63
|
+
def create_fresh_analyzer(class_name)
|
64
|
+
ActiveSupport::DescendantsTracker.clear
|
65
|
+
ActiveSupport::Dependencies.clear
|
66
|
+
Object.const_get(class_name).new
|
86
67
|
end
|
87
68
|
end
|
88
69
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module Radar
|
4
|
+
module App
|
5
|
+
module Controller
|
6
|
+
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def forward(*methods)
|
14
|
+
methods.each do |method|
|
15
|
+
define_method(method) do |session_id, *args|
|
16
|
+
handle_error do
|
17
|
+
@sessions[session_id].send(method, *args)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def handle_error
|
27
|
+
begin
|
28
|
+
yield
|
29
|
+
rescue => e
|
30
|
+
$stderr.puts "#{e.class}: #{e.message}"
|
31
|
+
$stderr.puts e.backtrace
|
32
|
+
$stderr.puts
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
data/lib/radar/app/server.rb
CHANGED
@@ -4,12 +4,13 @@ module Radar
|
|
4
4
|
module App
|
5
5
|
class Server
|
6
6
|
def self.start
|
7
|
+
port = ENV['PORT'] || 5000
|
7
8
|
handler = Radar::App::AnalyzerController.new
|
8
9
|
processor = Radar::API::AnalyzerController::Processor.new(handler)
|
9
|
-
transport = Thrift::ServerSocket.new(
|
10
|
+
transport = Thrift::ServerSocket.new(port)
|
10
11
|
transportFactory = Thrift::BufferedTransportFactory.new
|
11
12
|
server = Thrift::ThreadedServer.new(processor, transport)
|
12
|
-
$stderr.puts "Starting server..."
|
13
|
+
$stderr.puts "Starting server on port #{port}..."
|
13
14
|
server.serve()
|
14
15
|
end
|
15
16
|
end
|
data/lib/radar/app/version.rb
CHANGED
data/radar-app.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radar-app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonardo Mendonca
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '2.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: activesupport
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '4.1'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '4.1'
|
97
111
|
description: generates and run a radar-app.
|
98
112
|
email:
|
99
113
|
- leonardo.mendonca@investtools.com.br
|
@@ -112,6 +126,7 @@ files:
|
|
112
126
|
- lib/radar-app.rb
|
113
127
|
- lib/radar/app.rb
|
114
128
|
- lib/radar/app/analyzer_controller.rb
|
129
|
+
- lib/radar/app/controller.rb
|
115
130
|
- lib/radar/app/core_ext.rb
|
116
131
|
- lib/radar/app/core_ext/date.rb
|
117
132
|
- lib/radar/app/server.rb
|