press 0.14 → 0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/press.rb +5 -5
- data/lib/press/printer.rb +9 -20
- metadata +2 -2
data/lib/press.rb
CHANGED
@@ -6,7 +6,7 @@ module Press
|
|
6
6
|
Printer.ctx = data
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
9
|
+
def mctx(tag, data)
|
10
10
|
Printer.mtx, Printer.ctx = tag, data
|
11
11
|
end
|
12
12
|
|
@@ -14,16 +14,16 @@ module Press
|
|
14
14
|
Printer.pd *data, &blk
|
15
15
|
end
|
16
16
|
|
17
|
-
def mpd(*data
|
18
|
-
Printer.mpd *data
|
17
|
+
def mpd(*data)
|
18
|
+
Printer.mpd *data
|
19
19
|
end
|
20
20
|
|
21
21
|
def pdfm(file, m, *data, &blk)
|
22
22
|
Printer.pdfm file, m, *data, &blk
|
23
23
|
end
|
24
24
|
|
25
|
-
def mpdfm(file, m, *data
|
26
|
-
Printer.mpdfm file, m, *data
|
25
|
+
def mpdfm(file, m, *data)
|
26
|
+
Printer.mpdfm file, m, *data
|
27
27
|
end
|
28
28
|
|
29
29
|
def pde(e, *data)
|
data/lib/press/printer.rb
CHANGED
@@ -3,10 +3,6 @@ require "time"
|
|
3
3
|
module Press
|
4
4
|
module Printer
|
5
5
|
|
6
|
-
def self.ctx
|
7
|
-
@ctx ||= {}
|
8
|
-
end
|
9
|
-
|
10
6
|
def self.ctx=(data)
|
11
7
|
@ctx = data
|
12
8
|
end
|
@@ -19,16 +15,16 @@ module Press
|
|
19
15
|
write $stdout, hashify(*data, {}), &blk
|
20
16
|
end
|
21
17
|
|
22
|
-
def self.mpd(*data
|
23
|
-
write $stdout, mhashify(@mtx, *data, {})
|
18
|
+
def self.mpd(*data)
|
19
|
+
write $stdout, mhashify(@mtx, *data, {})
|
24
20
|
end
|
25
21
|
|
26
22
|
def self.pdfm(file, m, *data, &blk)
|
27
23
|
write $stdout, hashify(*data, :file => File.basename(file, ".rb"), :fn => m), &blk
|
28
24
|
end
|
29
25
|
|
30
|
-
def self.mpdfm(file, m, *data
|
31
|
-
write $stdout, mhashify([@mtx, File.basename(file, ".rb"), m].compact.join("."), *data, :file => File.basename(file, ".rb"), :fn => m)
|
26
|
+
def self.mpdfm(file, m, *data)
|
27
|
+
write $stdout, mhashify([@mtx, File.basename(file, ".rb"), m].compact.join("."), *data, :file => File.basename(file, ".rb"), :fn => m)
|
32
28
|
end
|
33
29
|
|
34
30
|
def self.pde(e, *data)
|
@@ -36,7 +32,7 @@ module Press
|
|
36
32
|
end
|
37
33
|
|
38
34
|
def self.mpde(e, *data)
|
39
|
-
write $stderr, mhashify(@mtx, *data, :at => "error", :class => e.class, :message => e.message.lines.to_a.first, :trace => e.backtrace.map { |i| i.match(/(#{Gem.dir}|#{Dir.getwd})?\/(.*):in (.*)/) && $2 }[0..5].inspect)
|
35
|
+
write $stderr, mhashify([@mtx, "error"].compact.join("."), *data, :at => "error", :class => e.class, :message => e.message.lines.to_a.first, :trace => e.backtrace.map { |i| i.match(/(#{Gem.dir}|#{Dir.getwd})?\/(.*):in (.*)/) && $2 }[0..5].inspect)
|
40
36
|
end
|
41
37
|
|
42
38
|
def self.pdfme(file, m, e, *data)
|
@@ -44,15 +40,15 @@ module Press
|
|
44
40
|
end
|
45
41
|
|
46
42
|
def self.mpdfme(file, m, e, *data)
|
47
|
-
write $stderr, mhashify([@mtx,
|
43
|
+
write $stderr, mhashify([@mtx, "error"].compact.join("."), *data, :at => "error", :class => e.class, :message => e.message.lines.to_a.first, :trace => e.backtrace.map { |i| i.match(/(#{Gem.dir}|#{Dir.getwd})?\/(.*):in (.*)/) && $2 }[0..5].inspect, :file => File.basename(file, ".rb"), :fn => m)
|
48
44
|
end
|
49
45
|
|
50
46
|
def self.hashify(*data, initial)
|
51
|
-
data.compact.reduce(initial.merge(ctx)) { |d, v| d.merge v }
|
47
|
+
data.compact.reduce(initial.merge(@ctx || {})) { |d, v| d.merge v }
|
52
48
|
end
|
53
49
|
|
54
50
|
def self.mhashify(mtx, *data, initial)
|
55
|
-
hashify(*data, initial).tap { |d| d[:measure] = [mtx, d[:
|
51
|
+
hashify(*data, initial).tap { |d| d[:measure] = [mtx, d[:event]].compact.join(".") if mtx }
|
56
52
|
end
|
57
53
|
|
58
54
|
def self.stringify(data)
|
@@ -82,14 +78,7 @@ module Press
|
|
82
78
|
else
|
83
79
|
start = Time.now
|
84
80
|
write file, { :at => "start" }.merge(data)
|
85
|
-
|
86
|
-
result = yield
|
87
|
-
rescue => e
|
88
|
-
pde e, data
|
89
|
-
raise
|
90
|
-
end
|
91
|
-
write file, { :at => "finish", :elapsed => Time.now - start }.merge(data)
|
92
|
-
result
|
81
|
+
yield.tap { write file, { :at => "finish", :elapsed => Time.now - start }.merge(data) }
|
93
82
|
end
|
94
83
|
end
|
95
84
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: press
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.15'
|
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-11-
|
12
|
+
date: 2012-11-15 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Data and exception printer.
|
15
15
|
email: mark.fine@gmail.com
|