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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f85510a137aac0904fe42a71910dce12ee9b3454bfff43194b2edb62d603bd4b
4
- data.tar.gz: e350be8bfd6a09075e60f14f5e72cf6b63e20834c66ed61bfa258804834ac311
3
+ metadata.gz: 97c8ae8dea0797ddba31f74ce70e3ca06e31b48552e3a06c656bdf6180405bbb
4
+ data.tar.gz: 3ecb60c68261649f24a6daec63f2253316937fb5081fdb6f76bb23f7f80d2269
5
5
  SHA512:
6
- metadata.gz: 8c5ef96b2a29119bdbfa6a59e693ab24bd7ffa54ed1bfd2efcda5679b421d484ee2af84ec0eac47ea1fad8a06d592b73fb7d31a2c554a5dd630db4145e5f4e0e
7
- data.tar.gz: eec82715d42065ad222c69647626fb56a19d138edeef66a9c1b7d68e1f632bebe15b08112d6625f4cf72006eb83536da09e5ef64f600398f240d60d2d74ef26b
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 + 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
 
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Ladd