whirled_peas 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +315 -43
- data/Rakefile +8 -18
- data/lib/whirled_peas/graphics.rb +14 -0
- data/lib/whirled_peas/graphics/box_painter.rb +39 -46
- data/lib/whirled_peas/graphics/canvas.rb +22 -11
- data/lib/whirled_peas/graphics/container_coords.rb +6 -5
- data/lib/whirled_peas/graphics/container_dimensions.rb +26 -8
- data/lib/whirled_peas/graphics/container_painter.rb +42 -4
- data/lib/whirled_peas/graphics/grid_painter.rb +11 -10
- data/lib/whirled_peas/graphics/painter.rb +5 -1
- data/lib/whirled_peas/graphics/renderer.rb +6 -1
- data/lib/whirled_peas/graphics/text_painter.rb +2 -2
- data/lib/whirled_peas/settings/alignment.rb +24 -0
- data/lib/whirled_peas/settings/bg_color.rb +2 -0
- data/lib/whirled_peas/settings/border.rb +16 -16
- data/lib/whirled_peas/settings/color.rb +13 -14
- data/lib/whirled_peas/settings/container_settings.rb +126 -42
- data/lib/whirled_peas/settings/display_flow.rb +13 -11
- data/lib/whirled_peas/settings/element_settings.rb +3 -3
- data/lib/whirled_peas/settings/grid_settings.rb +5 -1
- data/lib/whirled_peas/settings/sizing.rb +19 -0
- data/lib/whirled_peas/settings/spacing.rb +34 -0
- data/lib/whirled_peas/settings/text_color.rb +2 -0
- data/lib/whirled_peas/settings/vert_alignment.rb +24 -0
- data/lib/whirled_peas/utils/title_font.rb +1 -1
- data/lib/whirled_peas/version.rb +1 -1
- data/screen_test/{rendered/elements → elements}/box.frame +1 -1
- data/screen_test/{rendered/elements → elements}/box.rb +0 -0
- data/screen_test/elements/grid.frame +1 -0
- data/screen_test/{rendered/elements → elements}/grid.rb +0 -0
- data/screen_test/elements/screen_overflow_x.frame +1 -0
- data/screen_test/{rendered/elements/screen_overflow.rb → elements/screen_overflow_x.rb} +0 -0
- data/screen_test/elements/screen_overflow_y.frame +1 -0
- data/screen_test/elements/screen_overflow_y.rb +9 -0
- data/screen_test/elements/text.frame +1 -0
- data/screen_test/{rendered/elements → elements}/text.rb +0 -0
- data/screen_test/elements/text_multiline.frame +1 -0
- data/screen_test/{rendered/elements → elements}/text_multiline.rb +0 -0
- data/screen_test/settings/align/box_around.frame +1 -0
- data/screen_test/settings/align/box_around.rb +16 -0
- data/screen_test/settings/align/box_between.frame +1 -0
- data/screen_test/settings/align/box_between.rb +16 -0
- data/screen_test/settings/align/box_center.frame +1 -0
- data/screen_test/{rendered/settings/align/grid.rb → settings/align/box_center.rb} +7 -6
- data/screen_test/settings/align/box_default.frame +1 -0
- data/screen_test/settings/align/box_default.rb +20 -0
- data/screen_test/settings/align/box_evenly.frame +1 -0
- data/screen_test/settings/align/box_evenly.rb +16 -0
- data/screen_test/settings/align/box_left.frame +1 -0
- data/screen_test/settings/align/box_left.rb +21 -0
- data/screen_test/settings/align/box_right.frame +1 -0
- data/screen_test/settings/align/box_right.rb +21 -0
- data/screen_test/settings/align/children_center.frame +1 -0
- data/screen_test/settings/align/children_center.rb +15 -0
- data/screen_test/settings/align/children_left.frame +1 -0
- data/screen_test/settings/align/children_left.rb +15 -0
- data/screen_test/settings/align/children_right.frame +1 -0
- data/screen_test/settings/align/children_right.rb +15 -0
- data/screen_test/settings/align/grid_center.frame +1 -0
- data/screen_test/settings/align/grid_center.rb +18 -0
- data/screen_test/settings/align/grid_default.frame +1 -0
- data/screen_test/settings/align/grid_default.rb +17 -0
- data/screen_test/settings/align/grid_left.frame +1 -0
- data/screen_test/settings/align/grid_left.rb +18 -0
- data/screen_test/settings/align/grid_right.frame +1 -0
- data/screen_test/settings/align/grid_right.rb +18 -0
- data/screen_test/settings/ansi/bold.frame +1 -0
- data/screen_test/{rendered/settings/height/overflow_box_t2b.rb → settings/ansi/bold.rb} +4 -4
- data/screen_test/{rendered/settings → settings}/ansi/color.frame +1 -1
- data/screen_test/{rendered/settings → settings}/ansi/color.rb +0 -0
- data/screen_test/settings/ansi/underline.frame +1 -0
- data/screen_test/{rendered/settings → settings}/ansi/underline.rb +4 -5
- data/screen_test/{rendered/settings → settings}/border.frame +1 -1
- data/screen_test/{rendered/settings → settings}/border.rb +1 -1
- data/screen_test/settings/flow/box_b2t.frame +1 -0
- data/screen_test/settings/flow/box_b2t.rb +26 -0
- data/screen_test/settings/flow/box_l2r.frame +1 -0
- data/screen_test/settings/flow/box_l2r.rb +26 -0
- data/screen_test/settings/flow/box_r2l.frame +1 -0
- data/screen_test/settings/flow/box_r2l.rb +26 -0
- data/screen_test/settings/flow/box_t2b.frame +1 -0
- data/screen_test/settings/flow/box_t2b.rb +26 -0
- data/screen_test/settings/flow/grid_b2t.frame +1 -0
- data/screen_test/{rendered/settings → settings}/flow/grid_b2t.rb +0 -0
- data/screen_test/settings/flow/grid_l2r.frame +1 -0
- data/screen_test/{rendered/settings → settings}/flow/grid_l2r.rb +0 -0
- data/screen_test/settings/flow/grid_r2l.frame +1 -0
- data/screen_test/{rendered/settings → settings}/flow/grid_r2l.rb +0 -0
- data/screen_test/settings/flow/grid_t2b.frame +1 -0
- data/screen_test/{rendered/settings → settings}/flow/grid_t2b.rb +0 -0
- data/screen_test/settings/height/box.frame +1 -0
- data/screen_test/{rendered/settings → settings}/height/box.rb +0 -0
- data/screen_test/settings/height/box_border_sizing.frame +1 -0
- data/screen_test/settings/height/box_border_sizing.rb +15 -0
- data/screen_test/settings/height/grid.frame +1 -0
- data/screen_test/{rendered/settings → settings}/height/grid.rb +0 -0
- data/screen_test/settings/height/overflow_box.frame +1 -0
- data/screen_test/settings/height/overflow_box.rb +13 -0
- data/screen_test/settings/height/overflow_box_l2r.frame +1 -0
- data/screen_test/settings/height/overflow_box_l2r.rb +17 -0
- data/screen_test/settings/height/overflow_box_t2b.frame +1 -0
- data/screen_test/settings/height/overflow_box_t2b.rb +16 -0
- data/screen_test/settings/height/overflow_grid.frame +1 -0
- data/screen_test/{rendered/settings → settings}/height/overflow_grid.rb +0 -0
- data/screen_test/settings/margin.frame +1 -0
- data/screen_test/settings/margin.rb +16 -0
- data/screen_test/settings/padding.frame +1 -0
- data/screen_test/settings/padding.rb +13 -0
- data/screen_test/settings/position/box_left.frame +1 -0
- data/screen_test/{rendered/settings → settings}/position/box_left.rb +2 -2
- data/screen_test/settings/position/box_left_negative.frame +1 -0
- data/screen_test/{rendered/settings → settings}/position/box_left_negative.rb +2 -2
- data/screen_test/settings/position/box_top.frame +1 -0
- data/screen_test/{rendered/settings → settings}/position/box_top.rb +1 -1
- data/screen_test/settings/position/box_top_negative.frame +1 -0
- data/screen_test/{rendered/settings → settings}/position/box_top_negative.rb +2 -2
- data/screen_test/settings/position/grid_left.frame +1 -0
- data/screen_test/{rendered/settings → settings}/position/grid_left.rb +1 -1
- data/screen_test/settings/position/grid_left_negative.frame +1 -0
- data/screen_test/{rendered/settings → settings}/position/grid_left_negative.rb +1 -1
- data/screen_test/settings/position/grid_top.frame +1 -0
- data/screen_test/{rendered/settings → settings}/position/grid_top.rb +1 -1
- data/screen_test/settings/position/grid_top_negative.frame +1 -0
- data/screen_test/{rendered/settings → settings}/position/grid_top_negative.rb +1 -1
- data/screen_test/settings/scroll/horiz_box.frame +1 -0
- data/screen_test/settings/scroll/horiz_box.rb +17 -0
- data/screen_test/settings/scroll/horiz_box_align_center.rb +18 -0
- data/screen_test/settings/scroll/horiz_box_align_right.rb +18 -0
- data/screen_test/settings/scroll/vert_box.frame +1 -0
- data/screen_test/settings/scroll/vert_box.rb +20 -0
- data/screen_test/settings/title_font.frame +1 -0
- data/screen_test/{rendered/settings → settings}/title_font.rb +1 -1
- data/screen_test/settings/valign/box_around.frame +1 -0
- data/screen_test/settings/valign/box_around.rb +17 -0
- data/screen_test/settings/valign/box_between.frame +1 -0
- data/screen_test/settings/valign/box_between.rb +17 -0
- data/screen_test/settings/valign/box_bottom.frame +1 -0
- data/screen_test/settings/valign/box_bottom.rb +17 -0
- data/screen_test/settings/valign/box_default.frame +1 -0
- data/screen_test/settings/valign/box_default.rb +16 -0
- data/screen_test/settings/valign/box_evenly.frame +1 -0
- data/screen_test/settings/valign/box_evenly.rb +17 -0
- data/screen_test/settings/valign/box_middle.frame +1 -0
- data/screen_test/settings/valign/box_middle.rb +17 -0
- data/screen_test/settings/valign/box_top.frame +1 -0
- data/screen_test/settings/valign/box_top.rb +17 -0
- data/screen_test/settings/valign/grid_bottom.frame +1 -0
- data/screen_test/settings/valign/grid_bottom.rb +15 -0
- data/screen_test/settings/valign/grid_default.frame +1 -0
- data/screen_test/settings/valign/grid_default.rb +14 -0
- data/screen_test/settings/valign/grid_middle.frame +1 -0
- data/screen_test/settings/valign/grid_middle.rb +15 -0
- data/screen_test/settings/valign/grid_top.frame +1 -0
- data/screen_test/settings/valign/grid_top.rb +15 -0
- data/screen_test/settings/width/box_border_sizing.frame +1 -0
- data/screen_test/settings/width/box_border_sizing.rb +15 -0
- data/screen_test/settings/width/box_content.frame +1 -0
- data/screen_test/settings/width/box_content.rb +15 -0
- data/screen_test/settings/width/box_default.frame +1 -0
- data/screen_test/{rendered/settings/width/box.rb → settings/width/box_default.rb} +3 -2
- data/screen_test/settings/width/grid.frame +1 -0
- data/screen_test/{rendered/settings → settings}/width/grid.rb +2 -2
- data/screen_test/settings/width/overflow_align_center.frame +1 -0
- data/screen_test/settings/width/overflow_align_center.rb +14 -0
- data/screen_test/settings/width/overflow_align_right.frame +1 -0
- data/screen_test/settings/width/overflow_align_right.rb +14 -0
- data/screen_test/settings/width/overflow_box.frame +1 -0
- data/screen_test/settings/width/overflow_box.rb +13 -0
- data/screen_test/settings/width/overflow_box_l2r.frame +1 -0
- data/screen_test/settings/width/overflow_box_l2r.rb +16 -0
- data/screen_test/settings/width/overflow_box_t2b.frame +1 -0
- data/screen_test/settings/width/overflow_box_t2b.rb +17 -0
- data/screen_test/settings/width/overflow_grid.frame +1 -0
- data/screen_test/{rendered/settings → settings}/width/overflow_grid.rb +0 -0
- data/tools/whirled_peas/tools/screen_tester.rb +233 -0
- metadata +154 -98
- data/lib/whirled_peas/settings/text_align.rb +0 -19
- data/screen_test/rendered/elements/grid.frame +0 -1
- data/screen_test/rendered/elements/screen_overflow.frame +0 -1
- data/screen_test/rendered/elements/text.frame +0 -1
- data/screen_test/rendered/elements/text_multiline.frame +0 -1
- data/screen_test/rendered/settings/align/box.frame +0 -1
- data/screen_test/rendered/settings/align/box.rb +0 -24
- data/screen_test/rendered/settings/align/children_center.frame +0 -1
- data/screen_test/rendered/settings/align/children_center.rb +0 -13
- data/screen_test/rendered/settings/align/children_left.frame +0 -1
- data/screen_test/rendered/settings/align/children_left.rb +0 -13
- data/screen_test/rendered/settings/align/children_right.frame +0 -1
- data/screen_test/rendered/settings/align/children_right.rb +0 -13
- data/screen_test/rendered/settings/align/grid.frame +0 -1
- data/screen_test/rendered/settings/ansi/bold.frame +0 -1
- data/screen_test/rendered/settings/ansi/bold.rb +0 -15
- data/screen_test/rendered/settings/ansi/underline.frame +0 -1
- data/screen_test/rendered/settings/flow/box_b2t.frame +0 -1
- data/screen_test/rendered/settings/flow/box_b2t.rb +0 -24
- data/screen_test/rendered/settings/flow/box_l2r.frame +0 -1
- data/screen_test/rendered/settings/flow/box_l2r.rb +0 -24
- data/screen_test/rendered/settings/flow/box_r2l.frame +0 -1
- data/screen_test/rendered/settings/flow/box_r2l.rb +0 -24
- data/screen_test/rendered/settings/flow/box_t2b.frame +0 -1
- data/screen_test/rendered/settings/flow/box_t2b.rb +0 -24
- data/screen_test/rendered/settings/flow/grid_b2t.frame +0 -1
- data/screen_test/rendered/settings/flow/grid_l2r.frame +0 -1
- data/screen_test/rendered/settings/flow/grid_r2l.frame +0 -1
- data/screen_test/rendered/settings/flow/grid_t2b.frame +0 -1
- data/screen_test/rendered/settings/height/box.frame +0 -1
- data/screen_test/rendered/settings/height/grid.frame +0 -1
- data/screen_test/rendered/settings/height/overflow_box.frame +0 -1
- data/screen_test/rendered/settings/height/overflow_box.rb +0 -13
- data/screen_test/rendered/settings/height/overflow_box_l2r.frame +0 -1
- data/screen_test/rendered/settings/height/overflow_box_l2r.rb +0 -15
- data/screen_test/rendered/settings/height/overflow_box_t2b.frame +0 -1
- data/screen_test/rendered/settings/height/overflow_grid.frame +0 -1
- data/screen_test/rendered/settings/margin.frame +0 -1
- data/screen_test/rendered/settings/margin.rb +0 -14
- data/screen_test/rendered/settings/padding.frame +0 -1
- data/screen_test/rendered/settings/padding.rb +0 -11
- data/screen_test/rendered/settings/position/box_left.frame +0 -1
- data/screen_test/rendered/settings/position/box_left_negative.frame +0 -1
- data/screen_test/rendered/settings/position/box_top.frame +0 -1
- data/screen_test/rendered/settings/position/box_top_negative.frame +0 -1
- data/screen_test/rendered/settings/position/grid_left.frame +0 -1
- data/screen_test/rendered/settings/position/grid_left_negative.frame +0 -1
- data/screen_test/rendered/settings/position/grid_top.frame +0 -1
- data/screen_test/rendered/settings/position/grid_top_negative.frame +0 -1
- data/screen_test/rendered/settings/scroll/horiz_box.frame +0 -1
- data/screen_test/rendered/settings/scroll/horiz_box.rb +0 -15
- data/screen_test/rendered/settings/scroll/vert_box.frame +0 -1
- data/screen_test/rendered/settings/scroll/vert_box.rb +0 -18
- data/screen_test/rendered/settings/title_font.frame +0 -1
- data/screen_test/rendered/settings/width/box.frame +0 -1
- data/screen_test/rendered/settings/width/grid.frame +0 -1
- data/screen_test/rendered/settings/width/overflow_box.frame +0 -1
- data/screen_test/rendered/settings/width/overflow_box.rb +0 -11
- data/screen_test/rendered/settings/width/overflow_box_l2r.frame +0 -1
- data/screen_test/rendered/settings/width/overflow_box_l2r.rb +0 -14
- data/screen_test/rendered/settings/width/overflow_box_t2b.frame +0 -1
- data/screen_test/rendered/settings/width/overflow_box_t2b.rb +0 -15
- data/screen_test/rendered/settings/width/overflow_grid.frame +0 -1
- data/screen_test/screen_tester.rb +0 -201
@@ -1 +0,0 @@
|
|
1
|
-
[?25l[1;1H[J[1;1H[37m┏━━━━━━━━━━┓[0m[2;1H[37m┃ ┃[0m[3;1H[37m┃ ┃[0m[4;1H[37m┃ ┃[0m[5;1H[37m┃ ┃[0m[6;1H[37m┃ ┃[0m[7;1H[37m┃ ┃[0m[8;1H[37m┃ ┃[0m[9;1H[37m┃ ┃[0m[10;1H[37m┃ ┃[0m[11;1H[37m┃ ┃[0m[12;1H[37m┗━━━━━━━━━━┛[0m[2;2HXO[3;2HXOXO[4;2HXOXOXO[5;2HXOXOXOXO[6;2HXOXOXOXOXO[7;2HXOXOXOXOXO[8;2HXOXOXOXOXO[9;2HXOXOXOXOXO[10;2HXOXOXOXOXO[11;2HXOXOXOXOXO[0m[32;1H[?25h
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'whirled_peas'
|
2
|
-
|
3
|
-
class TemplateFactory
|
4
|
-
def build(*)
|
5
|
-
WhirledPeas.template do |composer, settings|
|
6
|
-
settings.width = 10
|
7
|
-
settings.flow = :t2b
|
8
|
-
settings.full_border
|
9
|
-
str = ''
|
10
|
-
10.times do
|
11
|
-
composer.add_text { str += 'XO' }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
[?25l[1;1H[J[1;1H[37m┏━━━━━━━━━━┓[0m[2;1H[37m┃ ┃[0m[3;1H[37m┗━━━━━━━━━━┛[0m[2;2HABCDEFGHIJ[0m[32;1H[?25h
|
@@ -1,201 +0,0 @@
|
|
1
|
-
require 'bundler/setup'
|
2
|
-
require 'whirled_peas'
|
3
|
-
require 'whirled_peas/frame/event_loop'
|
4
|
-
require 'whirled_peas/frame/producer'
|
5
|
-
require 'whirled_peas/graphics/debugger'
|
6
|
-
require 'whirled_peas/graphics/renderer'
|
7
|
-
require 'whirled_peas/graphics/screen'
|
8
|
-
require 'whirled_peas/settings/text_color'
|
9
|
-
require 'whirled_peas/utils/formatted_string'
|
10
|
-
|
11
|
-
module WhirledPeas
|
12
|
-
class ScreenTester
|
13
|
-
SCREEN_WIDTH = 80
|
14
|
-
SCREEN_HEIGHT = 32
|
15
|
-
|
16
|
-
def self.run_all
|
17
|
-
base_dir = File.dirname(__FILE__)
|
18
|
-
test_files = Dir.glob(File.join(base_dir, 'rendered', '**', '*.rb'))
|
19
|
-
failures = {}
|
20
|
-
pendings = Set.new
|
21
|
-
puts "Running #{test_files.length} rendered screen test(s)"
|
22
|
-
puts
|
23
|
-
test_files.each do |file|
|
24
|
-
tester = new(file)
|
25
|
-
if tester.pending?
|
26
|
-
print Utils::FormattedString.new('.', Settings::TextColor::YELLOW)
|
27
|
-
pendings << file
|
28
|
-
elsif tester.failed?
|
29
|
-
print Utils::FormattedString.new('.', Settings::TextColor::RED)
|
30
|
-
failures[file] = tester.error
|
31
|
-
else
|
32
|
-
print Utils::FormattedString.new('.', Settings::TextColor::GREEN)
|
33
|
-
end
|
34
|
-
STDOUT.flush
|
35
|
-
end
|
36
|
-
puts
|
37
|
-
puts if pendings.count > 0
|
38
|
-
pendings.each do |file|
|
39
|
-
puts Utils::FormattedString.new("PENDING: #{file}", Settings::TextColor::YELLOW)
|
40
|
-
end
|
41
|
-
puts if failures.count > 0
|
42
|
-
failures.each do |file, error|
|
43
|
-
puts Utils::FormattedString.new("Failed: #{file}:\n\n #{error}\n", Settings::TextColor::RED)
|
44
|
-
end
|
45
|
-
|
46
|
-
if failures.count == 0
|
47
|
-
puts
|
48
|
-
puts Utils::FormattedString.new('No failures', Settings::TextColor::GREEN)
|
49
|
-
else
|
50
|
-
exit(1)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.update_all
|
55
|
-
base_dir = File.dirname(__FILE__)
|
56
|
-
test_files = Dir.glob(File.join(base_dir, 'rendered', '**', '*.rb'))
|
57
|
-
test_files.each do |file|
|
58
|
-
tester = new(file)
|
59
|
-
if tester.pending?
|
60
|
-
tester.ask_pending
|
61
|
-
elsif tester.failed?
|
62
|
-
tester.ask_failed
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
attr_reader :error
|
68
|
-
|
69
|
-
def initialize(test_file)
|
70
|
-
@full_test_file = test_file[0] == '/' ? test_file : File.join(Dir.pwd, test_file)
|
71
|
-
raise ArgumentError, "File not found: #{test_file}" unless File.exist?(@full_test_file)
|
72
|
-
@test_file = test_file.sub(File.dirname(__FILE__), '')[1..-1]
|
73
|
-
@full_output_file = @full_test_file.sub(/\.rb$/, '.frame')
|
74
|
-
@output_file = @full_output_file.sub(File.dirname(__FILE__), '')[1..-1]
|
75
|
-
end
|
76
|
-
|
77
|
-
def pending?
|
78
|
-
!File.exist?(full_output_file)
|
79
|
-
end
|
80
|
-
|
81
|
-
def failed?
|
82
|
-
if rendered != File.read(full_output_file)
|
83
|
-
@error = 'Rendered output does not match saved output'
|
84
|
-
end
|
85
|
-
!@error.nil?
|
86
|
-
end
|
87
|
-
|
88
|
-
def view
|
89
|
-
with_template_factory do |template_factory|
|
90
|
-
render_screen(template_factory, STDOUT)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def debug
|
95
|
-
with_template_factory do |template_factory|
|
96
|
-
render_screen(template_factory, StringIO.new)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def template
|
101
|
-
with_template_factory do |template_factory|
|
102
|
-
template = template_factory.build('Test', {})
|
103
|
-
puts Graphics::Debugger.new(template).debug
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def save
|
108
|
-
if File.exist?(full_output_file)
|
109
|
-
puts "Existing output file found: #{full_output_file}"
|
110
|
-
puts "overwriting..."
|
111
|
-
else
|
112
|
-
puts "Writing output to file: #{full_output_file}"
|
113
|
-
end
|
114
|
-
|
115
|
-
with_template_factory do |template_factory|
|
116
|
-
File.open(full_output_file, 'w') do |file|
|
117
|
-
render_screen(template_factory, file)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def ask_pending
|
123
|
-
puts Utils::FormattedString.new("Frame file does not exist for #{test_file}", Settings::TextColor::YELLOW)
|
124
|
-
print 'View rendered frame? [Y/n/q] '
|
125
|
-
STDOUT.flush
|
126
|
-
response = STDIN.gets.strip.downcase
|
127
|
-
case response
|
128
|
-
when 'q'
|
129
|
-
exit
|
130
|
-
when 'n'
|
131
|
-
return
|
132
|
-
end
|
133
|
-
print rendered
|
134
|
-
STDOUT.flush
|
135
|
-
ask_to_save
|
136
|
-
end
|
137
|
-
|
138
|
-
def ask_failed
|
139
|
-
puts Utils::FormattedString.new("Output from test does not match saved output for #{test_file}", Settings::TextColor::RED)
|
140
|
-
print 'View expected output? [Y/q] '
|
141
|
-
STDOUT.flush
|
142
|
-
exit if 'q' == STDIN.gets.strip.downcase
|
143
|
-
print File.read(full_output_file)
|
144
|
-
print 'View actual output? [Y/q] '
|
145
|
-
STDOUT.flush
|
146
|
-
exit if 'q' == STDIN.gets.strip.downcase
|
147
|
-
print rendered
|
148
|
-
STDOUT.flush
|
149
|
-
ask_to_save
|
150
|
-
end
|
151
|
-
|
152
|
-
private
|
153
|
-
|
154
|
-
attr_reader :full_test_file, :test_file, :full_output_file, :output_file
|
155
|
-
|
156
|
-
def ask_to_save
|
157
|
-
print "Save actual as the expected test output (#{output_file})? [y/N/q] "
|
158
|
-
STDOUT.flush
|
159
|
-
response = STDIN.gets.strip.downcase
|
160
|
-
print Utils::Ansi.cursor_pos(left: 0, top: 0)
|
161
|
-
print Utils::Ansi.clear_down
|
162
|
-
if response == 'y'
|
163
|
-
File.open(full_output_file, 'w') { |file| file.print(rendered) }
|
164
|
-
puts "Saved to #{output_file}"
|
165
|
-
elsif response == 'q'
|
166
|
-
puts 'Exiting'
|
167
|
-
exit
|
168
|
-
else
|
169
|
-
puts 'Skipped'
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
def rendered
|
174
|
-
@rendered ||= begin
|
175
|
-
string_io = StringIO.new
|
176
|
-
with_template_factory do |template_factory|
|
177
|
-
render_screen(template_factory, string_io)
|
178
|
-
end
|
179
|
-
string_io.string
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
def with_template_factory(&block)
|
184
|
-
require full_test_file
|
185
|
-
raise 'TemplateFactory must be defined' unless defined?(TemplateFactory)
|
186
|
-
yield TemplateFactory.new
|
187
|
-
ensure
|
188
|
-
Object.send(:remove_const, :TemplateFactory)
|
189
|
-
end
|
190
|
-
|
191
|
-
def render_screen(template_factory, output)
|
192
|
-
screen = Graphics::Screen.new(output: output, width: SCREEN_WIDTH, height: SCREEN_HEIGHT)
|
193
|
-
consumer = Frame::EventLoop.new(
|
194
|
-
template_factory, screen: screen, refresh_rate: 100000
|
195
|
-
)
|
196
|
-
Frame::Producer.produce(consumer) do |producer|
|
197
|
-
producer.send_frame('test', args: {})
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|