akaer 0.3.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/Gemfile.lock +20 -24
- data/README.md +19 -14
- data/akaer.gemspec +3 -6
- data/bin/akaer +83 -1
- data/lib/akaer.rb +2 -9
- data/lib/akaer/application.rb +284 -76
- data/lib/akaer/configuration.rb +39 -24
- data/lib/akaer/version.rb +11 -2
- data/spec/akaer/application_spec.rb +311 -1
- data/spec/akaer/configuration_spec.rb +13 -1
- data/spec/spec_helper.rb +7 -1
- metadata +16 -68
- data/lib/akaer/errors.rb +0 -12
- data/lib/akaer/logger.rb +0 -58
- data/spec/akaer/logger_spec.rb +0 -11
data/lib/akaer/errors.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# This file is part of the akaer gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
|
4
|
-
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Akaer
|
8
|
-
module Errors
|
9
|
-
class InvalidConfiguration < ArgumentError
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
data/lib/akaer/logger.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# This file is part of the akaer gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
|
4
|
-
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
|
-
#
|
6
|
-
|
7
|
-
Sickill::Rainbow.enabled = true
|
8
|
-
|
9
|
-
module Akaer
|
10
|
-
class Logger < ::Logger
|
11
|
-
mattr_accessor :global_start_time
|
12
|
-
attr_accessor :start_time
|
13
|
-
|
14
|
-
def initialize(logdev, shift_age = 0, shift_size = 1048576)
|
15
|
-
super(logdev, shift_age, shift_size)
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.create(file, level = Logger::INFO, formatter = nil)
|
19
|
-
rv = self.new(self.get_real_file(file))
|
20
|
-
rv.level = level.to_i
|
21
|
-
rv.formatter = formatter || self.default_formatter
|
22
|
-
rv
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.get_real_file(file)
|
26
|
-
case file
|
27
|
-
when "STDOUT" then $stdout
|
28
|
-
when "STDERR" then $stderr
|
29
|
-
else file
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.default_file
|
34
|
-
$stdout
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.default_formatter
|
38
|
-
Proc.new {|severity, datetime, progname, msg|
|
39
|
-
color = case severity
|
40
|
-
when "DEBUG" then :cyan
|
41
|
-
when "INFO" then :green
|
42
|
-
when "WARN" then :yellow
|
43
|
-
when "ERROR" then :red
|
44
|
-
when "FATAL" then :magenta
|
45
|
-
else nil
|
46
|
-
end
|
47
|
-
|
48
|
-
header = ("[%s T+%0.5f] %s:" %[datetime.strftime("%Y/%b/%d %H:%M:%S"), [datetime.to_f - self.start_time.to_f, 0].max, severity.rjust(5)]).bright
|
49
|
-
header = header.color(color) if color.present?
|
50
|
-
"%s %s\n" % [header, msg]
|
51
|
-
}
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.start_time
|
55
|
-
@start_time ||= Time.now
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
data/spec/akaer/logger_spec.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# This file is part of the devdns gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
|
4
|
-
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
|
-
#
|
6
|
-
|
7
|
-
require "spec_helper"
|
8
|
-
|
9
|
-
describe Akaer::Logger do
|
10
|
-
pending "Test all."
|
11
|
-
end
|