radar-app 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9730dfa668d43c9980dd5b5c978a3b8ed49fd57f
4
- data.tar.gz: df4d42bb45c2ed512882609ab369b347b8d947fd
3
+ metadata.gz: bfa68551cb0b966589030147fd428918fb38c959
4
+ data.tar.gz: 8c5c7dbfb83f4d77915853d1a76f335aa234e9aa
5
5
  SHA512:
6
- metadata.gz: b47f5ec1735bab38fc1f1eee47786e29bb894fd7918e381db6ed653ee3117abf8642efbc6570c447124f11e1d96e4880bea1df3a5da7a2a62ca63cc72083e7b3
7
- data.tar.gz: 1e3dc79e649773ba3c9b6c887fb0b2ef7e2343c23f4306eb2689e72018639e3b4ba11e250f6e56378d5a319e0e31b312f852c5873617b0f8ec79584130a15cd5
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("../lib/", __FILE__)
3
+ $: << File.expand_path('../lib/', __FILE__)
4
4
 
5
5
 
6
- require 'rubygems' # ruby1.9 doesn't "require" it though
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 => "-l", :default => 'ruby',
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
- RadarApp::Server.start
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, analzyer_name)
51
+ def generate(command, analyzer_name)
50
52
  case command.to_s.downcase
51
53
  when 'analyzer'
52
- generate_analyzer(analzyer_name) if command == '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
- puts "java #{project_name}"
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
 
@@ -1,44 +1,45 @@
1
- module RadarApp
2
- class AnalyzerController
3
- attr_reader :sessions
1
+ module Radar
2
+ module App
3
+ class AnalyzerController
4
+ attr_reader :sessions
4
5
 
5
- def initialize
6
- @sessions = {}
7
- end
6
+ def initialize
7
+ @sessions = {}
8
+ end
8
9
 
9
- def self.register_analyzer(analyzer_id, analyzer_class)
10
- (@@analyzers ||= {})[analyzer_id] = analyzer_class
11
- end
10
+ def self.register_analyzer(analyzer_id, analyzer_class)
11
+ (@@analyzers ||= {})[analyzer_id] = analyzer_class
12
+ end
12
13
 
13
- def on_each_day(session_id, portfolio)
14
- @sessions[session_id].on_each_day(portfolio)
15
- end
14
+ def on_each_day(session_id, portfolio)
15
+ @sessions[session_id].on_each_day(portfolio)
16
+ end
16
17
 
17
- def on_finish(session_id, portfolio)
18
- @sessions[session_id].on_finish(portfolio)
19
- end
18
+ def on_finish(session_id, portfolio)
19
+ @sessions[session_id].on_finish(portfolio)
20
+ end
20
21
 
21
- def create_session(session_id, analyzer_id)
22
- analyzer = @@analyzers[analyzer_id].new
23
- @sessions[session_id] = analyzer
24
- analyzer.config
25
- end
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
- def dump(session_id)
28
- @sessions[session_id].dump
29
- end
28
+ def dump(session_id)
29
+ @sessions[session_id].dump
30
+ end
30
31
 
31
- def resume(session_id, data)
32
- @sessions[session_id].resume(data)
33
- end
32
+ def resume(session_id, data)
33
+ @sessions[session_id].resume(data)
34
+ end
34
35
 
35
- def result(session_id)
36
- @sessions[session_id].result
37
- end
36
+ def result(session_id)
37
+ @sessions[session_id].result
38
+ end
38
39
 
39
- def destroy_session(session_id)
40
- @sessions.delete(session_id)
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 RadarApp
6
- class Server
7
- def self.start
8
- handler = RadarApp::AnalyzerController.new
9
- processor = Radar::API::AnalyzerController::Processor.new(handler)
10
- transport = Thrift::ServerSocket.new(5000)
11
- transportFactory = Thrift::BufferedTransportFactory.new
12
- server = Thrift::ThreadedServer.new(processor, transport)
13
- puts "Starting server..."
14
- server.serve()
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
@@ -1,5 +1,5 @@
1
1
  module Radar
2
2
  module App
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
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.2
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-02 00:00:00.000000000 Z
11
+ date: 2014-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler