radar-app 0.0.2 → 0.0.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 +4 -4
- data/bin/radar-app +39 -9
- data/lib/analyzer_controller.rb +33 -32
- data/lib/radar-app.rb +12 -10
- data/lib/radar/app/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfa68551cb0b966589030147fd428918fb38c959
|
4
|
+
data.tar.gz: 8c5c7dbfb83f4d77915853d1a76f335aa234e9aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5619d0b7fde1f6ab9df1bcf1feeb246f0c9244abac97369d0ab9fda62478ccdcc209167c50db873f4ae8bfaf532cf69bfea76217b08a1ccbcf96e939bd5bbe19
|
7
|
+
data.tar.gz: 1231aa3cc391341dc88c002ee0bad6c560e82531150244d0b173e34b9c26a425af6a2d56b45330fc2dacb166b7c60fa314d68d72e8c399f337ba8996196c5d79
|
data/bin/radar-app
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
$: << File.expand_path(
|
3
|
+
$: << File.expand_path('../lib/', __FILE__)
|
4
4
|
|
5
5
|
|
6
|
-
require 'rubygems'
|
6
|
+
require 'rubygems'
|
7
7
|
require 'bundler/setup'
|
8
8
|
require 'thor'
|
9
9
|
|
@@ -16,9 +16,9 @@ class RadarApp < Thor
|
|
16
16
|
"#{dir}/../templates"
|
17
17
|
end
|
18
18
|
|
19
|
-
desc 'new', 'Creates a new project with the given name'
|
19
|
+
desc 'new NAME', 'Creates a new project with the given name'
|
20
20
|
method_option :alias => 'n'
|
21
|
-
method_option :language, :type => :string, :aliases =>
|
21
|
+
method_option :language, :type => :string, :aliases => '-l', :default => 'ruby',
|
22
22
|
:desc => 'Choose the project language. Available options [Java, Ruby]'
|
23
23
|
def new(project_name)
|
24
24
|
if File.directory?(project_name.to_s)
|
@@ -26,6 +26,8 @@ class RadarApp < Thor
|
|
26
26
|
return
|
27
27
|
end
|
28
28
|
|
29
|
+
empty_directory project_name.to_s
|
30
|
+
|
29
31
|
language = options[:language].downcase
|
30
32
|
case language
|
31
33
|
when 'ruby'
|
@@ -41,15 +43,15 @@ class RadarApp < Thor
|
|
41
43
|
method_option :aliases => 's'
|
42
44
|
def server
|
43
45
|
require './analyzers_registry'
|
44
|
-
|
46
|
+
Radar::App::Server.start
|
45
47
|
end
|
46
48
|
|
47
49
|
desc 'generate', 'generates an analyzer'
|
48
50
|
method_option :alias => 'g'
|
49
|
-
def generate(command,
|
51
|
+
def generate(command, analyzer_name)
|
50
52
|
case command.to_s.downcase
|
51
53
|
when 'analyzer'
|
52
|
-
generate_analyzer(
|
54
|
+
generate_analyzer(analyzer_name) if command == 'analyzer'
|
53
55
|
else
|
54
56
|
puts 'invalid command'
|
55
57
|
end
|
@@ -71,16 +73,44 @@ class RadarApp < Thor
|
|
71
73
|
copy_file 'spec/analyzer_spec.rb', spec_file_name
|
72
74
|
gsub_file spec_file_name, 'file_name', analyzer_name
|
73
75
|
gsub_file spec_file_name, 'ClassName', class_name
|
76
|
+
|
77
|
+
#append_to_file 'analyzers_registry.rb', "RadarApp::AnalyzerController.register_analyzer('#{class_name}', '#{class_name}')"
|
74
78
|
end
|
75
79
|
|
76
80
|
def new_ruby_project(project_name)
|
77
|
-
empty_directory project_name.to_s
|
78
81
|
copy_file 'Gemfile', "#{project_name}/Gemfile"
|
79
82
|
copy_file 'analyzers_registry.rb', "#{project_name}/analyzers_registry.rb"
|
80
83
|
end
|
81
84
|
|
82
85
|
def new_java_project(project_name)
|
83
|
-
|
86
|
+
lib_directory = "#{project_name.to_s}/lib"
|
87
|
+
empty_directory lib_directory
|
88
|
+
empty_directory "#{project_name.to_s}/src"
|
89
|
+
|
90
|
+
download('http://repo2.maven.org/maven2/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar', lib_directory)
|
91
|
+
download('http://repo2.maven.org/maven2/org/apache/httpcomponents/httpclient/4.2.5/httpclient-4.2.5.jar', lib_directory)
|
92
|
+
download('http://repo2.maven.org/maven2/org/apache/httpcomponents/httpcore/4.2.4/httpcore-4.2.4.jar', lib_directory)
|
93
|
+
download('http://repo2.maven.org/maven2/org/apache/thrift/libthrift/0.9.1/libthrift-0.9.1.jar', lib_directory)
|
94
|
+
download('http://central.maven.org/maven2/log4j/log4j/1.2.16/log4j-1.2.16.jar', lib_directory)
|
95
|
+
download('http://central.maven.org/maven2/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8.jar', lib_directory)
|
96
|
+
download('http://central.maven.org/maven2/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8.jar', lib_directory)
|
97
|
+
end
|
98
|
+
|
99
|
+
def download(url, dir)
|
100
|
+
File.join(dir, File.basename(url)).tap do |localpath|
|
101
|
+
File.open(localpath, 'wb') do |localfile|
|
102
|
+
begin
|
103
|
+
Net::HTTP.get_response(URI.parse(url)) do |resp|
|
104
|
+
puts "error downloading #{url}" if resp.code == '404'
|
105
|
+
resp.read_body do |segment|
|
106
|
+
localfile << segment
|
107
|
+
end
|
108
|
+
end
|
109
|
+
rescue EOFError
|
110
|
+
puts "error downloading #{url}"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
84
114
|
end
|
85
115
|
end
|
86
116
|
|
data/lib/analyzer_controller.rb
CHANGED
@@ -1,44 +1,45 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
1
|
+
module Radar
|
2
|
+
module App
|
3
|
+
class AnalyzerController
|
4
|
+
attr_reader :sessions
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
def initialize
|
7
|
+
@sessions = {}
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
def self.register_analyzer(analyzer_id, analyzer_class)
|
11
|
+
(@@analyzers ||= {})[analyzer_id] = analyzer_class
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
def on_each_day(session_id, portfolio)
|
15
|
+
@sessions[session_id].on_each_day(portfolio)
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
def on_finish(session_id, portfolio)
|
19
|
+
@sessions[session_id].on_finish(portfolio)
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
def create_session(session_id, analyzer_id)
|
23
|
+
analyzer = @@analyzers[analyzer_id].new
|
24
|
+
@sessions[session_id] = analyzer
|
25
|
+
analyzer.config
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
def dump(session_id)
|
29
|
+
@sessions[session_id].dump
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
def resume(session_id, data)
|
33
|
+
@sessions[session_id].resume(data)
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
def result(session_id)
|
37
|
+
@sessions[session_id].result
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
-
|
40
|
+
def destroy_session(session_id)
|
41
|
+
@sessions.delete(session_id)
|
42
|
+
end
|
41
43
|
end
|
42
|
-
|
43
44
|
end
|
44
45
|
end
|
data/lib/radar-app.rb
CHANGED
@@ -2,16 +2,18 @@ require "radar/app/version"
|
|
2
2
|
require 'analyzer_controller'
|
3
3
|
require 'radar-api'
|
4
4
|
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
5
|
+
module Radar
|
6
|
+
module App
|
7
|
+
class Server
|
8
|
+
def self.start
|
9
|
+
handler = Radar::App::AnalyzerController.new
|
10
|
+
processor = Radar::API::AnalyzerController::Processor.new(handler)
|
11
|
+
transport = Thrift::ServerSocket.new(5000)
|
12
|
+
transportFactory = Thrift::BufferedTransportFactory.new
|
13
|
+
server = Thrift::ThreadedServer.new(processor, transport)
|
14
|
+
puts "Starting server..."
|
15
|
+
server.serve()
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
data/lib/radar/app/version.rb
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.3
|
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-04-
|
11
|
+
date: 2014-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|