tom 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/init.rb +0 -6
- data/lib/tom/log.rb +48 -16
- data/tom.gemspec +1 -1
- metadata +30 -30
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/lib/init.rb
CHANGED
@@ -3,12 +3,6 @@ Bundler.require :default
|
|
3
3
|
|
4
4
|
# Init Goliath env unless it was done already
|
5
5
|
Goliath.env rescue Goliath.env = (ENV['RACK_ENV'] || 'development').to_sym
|
6
|
-
|
7
|
-
# In dev mode, we do some logging (defaults to Logger::ERROR in other
|
8
|
-
# envs)
|
9
|
-
if Goliath.env == :development || ENV['BOBS']
|
10
|
-
Tom::Log.logger.level = Logger::INFO
|
11
|
-
end
|
12
6
|
Tom::Log.logger.info "Started goliath in #{Goliath.env} environment (change with ruby your_app.rb -e development or by setting $RACK_ENV)"
|
13
7
|
|
14
8
|
# Fetch the codes
|
data/lib/tom/log.rb
CHANGED
@@ -2,27 +2,59 @@ require 'logger'
|
|
2
2
|
|
3
3
|
module Tom
|
4
4
|
module Log
|
5
|
+
# Allows you to define your own logger. Tom itself will
|
6
|
+
# log things as .debug, so you can log with .info level
|
7
|
+
# in your app and do stuff. Or you can use your own
|
8
|
+
# logging altogether
|
9
|
+
#
|
10
|
+
# @param [Object] logger Some object that implements the
|
11
|
+
# .info .debug etc.
|
12
|
+
# @return [Object] The logger param
|
13
|
+
def self.logger=(logger)
|
14
|
+
@logger = logger
|
15
|
+
end
|
5
16
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def self.logger
|
12
|
-
unless @logger
|
17
|
+
# Accessor for the current logger
|
18
|
+
# @return [Object] See {Tom::Log.logger=}
|
19
|
+
def self.logger
|
20
|
+
return @logger if @logger
|
13
21
|
@logger = ::Logger.new(STDOUT)
|
14
22
|
init_logger_defaults
|
23
|
+
@logger
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
# Takes the current {Tom::Log.logger} and sets its level
|
28
|
+
# to {Logger::INFO} when you're in the development mode or
|
29
|
+
# when ENV['BOBS'] is set. Otherwise the log level is set
|
30
|
+
# to {Logger::ERROR}.
|
31
|
+
#
|
32
|
+
# Also, the log format is changed to something short (hh:mm:ss)
|
33
|
+
# @return [void]
|
34
|
+
def self.init_logger_defaults
|
35
|
+
set_log_level(default_log_level)
|
36
|
+
@logger.datetime_format = "%H:%M:%S:" rescue nil # might not respond_to
|
37
|
+
Logger::Formatter.module_eval(
|
38
|
+
%q{ def call(severity, time, progname, msg)} +
|
39
|
+
%q{ "#{format_datetime(time)} #{msg2str(msg)}\n" end}
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return ::Logger::INFO when in development mode or ENV['BOBS'] is set,
|
44
|
+
# ::Logger::ERROR otherwise
|
45
|
+
def self.default_log_level
|
46
|
+
return ::Logger::INFO if Goliath.env == :development || ENV['BOBS']
|
47
|
+
return ::Logger::ERROR
|
15
48
|
end
|
16
|
-
@logger
|
17
|
-
end
|
18
49
|
|
19
|
-
|
20
|
-
|
21
|
-
@
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
50
|
+
# Tries to set the level on the logger, if the logger has a method setter
|
51
|
+
#
|
52
|
+
# @param The log level you want to set
|
53
|
+
#
|
54
|
+
# @return The level you set or false when the logger doesn't have a method setter
|
55
|
+
def self.set_log_level(level)
|
56
|
+
return false unless @logger.respond_to?(:level=)
|
57
|
+
@logger.level = level
|
26
58
|
end
|
27
59
|
end
|
28
60
|
end
|
data/tom.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-12-13 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: goliath
|
16
|
-
requirement: &
|
16
|
+
requirement: &70179912287520 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70179912287520
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: em-synchrony
|
27
|
-
requirement: &
|
27
|
+
requirement: &70179912286880 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70179912286880
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: em-http-request
|
38
|
-
requirement: &
|
38
|
+
requirement: &70179912286380 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70179912286380
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: json
|
49
|
-
requirement: &
|
49
|
+
requirement: &70179912285860 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70179912285860
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rake
|
60
|
-
requirement: &
|
60
|
+
requirement: &70179912285280 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 0.9.2
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70179912285280
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
|
-
requirement: &
|
71
|
+
requirement: &70179912284760 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 1.0.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70179912284760
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: jeweler
|
82
|
-
requirement: &
|
82
|
+
requirement: &70179912284240 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 1.6.4
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70179912284240
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: shoulda
|
93
|
-
requirement: &
|
93
|
+
requirement: &70179912283720 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70179912283720
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: rcov
|
104
|
-
requirement: &
|
104
|
+
requirement: &70179912283220 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70179912283220
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: ruby-debug19
|
115
|
-
requirement: &
|
115
|
+
requirement: &70179912282700 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: '0'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *70179912282700
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: rspec
|
126
|
-
requirement: &
|
126
|
+
requirement: &70179912282180 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ! '>='
|
@@ -131,10 +131,10 @@ dependencies:
|
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *70179912282180
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: webmock
|
137
|
-
requirement: &
|
137
|
+
requirement: &70179912281680 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - ! '>='
|
@@ -142,10 +142,10 @@ dependencies:
|
|
142
142
|
version: '0'
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *70179912281680
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: yard
|
148
|
-
requirement: &
|
148
|
+
requirement: &70179912281140 !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
151
151
|
- - ! '>='
|
@@ -153,10 +153,10 @@ dependencies:
|
|
153
153
|
version: '0'
|
154
154
|
type: :development
|
155
155
|
prerelease: false
|
156
|
-
version_requirements: *
|
156
|
+
version_requirements: *70179912281140
|
157
157
|
- !ruby/object:Gem::Dependency
|
158
158
|
name: rdiscount
|
159
|
-
requirement: &
|
159
|
+
requirement: &70179912280540 !ruby/object:Gem::Requirement
|
160
160
|
none: false
|
161
161
|
requirements:
|
162
162
|
- - ! '>='
|
@@ -164,7 +164,7 @@ dependencies:
|
|
164
164
|
version: '0'
|
165
165
|
type: :development
|
166
166
|
prerelease: false
|
167
|
-
version_requirements: *
|
167
|
+
version_requirements: *70179912280540
|
168
168
|
description: ! ' Tom uses Goliath to dispatch HTTP requests to multiple other APIs
|
169
169
|
(via Adapters) in parallel. In a next step, a Merger merges the result and responds
|
170
170
|
to the clients request.'
|
@@ -212,7 +212,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
212
212
|
version: '0'
|
213
213
|
segments:
|
214
214
|
- 0
|
215
|
-
hash:
|
215
|
+
hash: -484356228756577305
|
216
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
217
|
none: false
|
218
218
|
requirements:
|