scarpe 0.2.2 → 0.4.0

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 (378) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +7 -1
  3. data/.yardopts +1 -0
  4. data/CHANGELOG.md +52 -6
  5. data/Gemfile +2 -1
  6. data/Gemfile.lock +20 -6
  7. data/LICENSE.txt +7 -1
  8. data/README.md +100 -21
  9. data/Rakefile +68 -1
  10. data/examples/Edit_box_Styles.rb +8 -0
  11. data/examples/Kerning.rb +7 -0
  12. data/examples/animate.rb +20 -0
  13. data/examples/arrow.rb +10 -0
  14. data/examples/border.rb +11 -0
  15. data/examples/btn_tooltip.rb +7 -0
  16. data/examples/button_style_changed.rb +7 -0
  17. data/examples/button_styles_default.rb +6 -0
  18. data/examples/check.rb +2 -0
  19. data/examples/download_and_show_image.rb +3 -0
  20. data/examples/flags/finland.rb +15 -0
  21. data/examples/flags/italy.rb +11 -0
  22. data/examples/flags/mauritius.rb +14 -0
  23. data/examples/font_family.rb +17 -0
  24. data/examples/font_shorthand.rb +9 -0
  25. data/examples/gen.rb +12 -8
  26. data/examples/highlander.rb +3 -3
  27. data/examples/legacy/README.md +6 -0
  28. data/examples/legacy/not_checked/shoes-contrib/basic/shoes-notes.rb +1 -1
  29. data/examples/legacy/not_checked/shoes-manual/append.rb +10 -0
  30. data/examples/legacy/not_checked/shoes-manual/background_change.rb +12 -0
  31. data/examples/legacy/not_checked/shoes-manual/background_pattern.rb +5 -0
  32. data/examples/legacy/not_checked/shoes-manual/basic_app.rb +8 -0
  33. data/examples/legacy/not_checked/shoes-manual/border.rb +9 -0
  34. data/examples/legacy/not_checked/shoes-manual/builtins/FONTS.rb +5 -0
  35. data/examples/legacy/not_checked/shoes-manual/builtins/ask.rb +2 -0
  36. data/examples/legacy/not_checked/shoes-manual/builtins/ask_color.rb +5 -0
  37. data/examples/legacy/not_checked/shoes-manual/builtins/ask_open_file.rb +5 -0
  38. data/examples/legacy/not_checked/shoes-manual/builtins/ask_save_folder.rb +2 -0
  39. data/examples/legacy/not_checked/shoes-manual/builtins/confirm.rb +4 -0
  40. data/examples/legacy/not_checked/shoes-manual/builtins/debug.rb +2 -0
  41. data/examples/legacy/not_checked/shoes-manual/builtins/info.rb +3 -0
  42. data/examples/legacy/not_checked/shoes-manual/button.rb +9 -0
  43. data/examples/legacy/not_checked/shoes-manual/clear.rb +7 -0
  44. data/examples/legacy/not_checked/shoes-manual/custom_header.rb +13 -0
  45. data/examples/legacy/not_checked/shoes-manual/displace.rb +14 -0
  46. data/examples/legacy/not_checked/shoes-manual/edit_box.rb +8 -0
  47. data/examples/legacy/not_checked/shoes-manual/fill_pattern.rb +5 -0
  48. data/examples/legacy/not_checked/shoes-manual/fonts.rb +7 -0
  49. data/examples/legacy/not_checked/shoes-manual/gutter.rb +6 -0
  50. data/examples/legacy/not_checked/shoes-manual/image_web.rb +4 -0
  51. data/examples/legacy/not_checked/shoes-manual/keypress.rb +7 -0
  52. data/examples/legacy/not_checked/shoes-manual/list_box.rb +10 -0
  53. data/examples/legacy/not_checked/shoes-manual/motion.rb +10 -0
  54. data/examples/legacy/not_checked/shoes-manual/mouse.rb +8 -0
  55. data/examples/legacy/not_checked/shoes-manual/move.rb +14 -0
  56. data/examples/legacy/not_checked/shoes-manual/nested_ovals.rb +8 -0
  57. data/examples/legacy/not_checked/shoes-manual/oval.rb +7 -0
  58. data/examples/legacy/not_checked/shoes-manual/ovals.rb +6 -0
  59. data/examples/legacy/not_checked/shoes-manual/ovals_image.rb +8 -0
  60. data/examples/legacy/not_checked/shoes-manual/prepend.rb +7 -0
  61. data/examples/legacy/not_checked/shoes-manual/progress_bar.rb +10 -0
  62. data/examples/legacy/not_checked/shoes-manual/radio.rb +18 -0
  63. data/examples/legacy/not_checked/shoes-manual/radio_alternative_1.rb +7 -0
  64. data/examples/legacy/not_checked/shoes-manual/radio_alternative_2.rb +9 -0
  65. data/examples/legacy/not_checked/shoes-manual/rotate_rectangle.rb +6 -0
  66. data/examples/legacy/not_checked/shoes-manual/shape.rb +11 -0
  67. data/examples/legacy/not_checked/shoes-manual/static/avatar.png +0 -0
  68. data/examples/legacy/not_checked/shoes-manual/stroke.rb +5 -0
  69. data/examples/legacy/not_checked/shoes-manual/style.rb +3 -0
  70. data/examples/legacy/not_checked/shoes-manual/style_alternative_1.rb +4 -0
  71. data/examples/legacy/not_checked/shoes-manual/style_alternative_2.rb +5 -0
  72. data/examples/legacy/not_checked/shoes-manual/style_length.rb +5 -0
  73. data/examples/legacy/not_checked/shoes-manual/timer.rb +6 -0
  74. data/examples/legacy/not_checked/shoes-manual/trigger_window.rb +8 -0
  75. data/examples/legacy/not_checked/shoes-manual/window_owner.rb +8 -0
  76. data/examples/legacy/not_checked/simple/anim-shapes.rb +1 -1
  77. data/examples/legacy/not_checked/speedometer_app.rb +55 -0
  78. data/examples/legacy/working/shoes_manual/alert_button.rb +2 -0
  79. data/examples/legacy/working/shoes_manual/animate.rb +7 -0
  80. data/examples/legacy/working/shoes_manual/background_para.rb +4 -0
  81. data/examples/legacy/working/shoes_manual/button_alternative.rb +7 -0
  82. data/examples/legacy/working/shoes_manual/checkbox.rb +17 -0
  83. data/examples/legacy/working/shoes_manual/download.rb +12 -0
  84. data/examples/legacy/working/shoes_manual/edit_box.rb +6 -0
  85. data/examples/legacy/working/shoes_manual/editline.rb +7 -0
  86. data/examples/legacy/working/shoes_manual/fixed_height.rb +8 -0
  87. data/examples/legacy/working/shoes_manual/fixed_width.rb +12 -0
  88. data/examples/legacy/working/shoes_manual/image.rb +5 -0
  89. data/examples/legacy/working/shoes_manual/instance_variable_check.rb +10 -0
  90. data/examples/legacy/working/shoes_manual/message.rb +18 -0
  91. data/examples/legacy/working/shoes_manual/rectangle.rb +6 -0
  92. data/examples/legacy/working/shoes_manual/save_download.rb +12 -0
  93. data/examples/legacy/working/shoes_manual/self_check.rb +10 -0
  94. data/examples/legacy/working/shoes_manual/stack.rb +7 -0
  95. data/examples/legacy/working/shoes_manual/style_info.rb +8 -0
  96. data/examples/legacy/working/shoes_manual/utf8_support.rb +8 -0
  97. data/examples/legacy/working/shoes_manual/width.rb +4 -0
  98. data/examples/legacy/working/simple/image-icon.rb +3 -0
  99. data/examples/legacy/{not_checked → working}/simple/image.rb +1 -1
  100. data/examples/list_box_choose.rb +17 -0
  101. data/examples/local_assets/local_file_server.rb +82 -0
  102. data/examples/local_assets/multi_image.rb +5 -0
  103. data/examples/local_assets/sample.gif +0 -0
  104. data/examples/local_assets/sample.mp4 +0 -0
  105. data/examples/local_assets/small.png +0 -0
  106. data/examples/local_fonts.rb +5 -2
  107. data/examples/local_images.rb +2 -3
  108. data/examples/margin.rb +13 -0
  109. data/examples/margin_check.rb +27 -0
  110. data/examples/oval-with-kwargs.rb +3 -0
  111. data/examples/oval.rb +26 -0
  112. data/examples/para/para_text.rb +14 -0
  113. data/examples/para_font_styles.rb +17 -0
  114. data/examples/para_font_variant.rb +6 -0
  115. data/examples/para_fontweight.rb +13 -0
  116. data/examples/parse_xl_funnies.rb +3 -0
  117. data/examples/progress.rb +31 -0
  118. data/examples/radio/radio_groups.rb +2 -2
  119. data/examples/rect.rb +4 -0
  120. data/examples/rotate_shapes.rb +17 -0
  121. data/examples/scarpe_ext.rb +3 -0
  122. data/examples/shapes/star.rb +1 -3
  123. data/examples/simpler-menu.rb +21 -0
  124. data/examples/spacing.rb +1 -1
  125. data/examples/span.rb +4 -2
  126. data/exe/scarpe +2 -1
  127. data/lacci/Gemfile +2 -0
  128. data/lacci/Gemfile.lock +8 -1
  129. data/lacci/lacci.gemspec +2 -2
  130. data/lacci/lib/lacci/scarpe_cli.rb +2 -2
  131. data/lacci/lib/lacci/scarpe_core.rb +2 -1
  132. data/lacci/lib/lacci/version.rb +1 -1
  133. data/lacci/lib/scarpe/niente/app.rb +23 -0
  134. data/lacci/lib/scarpe/niente/display_service.rb +66 -0
  135. data/lacci/lib/scarpe/niente/drawable.rb +59 -0
  136. data/lacci/lib/scarpe/niente/shoes_spec.rb +93 -0
  137. data/lacci/lib/scarpe/niente.rb +32 -0
  138. data/lacci/lib/shoes/app.rb +111 -72
  139. data/lacci/lib/shoes/background.rb +2 -2
  140. data/lacci/lib/shoes/border.rb +2 -2
  141. data/lacci/lib/shoes/builtins.rb +63 -0
  142. data/lacci/lib/shoes/changelog.rb +52 -0
  143. data/lacci/lib/shoes/colors.rb +3 -1
  144. data/lacci/lib/shoes/constants.rb +41 -2
  145. data/lacci/lib/shoes/display_service.rb +80 -18
  146. data/lacci/lib/shoes/download.rb +2 -2
  147. data/lacci/lib/shoes/drawable.rb +654 -0
  148. data/lacci/lib/shoes/drawables/arc.rb +27 -0
  149. data/lacci/lib/shoes/drawables/arrow.rb +21 -0
  150. data/lacci/lib/shoes/drawables/border.rb +28 -0
  151. data/lacci/lib/shoes/drawables/button.rb +57 -0
  152. data/lacci/lib/shoes/drawables/check.rb +33 -0
  153. data/lacci/lib/shoes/drawables/document_root.rb +20 -0
  154. data/lacci/lib/shoes/{widgets → drawables}/edit_box.rb +9 -8
  155. data/lacci/lib/shoes/{widgets → drawables}/edit_line.rb +8 -7
  156. data/lacci/lib/shoes/drawables/flow.rb +20 -0
  157. data/lacci/lib/shoes/drawables/font_helper.rb +62 -0
  158. data/lacci/lib/shoes/{widgets → drawables}/image.rb +7 -7
  159. data/lacci/lib/shoes/drawables/line.rb +17 -0
  160. data/lacci/lib/shoes/drawables/link.rb +31 -0
  161. data/lacci/lib/shoes/drawables/list_box.rb +59 -0
  162. data/lacci/lib/shoes/drawables/oval.rb +48 -0
  163. data/lacci/lib/shoes/drawables/para.rb +206 -0
  164. data/lacci/lib/shoes/drawables/progress.rb +15 -0
  165. data/lacci/lib/shoes/drawables/radio.rb +35 -0
  166. data/lacci/lib/shoes/drawables/rect.rb +18 -0
  167. data/lacci/lib/shoes/{widgets → drawables}/shape.rb +8 -8
  168. data/lacci/lib/shoes/drawables/slot.rb +178 -0
  169. data/lacci/lib/shoes/drawables/stack.rb +21 -0
  170. data/lacci/lib/shoes/drawables/star.rb +28 -0
  171. data/lacci/lib/shoes/drawables/subscription_item.rb +93 -0
  172. data/lacci/lib/shoes/drawables/text_drawable.rb +122 -0
  173. data/lacci/lib/shoes/drawables/video.rb +17 -0
  174. data/lacci/lib/shoes/drawables/widget.rb +74 -0
  175. data/lacci/lib/shoes/drawables.rb +32 -0
  176. data/lacci/lib/shoes/errors.rb +38 -0
  177. data/lacci/lib/shoes/log.rb +2 -2
  178. data/lacci/lib/shoes/margin_helper.rb +79 -0
  179. data/lacci/lib/shoes/ruby_extensions.rb +15 -0
  180. data/lacci/lib/shoes-spec.rb +93 -0
  181. data/lacci/lib/shoes.rb +31 -10
  182. data/lacci/test/.gitignore +1 -0
  183. data/lacci/test/test_draw_context.rb +167 -0
  184. data/lacci/test/test_font_helper.rb +57 -0
  185. data/lacci/test/test_helper.rb +81 -0
  186. data/lacci/test/test_lacci.rb +99 -3
  187. data/lacci/test/test_margin_helper.rb +82 -0
  188. data/lacci/test/test_niente_test_infra.rb +26 -0
  189. data/lacci/test/test_oval.rb +82 -0
  190. data/lacci/test/test_parenting.rb +140 -0
  191. data/lacci/test/test_shoes_errors.rb +49 -0
  192. data/lacci/test/test_text_drawables.rb +23 -0
  193. data/lib/scarpe/assets.rb +18 -0
  194. data/lib/scarpe/cats_cradle.rb +84 -103
  195. data/lib/scarpe/errors.rb +77 -0
  196. data/lib/scarpe/shoes_spec.rb +160 -0
  197. data/lib/scarpe/version.rb +2 -2
  198. data/lib/scarpe/wv/app.rb +21 -20
  199. data/lib/scarpe/wv/arc.rb +4 -51
  200. data/lib/scarpe/wv/arrow.rb +9 -0
  201. data/lib/scarpe/wv/border.rb +9 -18
  202. data/lib/scarpe/wv/button.rb +7 -35
  203. data/lib/scarpe/wv/check.rb +3 -5
  204. data/lib/scarpe/wv/control_interface.rb +20 -30
  205. data/lib/scarpe/wv/document_root.rb +81 -4
  206. data/lib/scarpe/wv/{widget.rb → drawable.rb} +71 -82
  207. data/lib/scarpe/wv/edit_box.rb +8 -18
  208. data/lib/scarpe/wv/edit_line.rb +9 -20
  209. data/lib/scarpe/wv/flow.rb +2 -18
  210. data/lib/scarpe/wv/image.rb +7 -30
  211. data/lib/scarpe/wv/line.rb +3 -25
  212. data/lib/scarpe/wv/link.rb +6 -17
  213. data/lib/scarpe/wv/list_box.rb +6 -29
  214. data/lib/scarpe/wv/oval.rb +13 -0
  215. data/lib/scarpe/wv/para.rb +12 -30
  216. data/lib/scarpe/wv/progress.rb +19 -0
  217. data/lib/scarpe/wv/radio.rb +9 -10
  218. data/lib/scarpe/wv/rect.rb +13 -0
  219. data/lib/scarpe/wv/scarpe_extensions.rb +8 -0
  220. data/lib/scarpe/wv/shape.rb +13 -13
  221. data/lib/scarpe/wv/slot.rb +8 -25
  222. data/lib/scarpe/wv/stack.rb +2 -18
  223. data/lib/scarpe/wv/star.rb +3 -53
  224. data/lib/scarpe/wv/subscription_item.rb +38 -4
  225. data/lib/scarpe/wv/text_drawable.rb +90 -0
  226. data/lib/scarpe/wv/video.rb +15 -15
  227. data/lib/scarpe/wv/web_wrangler.rb +320 -328
  228. data/lib/scarpe/wv/webview_local_display.rb +52 -33
  229. data/lib/scarpe/wv/webview_relay_display.rb +12 -12
  230. data/lib/scarpe/wv/webview_relay_util.rb +7 -10
  231. data/lib/scarpe/wv/wv_display_worker.rb +2 -2
  232. data/lib/scarpe/wv.rb +52 -12
  233. data/lib/scarpe/wv_local.rb +1 -1
  234. data/lib/scarpe/wv_relay.rb +1 -1
  235. data/lib/scarpe.rb +1 -0
  236. data/logger/debug_web_wrangler.json +1 -1
  237. data/logger/scarpe_wv_test.json +1 -1
  238. data/scarpe-components/Gemfile +4 -1
  239. data/scarpe-components/Gemfile.lock +85 -0
  240. data/scarpe-components/README.md +2 -2
  241. data/scarpe-components/assets/bootstrap-themes/bootstrap-cerulean.css +12229 -0
  242. data/scarpe-components/assets/bootstrap-themes/bootstrap-cosmo.css +11810 -0
  243. data/scarpe-components/assets/bootstrap-themes/bootstrap-cyborg.css +12210 -0
  244. data/scarpe-components/assets/bootstrap-themes/bootstrap-darkly.css +12153 -0
  245. data/scarpe-components/assets/bootstrap-themes/bootstrap-flatly.css +12126 -0
  246. data/scarpe-components/assets/bootstrap-themes/bootstrap-icons.min.css +5 -0
  247. data/scarpe-components/assets/bootstrap-themes/bootstrap-journal.css +12099 -0
  248. data/scarpe-components/assets/bootstrap-themes/bootstrap-litera.css +12211 -0
  249. data/scarpe-components/assets/bootstrap-themes/bootstrap-lumen.css +12369 -0
  250. data/scarpe-components/assets/bootstrap-themes/bootstrap-lux.css +11928 -0
  251. data/scarpe-components/assets/bootstrap-themes/bootstrap-materia.css +13184 -0
  252. data/scarpe-components/assets/bootstrap-themes/bootstrap-minty.css +12177 -0
  253. data/scarpe-components/assets/bootstrap-themes/bootstrap-morph.css +12750 -0
  254. data/scarpe-components/assets/bootstrap-themes/bootstrap-pulse.css +11890 -0
  255. data/scarpe-components/assets/bootstrap-themes/bootstrap-quartz.css +12622 -0
  256. data/scarpe-components/assets/bootstrap-themes/bootstrap-sandstone.css +12201 -0
  257. data/scarpe-components/assets/bootstrap-themes/bootstrap-simplex.css +12186 -0
  258. data/scarpe-components/assets/bootstrap-themes/bootstrap-sketchy.css +12451 -0
  259. data/scarpe-components/assets/bootstrap-themes/bootstrap-slate.css +12492 -0
  260. data/scarpe-components/assets/bootstrap-themes/bootstrap-solar.css +12149 -0
  261. data/scarpe-components/assets/bootstrap-themes/bootstrap-spacelab.css +12266 -0
  262. data/scarpe-components/assets/bootstrap-themes/bootstrap-superhero.css +12216 -0
  263. data/scarpe-components/assets/bootstrap-themes/bootstrap-united.css +12077 -0
  264. data/scarpe-components/assets/bootstrap-themes/bootstrap-vapor.css +12549 -0
  265. data/scarpe-components/assets/bootstrap-themes/bootstrap-yeti.css +12325 -0
  266. data/scarpe-components/assets/bootstrap-themes/bootstrap-zephyr.css +12283 -0
  267. data/scarpe-components/assets/bootstrap-themes/bootstrap.bundle.min.js +7 -0
  268. data/scarpe-components/lib/scarpe/components/asset_server.rb +219 -0
  269. data/scarpe-components/lib/scarpe/components/base64.rb +23 -5
  270. data/scarpe-components/lib/scarpe/components/calzini/alert.rb +49 -0
  271. data/scarpe-components/lib/scarpe/components/calzini/art_drawables.rb +227 -0
  272. data/scarpe-components/lib/scarpe/components/calzini/border.rb +38 -0
  273. data/scarpe-components/lib/scarpe/components/calzini/button.rb +37 -0
  274. data/scarpe-components/lib/scarpe/components/calzini/misc.rb +136 -0
  275. data/scarpe-components/lib/scarpe/components/calzini/para.rb +237 -0
  276. data/scarpe-components/lib/scarpe/components/calzini/slots.rb +109 -0
  277. data/scarpe-components/lib/scarpe/components/calzini.rb +236 -0
  278. data/scarpe-components/lib/scarpe/components/errors.rb +24 -0
  279. data/scarpe-components/lib/scarpe/components/file_helpers.rb +1 -0
  280. data/scarpe-components/lib/scarpe/components/html.rb +134 -0
  281. data/scarpe-components/lib/scarpe/components/minitest_export_reporter.rb +83 -0
  282. data/scarpe-components/lib/scarpe/components/minitest_import_runnable.rb +98 -0
  283. data/scarpe-components/lib/scarpe/components/minitest_result.rb +127 -0
  284. data/scarpe-components/lib/scarpe/components/modular_logger.rb +5 -5
  285. data/scarpe-components/lib/scarpe/components/print_logger.rb +22 -3
  286. data/scarpe-components/lib/scarpe/components/process_helpers.rb +37 -0
  287. data/scarpe-components/lib/scarpe/components/promises.rb +14 -14
  288. data/scarpe-components/lib/scarpe/components/segmented_file_loader.rb +36 -17
  289. data/scarpe-components/lib/scarpe/components/string_helpers.rb +10 -0
  290. data/scarpe-components/lib/scarpe/components/tiranti.rb +167 -0
  291. data/scarpe-components/lib/scarpe/components/unit_test_helpers.rb +48 -6
  292. data/scarpe-components/lib/scarpe/components/version.rb +2 -2
  293. data/scarpe-components/test/assets/big-image.png +0 -0
  294. data/scarpe-components/test/assets/big-stylesheet.css +497 -0
  295. data/scarpe-components/test/assets/little-image.png +0 -0
  296. data/scarpe-components/test/assets/little-stylesheet.css +1 -0
  297. data/scarpe-components/test/calzini/test_calzini_alert.rb +30 -0
  298. data/scarpe-components/test/calzini/test_calzini_art_drawables.rb +105 -0
  299. data/scarpe-components/test/calzini/test_calzini_button.rb +54 -0
  300. data/scarpe-components/test/calzini/test_calzini_misc.rb +115 -0
  301. data/scarpe-components/test/calzini/test_calzini_para.rb +34 -0
  302. data/scarpe-components/test/calzini/test_calzini_slots.rb +85 -0
  303. data/scarpe-components/test/calzini/test_calzini_text_drawables.rb +106 -0
  304. data/scarpe-components/test/calzini/test_various.rb +133 -0
  305. data/scarpe-components/test/mtr_data/exception.json +1 -0
  306. data/scarpe-components/test/mtr_data/fail_with_message.json +1 -0
  307. data/scarpe-components/test/mtr_data/skipped_no_message.json +1 -0
  308. data/scarpe-components/test/mtr_data/skipped_w_msg.json +1 -0
  309. data/scarpe-components/test/mtr_data/succeed_2_asserts.json +1 -0
  310. data/scarpe-components/test/test_asset_server.rb +72 -0
  311. data/scarpe-components/test/test_components.rb +31 -2
  312. data/scarpe-components/test/test_dimensions.rb +26 -0
  313. data/scarpe-components/test/test_helper.rb +20 -1
  314. data/scarpe-components/test/test_html.rb +65 -0
  315. data/scarpe-components/test/test_minitest_result.rb +68 -0
  316. data/scarpe-components/test/test_promises.rb +5 -4
  317. data/scarpe-components/test/test_segmented_app_files.rb +10 -6
  318. data/scarpegen.rb +14 -14
  319. data/sig/scarpe.rbs +1 -1
  320. data/tasks/check_html_fixtures.rb +140 -0
  321. data/tasks/regenerate_html_fixtures.rb +104 -0
  322. data/templates/basic_class_template.erb +13 -14
  323. data/templates/class_template_with_event_bind.erb +4 -4
  324. data/templates/class_template_with_shapes.erb +8 -28
  325. data/templates/example_template.erb +1 -1
  326. data/templates/module_template.erb +4 -4
  327. data/templates/webview_template.erb +3 -2
  328. metadata +286 -80
  329. data/examples/legacy/not_checked/shoes-contrib/elements/image-icon.rb +0 -3
  330. data/lacci/lib/shoes/spacing.rb +0 -9
  331. data/lacci/lib/shoes/widget.rb +0 -218
  332. data/lacci/lib/shoes/widgets/alert.rb +0 -19
  333. data/lacci/lib/shoes/widgets/arc.rb +0 -51
  334. data/lacci/lib/shoes/widgets/button.rb +0 -35
  335. data/lacci/lib/shoes/widgets/check.rb +0 -28
  336. data/lacci/lib/shoes/widgets/document_root.rb +0 -20
  337. data/lacci/lib/shoes/widgets/flow.rb +0 -22
  338. data/lacci/lib/shoes/widgets/font.rb +0 -14
  339. data/lacci/lib/shoes/widgets/line.rb +0 -18
  340. data/lacci/lib/shoes/widgets/link.rb +0 -25
  341. data/lacci/lib/shoes/widgets/list_box.rb +0 -25
  342. data/lacci/lib/shoes/widgets/para.rb +0 -68
  343. data/lacci/lib/shoes/widgets/radio.rb +0 -35
  344. data/lacci/lib/shoes/widgets/slot.rb +0 -75
  345. data/lacci/lib/shoes/widgets/span.rb +0 -26
  346. data/lacci/lib/shoes/widgets/stack.rb +0 -24
  347. data/lacci/lib/shoes/widgets/star.rb +0 -44
  348. data/lacci/lib/shoes/widgets/subscription_item.rb +0 -60
  349. data/lacci/lib/shoes/widgets/text_widget.rb +0 -51
  350. data/lacci/lib/shoes/widgets/video.rb +0 -15
  351. data/lacci/lib/shoes/widgets.rb +0 -29
  352. data/lib/scarpe/evented_assertions.rb +0 -88
  353. data/lib/scarpe/wv/alert.rb +0 -66
  354. data/lib/scarpe/wv/background.rb +0 -27
  355. data/lib/scarpe/wv/control_interface_test.rb +0 -238
  356. data/lib/scarpe/wv/dimensions.rb +0 -22
  357. data/lib/scarpe/wv/font.rb +0 -36
  358. data/lib/scarpe/wv/html.rb +0 -108
  359. data/lib/scarpe/wv/spacing.rb +0 -41
  360. data/lib/scarpe/wv/span.rb +0 -68
  361. data/lib/scarpe/wv/text_widget.rb +0 -30
  362. /data/examples/legacy/not_checked/{expert → shoes-contrib/basic}/definr.rb +0 -0
  363. /data/examples/legacy/not_checked/{expert → shoes-contrib/basic}/funnies.rb +0 -0
  364. /data/examples/legacy/not_checked/shoes-contrib/{elements → basic}/list_box-select-class.rb +0 -0
  365. /data/examples/legacy/{not_checked → working}/shoes3-tests/editline/editline.rb +0 -0
  366. /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/basic-edit-box.rb +0 -0
  367. /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/basic-fps.rb +0 -0
  368. /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/border-cat.rb +0 -0
  369. /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/check-mate.rb +0 -0
  370. /data/examples/legacy/{not_checked/shoes-contrib/manipulation → working/simple}/clear-slot.rb +0 -0
  371. /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/clock.rb +0 -0
  372. /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/gradient-shoes.rb +0 -0
  373. /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/list_box-shape-report.rb +0 -0
  374. /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/list_box.rb +0 -0
  375. /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/phat-button.rb +0 -0
  376. /data/examples/legacy/{not_checked/shoes-contrib → working}/simple/simple-calc.rb +0 -0
  377. /data/examples/legacy/{not_checked/shoes-contrib/position → working/simple}/stack-width.rb +0 -0
  378. /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/width-introspec.rb +0 -0
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes; end
4
+ module Shoes::Errors
5
+ class InvalidAttributeValueError < Shoes::Error; end
6
+
7
+ class TooManyInstancesError < Shoes::Error; end
8
+
9
+ class NoSuchListItemError < Shoes::Error; end
10
+
11
+ class DuplicateCreateDrawableError < Shoes::Error; end
12
+
13
+ class MultipleDrawablesFoundError < Shoes::Error; end
14
+
15
+ class NoDrawablesFoundError < Shoes::Error; end
16
+
17
+ class NoSuchStyleError < Shoes::Error; end
18
+
19
+ class NoSuchLinkableIdError < Shoes::Error; end
20
+
21
+ class BadLinkableIdError < Shoes::Error; end
22
+
23
+ class UnregisteredShoesEventError < Shoes::Error; end
24
+
25
+ class BadArgumentListError < Shoes::Error; end
26
+
27
+ class SingletonError < Shoes::Error; end
28
+
29
+ class MultipleShoesSpecRunsError < Shoes::Error; end
30
+
31
+ class UnsupportedFeatureError < Shoes::Error; end
32
+
33
+ class BadFilenameError < Shoes::Error; end
34
+
35
+ class UnknownEventsForClassError < Shoes::Error; end
36
+
37
+ class DoubleRegisteredShoesEventError < Shoes::Error; end
38
+ end
@@ -8,7 +8,7 @@
8
8
  # If used alone, this will fail because the @instance is nil. It needs
9
9
  # an implementation to be plugged in.
10
10
 
11
- module Shoes
11
+ class Shoes
12
12
  LOG_LEVELS = [:debug, :info, :warn, :error, :fatal].freeze
13
13
 
14
14
  # Include this module to get a @log instance variable to log as your
@@ -28,7 +28,7 @@ module Shoes
28
28
  attr_reader :current_log_config
29
29
 
30
30
  def instance=(impl_object)
31
- raise(Shoes::Error, "Already have an instance for Shoes::Log!") if @instance
31
+ raise(Shoes::Errors::TooManyInstancesError, "Already have an instance for Shoes::Log!") if @instance
32
32
 
33
33
  @instance = impl_object
34
34
  end
@@ -0,0 +1,79 @@
1
+ module MarginHelper
2
+
3
+ def margin_parse(kwargs)
4
+
5
+ if kwargs[:margin]
6
+
7
+ if kwargs[:margin].is_a?(Numeric)
8
+
9
+ if !kwargs[:margin_top]
10
+ kwargs[:margin_top] = kwargs[:margin]
11
+ end
12
+ if !kwargs[:margin_bottom]
13
+ kwargs[:margin_bottom] = kwargs[:margin]
14
+ end
15
+ if !kwargs[:margin_left]
16
+ kwargs[:margin_left] = kwargs[:margin]
17
+ end
18
+ if !kwargs[:margin_right]
19
+ kwargs[:margin_right] = kwargs[:margin]
20
+ end
21
+
22
+ elsif kwargs[:margin].is_a?(Hash)
23
+
24
+ kwargs[:margin].each do |key,value|
25
+ kwargs[:"margin_#{key}"] = value
26
+ end
27
+
28
+ else
29
+ margin_props = kwargs[:margin].is_a?(String) ? kwargs[:margin].split(/\s+|\,|-/) : kwargs[:margin]
30
+ if margin_props.length == 1
31
+
32
+ if !kwargs[:margin_top]
33
+ kwargs[:margin_top] = margin_props[0]
34
+ end
35
+ if !kwargs[:margin_bottom]
36
+ kwargs[:margin_bottom] = margin_props[0]
37
+ end
38
+ if !kwargs[:margin_left]
39
+ kwargs[:margin_left] = margin_props[0]
40
+ end
41
+ if !kwargs[:margin_right]
42
+ kwargs[:margin_right] = margin_props[0]
43
+ end
44
+
45
+ elsif margin_props.length == 2
46
+
47
+ raise(Shoes::Errors::InvalidAttributeValueError, "Margin don't support 2-3 values as Array/string input for using 2-3 input you can use the hash input method like '{left:value, right:value, top:value, bottom:value}'")
48
+
49
+ elsif margin_props.length == 3
50
+
51
+ raise(Shoes::Errors::InvalidAttributeValueError, "Margin don't support 2-3 values as Array/string input for using 2-3 input you can use the hash input method like '{left:value,right:value,top:value,bottom:value}'")
52
+
53
+ else
54
+
55
+ if !kwargs[:margin_top]
56
+ kwargs[:margin_top] = margin_props[1]
57
+ end
58
+ if !kwargs[:margin_bottom]
59
+ kwargs[:margin_bottom] = margin_props[3]
60
+ end
61
+ if !kwargs[:margin_left]
62
+ kwargs[:margin_left] = margin_props[0]
63
+ end
64
+ if !kwargs[:margin_right]
65
+ kwargs[:margin_right] = margin_props[2]
66
+ end
67
+
68
+ end
69
+ end
70
+ kwargs[:margin] = nil
71
+ end
72
+ if kwargs["options"] && !kwargs[:margin] && !kwargs[:margin_left] && !kwargs[:margin_right] && !kwargs[:margin_top] && !kwargs[:margin_bottom]
73
+ kwargs[options].each do |key,value|
74
+ kwargs[key] = value
75
+ end
76
+ end
77
+ kwargs
78
+ end
79
+ end
@@ -0,0 +1,15 @@
1
+
2
+ class Range
3
+ def rand
4
+ conv = (Integer === self.end && Integer === self.begin ? :to_i : :to_f)
5
+ ((Kernel.rand * (self.end - self.begin)) + self.begin).send(conv)
6
+ end
7
+ end
8
+
9
+ unless Time.respond_to? :today
10
+ def Time.today
11
+ t = Time.now
12
+ t - (t.to_i % 86_400)
13
+ end
14
+ end
15
+
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes
4
+ # A Scarpe-compatible display service can set Shoes::Spec.instance to
5
+ # a ShoesSpec testing class, and use it to run Shoes-Spec code.
6
+ # A Shoes application should never do this. It's intended to be used
7
+ # by display services.
8
+ module Spec
9
+ def self.instance
10
+ @instance
11
+ end
12
+
13
+ def self.instance=(spec_inst)
14
+ if @instance && @instance != spec_inst
15
+ raise "Lacci can only use a single ShoesSpec implementation at one time!"
16
+ end
17
+
18
+ @instance = spec_inst
19
+ end
20
+ end
21
+
22
+ # ShoesSpec testing objects can optionally inherit from this object,
23
+ # which shows the ShoesSpec testing API.
24
+ #
25
+ # @see {Shoes::Spec.instance=}
26
+ class SpecInstance
27
+ # Once a Shoes app has been created, this method can be called to
28
+ # execute Shoes-Spec testing code for that application. Shoes-Spec
29
+ # uses Minitest for most of its APIs, and Minitest generally reports
30
+ # results with a class name and test name. If those aren't passed
31
+ # explicitly, the SpecInstance can choose reasonable defaults.
32
+ #
33
+ # The test code should be set up to run automatically from the
34
+ # display service's existing hooks. For instance, the code might
35
+ # run in response to the first heartbeat, if the display service
36
+ # uses heartbeats.
37
+ #
38
+ # The test code will export assertion data in its native format.
39
+ # Multiple display services choose to use the Scarpe-Component
40
+ # for Minitest data export, which is straightforward to import
41
+ # into the Shoes-Spec test harness.
42
+ #
43
+ # @param code [String] the ShoesSpec code to execute
44
+ # @param class_name [String|NilClass] the Minitest class name for reporting or nil
45
+ # @param test_name [String|NilClass] the Minitest test name for reporting or nil
46
+ # @return [void]
47
+ def run_shoes_spec_test_code(code, class_name: nil, test_name: nil)
48
+ raise "Child class should override this!"
49
+ end
50
+ end
51
+
52
+ # ShoesSpec instances support finder methods like button() that return
53
+ # a proxy to the corresponding drawable. Those proxies should support
54
+ # standard Shoes::Drawable methods, including the ones appropriate to
55
+ # the same drawable object. They should also support certain other
56
+ # testing-specific methods like "trigger_click" that are used to
57
+ # simulate display-side events during testing.
58
+ #
59
+ # Keep in mind that a proxy will often be in a different process from
60
+ # the Shoes app. So the proxy can't portably return the object or
61
+ # display object, though it could possibly return another proxy for such
62
+ # a thing.
63
+ class SpecProxy
64
+ # The proxy will have finder methods for all drawables, such as
65
+ # button(), edit_line(), etc. How to document those?
66
+
67
+ # Trigger a click on a button or button-like drawable. Not every
68
+ # drawable will support this operation.
69
+ def trigger_click()
70
+ raise "Child class should override this!"
71
+ end
72
+
73
+ # Trigger a hover over a hoverable drawable. Not every
74
+ # drawable will support this operation. A drawable that supports
75
+ # hover should support leave and vice-versa.
76
+ def trigger_hover()
77
+ raise "Child class should override this!"
78
+ end
79
+
80
+ # Trigger ending hover over a hoverable drawable. Not every
81
+ # drawable will support this operation. A drawable that supports
82
+ # hover should support leave and vice-versa.
83
+ def trigger_leave()
84
+ raise "Child class should override this!"
85
+ end
86
+
87
+ # Trigger a change in value for a drawable like a list_box
88
+ # with multiple values.
89
+ def trigger_change(value)
90
+ raise "Child class should override this!"
91
+ end
92
+ end
93
+ end
data/lacci/lib/shoes.rb CHANGED
@@ -12,38 +12,51 @@ if RUBY_VERSION[0..2] < "3.2"
12
12
  exit(-1)
13
13
  end
14
14
 
15
- module Shoes; end
15
+ class Shoes; end
16
16
  class Shoes::Error < StandardError; end
17
+ require_relative "shoes/errors"
17
18
 
18
19
  require_relative "shoes/constants"
20
+ require_relative "shoes/ruby_extensions"
19
21
 
20
22
  # Shoes adds some top-level methods and constants that can be used everywhere. Kernel is where they go.
21
23
  module Kernel
22
24
  include Shoes::Constants
23
25
  end
24
26
 
25
- require_relative "shoes/log"
26
27
  require_relative "shoes/display_service"
28
+
29
+ # Pre-declare classes that get referenced outside their own require file
30
+ class Shoes::Drawable < Shoes::Linkable; end
31
+ class Shoes::Slot < Shoes::Drawable; end
32
+ class Shoes::Widget < Shoes::Slot; end
33
+
34
+ require_relative "shoes/log"
27
35
  require_relative "shoes/colors"
28
36
 
37
+ require_relative "shoes/builtins"
38
+
29
39
  require_relative "shoes/background"
30
- require_relative "shoes/border"
31
- require_relative "shoes/spacing"
32
40
 
33
- require_relative "shoes/widget"
41
+ require_relative "shoes/drawable"
34
42
  require_relative "shoes/app"
35
- require_relative "shoes/widgets"
43
+ require_relative "shoes/drawables"
36
44
 
37
45
  require_relative "shoes/download"
38
46
 
47
+ # No easy way to tell at this point whether
48
+ # we will later load Shoes-Spec code, e.g.
49
+ # by running a segmented app with test code.
50
+ require_relative "shoes-spec"
51
+
39
52
  # The module containing Shoes in all its glory.
40
53
  # Shoes is a platform-independent GUI library, designed to create
41
54
  # small visual applications in Ruby.
42
55
  #
43
- module Shoes
56
+ class Shoes
44
57
  class << self
45
58
  # Creates a Shoes app with a new window. The block parameter is used to create
46
- # widgets and set up handlers. Arguments are passed to Shoes::App.new internally.
59
+ # drawables and set up handlers. Arguments are passed to Shoes::App.new internally.
47
60
  #
48
61
  # @incompatibility In Shoes3, this method will return normally.
49
62
  # In Scarpe, after the block is executed, the method will not return and Scarpe
@@ -61,6 +74,7 @@ module Shoes
61
74
  # @param width [Integer] The new app window width
62
75
  # @param height [Integer] The new app window height
63
76
  # @param resizable [Boolean] Whether the app window should be resizeable
77
+ # @param features [Symbol,Array<Symbol>] Additional Shoes extensions requested by the app
64
78
  # @return [void]
65
79
  # @see Shoes::App#new
66
80
  def app(
@@ -68,9 +82,11 @@ module Shoes
68
82
  width: 480,
69
83
  height: 420,
70
84
  resizable: true,
85
+ features: [],
71
86
  &app_code_body
72
87
  )
73
- app = Shoes::App.new(title:, width:, height:, resizable:, &app_code_body)
88
+ f = [features].flatten # Make sure this is a list, not a single symbol
89
+ app = Shoes::App.new(title:, width:, height:, resizable:, features: f, &app_code_body)
74
90
  app.init
75
91
  app.run
76
92
  nil
@@ -81,11 +97,16 @@ module Shoes
81
97
  # more loaders, a Lacci-based display library can accept new file formats as
82
98
  # well, not just raw Shoes .rb files.
83
99
  #
84
- # @param path [String] The current-dir-relative path to the file
100
+ # @param relative_path [String] The current-dir-relative path to the file
85
101
  # @return [void]
86
102
  # @see Shoes.add_file_loader
87
103
  def run_app(relative_path)
88
104
  path = File.expand_path relative_path
105
+ dir = File.dirname(path)
106
+
107
+ # Shoes assumes we're starting from the app code's path
108
+ Dir.chdir(dir)
109
+
89
110
  loaded = false
90
111
  file_loaders.each do |loader|
91
112
  if loader.call(path)
@@ -0,0 +1 @@
1
+ niente_test.json
@@ -0,0 +1,167 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "test_helper"
4
+
5
+ class TestDrawContext < NienteTest
6
+ # need tests for:
7
+ # default values vs draw context values
8
+ # setting value explicitly w/ positional or keyword arg
9
+
10
+ # Test w/ color string names for now. This reveals a
11
+ # problem - our highly-variable color handling makes it
12
+ # hard to be sure about what comes through in a style.
13
+
14
+ # We do a bunch of wacky stuff with colors. We need some kind of
15
+ # equality check. This is good enough for this test until we
16
+ # have a proper color object backing up what we do in Scarpe.
17
+ def assert_color_equal(c1, c2)
18
+ if c1.nil? && c2.nil?
19
+ raise "Is this an expected use case?"
20
+ end
21
+
22
+ if (c1.is_a?(String) || c1.is_a?(Symbol)) && (c2.is_a?(String) || c2.is_a?(Symbol))
23
+ return assert_equal c1.to_s, c2.to_s, "Expected color #{c1.inspect} to equal #{c2.inspect}"
24
+ end
25
+
26
+ if c1.is_a?(Array) && c2.is_a?(Array)
27
+ return assert_equal c1, c2, "Expected color #{c1.inspect} to equal #{c2.inspect}"
28
+ end
29
+
30
+ raise "Oopsie! We got an unexpected comparison between colors #{c1.inspect}"
31
+ end
32
+
33
+ def test_draw_context_default
34
+ run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
35
+ Shoes.app do
36
+ oval 5, 10, 25 # circle with radius 25 with its upper-left point at 5, 10
37
+ end
38
+ SHOES_APP
39
+ ov = oval()
40
+ assert_equal "black", ov.style["fill"]
41
+ assert_equal "black", ov.style["stroke"]
42
+ SHOES_SPEC
43
+ end
44
+
45
+ def test_draw_context_basic
46
+ run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
47
+ Shoes.app do
48
+ fill darkgreen
49
+ stroke blue
50
+ oval 5, 10, 25 # circle with radius 25 with its upper-left point at 5, 10
51
+ end
52
+ SHOES_APP
53
+ ov = oval()
54
+ assert_equal [0, 100, 0, 255], ov.style["fill"]
55
+ assert_equal [0, 0, 255, 255], ov.style["stroke"]
56
+ SHOES_SPEC
57
+ end
58
+
59
+ def test_draw_context_explicit
60
+ run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
61
+ Shoes.app do
62
+ fill blue
63
+ stroke blue
64
+ oval 5, 10, 25, fill: darkgreen
65
+ end
66
+ SHOES_APP
67
+ ov = oval()
68
+ assert_equal [0, 100, 0, 255], ov.style["fill"]
69
+ assert_equal [0, 0, 255, 255], ov.style["stroke"]
70
+ SHOES_SPEC
71
+ end
72
+
73
+ def test_draw_context_basic_nofill
74
+ run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
75
+ Shoes.app do
76
+ nofill
77
+ oval 5, 10, 25
78
+ end
79
+ SHOES_APP
80
+ ov = oval()
81
+ assert_equal [0, 0, 0, 0], ov.style["fill"]
82
+ SHOES_SPEC
83
+ end
84
+
85
+ def test_draw_context_inherited_nofill
86
+ run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
87
+ Shoes.app do
88
+ nofill
89
+ nostroke
90
+ stack do
91
+ oval 5, 10, 25
92
+ end
93
+ end
94
+ SHOES_APP
95
+ ov = oval()
96
+ assert_equal [0, 0, 0, 0], ov.style["fill"]
97
+ assert_equal [0, 0, 0, 0], ov.style["stroke"]
98
+ SHOES_SPEC
99
+ end
100
+
101
+ def test_draw_context_inherited_no_sibling
102
+ run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
103
+ Shoes.app do
104
+ fill yellow
105
+ stroke yellow
106
+ stack do
107
+ fill blue
108
+ stroke darkgreen
109
+ stack do
110
+ fill aquamarine
111
+ stroke aquamarine
112
+ end
113
+ stack do
114
+ oval 5, 10, 25
115
+ end
116
+ end
117
+ end
118
+ SHOES_APP
119
+ ov = oval()
120
+ assert_equal [0, 0, 255, 255], ov.style["fill"]
121
+ assert_equal [0, 100, 0, 255], ov.style["stroke"]
122
+ SHOES_SPEC
123
+ end
124
+
125
+ def test_draw_context_inherited_nil_props
126
+ run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
127
+ Shoes.app do
128
+ stack do
129
+ fill blue
130
+ stroke darkgreen
131
+ stack do
132
+ fill nil
133
+ stroke nil
134
+ oval 5, 10, 25
135
+ end
136
+ end
137
+ end
138
+ SHOES_APP
139
+ ov = oval()
140
+ assert_equal [0, 0, 255, 255], ov.style["fill"]
141
+ assert_equal [0, 100, 0, 255], ov.style["stroke"]
142
+ SHOES_SPEC
143
+ end
144
+
145
+ def test_draw_context_inherited_cancel_default
146
+ run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
147
+ Shoes.app do
148
+ stack do
149
+ fill blue
150
+ stroke darkgreen
151
+ stack do
152
+ fill yellow
153
+ stroke yellow
154
+ oval 5, 10, 25
155
+ fill nil
156
+ stroke nil
157
+ @o2 = oval 5, 10, 25
158
+ end
159
+ end
160
+ end
161
+ SHOES_APP
162
+ ov = oval("@o2")
163
+ assert_equal [0, 0, 255, 255], ov.style["fill"]
164
+ assert_equal [0, 100, 0, 255], ov.style["stroke"]
165
+ SHOES_SPEC
166
+ end
167
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "test_helper"
4
+
5
+
6
+ class TestFontHelper < Minitest::Test
7
+ include FontHelper
8
+ def test_parse_full_font
9
+
10
+ string = "Pacifico 20px bold italic small-caps"
11
+
12
+ assert_equal(["italic", "small-caps" , "bold" , "20px" , "Pacifico"],parse_font(string))
13
+
14
+ end
15
+
16
+ def test_parse_quotesFamily
17
+ string = "'Times new roman', serif 20px bold italic small-caps"
18
+
19
+ assert_equal(["italic", "small-caps", "bold", "20px", "'Times new roman', serif"],parse_font(string))
20
+ end
21
+
22
+ def test_parse_empty
23
+ string = ""
24
+
25
+ assert_equal([nil,nil,nil,nil,""],parse_font(string))
26
+ end
27
+
28
+ def test_parse_onlyFamily
29
+ string = "arial"
30
+
31
+ assert_equal([nil,nil,nil,nil,"arial"],parse_font(string))
32
+ end
33
+
34
+ def test_parse_onlySize
35
+ string = "40px"
36
+
37
+ assert_equal([nil,nil,nil,"40px",""],parse_font(string))
38
+ end
39
+
40
+ def test_parse_onlyFontStyle
41
+ string = "italic"
42
+
43
+ assert_equal(["italic",nil,nil,nil,""],parse_font(string))
44
+ end
45
+
46
+ def test_parse_onlyFontVariant
47
+ string = "small-caps"
48
+
49
+ assert_equal([nil,"small-caps",nil,nil,""],parse_font(string))
50
+ end
51
+
52
+ def test_parse_onlyFontWeight
53
+ string = "900"
54
+
55
+ assert_equal([nil,nil,"900",nil,""],parse_font(string))
56
+ end
57
+ end
@@ -3,7 +3,88 @@
3
3
  $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
4
  require "shoes"
5
5
 
6
+ require "scarpe/components/unit_test_helpers"
7
+ require "scarpe/components/minitest_result"
8
+
6
9
  require "minitest/autorun"
7
10
 
8
11
  require "minitest/reporters"
9
12
  Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
13
+
14
+ # For testing Lacci, it's kind of silly to start a Webview application.
15
+ # They're slow, unreliable and memory-hungry. So instead we start a
16
+ # Niente do-nothing application for a simple API test. It's a lot like
17
+ # mocking.
18
+ class NienteTest < Minitest::Test
19
+ include ::Scarpe::Test::Helpers
20
+
21
+ SCARPE_EXE = File.expand_path("../../exe/scarpe", __dir__)
22
+
23
+ def run_test_niente_code(
24
+ scarpe_app_code,
25
+ test_extension: ".rb",
26
+ **opts
27
+ )
28
+ with_tempfile(["scarpe_test_app", test_extension], scarpe_app_code) do |test_app_location|
29
+ run_test_niente_app(test_app_location, **opts)
30
+ end
31
+ end
32
+
33
+ def run_test_niente_app(
34
+ test_app_location,
35
+ app_test_code: "",
36
+ timeout: 5.0,
37
+ class_name: self.class,
38
+ method_name: self.name,
39
+ expect_process_fail: false,
40
+ expect_minitest_exception: false,
41
+ display_service: "niente",
42
+ log_level: "warn"
43
+ )
44
+ sspec_file = File.expand_path(File.join __dir__, "niente_test.json")
45
+ File.unlink sspec_file rescue nil
46
+
47
+ with_tempfiles([
48
+ #["scarpe_log_config.json", JSON.dump(log_config_for_test)],
49
+ [["shoes_spec_code", ".rb"], app_test_code],
50
+ ]) do |shoes_spec_path,_|
51
+ system(
52
+ "LOCALAPPDATA=\"#{Dir.tmpdir}\" " +
53
+ "NIENTE_LOG_LEVEL=#{log_level} " +
54
+ "SHOES_SPEC_TEST=\"#{shoes_spec_path}\" " +
55
+ "SCARPE_DISPLAY_SERVICE=\"#{display_service}\" " +
56
+ "SHOES_MINITEST_EXPORT_FILE=#{sspec_file} " +
57
+ "SHOES_MINITEST_CLASS_NAME=\"#{class_name}\" " +
58
+ "SHOES_MINITEST_METHOD_NAME=\"#{method_name}\" " +
59
+ "ruby #{SCARPE_EXE} --dev #{test_app_location}"
60
+ )
61
+ end
62
+
63
+ if expect_process_fail
64
+ assert(false, "Expected app to fail but it succeeded!") if $?.success?
65
+ return
66
+ end
67
+
68
+ # Check if the process exited normally or crashed (segfault, failure, timeout)
69
+ unless $?.success?
70
+ assert(false, "App failed with exit code: #{$?.exitstatus}")
71
+ return
72
+ end
73
+
74
+ result = Scarpe::Components::MinitestResult.new(sspec_file)
75
+ if result.error?
76
+ if expect_minitest_exception
77
+ assert_equal true, true
78
+ else
79
+ raise result.error_message
80
+ end
81
+ elsif result.fail?
82
+ assert false, result.fail_message
83
+ elsif result.skip?
84
+ skip
85
+ else
86
+ # Count out the correct number of assertions
87
+ result.assertions.times { assert true }
88
+ end
89
+ end
90
+ end