slides 0.1.10 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/slides.rb +13 -6
  2. metadata +3 -3
@@ -3,16 +3,23 @@ require "time"
3
3
 
4
4
  module Slides
5
5
  module Log
6
- def log(event, attrs = {})
7
- unless block_given?
8
- str = "#{event} #{unparse(attrs)}"
6
+ def log(event, attrs={}, &block)
7
+ log_array(event, attrs.map { |k, v| [k, v] }, &block)
8
+ end
9
+
10
+ def log_array(event, arr, &block)
11
+ unless block
12
+ str = "#{event} #{unparse(arr)}"
9
13
  mtx.synchronize { stream.puts str }
10
14
  else
15
+ arr = arr.dup
11
16
  start = Time.now
12
- log(event, attrs.merge(:at => :start))
17
+ arr << [:at, :start]
18
+ log(event, arr)
13
19
  res = yield
14
- log(event, attrs.merge(:at => :finish,
15
- :elapsed => (Time.now - start).to_f))
20
+ arr.pop
21
+ arr << [:at, :finish] << [:elapsed, (Time.now - start).to_f]
22
+ log(event, arr)
16
23
  res
17
24
  end
18
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slides
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-18 00:00:00.000000000 Z
12
+ date: 2013-02-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: brandur@mutelight.org
@@ -39,7 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
39
39
  version: '0'
40
40
  requirements: []
41
41
  rubyforge_project:
42
- rubygems_version: 1.8.23
42
+ rubygems_version: 1.8.24
43
43
  signing_key:
44
44
  specification_version: 3
45
45
  summary: An extremely simplistic logs-as-events implementation.