whirled_peas 0.8.0 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (249) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -2
  3. data/CHANGELOG.md +23 -0
  4. data/README.md +9 -777
  5. data/doc/application.md +92 -0
  6. data/doc/cli.md +115 -0
  7. data/doc/components.md +55 -0
  8. data/doc/easing.md +257 -0
  9. data/doc/elements.md +69 -0
  10. data/doc/screen_test.md +23 -0
  11. data/doc/settings.md +466 -0
  12. data/doc/template_factory.md +53 -0
  13. data/doc/themes.md +15 -0
  14. data/examples/components.rb +35 -0
  15. data/examples/graph.rb +54 -0
  16. data/examples/scrolling.rb +9 -20
  17. data/lib/data/themes.yaml +17 -0
  18. data/lib/whirled_peas.rb +31 -9
  19. data/lib/whirled_peas/animator/frameset.rb +1 -1
  20. data/lib/whirled_peas/animator/producer.rb +1 -1
  21. data/lib/whirled_peas/command/config_command.rb +3 -3
  22. data/lib/whirled_peas/command/play.rb +4 -0
  23. data/lib/whirled_peas/command/themes.rb +77 -0
  24. data/lib/whirled_peas/command_line.rb +3 -1
  25. data/lib/whirled_peas/component.rb +35 -0
  26. data/lib/whirled_peas/component/list_with_active.rb +88 -0
  27. data/lib/whirled_peas/graphics/box_painter.rb +4 -4
  28. data/lib/whirled_peas/graphics/composer.rb +27 -2
  29. data/lib/whirled_peas/graphics/container_coords.rb +23 -25
  30. data/lib/whirled_peas/graphics/container_dimensions.rb +24 -0
  31. data/lib/whirled_peas/graphics/container_painter.rb +27 -139
  32. data/lib/whirled_peas/graphics/content_dimensions.rb +19 -0
  33. data/lib/whirled_peas/graphics/content_painter.rb +20 -0
  34. data/lib/whirled_peas/graphics/debugger.rb +2 -7
  35. data/lib/whirled_peas/graphics/graph_dimensions.rb +12 -0
  36. data/lib/whirled_peas/graphics/graph_painter.rb +104 -0
  37. data/lib/whirled_peas/graphics/grid_painter.rb +0 -3
  38. data/lib/whirled_peas/graphics/scrollbar_helper.rb +126 -0
  39. data/lib/whirled_peas/graphics/text_painter.rb +7 -11
  40. data/lib/whirled_peas/null_logger.rb +0 -1
  41. data/lib/whirled_peas/settings/bg_color.rb +5 -1
  42. data/lib/whirled_peas/settings/border.rb +25 -4
  43. data/lib/whirled_peas/settings/color.rb +8 -4
  44. data/lib/whirled_peas/settings/container_settings.rb +14 -9
  45. data/lib/whirled_peas/settings/debugger.rb +3 -1
  46. data/lib/whirled_peas/settings/element_settings.rb +22 -5
  47. data/lib/whirled_peas/settings/graph_settings.rb +21 -0
  48. data/lib/whirled_peas/settings/grid_settings.rb +7 -0
  49. data/lib/whirled_peas/settings/position.rb +17 -5
  50. data/lib/whirled_peas/settings/text_color.rb +5 -0
  51. data/lib/whirled_peas/settings/text_settings.rb +1 -0
  52. data/lib/whirled_peas/settings/theme.rb +61 -0
  53. data/lib/whirled_peas/settings/theme_library.rb +69 -0
  54. data/lib/whirled_peas/utils/ansi.rb +1 -1
  55. data/lib/whirled_peas/version.rb +1 -1
  56. data/screen_test/components/list_with_active/l2r_active_color.frame +1 -0
  57. data/screen_test/components/list_with_active/l2r_active_color.rb +18 -0
  58. data/screen_test/components/list_with_active/l2r_position_end.frame +1 -0
  59. data/screen_test/components/list_with_active/l2r_position_end.rb +16 -0
  60. data/screen_test/components/list_with_active/l2r_position_middle.frame +1 -0
  61. data/screen_test/components/list_with_active/l2r_position_middle.rb +16 -0
  62. data/screen_test/components/list_with_active/l2r_position_start.frame +1 -0
  63. data/screen_test/components/list_with_active/l2r_position_start.rb +16 -0
  64. data/screen_test/components/list_with_active/l2r_separator.frame +1 -0
  65. data/screen_test/components/list_with_active/l2r_separator.rb +17 -0
  66. data/screen_test/components/list_with_active/t2b_active_color.frame +1 -0
  67. data/screen_test/components/list_with_active/t2b_active_color.rb +19 -0
  68. data/screen_test/components/list_with_active/t2b_position_end.frame +1 -0
  69. data/screen_test/components/list_with_active/t2b_position_end.rb +17 -0
  70. data/screen_test/components/list_with_active/t2b_position_middle.frame +1 -0
  71. data/screen_test/components/list_with_active/t2b_position_middle.rb +17 -0
  72. data/screen_test/components/list_with_active/t2b_position_start.frame +1 -0
  73. data/screen_test/components/list_with_active/t2b_position_start.rb +17 -0
  74. data/screen_test/components/list_with_active/t2b_separator.frame +1 -0
  75. data/screen_test/components/list_with_active/t2b_separator.rb +18 -0
  76. data/screen_test/elements/box.frame +1 -1
  77. data/screen_test/elements/box.rb +1 -1
  78. data/screen_test/elements/graph_asc.frame +1 -0
  79. data/screen_test/elements/graph_asc.rb +12 -0
  80. data/screen_test/elements/graph_desc.frame +1 -0
  81. data/screen_test/elements/graph_desc.rb +12 -0
  82. data/screen_test/elements/graph_horiz.frame +1 -0
  83. data/screen_test/elements/graph_horiz.rb +12 -0
  84. data/screen_test/elements/graph_sin.frame +1 -0
  85. data/screen_test/elements/graph_sin.rb +12 -0
  86. data/screen_test/elements/grid.frame +1 -1
  87. data/screen_test/elements/grid.rb +1 -1
  88. data/screen_test/elements/screen_overflow_x.frame +1 -1
  89. data/screen_test/elements/screen_overflow_x.rb +1 -1
  90. data/screen_test/elements/screen_overflow_y.frame +1 -1
  91. data/screen_test/elements/screen_overflow_y.rb +1 -1
  92. data/screen_test/elements/text.frame +1 -1
  93. data/screen_test/elements/text.rb +1 -1
  94. data/screen_test/elements/text_multiline.frame +1 -1
  95. data/screen_test/elements/text_multiline.rb +1 -1
  96. data/screen_test/elements/theme.frame +1 -0
  97. data/screen_test/elements/theme.rb +26 -0
  98. data/screen_test/settings/align/box_around.frame +1 -1
  99. data/screen_test/settings/align/box_around.rb +1 -1
  100. data/screen_test/settings/align/box_between.frame +1 -1
  101. data/screen_test/settings/align/box_between.rb +1 -1
  102. data/screen_test/settings/align/box_center.frame +1 -1
  103. data/screen_test/settings/align/box_center.rb +1 -1
  104. data/screen_test/settings/align/box_default.frame +1 -1
  105. data/screen_test/settings/align/box_default.rb +1 -1
  106. data/screen_test/settings/align/box_evenly.frame +1 -1
  107. data/screen_test/settings/align/box_evenly.rb +1 -1
  108. data/screen_test/settings/align/box_left.frame +1 -1
  109. data/screen_test/settings/align/box_left.rb +1 -1
  110. data/screen_test/settings/align/box_right.frame +1 -1
  111. data/screen_test/settings/align/box_right.rb +1 -1
  112. data/screen_test/settings/align/children_center.frame +1 -1
  113. data/screen_test/settings/align/children_center.rb +1 -1
  114. data/screen_test/settings/align/children_left.frame +1 -1
  115. data/screen_test/settings/align/children_left.rb +1 -1
  116. data/screen_test/settings/align/children_right.frame +1 -1
  117. data/screen_test/settings/align/children_right.rb +1 -1
  118. data/screen_test/settings/align/grid_center.frame +1 -1
  119. data/screen_test/settings/align/grid_center.rb +1 -1
  120. data/screen_test/settings/align/grid_default.frame +1 -1
  121. data/screen_test/settings/align/grid_default.rb +1 -1
  122. data/screen_test/settings/align/grid_left.frame +1 -1
  123. data/screen_test/settings/align/grid_left.rb +1 -1
  124. data/screen_test/settings/align/grid_right.frame +1 -1
  125. data/screen_test/settings/align/grid_right.rb +1 -1
  126. data/screen_test/settings/ansi/bold.frame +1 -1
  127. data/screen_test/settings/ansi/bold.rb +1 -1
  128. data/screen_test/settings/ansi/color.frame +1 -1
  129. data/screen_test/settings/ansi/color.rb +1 -1
  130. data/screen_test/settings/ansi/underline.frame +1 -1
  131. data/screen_test/settings/ansi/underline.rb +1 -1
  132. data/screen_test/settings/border.frame +1 -1
  133. data/screen_test/settings/border.rb +1 -1
  134. data/screen_test/settings/content_start/box_bottom.frame +1 -0
  135. data/screen_test/settings/content_start/box_bottom.rb +17 -0
  136. data/screen_test/settings/content_start/box_left.frame +1 -0
  137. data/screen_test/settings/{position → content_start}/box_left.rb +2 -2
  138. data/screen_test/settings/content_start/box_left_negative.frame +1 -0
  139. data/screen_test/settings/{position → content_start}/box_left_negative.rb +2 -2
  140. data/screen_test/settings/content_start/box_right.frame +1 -0
  141. data/screen_test/settings/content_start/box_right.rb +17 -0
  142. data/screen_test/settings/content_start/box_top.frame +1 -0
  143. data/screen_test/settings/{position → content_start}/box_top.rb +2 -2
  144. data/screen_test/settings/content_start/box_top_negative.frame +1 -0
  145. data/screen_test/settings/{position → content_start}/box_top_negative.rb +2 -2
  146. data/screen_test/settings/content_start/grid_left.frame +1 -0
  147. data/screen_test/settings/{position → content_start}/grid_left.rb +2 -2
  148. data/screen_test/settings/content_start/grid_left_negative.frame +1 -0
  149. data/screen_test/settings/{position → content_start}/grid_left_negative.rb +2 -2
  150. data/screen_test/settings/content_start/grid_top.frame +1 -0
  151. data/screen_test/settings/{position → content_start}/grid_top.rb +2 -2
  152. data/screen_test/settings/content_start/grid_top_negative.frame +1 -0
  153. data/screen_test/settings/{position → content_start}/grid_top_negative.rb +2 -2
  154. data/screen_test/settings/flow/box_b2t.frame +1 -1
  155. data/screen_test/settings/flow/box_b2t.rb +1 -1
  156. data/screen_test/settings/flow/box_l2r.frame +1 -1
  157. data/screen_test/settings/flow/box_l2r.rb +1 -1
  158. data/screen_test/settings/flow/box_r2l.frame +1 -1
  159. data/screen_test/settings/flow/box_r2l.rb +1 -1
  160. data/screen_test/settings/flow/box_t2b.frame +1 -1
  161. data/screen_test/settings/flow/box_t2b.rb +1 -1
  162. data/screen_test/settings/flow/grid_b2t.frame +1 -1
  163. data/screen_test/settings/flow/grid_b2t.rb +1 -1
  164. data/screen_test/settings/flow/grid_l2r.frame +1 -1
  165. data/screen_test/settings/flow/grid_l2r.rb +1 -1
  166. data/screen_test/settings/flow/grid_r2l.frame +1 -1
  167. data/screen_test/settings/flow/grid_r2l.rb +1 -1
  168. data/screen_test/settings/flow/grid_t2b.frame +1 -1
  169. data/screen_test/settings/flow/grid_t2b.rb +1 -1
  170. data/screen_test/settings/height/box.frame +1 -1
  171. data/screen_test/settings/height/box.rb +1 -1
  172. data/screen_test/settings/height/box_border_sizing.frame +1 -1
  173. data/screen_test/settings/height/box_border_sizing.rb +1 -1
  174. data/screen_test/settings/height/grid.frame +1 -1
  175. data/screen_test/settings/height/grid.rb +1 -1
  176. data/screen_test/settings/height/overflow_box.frame +1 -1
  177. data/screen_test/settings/height/overflow_box.rb +1 -1
  178. data/screen_test/settings/height/overflow_box_l2r.frame +1 -1
  179. data/screen_test/settings/height/overflow_box_l2r.rb +1 -1
  180. data/screen_test/settings/height/overflow_box_t2b.frame +1 -1
  181. data/screen_test/settings/height/overflow_box_t2b.rb +1 -1
  182. data/screen_test/settings/height/overflow_grid.frame +1 -1
  183. data/screen_test/settings/height/overflow_grid.rb +1 -1
  184. data/screen_test/settings/margin.frame +1 -1
  185. data/screen_test/settings/margin.rb +1 -1
  186. data/screen_test/settings/padding.frame +1 -1
  187. data/screen_test/settings/padding.rb +1 -1
  188. data/screen_test/settings/scroll/horiz_box.frame +1 -1
  189. data/screen_test/settings/scroll/horiz_box.rb +3 -5
  190. data/screen_test/settings/scroll/horiz_box_align_center.rb +3 -5
  191. data/screen_test/settings/scroll/horiz_box_align_right.rb +3 -5
  192. data/screen_test/settings/scroll/vert_box.frame +1 -1
  193. data/screen_test/settings/scroll/vert_box.rb +6 -8
  194. data/screen_test/settings/title_font.frame +1 -1
  195. data/screen_test/settings/title_font.rb +1 -1
  196. data/screen_test/settings/valign/box_around.frame +1 -1
  197. data/screen_test/settings/valign/box_around.rb +1 -1
  198. data/screen_test/settings/valign/box_between.frame +1 -1
  199. data/screen_test/settings/valign/box_between.rb +1 -1
  200. data/screen_test/settings/valign/box_bottom.frame +1 -1
  201. data/screen_test/settings/valign/box_bottom.rb +1 -1
  202. data/screen_test/settings/valign/box_default.frame +1 -1
  203. data/screen_test/settings/valign/box_default.rb +1 -1
  204. data/screen_test/settings/valign/box_evenly.frame +1 -1
  205. data/screen_test/settings/valign/box_evenly.rb +1 -1
  206. data/screen_test/settings/valign/box_middle.frame +1 -1
  207. data/screen_test/settings/valign/box_middle.rb +1 -1
  208. data/screen_test/settings/valign/box_top.frame +1 -1
  209. data/screen_test/settings/valign/box_top.rb +1 -1
  210. data/screen_test/settings/valign/grid_bottom.frame +1 -1
  211. data/screen_test/settings/valign/grid_bottom.rb +1 -1
  212. data/screen_test/settings/valign/grid_default.frame +1 -1
  213. data/screen_test/settings/valign/grid_default.rb +1 -1
  214. data/screen_test/settings/valign/grid_middle.frame +1 -1
  215. data/screen_test/settings/valign/grid_middle.rb +1 -1
  216. data/screen_test/settings/valign/grid_top.frame +1 -1
  217. data/screen_test/settings/valign/grid_top.rb +1 -1
  218. data/screen_test/settings/width/box_border_sizing.frame +1 -1
  219. data/screen_test/settings/width/box_border_sizing.rb +1 -1
  220. data/screen_test/settings/width/box_content.frame +1 -1
  221. data/screen_test/settings/width/box_content.rb +1 -1
  222. data/screen_test/settings/width/box_default.frame +1 -1
  223. data/screen_test/settings/width/box_default.rb +1 -1
  224. data/screen_test/settings/width/grid.frame +1 -1
  225. data/screen_test/settings/width/grid.rb +1 -1
  226. data/screen_test/settings/width/overflow_align_center.frame +1 -1
  227. data/screen_test/settings/width/overflow_align_center.rb +1 -1
  228. data/screen_test/settings/width/overflow_align_right.frame +1 -1
  229. data/screen_test/settings/width/overflow_align_right.rb +1 -1
  230. data/screen_test/settings/width/overflow_box.frame +1 -1
  231. data/screen_test/settings/width/overflow_box.rb +1 -1
  232. data/screen_test/settings/width/overflow_box_l2r.frame +1 -1
  233. data/screen_test/settings/width/overflow_box_l2r.rb +1 -1
  234. data/screen_test/settings/width/overflow_box_t2b.frame +1 -1
  235. data/screen_test/settings/width/overflow_box_t2b.rb +1 -1
  236. data/screen_test/settings/width/overflow_grid.frame +1 -1
  237. data/screen_test/settings/width/overflow_grid.rb +1 -1
  238. data/tools/whirled_peas/tools/screen_tester.rb +15 -1
  239. metadata +75 -20
  240. data/lib/whirled_peas/graphics/mock_screen.rb +0 -26
  241. data/lib/whirled_peas/graphics/text_dimensions.rb +0 -15
  242. data/screen_test/settings/position/box_left.frame +0 -1
  243. data/screen_test/settings/position/box_left_negative.frame +0 -1
  244. data/screen_test/settings/position/box_top.frame +0 -1
  245. data/screen_test/settings/position/box_top_negative.frame +0 -1
  246. data/screen_test/settings/position/grid_left.frame +0 -1
  247. data/screen_test/settings/position/grid_left_negative.frame +0 -1
  248. data/screen_test/settings/position/grid_top.frame +0 -1
  249. data/screen_test/settings/position/grid_top_negative.frame +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9652a887fc6a68ba5367864a25b4a211674433eae86a2f68db3923e873ab49e8
4
- data.tar.gz: 72926cd288adc3c30393990d88dcc0bca53e2fbfe79d56768e438ffaee2cf3ba
3
+ metadata.gz: 16dc58df5e4b6dbb2bdf51d95841d02bc9172f1e116efd8afd0633df592a7c8e
4
+ data.tar.gz: 0a2a14b167b502954a9ec2e58d762b32b60a2ab62e136d976b7d1d70e5630189
5
5
  SHA512:
6
- metadata.gz: 9e0124bd724ece36b76e1d527ffb3ccd5a06e9cd7f00c1ae5d0c39445d0c4ed4804d8c2cdc0c3df250f0d927b9927efd97d118fd0fd76bbc42277fda68a674cb
7
- data.tar.gz: '09edc4873598d1363d7d3ef2c548699bcbfa229a8821e458c201608ec9f7e3aba8cf2f081f559edc51c04244267f569e8444b7952b21ab41bfea8a7807c0432a'
6
+ metadata.gz: 94d96284d6b3201496456fad7b464f3b71ab02c51878817e81856331fa3cb763a36383198ffe2be31f2e9747580656cb13a587b630f4f5866cd40340c1617744
7
+ data.tar.gz: 51e6271630fda2450af38f59f9c8d888b2b9338efacb6f8c7664393b1fdea8e616f00e20eec47b8bba59c25db510cade9a359119e06d02f8ac9c8de79f372664
data/.gitignore CHANGED
@@ -2,7 +2,6 @@
2
2
  /.yardoc
3
3
  /_yardoc/
4
4
  /coverage/
5
- /doc/
6
5
  /pkg/
7
6
  /spec/reports/
8
7
  /tmp/
@@ -12,4 +11,3 @@ Gemfile.lock
12
11
  # rspec failure tracking
13
12
  .rspec_status
14
13
  *.wpz
15
-
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.11.1 - 2021-01-31
4
+
5
+ - [36e48cf](https://github.com/tcollier/whirled_peas/tree/36e48cf6731706539c6c41ce0ef66e86c62380a5): Add highlight colors and border style to theme
6
+ - [93b1034](https://github.com/tcollier/whirled_peas/tree/93b1034b9401fe9e31cd3199a5e2426d7a893ed6): Better handling of non-ascending graphs
7
+
8
+ ## v0.11.0 - 2021-01-30
9
+
10
+ - [c1f3d94](https://github.com/tcollier/whirled_peas/tree/c1f3d944a35305c3032681db13ffd6142a7e19e4): Add component support
11
+
12
+ ## v0.10.0 - 2021-01-29
13
+
14
+ - [3063a2b](https://github.com/tcollier/whirled_peas/tree/3063a2becb7680b5e320a1733b3da933e6c65210): Add built-in and user-defined themes
15
+
16
+ ## v0.9.1 - 2021-01-29
17
+
18
+ - [c35b134](https://github.com/tcollier/whirled_peas/tree/c35b134e1340b8b5f1d1fb0e6e56dc2a99b52e94): Improve graph plots
19
+
20
+ ## v0.9.0 - 2021-01-29
21
+
22
+ BREAKING: `Frameset#add_frame` signature changed
23
+
24
+ - [1c28947](https://github.com/tcollier/whirled_peas/tree/1c28947980eedce034d2596732ee4860717904c5): Add graph support
25
+
3
26
  ## v0.8.0 - 2021-01-29
4
27
 
5
28
  BREAKING: `Producer` now responds to `#add_frame` instead of `#send_frame`
data/README.md CHANGED
@@ -38,10 +38,10 @@ Or install it yourself as:
38
38
 
39
39
  ## Usage
40
40
 
41
- A Whirled Peas application consists of the following pieces
41
+ A Whirled Peas application consists of the following required pieces
42
42
 
43
- - The application (required) - the code that is to be visualized, it emits lightweight frame events through a producer
44
- - The main template factory (required) - builds templates to convert frame events from the application into terminal graphics
43
+ - [The application](doc/application.md) - the code that is to be visualized, it dictates the frame contents and playback speed
44
+ - [The template factory](doc/template_factory.md) - builds templates to convert frame from the application into terminal graphics
45
45
 
46
46
  These pieces are configured as following
47
47
 
@@ -74,787 +74,23 @@ WhirledPeas.configure do |config|
74
74
  end
75
75
  ```
76
76
 
77
- Then the visualizer is started on the command line with
77
+ Then the visualizer is started on the [command line](doc/cli.md) with
78
78
 
79
79
  ```
80
80
  $ whirled_peas play visualize.rb
81
81
  ```
82
82
 
83
- ### Application
84
-
85
- The application is code to be visualized that integrates with Whirled Peas by providing the signature below
86
-
87
- ```ruby
88
- # Start the application and pass frame events to the producer to be rendered by the UI
89
- #
90
- # @param producer [Producer] frame producer that sends events to the UI
91
- def start(producer)
92
- # application code here
93
- end
94
- ```
95
-
96
- The producer provides a single method
97
-
98
- ```ruby
99
- # Send frame events to the UI
100
- #
101
- # @param name [String] application defined name for the frame. The template factory will be provided this name
102
- # @param duration [Number] time in seconds this frame should be displayed for (defaults to 1 frame)
103
- # @param args [Hash<Symbol, Object>] key value pairs to send as arguments to the template factory
104
- def add_frame(name, duration:, args:)
105
- # implementation
106
- end
107
- ```
108
-
109
- **IMPORTANT**: the keys in the `args` hash must be symbols!
110
-
111
- #### Example
112
-
113
- Simple application that loads a set of numbers and looks for a pair that adds up to 1,000
114
-
115
- ```ruby
116
- class Application
117
- def start(producer)
118
- numbers = File.readlines('/path/to/numbers.txt').map(&:to_i)
119
- producer.add_frame('load-numbers', duration: 3, args: { numbers: numbers })
120
- numbers.sort!
121
- producer.add_frame('sort-numbers', duration: 3, args: { numbers: numbers })
122
- low = 0
123
- high = numbers.length - 1
124
- while low < high
125
- sum = numbers[low] + numbers[high]
126
- if sum == 1000
127
- producer.add_frame('found-pair', duration: 5, args: { low: low, high: high, sum: sum })
128
- return
129
- elsif sum < 1000
130
- producer.add_frame('too-low', args: { low: low, high: high, sum: sum })
131
- low += 1
132
- else
133
- producer.add_frame('too-high', args: { low: low, high: high, sum: sum })
134
- high -= 1
135
- end
136
- end
137
- producer.add_frame('no-solution', duration: 5)
138
- end
139
- end
140
- ```
141
-
142
- ### Template Factory
143
-
144
- To render the frame events sent by the application, the application requires a template factory. This factory will be called for each frame event, with the frame name and the arguments supplied by the application. A template factory can be an instance of ruby class and thus can maintain state. Whirled Peas provides a few basic building blocks to make simple, yet elegant terminal-based UIs.
145
-
146
- #### Building Blocks
147
-
148
- A template is created with `WhirledPeas.template`, which yields a `Composer` object for a `Box` and `BoxSettings`. The composer allows for attaching child elements and the settings for setting layout options. The following attributes of the template's settings will be overridden before it is rendered to ensure that it fills the screen exactly
149
-
150
- - `margin` - all margin will be set to 0
151
- - `width` - will be set to the screen's width
152
- - `height` - will be set to the screen's height
153
- - `sizing` - will be set `:border` to ensure the entire box fits on the screen and fills it entirely.
154
-
155
- A `Composer` provides the following methods to add child elements, each of these takes an optional string argument that is set as the name of the element (which can be useful when debugging).
156
-
157
- - `add_box` - yields a `Composer` for a `Box` and a `BoxSettings`, which will be added to the parent's children
158
- - `add_grid` - yields a `Composer` for a `Grid` and a `GridSettings`, which will be added to the parent's children
159
- - `add_text` - yields `nil` and a `TextSettings`, which will be added to the parent's children
160
-
161
- E.g.
162
-
163
- ```ruby
164
- WhirledPeas.template do |composer, settings|
165
- settings.bg_color = :blue
166
- composer.add_grid do |composer, settings|
167
- settings.num_cols = 10
168
- 100.times do |i|
169
- composer.add_text { i }
170
- end
171
- end
172
- end
173
- ```
174
-
175
- The above template can also be broken down into more manageable methods, e.g.
176
-
177
- ```ruby
178
- def number_grid(_composer, settings)
179
- settings.num_cols = 10
180
- 100.times.map(&:itself)
181
- end
182
-
183
- WhirledPeas.template do |composer, settings|
184
- settings.bg_color = :blue
185
- composer.add_grid(&method(:number_grid))
186
- end
187
- ```
188
-
189
- Additionally, if no child element is explicitly added to a `Grid`, but the block returns an array of strings or numbers, those will be converted to `Text` elements and added as children to the `Grid`. For example, these are identical ways to create a grid of strings
190
-
191
- ```ruby
192
- template.add_grid do |composer|
193
- 100.times do |i|
194
- composer.add_text { i }
195
- end
196
- end
197
-
198
- template.add_grid do
199
- 100.times.map(&:itself)
200
- end
201
- ```
202
-
203
- Similarly, if no child element is explicilty added to a `Box`, but the block returns a string or number, that value will be converted to a `Text` and added as a child. For example, these are identical ways to create a box with string content
204
-
205
- ```ruby
206
- template.add_box do |composer|
207
- composer.add_text { "Hello!" }
208
- end
209
-
210
- template.add_box do
211
- "Hello!"
212
- end
213
- ```
214
-
215
- #### Settings
216
-
217
- Each element type has an associated settings type, which provide a custom set of options to format the output. Child settings will inherit from the parent, where applicable
218
- The available settigs are
219
-
220
- | Setting | Description | Default | Availability | Inherited |
221
- | ------------ | -------------------------------------------------------------------------------- | ---------- | --------------------- | -------------------- |
222
- | `align` | Justifies the content in the horizontal direction | `:left` | `Box`, `Grid` | No |
223
- | `bg_color` | Background color (see [Colors](#colors)) | | `Box`, `Grid`, `Text` | Yes |
224
- | `bold` | `true` makes the font bold | `false` | `Box`, `Grid`, `Text` | Yes |
225
- | `border` | Set the border for the lements | none | `Box`, `Grid`, | Only style and color |
226
- | `color` | Foreground text color (see [Colors](#colors)) | | `Box`, `Grid`, `Text` | Yes |
227
- | `flow` | Flow to display child elements (see [Display Flow](#display-flow)) | `:l2r` | `Box`, `Grid` | No |
228
- | `height` | Override the calculated height of an element's content area | | `Box`, `Grid` | No |
229
- | `margin` | Set the (left, top, right, bottom) margin of the element | `0` | `Box`, `Grid` | No |
230
- | `num_cols` | Number of columns in the grid (must be set!) | | `Grid` | No |
231
- | `padding` | Set the (left, top, right, bottom) padding of the element | `0` | `Box`, `Grid` | No |
232
- | `position` | Set the (left, top) position of the element relative to parent content area | `0` | `Box`, `Grid` | No |
233
- | `scrollbar` | Display a scroll bar for vertical or horizontal scrolling | | `Box` | No |
234
- | `sizing` | Sizing model (`:content` or `:border`) used in conjunction with `width`/`height` | `:content` | `Box` | No |
235
- | `title_font` | Font used for "large" text (see [Large Text](#large-text), ignores `underline`) | | `Text` | No |
236
- | `underline` | `true` underlines the font | `false` | `Box`, `Grid`, `Text` | Yes |
237
- | `width` | Override the calculated width of an element's content area | | `Box`, `Grid` | No |
238
- | `valign` | Justifies the content in the vertical direction | `:top` | `Box`, `Grid` | No |
239
-
240
- ##### Alignment
241
-
242
- The `align` setting takes one of several values
243
-
244
- - `:left` - align content starting at the leftmost edge of the container's content area
245
-
246
- ```
247
- ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
248
- ┃[child 1][child 2][child 3] ┃
249
- ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
250
- ```
251
-
252
- - `:right` - align content starting at the rightmost edge of the container's content area
253
-
254
- ```
255
- ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
256
- ┃ [child 1][child 2][child 3]┃
257
- ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
258
- ```
259
-
260
- - `:center` - align content starting in the horizontal center of the container's content area
261
-
262
- ```
263
- ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
264
- ┃ [child 1][child 2][child 3] ┃
265
- ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
266
- ```
267
-
268
- - `:between` - distribute children so there is equal space between children no space outside of the children
269
-
270
- ```
271
- ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
272
- ┃[child 1] [child 2] [child 3]┃
273
- ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
274
- ```
275
-
276
- - `:around` - distribute children so that they have equal spacing around them, space between two children is twice the space between an edge and a child.
277
-
278
- ```
279
- ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
280
- ┃ [child 1] [child 2] [child 3] ┃
281
- ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
282
- ```
283
-
284
- - `:evenly` - distribute children so there is even spacing between any two children (or space to the edge)
285
-
286
- ```
287
- ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
288
- ┃ [child 1] [child 2] [child 3] ┃
289
- ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
290
- ```
291
-
292
- The `valign` setting takes one of several values
293
-
294
- - `:top` - align content starting at the top of the container's content area
295
-
296
- ```
297
- ┏━━━━━━━━━┓
298
- ┃[child 1]┃
299
- ┃[child 2]┃
300
- ┃[child 3]┃
301
- ┃ ┃
302
- ┃ ┃
303
- ┃ ┃
304
- ┃ ┃
305
- ┃ ┃
306
- ┃ ┃
307
- ┃ ┃
308
- ┃ ┃
309
- ┃ ┃
310
- ┃ ┃
311
- ┃ ┃
312
- ┃ ┃
313
- ┗━━━━━━━━━┛
314
- ```
315
-
316
- - `:bottom` - align content starting at the bottom of the container's content area
317
-
318
- ```
319
- ┏━━━━━━━━━┓
320
- ┃ ┃
321
- ┃ ┃
322
- ┃ ┃
323
- ┃ ┃
324
- ┃ ┃
325
- ┃ ┃
326
- ┃ ┃
327
- ┃ ┃
328
- ┃ ┃
329
- ┃ ┃
330
- ┃ ┃
331
- ┃ ┃
332
- ┃[child 1]┃
333
- ┃[child 2]┃
334
- ┃[child 3]┃
335
- ┗━━━━━━━━━┛
336
- ```
337
-
338
- - `:middle` - align content starting in the vertical middle of the container's content area
339
-
340
- ```
341
- ┏━━━━━━━━━┓
342
- ┃ ┃
343
- ┃ ┃
344
- ┃ ┃
345
- ┃ ┃
346
- ┃ ┃
347
- ┃ ┃
348
- ┃[child 1]┃
349
- ┃[child 2]┃
350
- ┃[child 3]┃
351
- ┃ ┃
352
- ┃ ┃
353
- ┃ ┃
354
- ┃ ┃
355
- ┃ ┃
356
- ┃ ┃
357
- ┗━━━━━━━━━┛
358
- ```
359
-
360
- - `:between` - distribute children so there is equal space between children no space outside of the children
361
-
362
- ```
363
- ┏━━━━━━━━━┓
364
- ┃[child 1]┃
365
- ┃ ┃
366
- ┃ ┃
367
- ┃ ┃
368
- ┃ ┃
369
- ┃ ┃
370
- ┃ ┃
371
- ┃[child 2]┃
372
- ┃ ┃
373
- ┃ ┃
374
- ┃ ┃
375
- ┃ ┃
376
- ┃ ┃
377
- ┃ ┃
378
- ┃[child 3]┃
379
- ┗━━━━━━━━━┛
380
- ```
381
-
382
- - `:around` - distribute children so that they have equal spacing around them, space between two children is twice the space between an edge and a child.
383
-
384
- ```
385
- ┏━━━━━━━━━┓
386
- ┃ ┃
387
- ┃ ┃
388
- ┃[child 1]┃
389
- ┃ ┃
390
- ┃ ┃
391
- ┃ ┃
392
- ┃ ┃
393
- ┃[child 2]┃
394
- ┃ ┃
395
- ┃ ┃
396
- ┃ ┃
397
- ┃ ┃
398
- ┃[child 3]┃
399
- ┃ ┃
400
- ┃ ┃
401
- ┗━━━━━━━━━┛
402
- ```
403
-
404
- - `:evenly` - distribute children so there is even spacing between any two children (or space to the edge)
405
-
406
- ```
407
- ┏━━━━━━━━━┓
408
- ┃ ┃
409
- ┃ ┃
410
- ┃ ┃
411
- ┃[child 1]┃
412
- ┃ ┃
413
- ┃ ┃
414
- ┃ ┃
415
- ┃[child 2]┃
416
- ┃ ┃
417
- ┃ ┃
418
- ┃ ┃
419
- ┃[child 3]┃
420
- ┃ ┃
421
- ┃ ┃
422
- ┃ ┃
423
- ┗━━━━━━━━━┛
424
- ```
425
-
426
- ##### Position
427
-
428
- Position settings dictate the relative position from where the painter would have preferred to place the container. Negative numbers move the container left/up and positive numbers move it right/down. To set these values, use
429
-
430
- - `set_position(left:, top:)`
431
-
432
- ##### Sizing Model
433
-
434
- The sizing model determines how to interpret the `width` and `height` settings. The default sizing model is `:content`, which sets the width and height of the cotent area, whereas `:border` sets the width and height of the element inlcuding the padding and border and scroll bars.
435
-
436
- ###### Examples
437
-
438
- In the examples below, the `~` character represents padding and would not be displayed in the acutal rendered screen.
439
-
440
- ```ruby
441
- settings.width = 10
442
- settings.height = 3
443
- settings.set_padding(left: 3, top: 1, right: 3, bottom: 1)
444
- settings.full_border
445
-
446
- ## Content sizing
447
- settings.sizing = :content
448
-
449
- # Results in the box
450
- #
451
- # ┏━━━━━━━━━━━━━━━━┓
452
- # ┃~~~~~~~~~~~~~~~~┃
453
- # ┃~~~1234567890~~~┃
454
- # ┃~~~1234567890~~~┃
455
- # ┃~~~1234567890~~~┃
456
- # ┃~~~~~~~~~~~~~~~~┃
457
- # ┗━━━━━━━━━━━━━━━━┛
458
-
459
- ## Border sizing
460
- settings.sizing = :border
461
-
462
- # Results in the box
463
- #
464
- # ┏━━━━━━━━┓
465
- # ┃~~~12~~~┃
466
- # ┗━━━━━━━━┛
467
- ```
468
-
469
- Notice that a box rendered with `:border` sizing would fit exactly in the content area of a box with the same `width` and `height` that is rendered with `:content` sizing. For containers with no padding and no border, the resulting size is the same for either sizing model.
470
-
471
- ##### Margin
472
-
473
- Margin settings dictate the spacing on the outside (i.e. outside of the border) of each of the 4 sides of the container independently. To set these values, use
474
-
475
- - `set_margin(left:, top:, right:, bottom:, horiz:, vert:)` - set any combination of margin (note: setting `horiz` and `left`/`right` or setting `vert` and `top`/`bottom` is not allowed)
476
- - `margin.left=(value)` - set left margin
477
- - `margin.top=(value)` - set top margin
478
- - `margin.right=(value)` - set right margin
479
- - `margin.bottom=(value)` - set bottom margin
480
- - `margin.horiz=(value)` - set left and right margin to the same value
481
- - `margin.vert=(value)` - set top and bottom margin to the same value
482
-
483
- Note: values cannot be negative
484
-
485
- ##### Padding
486
-
487
- Padding settings dictate the spacing on the inside (i.e. inside of the border) of each of the 4 sides of the container independently. To set these values, use
488
-
489
- - `set_padding(left:, top:, right:, bottom:, horiz:, vert:)` - set any combination of padding (note: setting `horiz` and `left`/`right` or setting `vert` and `top`/`bottom` is not allowed)
490
- - `padding.left=(value)` - set left padding
491
- - `padding.top=(value)` - set top padding
492
- - `padding.right=(value)` - set right padding
493
- - `padding.bottom=(value)` - set bottom padding
494
- - `padding.horiz=(value)` - set left and right padding to the same value
495
- - `padding.vert=(value)` - set top and bottom padding to the same value
496
-
497
- Note: values cannot be negative
498
-
499
- ##### Scrollbar
500
-
501
- Scroll settings dictate whether the scrollbar will be shown when child content is larger the the container's viewport. A scrollbar adds a unit to the dimensions of a container (as opposed to overwriting the leftmost/bottommost padding)
502
-
503
- - `set_scrollbar(horiz:, vert:)` - set both scrollbar settings
504
- - `scrollbar.horiz=(flag)` - show/hide the horizontal scrollbar
505
- - `scrollbar.vert=(flag)` - show/hide the vertical scrollbar
506
-
507
- Note: there is a know bug with scrollbars and `center`/`right` alignments. Using `left` alignment is the supported workaround
508
-
509
- ##### Border
510
-
511
- The border settings consist of 6 boolean values (border are either width 1 or not shown), the 4 obvious values (`left`, `top`, `right`, and `bottom`) along with 2 other values for inner borders (`inner_horiz` and `inner_vert`) in a grid. A border also has a foreground color (defaults to `:white`) and a style. The background color is determined by the `bg_color` of the element. Border values can be set with
512
-
513
- - `set_border(left:, top:, right:, bottom:, inner_horiz:, inner_vert:, color:, style:)` - set any combination of border settings
514
- - `full_border(style:, color:)` - set all borders to true and optionally set the style or color
515
- - `border.left=(flag)` - show/hide left border
516
- - `border.top=(flag)` - show/hide top border
517
- - `border.right=(flag)` - show/hide right border
518
- - `border.bottom=(flag)` - show/hide bottom border
519
- - `border.inner_horiz=(flag)` - show/hide inner horizontal border (dividing grid rows)
520
- - `border.inner_vert=(flag)` - show/hide inner vertical border (dividing grid columns)
521
- - `border.color=(text_color)` - set the border color
522
- - `border.style=(style)` - set the border style
523
-
524
- Available border styles are
525
-
526
- - `:bold` (default)
527
-
528
- ```
529
- ┏━━┳━━┓
530
- ┃ ┃ ┃
531
- ┣━━╋━━┫
532
- ┃ ┃ ┃
533
- ┗━━┻━━┛
534
- ```
535
-
536
- - `:double`
537
-
538
- ```
539
- ╔══╦══╗
540
- ║ ║ ║
541
- ╠══╬══╣
542
- ║ ║ ║
543
- ╚══╩══╝
544
- ```
545
-
546
- - `:soft`
547
-
548
- ```
549
- ╭──┬──╮
550
- │ │ │
551
- ├──┼──┤
552
- │ │ │
553
- ╰──┴──╯
554
- ```
555
-
556
- ##### Display Flow
557
-
558
- Child elements can flow in one of 4 directions
559
-
560
- - `:l2r` left-to-right
561
-
562
- ```
563
- # In a Box
564
- ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
565
- ┃[child 1] [child 2] ... [child N]┃
566
- ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
567
-
568
- # In a Grid
569
- ┏━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┓
570
- ┃[child 1]┃[child 2]┃[child 3]┃
571
- ┣━━━━━━━━━╋━━━━━━━━━╋━━━━━━━━━┫
572
- ┃[chiid 4]┃[child 5]┃ ┃
573
- ┗━━━━━━━━━┻━━━━━━━━━┻━━━━━━━━━┛
574
- ```
575
-
576
- - `:r2l` right-to-left
577
-
578
- ```
579
- # In a Box
580
- ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
581
- ┃[child N] [child N - 1] ... [child 1]┃
582
- ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
583
-
584
- # In a Grid
585
- ┏━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┓
586
- ┃[child 3]┃[child 2]┃[child 1]┃
587
- ┣━━━━━━━━━╋━━━━━━━━━╋━━━━━━━━━┫
588
- ┃ ┃[chiid 5]┃[child 4]┃
589
- ┗━━━━━━━━━┻━━━━━━━━━┻━━━━━━━━━┛
590
- ```
591
-
592
- - `:t2b` top-to-bottom
593
-
594
- ```
595
- # In a Box
596
- ┏━━━━━━━━━┓
597
- ┃[child 1]┃
598
- ┃[child 2]┃
599
- ┃ ... ┃
600
- ┃[child N]┃
601
- ┗━━━━━━━━━┛
602
-
603
- # In a Grid
604
- ┏━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┓
605
- ┃[child 1]┃[child 3]┃[child 5]┃
606
- ┣━━━━━━━━━╋━━━━━━━━━╋━━━━━━━━━┫
607
- ┃[child 2]┃[child 4]┃ ┃
608
- ┗━━━━━━━━━┻━━━━━━━━━┻━━━━━━━━━┛
609
- ```
610
-
611
- - `:b2t` bottom-to-top
612
-
613
- ```
614
- # In a Box
615
- ┏━━━━━━━━━━━━━┓
616
- ┃[child N] ┃
617
- ┃[child N - 1]┃
618
- ┃ ... ┃
619
- ┃[child 1] ┃
620
- ┗━━━━━━━━━━━━━┛
621
-
622
- # In a Grid
623
- ┏━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┓
624
- ┃[child 2]┃[child 4]┃ ┃
625
- ┣━━━━━━━━━╋━━━━━━━━━╋━━━━━━━━━┫
626
- ┃[child 1]┃[child 3]┃[child 5]┃
627
- ┗━━━━━━━━━┻━━━━━━━━━┻━━━━━━━━━┛
628
- ```
629
-
630
- ##### Colors
631
-
632
- Below is the list of available colors (for both foreground and background)
633
-
634
- - `:black`
635
- - `:blue`
636
- - `:cyan`
637
- - `:gray`
638
- - `:green`
639
- - `:magenta`
640
- - `:red`
641
- - `:white`
642
- - `:yellow`
643
-
644
- Many of these also have a "bright" option:
645
-
646
- - `:bright_blue`
647
- - `:bright_cyan`
648
- - `:bright_green`
649
- - `:bright_magenta`
650
- - `:bright_red`
651
- - `:bright_yellow`
652
-
653
- ##### Large Text
654
-
655
- The `title_font` setting for `Text`s converts the standard terminal font into a large block font. The available fonts vary from system to system. Every system will have a `:default` font available, this font could look like
656
-
657
- ```
658
- ██████╗ ███████╗███████╗ █████╗ ██╗ ██╗██╗ ████████╗
659
- ██╔══██╗██╔════╝██╔════╝██╔══██╗██║ ██║██║ ╚══██╔══╝
660
- ██║ ██║█████╗ █████╗ ███████║██║ ██║██║ ██║
661
- ██║ ██║██╔══╝ ██╔══╝ ██╔══██║██║ ██║██║ ██║
662
- ██████╔╝███████╗██║ ██║ ██║╚██████╔╝███████╗ ██║
663
- ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ ╚═╝
664
- ```
665
-
666
- To print out a list of all available fonts as well as sample text in that font, run
667
-
668
- ```
669
- $ whirled_peas title_fonts
670
- ```
671
-
672
- Note: when using a title font with WhirledPeas for the first time on a system, the gem loads all fonts to check which ones are available. This can be a slow process and may cause a noticeable delay when running a visualization. Running the command above will cache the results and thus when a WhirledPeas visualization is run, there will be no lag from loading fonts.
673
-
674
- ### Example
675
-
676
- ```ruby
677
- class TemplateFactory
678
- def build(frame, args)
679
- set_state(frame, args)
680
- WhirledPeas.template do |composer, settings|
681
- settings.flow = :l2r
682
- settings.align = :center
683
-
684
- composer.add_box('Title', &method(:title))
685
- composer.add_box('Sum', &method(:sum))
686
- composer.add_grid('NumberGrid', &method(:number_grid))
687
- end
688
- end
689
-
690
- private
691
-
692
- def set_state(frame, args)
693
- @frame = frame
694
- @numbers = args.key?(:numbers) ? args[:numbers] || []
695
- @sum = args[:sum] if args.key?(:sum)
696
- @low = args[:low] if args.key?(:low)
697
- @high = args[:high] if args.key?(:high)
698
- end
699
-
700
- def title(_composer, settings)
701
- settings.underline = true
702
- "Pair Finder"
703
- end
704
-
705
- def sum(_composer, settings)
706
- settings.color = @frame == 'found-pair' ? :green : :red
707
- @sum ? "Sum: #{@sum}" : 'N/A'
708
- end
709
-
710
- def number_grid(composer, settings)
711
- settings.full_border
712
- @numbers.each.with_index do |num, index|
713
- composer.add_text do |_, settings|
714
- settings.bg_color = (@low == index || @high == index) ? :cyan : :white
715
- num
716
- end
717
- end
718
- end
719
- end
720
- ```
721
-
722
- ### Full usage
723
-
724
- ```
725
- Usage: whirled_peas <command> [command options]
726
-
727
- Available commands:
728
-
729
- debug Print template tree for specified frame
730
- fonts List installed title fonts with sample text
731
- frames Print out list of frames generated by application
732
- help Show detailed help for a command
733
- play Play an animation from an application or prerecorded file
734
- record Record animation to a file
735
- still Show the specified still frame
736
- ```
737
-
738
- #### `debug`
739
-
740
- Print the template tree for specified frame.
741
-
742
- ```
743
- # Usage: whirled_peas debug <config file> <frame> [args as a JSON string]
744
- % whirled_peas debug my_app.rb greeting '{"name":"World"}'
745
- * WhirledPeas::Graphics::BoxPainter(TEMPLATE)
746
- - Dimensions(outer=140x27, content=120x15, grid=1x1)
747
- - Settings
748
- WhirledPeas::Settings::BoxSettings
749
- padding: Padding(left: 10, top: 6, right: 10, bottom: 6)
750
- align: :center
751
- width: 120
752
- flow: :t2b
753
- bold: true
754
- bg_color: BgColor(code=107, bright=true)
755
- - Children
756
- * WhirledPeas::Graphics::BoxPainter(Element-1)
757
- - Dimensions(outer=64x6, content=64x6, grid=1x1)
758
- ```
759
-
760
- #### `fonts`
761
-
762
- List all installed title fonts with sample text.
763
-
764
- ```
765
- # Usage: whirled_peas fonts
766
- ```
767
-
768
- #### `frames`
769
-
770
- Print out list of frames generated by application.
771
-
772
- ```
773
- # Usage: whirled_peas frames <config file>
774
- % whirled_peas frames my_app.rb
775
- Frame 'intro' displayed for 3 second(s) '{"title":"Foo"}'
776
- Frame 'greet' displayed for 0.3 second(s)
777
- ...
778
- ```
779
-
780
- #### `help`
781
-
782
- Print out command-specific help message
783
-
784
- ```
785
- Usage: whirled_peas help <command>
786
- ```
787
-
788
- #### `play`
789
-
790
- Play an animation from an application or prerecorded file
791
-
792
- ```
793
- # Usage: whirled_peas play <config/wpz file>
794
-
795
- # Play animation directly from app
796
- % whirled_peas play my_app.rb
797
- # Animation plays
798
-
799
- # Play animation from previously recorded file
800
- % whirled_peas play my_animation.wpz
801
- # Animation plays
802
- ```
803
-
804
- #### `record`
805
-
806
- Record animation to a file
807
-
808
- ```
809
- # Usage: whirled_peas record <config file> <output file>
810
- % whirled_peas record my_app.rb my_animation.wpz
811
- # Record animation to my_animation.wpz
812
- ```
813
-
814
- #### `still`
815
-
816
- Show the specified still frame
817
-
818
- ```
819
- # Usage: whirled_peas still <config file> <frame> [args as a JSON string]
820
- % whirled_peas still my_app.rb greeting '{"name":"World"}'
821
- # Still frame is displayed
822
- ```
823
-
824
83
  ## Development
825
84
 
826
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
827
-
828
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
829
-
830
- ### Testing
831
-
832
- In addition to standard RSpec tests, WhirledPeas has custom tests for rendered templates. These files live in `screen_test/`. Each ruby file is expected to define a class named `TemplateFactory` that responds to `#build(name, args)` returning a template (the standard template factory role). Each file should also be accompanied by a `.frame` file with the same base name. This file will contain the output of the rendered screen and is considered the correct output when running tests.
833
-
834
- Note: viewing `.frame` files with `cat` works better than most other text editors.
835
-
836
- ```
837
-
838
- Usage: screen_test [file] [options]
85
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
839
86
 
840
- If not file or options are provide, all tests are run
87
+ Tests inclued standard RSpec tests for application logic as well as custom [screen tests](doc/screen_test.md) to validate the rendered graphics.
841
88
 
842
- If no file is provided, the supported options are
843
- --help print this usage statement and exit
844
- --view-pending interactively display and optionally save rendered output for each pending test
845
- --view-failed interactively display and optionally save rendered output for each faiing test
846
-
847
- If the file provide is a screen test, the supported options are
848
- --run run screen test for given file
849
- --view interactively display and optionally save the file's test output
850
- --template print out template tree for the test template
851
- --debug render the test template without displying it, printing out debug information
852
-
853
- ```
89
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
854
90
 
855
91
  ## Contributing
856
92
 
857
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/whirled_peas. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/whirled_peas/blob/master/CODE_OF_CONDUCT.md).
93
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tcollier/whirled_peas. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/tcollier/whirled_peas/blob/master/CODE_OF_CONDUCT.md).
858
94
 
859
95
  ## License
860
96
 
@@ -862,8 +98,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
862
98
 
863
99
  ## Code of Conduct
864
100
 
865
- Everyone interacting in the WhirledPeas project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/whirled_peas/blob/master/CODE_OF_CONDUCT.md).
866
-
867
- ```
868
-
869
- ```
101
+ Everyone interacting in the WhirledPeas project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/tcollier/whirled_peas/blob/master/CODE_OF_CONDUCT.md).