test_bench-output 2.1.0.1 → 2.1.1.0
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
- 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: 97c8ae8dea0797ddba31f74ce70e3ca06e31b48552e3a06c656bdf6180405bbb
|
4
|
+
data.tar.gz: 3ecb60c68261649f24a6daec63f2253316937fb5081fdb6f76bb23f7f80d2269
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e686d19ee1293aa58553727eb96a151a54e3028a2998f4ce633d2bd00af02df6433f2afc7ce8019d1035bee1d841577438ba6a717d8b3e0167e5a3391c3ea9e
|
7
|
+
data.tar.gz: bf3258b0e25d03ec03dc0aeb4049ca6482ef0fe3871d9bbb267ac275a4bf4af604b1d3ca2d3393f725010b5323649ac21bd64c937a41ccadf73e60882948713f
|
@@ -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
|
|