test_bench-output 2.1.1.2 → 3.0.0.0.pre.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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/test_bench/output/comment_style.rb +61 -0
  3. data/lib/test_bench/output/controls/comment_style.rb +21 -0
  4. data/lib/test_bench/output/controls/event.rb +2 -2
  5. data/lib/test_bench/output/controls/events/aborted.rb +9 -0
  6. data/lib/test_bench/output/controls/events/commented.rb +21 -0
  7. data/lib/test_bench/output/controls/events/context_finished.rb +9 -0
  8. data/lib/test_bench/output/controls/events/context_started.rb +9 -0
  9. data/lib/test_bench/output/controls/events/detailed.rb +21 -0
  10. data/lib/test_bench/output/controls/events/failed.rb +9 -0
  11. data/lib/test_bench/output/controls/events/file_executed.rb +9 -0
  12. data/lib/test_bench/output/controls/events/file_not_found.rb +9 -0
  13. data/lib/test_bench/output/controls/events/file_queued.rb +9 -0
  14. data/lib/test_bench/output/controls/events/skipped.rb +9 -0
  15. data/lib/test_bench/output/controls/events/test_finished.rb +9 -0
  16. data/lib/test_bench/output/controls/events/test_started.rb +9 -0
  17. data/lib/test_bench/output/controls/random.rb +2 -2
  18. data/lib/test_bench/output/controls/session.rb +17 -0
  19. data/lib/test_bench/output/controls/status.rb +7 -0
  20. data/lib/test_bench/output/controls/style.rb +14 -6
  21. data/lib/test_bench/output/controls/text.rb +16 -4
  22. data/lib/test_bench/output/controls.rb +21 -5
  23. data/lib/test_bench/output/detail_policy.rb +44 -0
  24. data/lib/test_bench/output/device/null.rb +3 -3
  25. data/lib/test_bench/output/device/substitute.rb +19 -33
  26. data/lib/test_bench/output/device.rb +73 -0
  27. data/lib/test_bench/output/get.rb +30 -0
  28. data/lib/test_bench/output/level.rb +51 -0
  29. data/lib/test_bench/output/output.rb +540 -36
  30. data/lib/test_bench/output/writer/style.rb +5 -3
  31. data/lib/test_bench/output/writer/substitute.rb +10 -23
  32. data/lib/test_bench/output/writer.rb +54 -147
  33. data/lib/test_bench/output.rb +10 -4
  34. metadata +49 -21
  35. data/lib/test_bench/output/controls/data.rb +0 -49
  36. data/lib/test_bench/output/controls/device.rb +0 -27
  37. data/lib/test_bench/output/controls/output.rb +0 -34
  38. data/lib/test_bench/output/controls/styling.rb +0 -27
  39. data/lib/test_bench/output/digest.rb +0 -113
  40. data/lib/test_bench/output/writer/buffer.rb +0 -57
  41. data/lib/test_bench/output/writer/defaults.rb +0 -11
@@ -1,36 +1,23 @@
1
1
  module TestBench
2
- module Output
2
+ class Output
3
3
  class Writer
4
4
  module Substitute
5
5
  def self.build
6
- Writer.build
6
+ Writer.new
7
7
  end
8
8
 
9
- def self.included(cls)
10
- cls.class_exec do
11
- extend Build
9
+ class Writer < Writer
10
+ def set_styling
11
+ self.styling = true
12
12
  end
13
- end
14
13
 
15
- def written_data
16
- device.written_data
17
- end
18
- alias :written_text :written_data
19
-
20
- def styling!
21
- self.styling_policy = Styling.on
22
- end
23
-
24
- module Build
25
- def build
26
- instance = new
27
- instance.buffer.limit = 0
28
- instance
14
+ def written?(text=nil)
15
+ device.written?(text)
29
16
  end
30
- end
31
17
 
32
- class Writer < Writer
33
- include Substitute
18
+ def written_text
19
+ device.written_text
20
+ end
34
21
  end
35
22
  end
36
23
  end
@@ -1,208 +1,115 @@
1
1
  module TestBench
2
- module Output
2
+ class Output
3
3
  class Writer
4
4
  def device
5
5
  @device ||= Device::Substitute.build
6
6
  end
7
7
  attr_writer :device
8
8
 
9
- def styling_policy
10
- @styling_policy ||= Styling.default
11
- end
12
- alias :styling :styling_policy
13
- attr_writer :styling_policy
14
-
15
- def digest
16
- @digest ||= Digest.new
17
- end
18
- attr_writer :digest
19
-
20
- def sequence
21
- @sequence ||= 0
22
- end
23
- attr_writer :sequence
24
-
25
- def column_sequence
26
- @column_sequence ||= 0
27
- end
28
- attr_writer :column_sequence
29
-
30
- def buffer
31
- @buffer ||= Buffer.new
32
- end
33
- attr_writer :buffer
9
+ attr_accessor :styling
10
+ alias :styling? :styling
34
11
 
35
- def configure
36
- Buffer.configure(self)
12
+ def indentation_depth
13
+ @indentation_depth ||= 0
37
14
  end
15
+ attr_writer :indentation_depth
38
16
 
39
- def self.build(device=nil, styling: nil, inert_digest: nil)
40
- device ||= Defaults.device
41
-
17
+ def self.build(styling: nil, device: nil)
42
18
  instance = new
43
- instance.device = device
44
- instance.styling_policy = styling
45
19
 
46
- Digest.configure(instance, inert: inert_digest)
20
+ Device.configure(instance, device:)
21
+
22
+ device = instance.device
47
23
 
48
- instance.configure
24
+ styling = styling(styling, device)
25
+ instance.styling = styling
49
26
 
50
27
  instance
51
28
  end
52
29
 
53
- def self.configure(receiver, writer: nil, styling: nil, inert_digest: nil, device: nil, attr_name: nil)
30
+ def self.configure(receiver, styling: nil, device: nil, attr_name: nil)
54
31
  attr_name ||= :writer
55
32
 
56
- if not writer.nil?
57
- instance = writer
58
- else
59
- instance = build(device, styling:, inert_digest:)
60
- end
61
-
33
+ instance = build(styling:, device:)
62
34
  receiver.public_send(:"#{attr_name}=", instance)
63
35
  end
64
36
 
65
- def sync
66
- @sync.nil? ? @sync = true : @sync
37
+ def self.styling(styling_or_styling_policy, device)
38
+ case styling_or_styling_policy
39
+ in true | false => styling
40
+ return styling
41
+ in :detect | :on | :off => styling_policy
42
+ in nil
43
+ styling_policy = Defaults.styling_policy
44
+ end
45
+
46
+ case styling_policy
47
+ in :detect
48
+ device.tty?
49
+ in :on
50
+ true
51
+ in :off
52
+ false
53
+ end
67
54
  end
68
55
 
69
- def tty
70
- @tty.nil? ? @tty = device_tty? : @tty
56
+ def indent
57
+ indentation_width = 2 * indentation_depth
58
+
59
+ print(' ' * indentation_width)
71
60
  end
72
- attr_writer :tty
73
- alias :tty? :tty
74
61
 
75
62
  def puts(text=nil)
76
63
  if not text.nil?
77
- text = text.chomp
78
-
79
- print(text)
64
+ print(text.chomp)
80
65
  end
81
66
 
82
67
  style(:reset)
83
68
 
84
- if tty?
85
- write("\e[0K")
86
- end
87
-
88
- write("\n")
89
-
90
- self.column_sequence = 0
69
+ print("\n")
91
70
  end
92
71
 
93
72
  def style(style, *additional_styles)
94
- control_code = Style.control_code(style)
95
- control_codes = [control_code]
73
+ styles = [style, *additional_styles]
96
74
 
97
- additional_styles.each do |style|
98
- control_code = Style.control_code(style)
99
- control_codes << control_code
75
+ control_codes = styles.map do |style|
76
+ Style.control_code(style)
100
77
  end
101
78
 
102
79
  if styling?
103
- write("\e[#{control_codes.join(';')}m")
80
+ control_sequence = "\e[#{control_codes.join(';')}m"
81
+
82
+ print(control_sequence)
104
83
  end
105
84
 
106
85
  self
107
86
  end
108
87
 
109
88
  def print(text)
110
- self.column_sequence += text.length
111
-
112
89
  write(text)
113
90
 
114
91
  self
115
92
  end
116
93
 
117
- def write(data)
118
- if sync
119
- bytes_written = write!(data)
120
- else
121
- bytes_written = buffer.receive(data)
122
- end
123
-
124
- self.sequence += bytes_written
125
-
126
- data = data[0...bytes_written]
127
- digest.update(data)
128
-
129
- bytes_written
130
- end
131
-
132
- def write!(data)
133
- device.write(data)
134
-
135
- data.bytesize
136
- end
137
-
138
- def device_tty?
139
- device.tty?
140
- end
141
-
142
- def flush
143
- buffer.flush(device)
144
- end
145
-
146
- def sync=(sync)
147
- @sync = sync
148
-
149
- if sync
150
- flush
151
- end
152
- end
153
-
154
- def written?(data=nil)
155
- if data.nil?
156
- sequence > 0
157
- else
158
- digest.digest?(data)
159
- end
94
+ def write(text)
95
+ device.write(text)
160
96
  end
161
97
 
162
- def current?(sequence)
163
- sequence >= self.sequence
98
+ def increase_indentation
99
+ self.indentation_depth += 1
164
100
  end
165
101
 
166
- def styling?
167
- Styling.styling?(styling_policy, tty?)
102
+ def decrease_indentation
103
+ self.indentation_depth -= 1
168
104
  end
169
105
 
170
- module Styling
171
- Error = Class.new(RuntimeError)
172
-
173
- def self.styling?(policy, console)
174
- assure_styling(policy, console)
175
- end
176
-
177
- def self.assure_styling(policy, console=nil)
178
- console ||= false
179
-
180
- case policy
181
- when on
182
- true
183
- when off
184
- false
185
- when detect
186
- console ? true : false
187
- else
188
- raise Error, "Unknown styling policy #{policy.inspect}"
189
- end
190
- end
106
+ module Defaults
107
+ def self.styling_policy
108
+ env_styling_policy = ENV.fetch('TEST_BENCH_OUTPUT_STYLING', 'detect')
191
109
 
192
- def self.on = :on
193
- def self.off = :off
194
- def self.detect = :detect
195
-
196
- def self.default
197
- policy = ENV.fetch('TEST_BENCH_OUTPUT_STYLING') do
198
- return default!
199
- end
200
-
201
- policy.to_sym
202
- end
110
+ styling_policy = env_styling_policy.to_sym
203
111
 
204
- def self.default!
205
- :detect
112
+ styling_policy
206
113
  end
207
114
  end
208
115
  end
@@ -1,14 +1,20 @@
1
- require 'test_bench/telemetry'
1
+ require 'import_constants'
2
2
 
3
- require 'test_bench/output/digest'
3
+ require 'test_bench/session'
4
4
 
5
5
  require 'test_bench/output/device/null'
6
6
  require 'test_bench/output/device/substitute'
7
+ require 'test_bench/output/device'
7
8
 
8
- require 'test_bench/output/writer/buffer'
9
9
  require 'test_bench/output/writer'
10
10
  require 'test_bench/output/writer/style'
11
11
  require 'test_bench/output/writer/substitute'
12
- require 'test_bench/output/writer/defaults'
12
+
13
+ require 'test_bench/output/comment_style'
14
+ require 'test_bench/output/detail_policy'
15
+
16
+ require 'test_bench/output/level'
13
17
 
14
18
  require 'test_bench/output/output'
19
+
20
+ require 'test_bench/output/get'
metadata CHANGED
@@ -1,17 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_bench-output
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1.2
4
+ version: 3.0.0.0.pre.1
5
5
  platform: ruby
6
6
  authors:
7
- - Nathan Ladd
8
- autorequire:
7
+ - Brightworks Digital
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date:
12
10
  dependencies:
13
11
  - !ruby/object:Gem::Dependency
14
- name: test_bench-telemetry
12
+ name: import_constants
15
13
  requirement: !ruby/object:Gem::Requirement
16
14
  requirements:
17
15
  - - ">="
@@ -25,7 +23,21 @@ dependencies:
25
23
  - !ruby/object:Gem::Version
26
24
  version: '0'
27
25
  - !ruby/object:Gem::Dependency
28
- name: test_bench-isolated
26
+ name: test_bench-session
27
+ requirement: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
32
+ type: :runtime
33
+ prerelease: false
34
+ version_requirements: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ - !ruby/object:Gem::Dependency
40
+ name: test_bench-bootstrap
29
41
  requirement: !ruby/object:Gem::Requirement
30
42
  requirements:
31
43
  - - ">="
@@ -38,41 +50,58 @@ dependencies:
38
50
  - - ">="
39
51
  - !ruby/object:Gem::Version
40
52
  version: '0'
41
- description:
42
- email: nathanladd+github@gmail.com
53
+ description: Test output writer for TestBench.
54
+ email: development@bright.works
43
55
  executables: []
44
56
  extensions: []
45
57
  extra_rdoc_files: []
46
58
  files:
47
59
  - lib/test_bench
48
60
  - lib/test_bench/output
61
+ - lib/test_bench/output/comment_style.rb
49
62
  - lib/test_bench/output/controls
50
- - lib/test_bench/output/controls/data.rb
51
- - lib/test_bench/output/controls/device.rb
63
+ - lib/test_bench/output/controls/comment_style.rb
52
64
  - lib/test_bench/output/controls/event.rb
53
- - lib/test_bench/output/controls/output.rb
65
+ - lib/test_bench/output/controls/events
66
+ - lib/test_bench/output/controls/events/aborted.rb
67
+ - lib/test_bench/output/controls/events/commented.rb
68
+ - lib/test_bench/output/controls/events/context_finished.rb
69
+ - lib/test_bench/output/controls/events/context_started.rb
70
+ - lib/test_bench/output/controls/events/detailed.rb
71
+ - lib/test_bench/output/controls/events/failed.rb
72
+ - lib/test_bench/output/controls/events/file_executed.rb
73
+ - lib/test_bench/output/controls/events/file_not_found.rb
74
+ - lib/test_bench/output/controls/events/file_queued.rb
75
+ - lib/test_bench/output/controls/events/skipped.rb
76
+ - lib/test_bench/output/controls/events/test_finished.rb
77
+ - lib/test_bench/output/controls/events/test_started.rb
54
78
  - lib/test_bench/output/controls/random.rb
79
+ - lib/test_bench/output/controls/session.rb
80
+ - lib/test_bench/output/controls/status.rb
55
81
  - lib/test_bench/output/controls/style.rb
56
- - lib/test_bench/output/controls/styling.rb
57
82
  - lib/test_bench/output/controls/text.rb
58
83
  - lib/test_bench/output/controls.rb
84
+ - lib/test_bench/output/detail_policy.rb
59
85
  - lib/test_bench/output/device
60
86
  - lib/test_bench/output/device/null.rb
61
87
  - lib/test_bench/output/device/substitute.rb
62
- - lib/test_bench/output/digest.rb
88
+ - lib/test_bench/output/device.rb
89
+ - lib/test_bench/output/get.rb
90
+ - lib/test_bench/output/level.rb
63
91
  - lib/test_bench/output/output.rb
64
92
  - lib/test_bench/output/writer
65
- - lib/test_bench/output/writer/buffer.rb
66
- - lib/test_bench/output/writer/defaults.rb
67
93
  - lib/test_bench/output/writer/style.rb
68
94
  - lib/test_bench/output/writer/substitute.rb
69
95
  - lib/test_bench/output/writer.rb
70
96
  - lib/test_bench/output.rb
71
- homepage: https://github.com/test-bench/test-bench-output
97
+ homepage: http://test-bench.software
72
98
  licenses:
73
99
  - MIT
74
- metadata: {}
75
- post_install_message:
100
+ metadata:
101
+ homepage_uri: http://test-bench.software
102
+ source_code_uri: https://github.com/test-bench-demo/test-bench-output
103
+ allowed_push_host: https://rubygems.org
104
+ namespace: TestBench::Output
76
105
  rdoc_options: []
77
106
  require_paths:
78
107
  - lib
@@ -87,8 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
116
  - !ruby/object:Gem::Version
88
117
  version: '0'
89
118
  requirements: []
90
- rubygems_version: 3.4.10
91
- signing_key:
119
+ rubygems_version: 3.6.9
92
120
  specification_version: 4
93
- summary: ruby
121
+ summary: Test output writer for TestBench
94
122
  test_files: []
@@ -1,49 +0,0 @@
1
- module TestBench
2
- module Output
3
- module Controls
4
- module Data
5
- def self.example
6
- "some-data"
7
- end
8
-
9
- def self.random
10
- suffix = Random.string
11
-
12
- "#{example}-#{suffix}"
13
- end
14
-
15
- module Digest
16
- def self.example
17
- '0123456789:;<=>'
18
- end
19
-
20
- def self.digest
21
- 0x3031323334353637 + 0x0038393A3B3C3D3E
22
- end
23
-
24
- module Equivalent
25
- module SameLength
26
- def self.example
27
- '0123456789:;<=>'
28
- end
29
-
30
- def self.digest
31
- Digest.digest
32
- end
33
- end
34
-
35
- module DifferentLength
36
- def self.example
37
- [Digest.digest].pack('Q>')
38
- end
39
-
40
- def self.digest
41
- Digest.digest
42
- end
43
- end
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end
@@ -1,27 +0,0 @@
1
- module TestBench
2
- module Output
3
- module Controls
4
- module Device
5
- def self.example
6
- TestBench::Output::Device::Substitute.build
7
- end
8
-
9
- module TTY
10
- def self.example(tty: nil)
11
- tty = true if tty.nil?
12
-
13
- device = Device.example
14
- device.tty! if tty
15
- device
16
- end
17
-
18
- module Non
19
- def self.example
20
- TTY.example(tty: false)
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,34 +0,0 @@
1
- module TestBench
2
- module Output
3
- module Controls
4
- module Output
5
- def self.example_class(&block)
6
- Class.new do
7
- include TestBench::Output
8
-
9
- class_exec(&block)
10
- end
11
- end
12
-
13
- class Example
14
- include TestBench::Output
15
- end
16
-
17
- module Configure
18
- class Example
19
- include TestBench::Output
20
- attr_accessor :some_attr
21
-
22
- def configure(some_attr: nil, **arguments)
23
- self.some_attr = some_attr
24
- end
25
-
26
- def configured?(some_attr)
27
- self.some_attr == some_attr
28
- end
29
- end
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,27 +0,0 @@
1
- module TestBench
2
- module Output
3
- module Controls
4
- module Styling
5
- def self.example
6
- Writer::Styling.on
7
- end
8
-
9
- def self.other_example
10
- Writer::Styling.off
11
- end
12
-
13
- def self.random
14
- stylings = [
15
- Writer::Styling.on,
16
- Writer::Styling.off,
17
- Writer::Styling.detect
18
- ]
19
-
20
- index = Random.integer % stylings.count
21
-
22
- stylings[index]
23
- end
24
- end
25
- end
26
- end
27
- end