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.
@@ -1,3 +1,8 @@
1
+ === 0.2.1 2010-07-19
2
+
3
+ = Bug Fixes
4
+ * closing of logger is done ONLY if the logger has been initialized [#ngty]
5
+
1
6
  === 0.2.0 2010-07-19
2
7
 
3
8
  = Features
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -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
- Server.log($!.inspect)
81
+ Otaku.log $!.inspect
71
82
  ensure
72
- Server.cleanup
83
+ Otaku.cleanup
73
84
  end
74
85
  end
@@ -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(*msg)
66
- Server.log(*msg)
56
+ def log(*msgs)
57
+ Otaku.log(msgs)
67
58
  end
68
59
 
69
60
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{otaku}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["NgTzeYang"]
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: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - NgTzeYang