press 0.13 → 0.14
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.
- data/lib/press/printer.rb +24 -0
- data/lib/press.rb +20 -0
- metadata +2 -2
data/lib/press/printer.rb
CHANGED
@@ -11,26 +11,50 @@ module Press
|
|
11
11
|
@ctx = data
|
12
12
|
end
|
13
13
|
|
14
|
+
def self.mtx=(tag)
|
15
|
+
@mtx = tag
|
16
|
+
end
|
17
|
+
|
14
18
|
def self.pd(*data, &blk)
|
15
19
|
write $stdout, hashify(*data, {}), &blk
|
16
20
|
end
|
17
21
|
|
22
|
+
def self.mpd(*data, &blk)
|
23
|
+
write $stdout, mhashify(@mtx, *data, {}), &blk
|
24
|
+
end
|
25
|
+
|
18
26
|
def self.pdfm(file, m, *data, &blk)
|
19
27
|
write $stdout, hashify(*data, :file => File.basename(file, ".rb"), :fn => m), &blk
|
20
28
|
end
|
21
29
|
|
30
|
+
def self.mpdfm(file, m, *data, &blk)
|
31
|
+
write $stdout, mhashify([@mtx, File.basename(file, ".rb"), m].compact.join("."), *data, :file => File.basename(file, ".rb"), :fn => m), &blk
|
32
|
+
end
|
33
|
+
|
22
34
|
def self.pde(e, *data)
|
23
35
|
write $stderr, hashify(*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)
|
24
36
|
end
|
25
37
|
|
38
|
+
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)
|
40
|
+
end
|
41
|
+
|
26
42
|
def self.pdfme(file, m, e, *data)
|
27
43
|
write $stderr, hashify(*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)
|
28
44
|
end
|
29
45
|
|
46
|
+
def self.mpdfme(file, m, e, *data)
|
47
|
+
write $stderr, mhashify([@mtx, File.basename(file, ".rb"), m].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
|
+
end
|
49
|
+
|
30
50
|
def self.hashify(*data, initial)
|
31
51
|
data.compact.reduce(initial.merge(ctx)) { |d, v| d.merge v }
|
32
52
|
end
|
33
53
|
|
54
|
+
def self.mhashify(mtx, *data, initial)
|
55
|
+
hashify(*data, initial).tap { |d| d[:measure] = [mtx, d[:measure]].compact.join(".") if mtx }
|
56
|
+
end
|
57
|
+
|
34
58
|
def self.stringify(data)
|
35
59
|
data.map do |(k, v)|
|
36
60
|
case v
|
data/lib/press.rb
CHANGED
@@ -6,22 +6,42 @@ module Press
|
|
6
6
|
Printer.ctx = data
|
7
7
|
end
|
8
8
|
|
9
|
+
def mtx(tag, data)
|
10
|
+
Printer.mtx, Printer.ctx = tag, data
|
11
|
+
end
|
12
|
+
|
9
13
|
def pd(*data, &blk)
|
10
14
|
Printer.pd *data, &blk
|
11
15
|
end
|
12
16
|
|
17
|
+
def mpd(*data, &blk)
|
18
|
+
Printer.mpd *data, &blk
|
19
|
+
end
|
20
|
+
|
13
21
|
def pdfm(file, m, *data, &blk)
|
14
22
|
Printer.pdfm file, m, *data, &blk
|
15
23
|
end
|
16
24
|
|
25
|
+
def mpdfm(file, m, *data, &blk)
|
26
|
+
Printer.mpdfm file, m, *data, &blk
|
27
|
+
end
|
28
|
+
|
17
29
|
def pde(e, *data)
|
18
30
|
Printer.pde e, *data
|
19
31
|
end
|
20
32
|
|
33
|
+
def mpde(e, *data)
|
34
|
+
Printer.mpde e, *data
|
35
|
+
end
|
36
|
+
|
21
37
|
def pdfme(file, m, e, *data)
|
22
38
|
Printer.pdfme file, m, e, *data
|
23
39
|
end
|
24
40
|
|
41
|
+
def mpdfme(file, m, e, *data)
|
42
|
+
Printer.mpdfme file, m, e, *data
|
43
|
+
end
|
44
|
+
|
25
45
|
class Logger
|
26
46
|
|
27
47
|
def self.level(*attrs)
|
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.14'
|
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-
|
12
|
+
date: 2012-11-14 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Data and exception printer.
|
15
15
|
email: mark.fine@gmail.com
|