test_bench-output 2.1.0.1 → 2.1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/test_bench/output/digest.rb +22 -0
- data/lib/test_bench/output/writer/buffer.rb +3 -3
- data/lib/test_bench/output/writer.rb +19 -7
- data/lib/test_bench/output.rb +0 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d77fe7175bda6a0810ed9209d34eec5f77062cf64d14940fd96fdb5bf8fc7ad4
|
4
|
+
data.tar.gz: bbb2bfe7f8c18ed94e67084404f96463134792cff5ab5a22fa141ee0c219989d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d84f358043eb36ab559660ed5fd4b493a41abd5d9ed0bd89b99ab9f47e1b06466a1c296137cf73acf7bd296938cbf68dc6bc05f115b17fa1f03dcfc0d8d9641
|
7
|
+
data.tar.gz: a135fcccdaec32ea6385a0b2f1476cd989a92e22c841abda61b11d1f6b226c82674ee6fc88f21d1d216e9525735a1c833cc37c04942bdbd65f394aea5eb08bff
|
@@ -17,6 +17,19 @@ module TestBench
|
|
17
17
|
instance.digest
|
18
18
|
end
|
19
19
|
|
20
|
+
def self.configure(receiver, inert: nil, attr_name: nil)
|
21
|
+
attr_name ||= :digest
|
22
|
+
inert = true if inert.nil?
|
23
|
+
|
24
|
+
if inert
|
25
|
+
instance = Null.new
|
26
|
+
else
|
27
|
+
instance = self.new
|
28
|
+
end
|
29
|
+
|
30
|
+
receiver.public_send(:"#{attr_name}=", instance)
|
31
|
+
end
|
32
|
+
|
20
33
|
def clone
|
21
34
|
cloned_digest = Digest.new
|
22
35
|
cloned_digest.last_digest = last_digest
|
@@ -81,6 +94,15 @@ module TestBench
|
|
81
94
|
"0x%016X" % digest_uint64
|
82
95
|
end
|
83
96
|
|
97
|
+
class Null
|
98
|
+
def update(_data)
|
99
|
+
end
|
100
|
+
|
101
|
+
def digest?(_data)
|
102
|
+
false
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
84
106
|
module Defaults
|
85
107
|
def self.size_bytes
|
86
108
|
8
|
@@ -26,15 +26,15 @@ module TestBench
|
|
26
26
|
bytes = data.bytesize
|
27
27
|
|
28
28
|
if not limit.nil?
|
29
|
-
final_size = contents.bytesize +
|
29
|
+
final_size = contents.bytesize + bytes
|
30
30
|
|
31
31
|
if final_size > limit
|
32
32
|
bytes = limit - contents.bytesize
|
33
|
+
|
34
|
+
data = data[0...bytes]
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
36
|
-
data = data[0...bytes]
|
37
|
-
|
38
38
|
contents << data
|
39
39
|
|
40
40
|
bytes
|
@@ -36,23 +36,27 @@ module TestBench
|
|
36
36
|
Buffer.configure(self)
|
37
37
|
end
|
38
38
|
|
39
|
-
def self.build(device=nil, styling: nil)
|
39
|
+
def self.build(device=nil, styling: nil, inert_digest: nil)
|
40
40
|
device ||= Defaults.device
|
41
41
|
|
42
42
|
instance = new
|
43
43
|
instance.device = device
|
44
44
|
instance.styling_policy = styling
|
45
|
+
|
46
|
+
Digest.configure(instance, inert: inert_digest)
|
47
|
+
|
45
48
|
instance.configure
|
49
|
+
|
46
50
|
instance
|
47
51
|
end
|
48
52
|
|
49
|
-
def self.configure(receiver, writer: nil, styling: nil, device: nil, attr_name: nil)
|
53
|
+
def self.configure(receiver, writer: nil, styling: nil, inert_digest: nil, device: nil, attr_name: nil)
|
50
54
|
attr_name ||= :writer
|
51
55
|
|
52
56
|
if not writer.nil?
|
53
57
|
instance = writer
|
54
58
|
else
|
55
|
-
instance = build(device, styling:)
|
59
|
+
instance = build(device, styling:, inert_digest:)
|
56
60
|
end
|
57
61
|
|
58
62
|
receiver.public_send(:"#{attr_name}=", instance)
|
@@ -62,6 +66,12 @@ module TestBench
|
|
62
66
|
@sync.nil? ? @sync = true : @sync
|
63
67
|
end
|
64
68
|
|
69
|
+
def tty
|
70
|
+
@tty.nil? ? @tty = device_tty? : @tty
|
71
|
+
end
|
72
|
+
attr_writer :tty
|
73
|
+
alias :tty? :tty
|
74
|
+
|
65
75
|
def puts(text=nil)
|
66
76
|
if not text.nil?
|
67
77
|
text = text.chomp
|
@@ -81,10 +91,12 @@ module TestBench
|
|
81
91
|
end
|
82
92
|
|
83
93
|
def style(style, *additional_styles)
|
84
|
-
|
94
|
+
control_code = Style.control_code(style)
|
95
|
+
control_codes = [control_code]
|
85
96
|
|
86
|
-
|
87
|
-
Style.control_code(style)
|
97
|
+
additional_styles.each do |style|
|
98
|
+
control_code = Style.control_code(style)
|
99
|
+
control_codes << control_code
|
88
100
|
end
|
89
101
|
|
90
102
|
if styling?
|
@@ -123,7 +135,7 @@ module TestBench
|
|
123
135
|
data.bytesize
|
124
136
|
end
|
125
137
|
|
126
|
-
def
|
138
|
+
def device_tty?
|
127
139
|
device.tty?
|
128
140
|
end
|
129
141
|
|
data/lib/test_bench/output.rb
CHANGED