test_bench-output 2.1.0.1 → 2.1.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f85510a137aac0904fe42a71910dce12ee9b3454bfff43194b2edb62d603bd4b
4
- data.tar.gz: e350be8bfd6a09075e60f14f5e72cf6b63e20834c66ed61bfa258804834ac311
3
+ metadata.gz: d77fe7175bda6a0810ed9209d34eec5f77062cf64d14940fd96fdb5bf8fc7ad4
4
+ data.tar.gz: bbb2bfe7f8c18ed94e67084404f96463134792cff5ab5a22fa141ee0c219989d
5
5
  SHA512:
6
- metadata.gz: 8c5ef96b2a29119bdbfa6a59e693ab24bd7ffa54ed1bfd2efcda5679b421d484ee2af84ec0eac47ea1fad8a06d592b73fb7d31a2c554a5dd630db4145e5f4e0e
7
- data.tar.gz: eec82715d42065ad222c69647626fb56a19d138edeef66a9c1b7d68e1f632bebe15b08112d6625f4cf72006eb83536da09e5ef64f600398f240d60d2d74ef26b
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 + data.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
- styles = [style, *additional_styles]
94
+ control_code = Style.control_code(style)
95
+ control_codes = [control_code]
85
96
 
86
- control_codes = styles.map do |style|
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 tty?
138
+ def device_tty?
127
139
  device.tty?
128
140
  end
129
141
 
@@ -1,5 +1,3 @@
1
- require 'io/console'
2
-
3
1
  require 'test_bench/telemetry'
4
2
 
5
3
  require 'test_bench/output/digest'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_bench-output
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0.1
4
+ version: 2.1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Ladd