blabbermouth 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 +4 -4
- data/lib/blabbermouth.rb +5 -16
- data/lib/blabbermouth/blabber.rb +22 -20
- data/lib/blabbermouth/configuration.rb +1 -0
- data/lib/blabbermouth/version.rb +1 -1
- data/spec/spec_helper.rb +4 -0
- data/spec/support/gawker.rb +12 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a78223e98752990442658537e8adb72eb25c402a
|
4
|
+
data.tar.gz: c4075260334a80209ebaf6567547245afe32a0c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5f5d76743381b4a271030215d1c0cb0f5b748f001722addb4fbda92e6e21d3154ce136a677c80ceecb9a38f2465c099cc6c00dfc39761ab363023578f5afb15
|
7
|
+
data.tar.gz: 894723a59b490f1c86ebe83d21fddbb91c45c22d59e476418cf702413487cbfacffa5d565719f67515d286658bad0acac5175415eccc491e31c55338a51e6c79
|
data/lib/blabbermouth.rb
CHANGED
@@ -23,33 +23,22 @@ module Blabbermouth
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.error(key, e, *args)
|
26
|
-
|
27
|
-
gawkers = args.concat([opts.slice!(:data)])
|
28
|
-
blabber(*gawkers).error(key, e, opts)
|
26
|
+
Blabbermouth::Blabber.error key, e, *args
|
29
27
|
end
|
30
28
|
|
31
29
|
def self.info(key, msg=nil, *args)
|
32
|
-
|
33
|
-
gawkers = args.concat([opts.slice!(:data)])
|
34
|
-
blabber(*gawkers).info(key, msg, opts)
|
30
|
+
Blabbermouth::Blabber.info key, msg, *args
|
35
31
|
end
|
36
32
|
|
37
33
|
def self.increment(key, by=1, *args)
|
38
|
-
|
39
|
-
gawkers = args.concat([opts.slice!(:data)])
|
40
|
-
blabber(*gawkers).increment(key, by, opts)
|
34
|
+
Blabbermouth::Blabber.increment key, by, *args
|
41
35
|
end
|
42
36
|
|
43
37
|
def self.count(key, total, *args)
|
44
|
-
|
45
|
-
gawkers = args.concat([opts.slice!(:data)])
|
46
|
-
blabber(*gawkers).count(key, total, opts)
|
38
|
+
Blabbermouth::Blabber.count key, total, *args
|
47
39
|
end
|
48
40
|
|
49
41
|
def self.time(key, duration=nil, *args, &block)
|
50
|
-
|
51
|
-
opts = args.extract_options!
|
52
|
-
gawkers = args.concat([opts.slice!(:data)])
|
53
|
-
blabber(*gawkers).time(key, duration, opts, &block)
|
42
|
+
Blabbermouth::Blabber.time key, duration, *args, &block
|
54
43
|
end
|
55
44
|
end
|
data/lib/blabbermouth/blabber.rb
CHANGED
@@ -3,33 +3,35 @@ module Blabbermouth
|
|
3
3
|
attr_reader :gawkers, :options
|
4
4
|
|
5
5
|
class << self
|
6
|
-
def
|
6
|
+
def parse_args(*args)
|
7
7
|
opts = args.extract_options!
|
8
|
-
|
8
|
+
args = Blabbermouth.configuration.gawkers if args.empty?
|
9
|
+
gawkers = args + [opts.slice!(:data)]
|
10
|
+
[gawkers, opts]
|
11
|
+
end
|
12
|
+
|
13
|
+
def error(key, e, *args)
|
14
|
+
gawkers, opts = parse_args(*args)
|
9
15
|
new(*gawkers).error(key, e, opts)
|
10
16
|
end
|
11
17
|
|
12
18
|
def info(key, msg=nil, *args)
|
13
|
-
opts = args
|
14
|
-
gawkers = args.concat([opts.slice!(:data)])
|
19
|
+
gawkers, opts = parse_args(*args)
|
15
20
|
new(*gawkers).info(key, msg, opts)
|
16
21
|
end
|
17
22
|
|
18
23
|
def increment(key, by=1, *args)
|
19
|
-
opts = args
|
20
|
-
gawkers = args.concat([opts.slice!(:data)])
|
24
|
+
gawkers, opts = parse_args(*args)
|
21
25
|
new(*gawkers).increment(key, by, opts)
|
22
26
|
end
|
23
27
|
|
24
28
|
def count(key, total, *args)
|
25
|
-
opts = args
|
26
|
-
gawkers = args.concat([opts.slice!(:data)])
|
29
|
+
gawkers, opts = parse_args(*args)
|
27
30
|
new(*gawkers).count(key, total, opts)
|
28
31
|
end
|
29
32
|
|
30
33
|
def time(key, duration=nil, *args, &block)
|
31
|
-
opts = args
|
32
|
-
gawkers = args.concat([opts.slice!(:data)])
|
34
|
+
gawkers, opts = parse_args(*args)
|
33
35
|
new(*gawkers).time(key, duration, opts, &block)
|
34
36
|
end
|
35
37
|
end
|
@@ -61,26 +63,26 @@ module Blabbermouth
|
|
61
63
|
|
62
64
|
def error(key, e, *args)
|
63
65
|
opts = args.extract_options!
|
64
|
-
gawkers.map { |gawker| gawker.error key, e, *args.concat([gawker_options(gawker
|
66
|
+
gawkers.map { |gawker| gawker.error key, e, *args.concat([gawker_options(gawker, opts)]) }
|
65
67
|
end
|
66
68
|
|
67
69
|
def info(key, msg=nil, *args)
|
68
70
|
opts = args.extract_options!
|
69
|
-
gawkers.map { |gawker| gawker.info key, msg, *args.concat([gawker_options(gawker
|
71
|
+
gawkers.map { |gawker| gawker.info key, msg, *args.concat([gawker_options(gawker, opts)]) }
|
70
72
|
end
|
71
73
|
|
72
74
|
def increment(key, by=1, *args)
|
73
75
|
opts = args.extract_options!
|
74
|
-
gawkers.map { |gawker| gawker.increment key, by, *args.concat([gawker_options(gawker
|
76
|
+
gawkers.map { |gawker| gawker.increment key, by, *args.concat([gawker_options(gawker, opts)]) }
|
75
77
|
end
|
76
78
|
|
77
79
|
def count(key, total, *args)
|
78
80
|
opts = args.extract_options!
|
79
|
-
gawkers.map { |gawker| gawker.count key, total, *args.concat([gawker_options(gawker
|
81
|
+
gawkers.map { |gawker| gawker.count key, total, *args.concat([gawker_options(gawker, opts)]) }
|
80
82
|
end
|
81
83
|
|
82
84
|
def time(key, duration=nil, *args, &block)
|
83
|
-
raise "Blabbermouth::Blabber
|
85
|
+
raise "Blabbermouth::Blabber#time requires a duration or block" if duration.nil? && !block_given?
|
84
86
|
opts = args.extract_options!
|
85
87
|
|
86
88
|
if block_given?
|
@@ -89,7 +91,7 @@ module Blabbermouth
|
|
89
91
|
duration = (::Time.now - start_time).to_f
|
90
92
|
end
|
91
93
|
|
92
|
-
gawkers.map { |gawker| gawker.time key, duration, *args.concat([gawker_options(gawker
|
94
|
+
gawkers.map { |gawker| gawker.time key, duration, *args.concat([gawker_options(gawker, opts)]) }
|
93
95
|
end
|
94
96
|
|
95
97
|
def method_missing(meth, *args, &block)
|
@@ -107,12 +109,12 @@ module Blabbermouth
|
|
107
109
|
|
108
110
|
def initialize(*gawks)
|
109
111
|
@options = gawks.extract_options!
|
110
|
-
gawks.concat(options.keys)
|
111
|
-
gawks.each { |gawker| add_gawker gawker }
|
112
|
+
gawks.concat(options.keys).uniq
|
113
|
+
gawks.each { |gawker| add_gawker! gawker }
|
112
114
|
end
|
113
115
|
|
114
|
-
def gawker_options(gawker)
|
115
|
-
@options[gawker.class.name.demodulize.underscore.to_sym] || {}
|
116
|
+
def gawker_options(gawker, opts={})
|
117
|
+
(@options[gawker.class.name.demodulize.underscore.to_sym] || {}).merge(opts)
|
116
118
|
end
|
117
119
|
|
118
120
|
def gawker_index(gawker)
|
data/lib/blabbermouth/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -3,6 +3,10 @@ require 'rspec'
|
|
3
3
|
|
4
4
|
Dir[File.join(File.dirname(__FILE__), '..', "spec/support/**/*.rb")].each { |f| require f }
|
5
5
|
|
6
|
+
Blabbermouth.configure do |config|
|
7
|
+
config.gawkers = []
|
8
|
+
end
|
9
|
+
|
6
10
|
RSpec.configure do |config|
|
7
11
|
#config.before(:suite) do
|
8
12
|
# ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
|
data/spec/support/gawker.rb
CHANGED
@@ -2,7 +2,6 @@ module Blabbermouth
|
|
2
2
|
module Gawkers
|
3
3
|
class Test < Base
|
4
4
|
EVENTS = []
|
5
|
-
attr_reader :events
|
6
5
|
|
7
6
|
def self.logged?(event, key, msg)
|
8
7
|
EVENTS.any? { |e| e == [event, key, msg] }
|
@@ -12,27 +11,33 @@ module Blabbermouth
|
|
12
11
|
self.class.logged? event, key, msg
|
13
12
|
end
|
14
13
|
|
15
|
-
def error(key, e, *args
|
14
|
+
def error(key, e, *args)
|
15
|
+
data, opts, args = parse_args(*args)
|
16
16
|
log :error, key, e.message, data
|
17
17
|
end
|
18
18
|
|
19
|
-
def info(key, msg=nil, *args
|
19
|
+
def info(key, msg=nil, *args)
|
20
|
+
data, opts, args = parse_args(*args)
|
20
21
|
log :info, key, msg, data
|
21
22
|
end
|
22
23
|
|
23
|
-
def increment(key, by, *args
|
24
|
+
def increment(key, by=1, *args)
|
25
|
+
data, opts, args = parse_args(*args)
|
24
26
|
log :increment, key, by, data
|
25
27
|
end
|
26
28
|
|
27
|
-
def count(key, total, *args
|
29
|
+
def count(key, total, *args)
|
30
|
+
data, opts, args = parse_args(*args)
|
28
31
|
log :count, key, total, data
|
29
32
|
end
|
30
33
|
|
31
|
-
def time(key, value=nil, *args
|
34
|
+
def time(key, value=nil, *args)
|
35
|
+
data, opts, args = parse_args(*args)
|
32
36
|
log :time, key, value, data
|
33
37
|
end
|
34
38
|
|
35
|
-
def test(key, msg=nil, *args
|
39
|
+
def test(key, msg=nil, *args)
|
40
|
+
data, opts, args = parse_args(*args)
|
36
41
|
log :test, key, msg, data
|
37
42
|
end
|
38
43
|
|