otaku 0.2.0 → 0.2.1
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.
- data/HISTORY.txt +5 -0
- data/VERSION +1 -1
- data/lib/otaku.rb +14 -3
- data/lib/otaku/server.rb +3 -12
- data/otaku.gemspec +1 -1
- metadata +3 -3
data/HISTORY.txt
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/otaku.rb
CHANGED
@@ -5,7 +5,7 @@ require 'base64'
|
|
5
5
|
require 'ruby2ruby'
|
6
6
|
require 'ruby_parser'
|
7
7
|
|
8
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
8
|
+
# $LOAD_PATH.unshift(File.dirname(__FILE__))
|
9
9
|
require 'otaku/encoder'
|
10
10
|
require 'otaku/handler'
|
11
11
|
require 'otaku/server'
|
@@ -53,6 +53,17 @@ module Otaku
|
|
53
53
|
Client.get(data)
|
54
54
|
end
|
55
55
|
|
56
|
+
def log(*msgs)
|
57
|
+
@logger ||= Logger.new(Otaku.log_file)
|
58
|
+
[msgs].flatten.each{|msg| @logger << "[Otaku] %s\n" % msg }
|
59
|
+
end
|
60
|
+
|
61
|
+
def cleanup
|
62
|
+
@logger.close if @logger
|
63
|
+
end
|
64
|
+
|
65
|
+
# NOTE: Unexpected, it is possible for otaku to be required multiple times,
|
66
|
+
# we wanna avoid the irritating warning issued when DEFAULTS is redeclared.
|
56
67
|
Otaku.configure(DEFAULTS)
|
57
68
|
|
58
69
|
end
|
@@ -67,8 +78,8 @@ if $0 == __FILE__ && (encoded_data = ARGV[0])
|
|
67
78
|
Server.handler = data[:handler]
|
68
79
|
Server.start(true)
|
69
80
|
rescue
|
70
|
-
|
81
|
+
Otaku.log $!.inspect
|
71
82
|
ensure
|
72
|
-
|
83
|
+
Otaku.cleanup
|
73
84
|
end
|
74
85
|
end
|
data/lib/otaku/server.rb
CHANGED
@@ -14,7 +14,7 @@ module Otaku
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def run_evented_server
|
17
|
-
log 'started with pid #%s' % Process.pid,
|
17
|
+
Otaku.log 'started with pid #%s' % Process.pid,
|
18
18
|
'listening at %s:%s' % [Otaku.address, Otaku.port]
|
19
19
|
EventMachine::run { EventMachine::start_server(Otaku.address, Otaku.port, EM) }
|
20
20
|
end
|
@@ -30,15 +30,6 @@ module Otaku
|
|
30
30
|
Process.kill('SIGHUP', @process.pid) if @process
|
31
31
|
end
|
32
32
|
|
33
|
-
def log(*msgs)
|
34
|
-
@logger ||= Logger.new(Otaku.log_file)
|
35
|
-
msgs.each{|msg| @logger << "[Otaku] %s\n" % msg }
|
36
|
-
end
|
37
|
-
|
38
|
-
def cleanup
|
39
|
-
@logger.close
|
40
|
-
end
|
41
|
-
|
42
33
|
end
|
43
34
|
|
44
35
|
private
|
@@ -62,8 +53,8 @@ module Otaku
|
|
62
53
|
end
|
63
54
|
end
|
64
55
|
|
65
|
-
def log(*
|
66
|
-
|
56
|
+
def log(*msgs)
|
57
|
+
Otaku.log(msgs)
|
67
58
|
end
|
68
59
|
|
69
60
|
end
|
data/otaku.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: otaku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- NgTzeYang
|