blabbermouth 0.0.4 → 0.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 010d190597b04b7a4ea7709fddd137c9d9975b81
4
- data.tar.gz: 9263f8c9c390a5447092f5b4dba3735f1c2f77e1
3
+ metadata.gz: f98803c45f268ba1996c09ea11a80a6ef37c6a1a
4
+ data.tar.gz: ccd0de0419d5e61031e407f9b836787402c79a1d
5
5
  SHA512:
6
- metadata.gz: b08e982695a8e518ea8b7a3ed04d806743723ef9c815a944dbd968289114deddaa0a38143c882c1228caf93f882282d3f1bece563c39f1c7170a27a7c1ef38f8
7
- data.tar.gz: b6573f304388f7660560abffa576febf14d6190b94119ee57063da6c27c5be4ae63c28aade92c96c08d7c64b84ad3920f82b0bea63c0f86aa9eadc6dcbf410ce
6
+ metadata.gz: 49cf015a98b558aa260538ad3caf3e9a468a99837e7ebe7e0dc7b8d286f070d3dabe6b2ee27f52067be4a00e5b31ba8b8228c43bba7426104f6470eb023171bf
7
+ data.tar.gz: 631113f766998dfc7b002cd77b2baca5a39bb853eb522e4a010a7e7b73bc88627f957beeb957c3a59dba0d6b3e85e031fe2792f9dd2d6358ae4f6aa7df253cb3
@@ -62,28 +62,23 @@ module Blabbermouth
62
62
  end
63
63
 
64
64
  def error(key, e, *args)
65
- opts = args.extract_options!
66
- bystanders.map { |bystander| bystander.error key, e, *args.concat([bystander_options(bystander, opts)]) }
65
+ blab :error, key, e, *args
67
66
  end
68
67
 
69
68
  def info(key, msg=nil, *args)
70
- opts = args.extract_options!
71
- bystanders.map { |bystander| bystander.info key, msg, *args.concat([bystander_options(bystander, opts)]) }
69
+ blab :info, key, msg, *args
72
70
  end
73
71
 
74
72
  def increment(key, by=1, *args)
75
- opts = args.extract_options!
76
- bystanders.map { |bystander| bystander.increment key, by, *args.concat([bystander_options(bystander, opts)]) }
73
+ blab :increment, key, by, *args
77
74
  end
78
75
 
79
76
  def count(key, total, *args)
80
- opts = args.extract_options!
81
- bystanders.map { |bystander| bystander.count key, total, *args.concat([bystander_options(bystander, opts)]) }
77
+ blab :count, key, total, *args
82
78
  end
83
79
 
84
80
  def time(key, duration=nil, *args, &block)
85
81
  raise "Blabbermouth::Blabber#time requires a duration or block" if duration.nil? && !block_given?
86
- opts = args.extract_options!
87
82
 
88
83
  if block_given?
89
84
  start_time = ::Time.now
@@ -91,16 +86,21 @@ module Blabbermouth
91
86
  duration = (::Time.now - start_time).to_f
92
87
  end
93
88
 
94
- bystanders.map { |bystander| bystander.time key, duration, *args.concat([bystander_options(bystander, opts)]) }
89
+ blab :time, key, duration, *args
95
90
  end
96
91
 
97
- def method_missing(meth, *args, &block)
92
+ def blab(meth, key, *args, &block)
93
+ opts = args.extract_options!
98
94
  bystanders.map do |bystander|
99
95
  next unless bystander.respond_to?(meth)
100
- bystander.send(meth, *args, &block)
96
+ bystander.send meth, key, *args.concat([bystander_options(bystander, opts)]), &block
101
97
  end
102
98
  end
103
99
 
100
+ def method_missing(meth, *args, &block)
101
+ blab meth, *args, &block
102
+ end
103
+
104
104
  def respond_to_missing?(meth, include_private=false)
105
105
  bystanders.any? { |bystander| bystander.respond_to?(meth, include_private) }
106
106
  end
@@ -4,4 +4,5 @@ module Blabbermouth
4
4
  end
5
5
 
6
6
  require 'blabbermouth/bystanders/base'
7
+ require 'blabbermouth/bystanders/formatter'
7
8
  require 'blabbermouth/bystanders/stdout'
@@ -0,0 +1,12 @@
1
+ module Blabbermouth
2
+ module Bystanders
3
+ module Formatter
4
+ def log_message(event, key, msg, data={})
5
+ message = "[#{::Time.now.strftime('%Y/%m/%d %H:%M:%S %Z')}] Blabbermouth.#{event.to_s}: #{key.to_s}"
6
+ message += ": #{msg.to_s}" unless msg.to_s.blank?
7
+ message += " #{data.to_s}"
8
+ message
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,29 +1,31 @@
1
1
  module Blabbermouth
2
2
  module Bystanders
3
3
  class Stdout < Base
4
+ include Blabbermouth::Bystanders::Formatter
5
+
4
6
  def error(key, e, *args)
5
- data, opts, args = parse_args(*args)
6
- puts :error, key, e.message, data
7
+ blab :error, key, e, *args
7
8
  end
8
9
 
9
10
  def info(key, msg=nil, *args)
10
- data, opts, args = parse_args(*args)
11
- puts :info, key, msg, data
11
+ blab :info, key, msg, *args
12
12
  end
13
13
 
14
14
  def increment(key, by=1, *args)
15
- data, opts, args = parse_args(*args)
16
- puts :increment, key, by, data
15
+ blab :increment, key, by, *args
17
16
  end
18
17
 
19
18
  def count(key, total, *args)
20
- data, opts, args = parse_args(*args)
21
- puts :count, key, total, data
19
+ blab :count, key, total, *args
22
20
  end
23
21
 
24
- def time(key, value=nil, *args)
22
+ def time(key, duration, *args)
23
+ blab :time, key, duration, *args
24
+ end
25
+
26
+ def blab(meth, key, value, *args)
25
27
  data, opts, args = parse_args(*args)
26
- puts :time, key, value, data
28
+ puts meth, key, value, data
27
29
  end
28
30
 
29
31
  protected
@@ -31,13 +33,6 @@ module Blabbermouth
31
33
  def puts(event, key, msg, data={})
32
34
  $stdout.puts log_message(event, key, msg, data)
33
35
  end
34
-
35
- def log_message(event, key, msg, data={})
36
- message = "[#{::Time.now.strftime('%Y/%m/%d %H:%M:%S %Z')}] Blabbermouth.#{event.to_s}: #{key.to_s}"
37
- message += ": #{msg.to_s}" unless msg.to_s.blank?
38
- message += " #{data.to_s}"
39
- message
40
- end
41
36
  end
42
37
  end
43
38
  end
@@ -1,3 +1,3 @@
1
1
  module Blabbermouth
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -1,5 +1,7 @@
1
1
  require 'blabbermouth'
2
2
  require 'rspec'
3
+ require 'coveralls'
4
+ Coveralls.wear!
3
5
 
4
6
  Dir[File.join(File.dirname(__FILE__), '..', "spec/support/**/*.rb")].each { |f| require f }
5
7
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blabbermouth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Rebec
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-06 00:00:00.000000000 Z
11
+ date: 2015-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -65,6 +65,7 @@ files:
65
65
  - lib/blabbermouth/blabber.rb
66
66
  - lib/blabbermouth/bystanders.rb
67
67
  - lib/blabbermouth/bystanders/base.rb
68
+ - lib/blabbermouth/bystanders/formatter.rb
68
69
  - lib/blabbermouth/bystanders/new_relic.rb
69
70
  - lib/blabbermouth/bystanders/stdout.rb
70
71
  - lib/blabbermouth/configuration.rb