radar-app 0.2.0 → 0.4.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 +4 -4
- data/lib/radar-app.rb +0 -1
- data/lib/radar/app.rb +9 -0
- data/lib/radar/app/bootstrap.rb +6 -1
- data/lib/radar/app/runner.rb +2 -1
- data/lib/radar/app/server.rb +15 -3
- data/lib/radar/app/tasks.rb +1 -0
- data/lib/radar/app/tasks/console.rb +32 -0
- data/lib/radar/app/tasks/new.rb +1 -1
- data/lib/radar/app/tasks/server.rb +1 -1
- data/lib/radar/app/version.rb +1 -1
- data/templates/DOKKU_SCALE +1 -0
- data/templates/Procfile +1 -1
- metadata +4 -12
- data/lib/thrift/builder.rb +0 -36
- data/spec/example.thrift +0 -19
- data/spec/gen-rb/example_constants.rb +0 -9
- data/spec/gen-rb/example_types.rb +0 -66
- data/spec/lib/thrift/builder_spec.rb +0 -36
- data/templates/.webhook +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0aa7420cd66d5654f91c63d38055cd2d7391e2bb
|
4
|
+
data.tar.gz: bbc18a791718be0136d7714e123a28e382d347d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 943dde85e1c2a8e046ef48828ddcef5b81b5391936e44ae6c6337d5bcf6f03d7e9b006771599d71852574015abce6f9e93577f045cd55db44fa3b1bc26b80df3
|
7
|
+
data.tar.gz: 979d9ed0eb09e84822a3d97d4b02b79b6001543d8290b9735a4c9c2b14d7d560c28faf16250e3219c28ed2736d2e7368b8749206085d7a0828c9f88e31e27c55
|
data/lib/radar-app.rb
CHANGED
data/lib/radar/app.rb
CHANGED
@@ -17,6 +17,15 @@ require 'active_support/inflector'
|
|
17
17
|
|
18
18
|
module Radar
|
19
19
|
module App
|
20
|
+
|
21
|
+
def self.transaction_importer
|
22
|
+
@transaction_importer
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.transaction_importer=(ti)
|
26
|
+
@transaction_importer = ti
|
27
|
+
end
|
28
|
+
|
20
29
|
def self.env
|
21
30
|
@env ||= ActiveSupport::StringInquirer.new(ENV['RADAR_ENV'] || 'development')
|
22
31
|
end
|
data/lib/radar/app/bootstrap.rb
CHANGED
@@ -2,9 +2,10 @@ module Radar
|
|
2
2
|
module App
|
3
3
|
module Bootstrap
|
4
4
|
def self.startup
|
5
|
+
require 'radar-app'
|
5
6
|
load_env_config
|
6
7
|
load_app_config
|
7
|
-
|
8
|
+
load_initializers
|
8
9
|
end
|
9
10
|
|
10
11
|
protected
|
@@ -20,6 +21,10 @@ module Radar
|
|
20
21
|
def self.load_app_config
|
21
22
|
require './config/app.rb'
|
22
23
|
end
|
24
|
+
|
25
|
+
def self.load_initializers
|
26
|
+
Dir['./config/initializers/**/*.rb'].each { |f| require f }
|
27
|
+
end
|
23
28
|
end
|
24
29
|
end
|
25
30
|
end
|
data/lib/radar/app/runner.rb
CHANGED
@@ -6,8 +6,9 @@ module Radar
|
|
6
6
|
module App
|
7
7
|
class Runner < Thor
|
8
8
|
register(Radar::App::Tasks::New, :new, 'new APP', 'Create a new app')
|
9
|
-
register(Radar::App::Tasks::Generate, :generate, 'generate TYPE', 'Generate source files')
|
9
|
+
register(Radar::App::Tasks::Generate, :generate, 'generate TYPE NAME', 'Generate source files')
|
10
10
|
register(Radar::App::Tasks::Server, :server, 'server', 'Start the app server')
|
11
|
+
register(Radar::App::Tasks::Console, :console, 'console', 'Start the console for test')
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
data/lib/radar/app/server.rb
CHANGED
@@ -7,10 +7,22 @@ module Radar
|
|
7
7
|
include Radar::App::Logger
|
8
8
|
|
9
9
|
def start
|
10
|
-
|
11
|
-
|
10
|
+
multiplexer = Thrift::MultiplexedProcessor.new
|
11
|
+
analyzer_controller = Radar::App::AnalyzerController.new
|
12
|
+
multiplexer.register_processor(
|
13
|
+
'PortfolioAnalyzer',
|
14
|
+
ProcessorFactory.create_processor(Radar::API::AnalyzerController::Processor).
|
15
|
+
new(analyzer_controller)
|
16
|
+
)
|
17
|
+
unless Radar::App.transaction_importer.nil?
|
18
|
+
multiplexer.register_processor(
|
19
|
+
'TransactionImporter',
|
20
|
+
ProcessorFactory.create_processor(Radar::API::TransactionImporter::Processor).
|
21
|
+
new(Radar::App.transaction_importer)
|
22
|
+
)
|
23
|
+
end
|
12
24
|
transport = Thrift::ServerSocket.new(port)
|
13
|
-
server = Thrift::NonblockingServer.new(
|
25
|
+
server = Thrift::NonblockingServer.new(multiplexer, transport, Thrift::FramedTransportFactory.new)
|
14
26
|
logger.info { "Starting app on port #{port}..." }
|
15
27
|
server.serve
|
16
28
|
end
|
data/lib/radar/app/tasks.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'radar/app/bootstrap'
|
2
|
+
|
3
|
+
module Radar
|
4
|
+
module App
|
5
|
+
module Tasks
|
6
|
+
class Console < Thor::Group
|
7
|
+
include Thor::Actions
|
8
|
+
namespace :console
|
9
|
+
|
10
|
+
def start_console
|
11
|
+
Radar::App::Bootstrap.startup
|
12
|
+
if Object.const_defined?('Pry')
|
13
|
+
Pry.start(nil, commands: pry_commands)
|
14
|
+
else
|
15
|
+
IRB.start
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
def pry_commands
|
22
|
+
Pry::CommandSet.new do
|
23
|
+
command 'reload!', 'Reload the app classes' do
|
24
|
+
puts 'Reloading...'
|
25
|
+
$class_reloader.execute_if_updated
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/radar/app/tasks/new.rb
CHANGED
@@ -21,7 +21,7 @@ module Radar
|
|
21
21
|
def create_basic_files
|
22
22
|
copy_file 'Gemfile', "#{app_name}/Gemfile"
|
23
23
|
copy_file 'Procfile', "#{app_name}/Procfile"
|
24
|
-
copy_file '
|
24
|
+
copy_file 'DOKKU_SCALE', "#{app_name}/DOKKU_SCALE"
|
25
25
|
copy_file 'config/app.rb', "#{app_name}/config/app.rb"
|
26
26
|
end
|
27
27
|
|
data/lib/radar/app/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
app=1
|
data/templates/Procfile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
app: bundle exec radar-app server
|
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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonardo Mendonca
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -181,20 +181,16 @@ files:
|
|
181
181
|
- lib/radar/app/server.rb
|
182
182
|
- lib/radar/app/session.rb
|
183
183
|
- lib/radar/app/tasks.rb
|
184
|
+
- lib/radar/app/tasks/console.rb
|
184
185
|
- lib/radar/app/tasks/generate.rb
|
185
186
|
- lib/radar/app/tasks/new.rb
|
186
187
|
- lib/radar/app/tasks/server.rb
|
187
188
|
- lib/radar/app/version.rb
|
188
|
-
- lib/thrift/builder.rb
|
189
189
|
- radar-app.gemspec
|
190
|
-
- spec/example.thrift
|
191
|
-
- spec/gen-rb/example_constants.rb
|
192
|
-
- spec/gen-rb/example_types.rb
|
193
190
|
- spec/lib/radar/app/analyzer_spec.rb
|
194
191
|
- spec/lib/radar/app/processor_factory_spec.rb
|
195
192
|
- spec/lib/radar/app/tasks/generate_spec.rb
|
196
|
-
-
|
197
|
-
- templates/.webhook
|
193
|
+
- templates/DOKKU_SCALE
|
198
194
|
- templates/Gemfile
|
199
195
|
- templates/Procfile
|
200
196
|
- templates/analyzers/analyzer.rb.erb
|
@@ -225,10 +221,6 @@ signing_key:
|
|
225
221
|
specification_version: 4
|
226
222
|
summary: radar-app generator
|
227
223
|
test_files:
|
228
|
-
- spec/example.thrift
|
229
|
-
- spec/gen-rb/example_constants.rb
|
230
|
-
- spec/gen-rb/example_types.rb
|
231
224
|
- spec/lib/radar/app/analyzer_spec.rb
|
232
225
|
- spec/lib/radar/app/processor_factory_spec.rb
|
233
226
|
- spec/lib/radar/app/tasks/generate_spec.rb
|
234
|
-
- spec/lib/thrift/builder_spec.rb
|
data/lib/thrift/builder.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
module Thrift
|
2
|
-
class Builder
|
3
|
-
def initialize(clazz)
|
4
|
-
@class = clazz
|
5
|
-
end
|
6
|
-
|
7
|
-
def build(attributes)
|
8
|
-
@class.new.tap do |obj|
|
9
|
-
attributes.each do |attribute, value|
|
10
|
-
obj.send "#{attribute}=", build_attr(@class::FIELDS[obj.name_to_id(attribute.to_s)], value)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
protected
|
16
|
-
|
17
|
-
def build_attr(field, value)
|
18
|
-
case field[:type]
|
19
|
-
when Thrift::Types::STRUCT
|
20
|
-
Builder.new(field[:class]).build(value)
|
21
|
-
when Thrift::Types::LIST
|
22
|
-
value.map { |child| build_attr(field[:element], child) }
|
23
|
-
when Thrift::Types::SET
|
24
|
-
value.map { |child| build_attr(field[:element], child) }.to_set
|
25
|
-
when Thrift::Types::I32
|
26
|
-
if field.include?(:enum_class)
|
27
|
-
field[:enum_class].const_get(value.upcase)
|
28
|
-
else
|
29
|
-
value
|
30
|
-
end
|
31
|
-
else
|
32
|
-
value
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/spec/example.thrift
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
enum Gender {
|
2
|
-
MALE, FEMALE
|
3
|
-
}
|
4
|
-
|
5
|
-
struct PhoneNumber {
|
6
|
-
1: string contry_code
|
7
|
-
2: string area_code
|
8
|
-
3: string number
|
9
|
-
}
|
10
|
-
|
11
|
-
struct Person {
|
12
|
-
1: string name
|
13
|
-
2: PhoneNumber phone
|
14
|
-
3: list<Person> children
|
15
|
-
4: list<string> notes
|
16
|
-
5: Gender gender
|
17
|
-
6: i32 age
|
18
|
-
7: set<i32> favorite_numbers
|
19
|
-
}
|
@@ -1,66 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Autogenerated by Thrift Compiler (0.9.3)
|
3
|
-
#
|
4
|
-
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
5
|
-
#
|
6
|
-
|
7
|
-
require 'thrift'
|
8
|
-
|
9
|
-
module Gender
|
10
|
-
MALE = 0
|
11
|
-
FEMALE = 1
|
12
|
-
VALUE_MAP = {0 => "MALE", 1 => "FEMALE"}
|
13
|
-
VALID_VALUES = Set.new([MALE, FEMALE]).freeze
|
14
|
-
end
|
15
|
-
|
16
|
-
class PhoneNumber
|
17
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
18
|
-
CONTRY_CODE = 1
|
19
|
-
AREA_CODE = 2
|
20
|
-
NUMBER = 3
|
21
|
-
|
22
|
-
FIELDS = {
|
23
|
-
CONTRY_CODE => {:type => ::Thrift::Types::STRING, :name => 'contry_code'},
|
24
|
-
AREA_CODE => {:type => ::Thrift::Types::STRING, :name => 'area_code'},
|
25
|
-
NUMBER => {:type => ::Thrift::Types::STRING, :name => 'number'}
|
26
|
-
}
|
27
|
-
|
28
|
-
def struct_fields; FIELDS; end
|
29
|
-
|
30
|
-
def validate
|
31
|
-
end
|
32
|
-
|
33
|
-
::Thrift::Struct.generate_accessors self
|
34
|
-
end
|
35
|
-
|
36
|
-
class Person
|
37
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
38
|
-
NAME = 1
|
39
|
-
PHONE = 2
|
40
|
-
CHILDREN = 3
|
41
|
-
NOTES = 4
|
42
|
-
GENDER = 5
|
43
|
-
AGE = 6
|
44
|
-
FAVORITE_NUMBERS = 7
|
45
|
-
|
46
|
-
FIELDS = {
|
47
|
-
NAME => {:type => ::Thrift::Types::STRING, :name => 'name'},
|
48
|
-
PHONE => {:type => ::Thrift::Types::STRUCT, :name => 'phone', :class => ::PhoneNumber},
|
49
|
-
CHILDREN => {:type => ::Thrift::Types::LIST, :name => 'children', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Person}},
|
50
|
-
NOTES => {:type => ::Thrift::Types::LIST, :name => 'notes', :element => {:type => ::Thrift::Types::STRING}},
|
51
|
-
GENDER => {:type => ::Thrift::Types::I32, :name => 'gender', :enum_class => ::Gender},
|
52
|
-
AGE => {:type => ::Thrift::Types::I32, :name => 'age'},
|
53
|
-
FAVORITE_NUMBERS => {:type => ::Thrift::Types::SET, :name => 'favorite_numbers', :element => {:type => ::Thrift::Types::I32}}
|
54
|
-
}
|
55
|
-
|
56
|
-
def struct_fields; FIELDS; end
|
57
|
-
|
58
|
-
def validate
|
59
|
-
unless @gender.nil? || ::Gender::VALID_VALUES.include?(@gender)
|
60
|
-
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field gender!')
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
::Thrift::Struct.generate_accessors self
|
65
|
-
end
|
66
|
-
|
@@ -1,36 +0,0 @@
|
|
1
|
-
$:.unshift File.expand_path('../../../gen-rb', __FILE__)
|
2
|
-
|
3
|
-
require 'thrift/builder'
|
4
|
-
require 'example_types'
|
5
|
-
|
6
|
-
describe Thrift::Builder do
|
7
|
-
describe '#build' do
|
8
|
-
it 'builds a object of type defined by constructor' do
|
9
|
-
expect(Thrift::Builder.new(Person).build({})).to be_kind_of(Person)
|
10
|
-
end
|
11
|
-
it 'sets basic attributes' do
|
12
|
-
expect(Thrift::Builder.new(Person).build(name: 'Andre').name).to eq 'Andre'
|
13
|
-
end
|
14
|
-
it 'sets nested objects' do
|
15
|
-
expect(Thrift::Builder.new(Person).build(phone: {}).phone).to be_kind_of(PhoneNumber)
|
16
|
-
end
|
17
|
-
it 'sets nested objects attributes' do
|
18
|
-
expect(Thrift::Builder.new(Person).build(phone: {contry_code: '55'}).phone.contry_code).to eq '55'
|
19
|
-
end
|
20
|
-
it 'sets nested objects inside arrays' do
|
21
|
-
expect(Thrift::Builder.new(Person).build(children: [ { name: 'Helena' } ]).children.first.name).to eq 'Helena'
|
22
|
-
end
|
23
|
-
it 'sets basic attributes inside arrays' do
|
24
|
-
expect(Thrift::Builder.new(Person).build(notes: [ 'test' ]).notes).to eq [ 'test' ]
|
25
|
-
end
|
26
|
-
it 'sets enum attributes' do
|
27
|
-
expect(Thrift::Builder.new(Person).build(gender: :male).gender).to eq Gender::MALE
|
28
|
-
end
|
29
|
-
it 'sets i32 attributes' do
|
30
|
-
expect(Thrift::Builder.new(Person).build(age: 34).age).to eq 34
|
31
|
-
end
|
32
|
-
it 'sets set attributes' do
|
33
|
-
expect(Thrift::Builder.new(Person).build(favorite_numbers: [7, 10]).favorite_numbers).to eq Set.new([7, 10])
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/templates/.webhook
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
POST http://${RADAR_HOST:-radar.indicativos.com.br}/apps/$APP/up port=$PORT
|