scarpe 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/.yardopts +12 -0
- data/CHANGELOG.md +16 -2
- data/Gemfile +3 -0
- data/Gemfile.lock +116 -0
- data/README.md +53 -30
- data/Rakefile +13 -1
- data/docs/yard/catscradle.md +44 -0
- data/docs/yard/template/default/fulldoc/html/setup.rb +13 -0
- data/docs/yard/template/default/layout/html/setup.rb +9 -0
- data/examples/animate.rb +20 -0
- data/examples/arrow.rb +10 -0
- data/examples/background_with_image.rb +16 -0
- data/examples/bloopsaphone/working/bronx_army_knife.rb +66 -0
- data/examples/bloopsaphone/working/morning_serenity.rb +21 -0
- data/examples/bloopsaphone/working/simpsons_theme_song_by_why.rb +6 -4
- data/examples/btn_tooltip.rb +7 -0
- data/examples/button_go_away.rb +1 -1
- data/examples/button_style_changed.rb +7 -0
- data/examples/button_styles_default.rb +6 -0
- data/examples/check.rb +18 -0
- data/examples/clear_and_append.rb +24 -0
- data/examples/download_and_show_image.rb +28 -0
- data/examples/edit_box.rb +3 -5
- data/examples/fonts.rb +2 -2
- data/examples/gen.rb +8 -8
- data/examples/get_headers.rb +10 -0
- data/examples/highlander.rb +4 -2
- data/examples/legacy/README.md +6 -0
- data/examples/legacy/not_checked/shoes-contrib/basic/shoes-notes.rb +1 -1
- data/examples/legacy/not_checked/simple/anim-shapes.rb +1 -1
- data/examples/legacy/not_checked/speedometer_app.rb +55 -0
- data/examples/legacy/working/simple/image-icon.rb +3 -0
- data/examples/legacy/{not_checked → working}/simple/image.rb +1 -1
- data/examples/link.rb +2 -2
- data/examples/list_box_choose.rb +17 -0
- data/examples/local_assets/local_file_server.rb +82 -0
- data/examples/local_assets/sample.gif +0 -0
- data/examples/local_assets/sample.mp4 +0 -0
- data/examples/local_fonts.rb +4 -0
- data/examples/local_images.rb +3 -0
- data/examples/motion_events.rb +20 -0
- data/examples/para/para_text.rb +14 -0
- data/examples/parse_xl_funnies.rb +58 -0
- data/examples/progress.rb +31 -0
- data/examples/radio/radio.rb +16 -0
- data/examples/radio/radio_groups.rb +18 -0
- data/examples/radio/radio_same_slot.rb +6 -0
- data/examples/rect.rb +4 -0
- data/examples/rotate_shapes.rb +17 -0
- data/examples/ruby_racer.rb +13 -15
- data/examples/selfitude.rb +18 -0
- data/examples/shapes/shapes_fill.rb +4 -3
- data/examples/shoes_school.rb +2 -4
- data/examples/show_hide.rb +6 -0
- data/examples/simpler-menu.rb +21 -0
- data/examples/skip_ci/change_my_audio_source.rb +21 -0
- data/examples/skip_ci/guitar_fretboard.rb +137 -0
- data/examples/video.rb +10 -0
- data/exe/scarpe +43 -66
- data/fonts/Pacifico.ttf +0 -0
- data/lacci/Gemfile +24 -0
- data/lacci/Gemfile.lock +79 -0
- data/lacci/Rakefile +12 -0
- data/lacci/lacci.gemspec +37 -0
- data/lacci/lib/lacci/scarpe_cli.rb +71 -0
- data/lacci/lib/lacci/scarpe_core.rb +22 -0
- data/lacci/lib/lacci/version.rb +13 -0
- data/lacci/lib/scarpe/niente/app.rb +23 -0
- data/lacci/lib/scarpe/niente/display_service.rb +62 -0
- data/lacci/lib/scarpe/niente/drawable.rb +57 -0
- data/lacci/lib/scarpe/niente/logger.rb +29 -0
- data/lacci/lib/scarpe/niente/shoes_spec.rb +87 -0
- data/lacci/lib/scarpe/niente.rb +20 -0
- data/lacci/lib/shoes/app.rb +309 -0
- data/{lib/scarpe → lacci/lib/shoes}/background.rb +2 -2
- data/{lib/scarpe → lacci/lib/shoes}/border.rb +2 -2
- data/lacci/lib/shoes/builtins.rb +63 -0
- data/lacci/lib/shoes/changelog.rb +52 -0
- data/{lib/scarpe → lacci/lib/shoes}/colors.rb +3 -1
- data/lacci/lib/shoes/constants.rb +47 -0
- data/{lib/scarpe → lacci/lib/shoes}/display_service.rb +71 -53
- data/lacci/lib/shoes/download.rb +123 -0
- data/lacci/lib/shoes/drawable.rb +380 -0
- data/lacci/lib/shoes/drawables/arc.rb +49 -0
- data/lacci/lib/shoes/drawables/arrow.rb +41 -0
- data/lacci/lib/shoes/drawables/button.rb +73 -0
- data/lacci/lib/shoes/drawables/check.rb +29 -0
- data/lacci/lib/shoes/drawables/document_root.rb +20 -0
- data/lacci/lib/shoes/drawables/edit_box.rb +29 -0
- data/{lib/scarpe → lacci/lib/shoes/drawables}/edit_line.rb +6 -6
- data/lacci/lib/shoes/drawables/flow.rb +22 -0
- data/{lib/scarpe → lacci/lib/shoes/drawables}/image.rb +7 -11
- data/lacci/lib/shoes/drawables/line.rb +20 -0
- data/lacci/lib/shoes/drawables/link.rb +34 -0
- data/lacci/lib/shoes/drawables/list_box.rb +56 -0
- data/lacci/lib/shoes/drawables/para.rb +118 -0
- data/lacci/lib/shoes/drawables/progress.rb +14 -0
- data/lacci/lib/shoes/drawables/radio.rb +33 -0
- data/lacci/lib/shoes/drawables/rect.rb +17 -0
- data/lacci/lib/shoes/drawables/shape.rb +36 -0
- data/lacci/lib/shoes/drawables/slot.rb +87 -0
- data/{lib/scarpe → lacci/lib/shoes/drawables}/span.rb +8 -7
- data/lacci/lib/shoes/drawables/stack.rb +26 -0
- data/lacci/lib/shoes/drawables/star.rb +50 -0
- data/lacci/lib/shoes/drawables/subscription_item.rb +93 -0
- data/lacci/lib/shoes/drawables/text_drawable.rb +63 -0
- data/lacci/lib/shoes/drawables/video.rb +16 -0
- data/lacci/lib/shoes/drawables/widget.rb +69 -0
- data/lacci/lib/shoes/drawables.rb +31 -0
- data/lacci/lib/shoes/errors.rb +28 -0
- data/lacci/lib/shoes/log.rb +71 -0
- data/lacci/lib/shoes/ruby_extensions.rb +15 -0
- data/lacci/lib/shoes/spacing.rb +9 -0
- data/lacci/lib/shoes-spec.rb +93 -0
- data/lacci/lib/shoes.rb +147 -0
- data/lacci/test/test_colors.rb +39 -0
- data/lacci/test/test_helper.rb +63 -0
- data/lacci/test/test_lacci.rb +18 -0
- data/lacci/test/test_shoes_errors.rb +49 -0
- data/lib/scarpe/cats_cradle.rb +271 -0
- data/lib/scarpe/errors.rb +77 -0
- data/lib/scarpe/evented_assertions.rb +121 -0
- data/lib/scarpe/shoes_spec.rb +181 -0
- data/lib/scarpe/version.rb +2 -2
- data/lib/scarpe/wv/app.rb +45 -23
- data/lib/scarpe/wv/arc.rb +4 -48
- data/lib/scarpe/wv/arrow.rb +9 -0
- data/lib/scarpe/wv/button.rb +7 -33
- data/lib/scarpe/wv/check.rb +27 -0
- data/lib/scarpe/wv/control_interface.rb +32 -40
- data/lib/scarpe/wv/document_root.rb +66 -31
- data/lib/scarpe/wv/drawable.rb +273 -0
- data/lib/scarpe/wv/edit_box.rb +4 -19
- data/lib/scarpe/wv/edit_line.rb +4 -18
- data/lib/scarpe/wv/flow.rb +2 -28
- data/lib/scarpe/wv/image.rb +10 -25
- data/lib/scarpe/wv/line.rb +3 -28
- data/lib/scarpe/wv/link.rb +3 -15
- data/lib/scarpe/wv/list_box.rb +6 -29
- data/lib/scarpe/wv/para.rb +11 -28
- data/lib/scarpe/wv/progress.rb +19 -0
- data/lib/scarpe/wv/radio.rb +33 -0
- data/lib/scarpe/wv/rect.rb +13 -0
- data/lib/scarpe/wv/shape.rb +41 -10
- data/lib/scarpe/wv/slot.rb +64 -0
- data/lib/scarpe/wv/span.rb +3 -25
- data/lib/scarpe/wv/stack.rb +2 -38
- data/lib/scarpe/wv/star.rb +3 -54
- data/lib/scarpe/wv/subscription_item.rb +84 -0
- data/lib/scarpe/wv/text_drawable.rb +32 -0
- data/lib/scarpe/wv/video.rb +34 -0
- data/lib/scarpe/wv/web_wrangler.rb +449 -299
- data/lib/scarpe/wv/webview_local_display.rb +63 -26
- data/lib/scarpe/wv/webview_relay_display.rb +24 -125
- data/lib/scarpe/wv/webview_relay_util.rb +140 -0
- data/lib/scarpe/wv/wv_display_worker.rb +19 -6
- data/lib/scarpe/wv.rb +76 -14
- data/lib/scarpe/wv_local.rb +1 -1
- data/lib/scarpe/wv_relay.rb +1 -1
- data/lib/scarpe.rb +4 -32
- data/logger/debug_web_wrangler.json +1 -1
- data/logger/scarpe_wv_test.json +1 -1
- data/scarpe-components/.gitignore +1 -0
- data/scarpe-components/Gemfile +22 -0
- data/scarpe-components/Gemfile.lock +86 -0
- data/scarpe-components/README.md +35 -0
- data/scarpe-components/Rakefile +12 -0
- data/scarpe-components/lib/scarpe/components/base64.rb +25 -0
- data/scarpe-components/lib/scarpe/components/calzini/alert.rb +49 -0
- data/scarpe-components/lib/scarpe/components/calzini/art_widgets.rb +203 -0
- data/scarpe-components/lib/scarpe/components/calzini/button.rb +39 -0
- data/scarpe-components/lib/scarpe/components/calzini/misc.rb +146 -0
- data/scarpe-components/lib/scarpe/components/calzini/para.rb +35 -0
- data/scarpe-components/lib/scarpe/components/calzini/slots.rb +155 -0
- data/scarpe-components/lib/scarpe/components/calzini/text_widgets.rb +65 -0
- data/scarpe-components/lib/scarpe/components/calzini.rb +149 -0
- data/scarpe-components/lib/scarpe/components/errors.rb +20 -0
- data/scarpe-components/lib/scarpe/components/file_helpers.rb +66 -0
- data/scarpe-components/lib/scarpe/components/html.rb +131 -0
- data/scarpe-components/lib/scarpe/components/minitest_export_reporter.rb +75 -0
- data/scarpe-components/lib/scarpe/components/minitest_import_runnable.rb +98 -0
- data/scarpe-components/lib/scarpe/components/minitest_result.rb +86 -0
- data/scarpe-components/lib/scarpe/components/modular_logger.rb +113 -0
- data/scarpe-components/lib/scarpe/components/print_logger.rb +47 -0
- data/{lib/scarpe → scarpe-components/lib/scarpe/components}/promises.rb +115 -48
- data/scarpe-components/lib/scarpe/components/segmented_file_loader.rb +189 -0
- data/scarpe-components/lib/scarpe/components/string_helpers.rb +10 -0
- data/scarpe-components/lib/scarpe/components/tiranti.rb +225 -0
- data/scarpe-components/lib/scarpe/components/unit_test_helpers.rb +257 -0
- data/scarpe-components/lib/scarpe/components/version.rb +7 -0
- data/scarpe-components/scarpe-components.gemspec +38 -0
- data/scarpe-components/test/calzini/test_calzini_alert.rb +30 -0
- data/scarpe-components/test/calzini/test_calzini_art_drawables.rb +105 -0
- data/scarpe-components/test/calzini/test_calzini_button.rb +52 -0
- data/scarpe-components/test/calzini/test_calzini_misc.rb +115 -0
- data/scarpe-components/test/calzini/test_calzini_para.rb +37 -0
- data/scarpe-components/test/calzini/test_calzini_slots.rb +130 -0
- data/scarpe-components/test/calzini/test_calzini_text_drawables.rb +41 -0
- data/scarpe-components/test/mtr_data/exception.json +1 -0
- data/scarpe-components/test/mtr_data/fail_with_message.json +1 -0
- data/scarpe-components/test/mtr_data/skipped_no_message.json +1 -0
- data/scarpe-components/test/mtr_data/skipped_w_msg.json +1 -0
- data/scarpe-components/test/mtr_data/succeed_2_asserts.json +1 -0
- data/scarpe-components/test/test_components.rb +9 -0
- data/scarpe-components/test/test_dimensions.rb +26 -0
- data/scarpe-components/test/test_helper.rb +43 -0
- data/scarpe-components/test/test_html.rb +65 -0
- data/scarpe-components/test/test_minitest_result.rb +61 -0
- data/scarpe-components/test/test_promises.rb +261 -0
- data/scarpe-components/test/test_segmented_app_files.rb +184 -0
- data/scarpegen.rb +14 -14
- data/sig/scarpe.rbs +1 -1
- data/{lib/scarpe → spikes}/glibui/widget.rb +2 -2
- data/{lib/scarpe → spikes}/glibui.rb +1 -1
- data/templates/basic_class_template.erb +13 -14
- data/templates/class_template_with_event_bind.erb +4 -4
- data/templates/class_template_with_shapes.erb +8 -17
- data/templates/example_template.erb +1 -1
- data/templates/module_template.erb +4 -4
- data/templates/webview_template.erb +3 -5
- metadata +236 -145
- data/examples/fill.rb +0 -25
- data/examples/legacy/not_checked/shoes-contrib/basic/class-book.yaml +0 -387
- data/examples/legacy/not_checked/shoes-contrib/elements/image-icon.rb +0 -3
- data/examples/legacy/not_checked/shoes-contrib/good/good-clock.rb +0 -51
- data/examples/legacy/not_checked/shoes-contrib/good/good-follow.rb +0 -26
- data/examples/legacy/not_checked/shoes-contrib/good/good-reminder.rb +0 -174
- data/examples/legacy/not_checked/shoes-contrib/good/good-vjot.rb +0 -56
- data/examples/legacy/not_checked/shoes-contrib/simple/simple-timer.rb +0 -13
- data/examples/legacy/not_checked/shoes-dep-samples/good-clock.rb +0 -51
- data/examples/legacy/not_checked/shoes-dep-samples/good-follow.rb +0 -26
- data/examples/legacy/not_checked/shoes-dep-samples/good-reminder.rb +0 -174
- data/examples/legacy/not_checked/shoes-dep-samples/good-vjot.rb +0 -56
- data/examples/legacy/not_checked/shoes-dep-samples/simple-accordion.rb +0 -75
- data/examples/legacy/not_checked/shoes-dep-samples/simple-anim-shapes.rb +0 -17
- data/examples/legacy/not_checked/shoes-dep-samples/simple-anim-text.rb +0 -13
- data/examples/legacy/not_checked/shoes-dep-samples/simple-arc.rb +0 -23
- data/examples/legacy/not_checked/shoes-dep-samples/simple-bounce.rb +0 -24
- data/examples/legacy/not_checked/shoes-dep-samples/simple-calc.rb +0 -70
- data/examples/legacy/not_checked/shoes-dep-samples/simple-chipmunk.rb +0 -26
- data/examples/legacy/not_checked/shoes-dep-samples/simple-control-sizes.rb +0 -24
- data/examples/legacy/not_checked/shoes-dep-samples/simple-curve.rb +0 -26
- data/examples/legacy/not_checked/shoes-dep-samples/simple-dialogs.rb +0 -29
- data/examples/legacy/not_checked/shoes-dep-samples/simple-draw.rb +0 -13
- data/examples/legacy/not_checked/shoes-dep-samples/simple-editor.rb +0 -28
- data/examples/legacy/not_checked/shoes-dep-samples/simple-form.rb +0 -28
- data/examples/legacy/not_checked/shoes-dep-samples/simple-form.shy +0 -0
- data/examples/legacy/not_checked/shoes-dep-samples/simple-mask.rb +0 -21
- data/examples/legacy/not_checked/shoes-dep-samples/simple-menu.rb +0 -31
- data/examples/legacy/not_checked/shoes-dep-samples/simple-menu1.rb +0 -35
- data/examples/legacy/not_checked/shoes-dep-samples/simple-rubygems.rb +0 -29
- data/examples/legacy/not_checked/shoes-dep-samples/simple-slide.rb +0 -45
- data/examples/legacy/not_checked/shoes-dep-samples/simple-sphere.rb +0 -28
- data/examples/legacy/not_checked/shoes-dep-samples/simple-sqlite3.rb +0 -13
- data/examples/legacy/not_checked/shoes-dep-samples/simple-timer.rb +0 -13
- data/examples/legacy/not_checked/shoes-dep-samples/simple-video.rb +0 -13
- data/examples/legacy/not_checked/simple/anim-text.rb +0 -13
- data/examples/legacy/not_checked/simple/arc.rb +0 -23
- data/examples/legacy/not_checked/simple/bounce.rb +0 -24
- data/examples/legacy/not_checked/simple/chipmunk.rb +0 -26
- data/examples/legacy/not_checked/simple/curve.rb +0 -26
- data/examples/legacy/not_checked/simple/dialogs.rb +0 -29
- data/examples/legacy/not_checked/simple/downloader.rb +0 -40
- data/examples/legacy/not_checked/simple/draw.rb +0 -13
- data/examples/legacy/not_checked/simple/mask.rb +0 -21
- data/examples/legacy/not_checked/simple/slide.rb +0 -45
- data/examples/legacy/not_checked/simple/sphere.rb +0 -28
- data/lib/constants.rb +0 -5
- data/lib/scarpe/alert.rb +0 -19
- data/lib/scarpe/app.rb +0 -78
- data/lib/scarpe/arc.rb +0 -49
- data/lib/scarpe/button.rb +0 -35
- data/lib/scarpe/document_root.rb +0 -20
- data/lib/scarpe/edit_box.rb +0 -24
- data/lib/scarpe/fill.rb +0 -23
- data/lib/scarpe/flow.rb +0 -19
- data/lib/scarpe/line.rb +0 -25
- data/lib/scarpe/link.rb +0 -25
- data/lib/scarpe/list_box.rb +0 -25
- data/lib/scarpe/logger.rb +0 -155
- data/lib/scarpe/para.rb +0 -90
- data/lib/scarpe/shape.rb +0 -19
- data/lib/scarpe/spacing.rb +0 -9
- data/lib/scarpe/stack.rb +0 -70
- data/lib/scarpe/star.rb +0 -47
- data/lib/scarpe/text_widget.rb +0 -42
- data/lib/scarpe/unit_test_helpers.rb +0 -163
- data/lib/scarpe/widget.rb +0 -198
- data/lib/scarpe/widgets.rb +0 -30
- data/lib/scarpe/wv/alert.rb +0 -65
- data/lib/scarpe/wv/background.rb +0 -18
- data/lib/scarpe/wv/border.rb +0 -22
- data/lib/scarpe/wv/control_interface_test.rb +0 -253
- data/lib/scarpe/wv/dimensions.rb +0 -22
- data/lib/scarpe/wv/fill.rb +0 -30
- data/lib/scarpe/wv/html.rb +0 -107
- data/lib/scarpe/wv/shape_helper.rb +0 -44
- data/lib/scarpe/wv/spacing.rb +0 -41
- data/lib/scarpe/wv/text_widget.rb +0 -30
- data/lib/scarpe/wv/widget.rb +0 -181
- data/scarpe-0.2.0.gem +0 -0
- /data/examples/legacy/not_checked/{expert → shoes-contrib/basic}/definr.rb +0 -0
- /data/examples/legacy/not_checked/{expert → shoes-contrib/basic}/funnies.rb +0 -0
- /data/examples/legacy/not_checked/shoes-contrib/{elements → basic}/list_box-select-class.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/basic-edit-box.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/basic-fps.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/border-cat.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/check-mate.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/manipulation → working/simple}/clear-slot.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/clock.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/gradient-shoes.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/list_box-shape-report.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/list_box.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/phat-button.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib → working}/simple/simple-calc.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/position → working/simple}/stack-width.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/width-introspec.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/README.md +0 -0
- /data/{lib/scarpe → spikes}/glibui/alert.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/app.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/background.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/border.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/button.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/dimensions.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/document_root.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/edit_box.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/edit_line.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/flow.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/html.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/image.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/link.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/local_display.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/para.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/spacing.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/stack.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/text_widget.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/alert.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/button.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/colors.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/core.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/flow.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/libui.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/notepad.md +0 -0
- /data/{lib/scarpe → spikes}/libui/para.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/stack.rb +0 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Shoes
|
4
|
+
# TextDrawable is the parent class of various classes of
|
5
|
+
# text that can go inside a para. This includes normal
|
6
|
+
# text, but also links, italic text, bold text, etc.
|
7
|
+
class TextDrawable < Shoes::Drawable
|
8
|
+
class << self
|
9
|
+
# rubocop:disable Lint/MissingSuper
|
10
|
+
def inherited(subclass)
|
11
|
+
Shoes::Drawable.drawable_classes ||= []
|
12
|
+
Shoes::Drawable.drawable_classes << subclass
|
13
|
+
|
14
|
+
Shoes::Drawable.drawable_default_styles ||= {}
|
15
|
+
Shoes::Drawable.drawable_default_styles[subclass] = {}
|
16
|
+
end
|
17
|
+
# rubocop:enable Lint/MissingSuper
|
18
|
+
end
|
19
|
+
|
20
|
+
shoes_events # No TextDrawable-specific events yet
|
21
|
+
end
|
22
|
+
|
23
|
+
class << self
|
24
|
+
def default_text_drawable_with(element)
|
25
|
+
class_name = element.capitalize
|
26
|
+
|
27
|
+
drawable_class = Class.new(Shoes::TextDrawable) do
|
28
|
+
# Can we just change content to text to match the Shoes API?
|
29
|
+
shoes_style :content
|
30
|
+
|
31
|
+
def initialize(content)
|
32
|
+
super
|
33
|
+
|
34
|
+
@content = content
|
35
|
+
|
36
|
+
create_display_drawable
|
37
|
+
end
|
38
|
+
|
39
|
+
def text
|
40
|
+
self.content
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_s
|
44
|
+
self.content
|
45
|
+
end
|
46
|
+
|
47
|
+
def text=(new_text)
|
48
|
+
self.content = new_text
|
49
|
+
end
|
50
|
+
end
|
51
|
+
Shoes.const_set class_name, drawable_class
|
52
|
+
drawable_class.class_eval do
|
53
|
+
shoes_style :content
|
54
|
+
|
55
|
+
shoes_events # No specific events
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
Shoes.default_text_drawable_with(:code)
|
62
|
+
Shoes.default_text_drawable_with(:em)
|
63
|
+
Shoes.default_text_drawable_with(:strong)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Shoes
|
4
|
+
class Video < Shoes::Drawable
|
5
|
+
shoes_styles :url
|
6
|
+
shoes_events # No specific events yet
|
7
|
+
|
8
|
+
def initialize(url)
|
9
|
+
super
|
10
|
+
@url = url
|
11
|
+
create_display_drawable
|
12
|
+
end
|
13
|
+
|
14
|
+
# other methods
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# A Shoes::Widget is mostly a Slot (related to the
|
4
|
+
# old Shoes concepts of Canvas) that creates drawables
|
5
|
+
# inside itself. When a subclass of Widget is created,
|
6
|
+
# it adds a method to create new objects of that type
|
7
|
+
# on Shoes::App and all Shoes slots.
|
8
|
+
#
|
9
|
+
# The hardest part with a Shoes::Widget is that it
|
10
|
+
# should work fine even if initialize() doesn't call
|
11
|
+
# super, which would make it hard to set up a Shoes
|
12
|
+
# linkable_id, create a display widget, etc.
|
13
|
+
#
|
14
|
+
# It would be possible to add an extra method to set
|
15
|
+
# these up and call it on every created drawable
|
16
|
+
# in case a Widget's initialize method doesn't call
|
17
|
+
# super, which happens quite often. But then we wouldn't
|
18
|
+
# support automatic setting of styles (e.g. padding)
|
19
|
+
# for the widget object itself, which is mostly a Flow.
|
20
|
+
# We also couldn't support default styles -- I can't tell
|
21
|
+
# whether Shoes supports these things either.
|
22
|
+
#
|
23
|
+
# But there's another way to do all of this. When a
|
24
|
+
# subclass of Widget defines an initialize method,
|
25
|
+
# we can catch the method_added hook, save a copy of
|
26
|
+
# that initialize method, and substitute our own
|
27
|
+
# initialize that calls super. We have to be a little
|
28
|
+
# careful -- if the widget's initialize *does* call
|
29
|
+
# super that shouldn't be an error. But that's
|
30
|
+
# workable by defining an extra method with the
|
31
|
+
# copied-method name that does nothing.
|
32
|
+
|
33
|
+
##### TODO: when this is subclassed, grab :initialize out
|
34
|
+
# of the subclass, put it into :initialize_widget, and
|
35
|
+
# replace with an initialize that creates the display
|
36
|
+
# widget propertly, sets the linkable_id, etc.
|
37
|
+
|
38
|
+
class Shoes::Widget < Shoes::Slot
|
39
|
+
include Shoes::Background
|
40
|
+
include Shoes::Border
|
41
|
+
include Shoes::Spacing
|
42
|
+
|
43
|
+
shoes_events
|
44
|
+
|
45
|
+
def self.method_added(name)
|
46
|
+
# We're only looking for the initialize() method, and only on subclasses
|
47
|
+
# of Shoes::Widget, not Shoes::Widget itself.
|
48
|
+
return if self == ::Shoes::Widget || name != :initialize
|
49
|
+
|
50
|
+
# Need to avoid infinite adding of initialize() if we're re-adding the default initialize
|
51
|
+
return if @midway_through_adding_initialize
|
52
|
+
|
53
|
+
# Take the user-provided initialize method and save a copy named __widget_initialize
|
54
|
+
alias_method :__widget_initialize, :initialize
|
55
|
+
|
56
|
+
# And add the default initialize back where it belongs
|
57
|
+
@midway_through_adding_initialize = true
|
58
|
+
define_method(:initialize) do |*args, **kwargs, &block|
|
59
|
+
super(*args, **kwargs, &block)
|
60
|
+
@options = kwargs
|
61
|
+
create_display_drawable
|
62
|
+
__widget_initialize(*args, **kwargs, &block)
|
63
|
+
|
64
|
+
# Do Widgets do this?
|
65
|
+
Shoes::App.instance.with_slot(self, &block) if block
|
66
|
+
end
|
67
|
+
@midway_through_adding_initialize = false
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "shoes/drawables/slot"
|
4
|
+
require "shoes/drawables/stack"
|
5
|
+
require "shoes/drawables/flow"
|
6
|
+
require "shoes/drawables/widget"
|
7
|
+
require "shoes/drawables/document_root"
|
8
|
+
|
9
|
+
require "shoes/drawables/text_drawable"
|
10
|
+
|
11
|
+
require "shoes/drawables/subscription_item"
|
12
|
+
|
13
|
+
require "shoes/drawables/arc"
|
14
|
+
require "shoes/drawables/line"
|
15
|
+
require "shoes/drawables/rect"
|
16
|
+
require "shoes/drawables/shape"
|
17
|
+
require "shoes/drawables/star"
|
18
|
+
require "shoes/drawables/arrow"
|
19
|
+
|
20
|
+
require "shoes/drawables/button"
|
21
|
+
require "shoes/drawables/check"
|
22
|
+
require "shoes/drawables/edit_box"
|
23
|
+
require "shoes/drawables/edit_line"
|
24
|
+
require "shoes/drawables/image"
|
25
|
+
require "shoes/drawables/link"
|
26
|
+
require "shoes/drawables/list_box"
|
27
|
+
require "shoes/drawables/para"
|
28
|
+
require "shoes/drawables/radio"
|
29
|
+
require "shoes/drawables/span"
|
30
|
+
require "shoes/drawables/video"
|
31
|
+
require "shoes/drawables/progress"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Shoes; end
|
4
|
+
class 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 NoLinkableIdError < Shoes::Error; end
|
20
|
+
|
21
|
+
class BadLinkableIdError < Shoes::Error; end
|
22
|
+
|
23
|
+
class UnregisteredShoesEvent < Shoes::Error; end
|
24
|
+
|
25
|
+
class SingletonError < Shoes::Error; end
|
26
|
+
|
27
|
+
class MultipleShoesSpecRunsError < Shoes::Error; end
|
28
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Old-style Shoes logging is really simple. We need more logging for our
|
4
|
+
# framework, so we add a not-included-in-old-Shoes module for it. This adds
|
5
|
+
# the *possibility* of logging, but Scarpe includes a much more
|
6
|
+
# comprehensive solution that plugs into this one.
|
7
|
+
|
8
|
+
# If used alone, this will fail because the @instance is nil. It needs
|
9
|
+
# an implementation to be plugged in.
|
10
|
+
|
11
|
+
class Shoes
|
12
|
+
LOG_LEVELS = [:debug, :info, :warn, :error, :fatal].freeze
|
13
|
+
|
14
|
+
# Include this module to get a @log instance variable to log as your
|
15
|
+
# configured component.
|
16
|
+
module Log
|
17
|
+
# These constants will wind up included in a lot of places. Should they move?
|
18
|
+
DEFAULT_COMPONENT = "default"
|
19
|
+
DEFAULT_LOG_CONFIG = {
|
20
|
+
"default" => "info",
|
21
|
+
}
|
22
|
+
DEFAULT_DEBUG_LOG_CONFIG = {
|
23
|
+
"default" => "debug",
|
24
|
+
}
|
25
|
+
|
26
|
+
class << self
|
27
|
+
attr_reader :instance
|
28
|
+
attr_reader :current_log_config
|
29
|
+
|
30
|
+
def instance=(impl_object)
|
31
|
+
raise(Shoes::Errors::TooManyInstancesError, "Already have an instance for Shoes::Log!") if @instance
|
32
|
+
|
33
|
+
@instance = impl_object
|
34
|
+
end
|
35
|
+
|
36
|
+
def logger(component = self)
|
37
|
+
@instance.logger_for_component(component)
|
38
|
+
end
|
39
|
+
|
40
|
+
def configure_logger(log_config)
|
41
|
+
@instance.configure_logger(log_config)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def log_init(component = self)
|
46
|
+
@log = Shoes::Log.instance.logger_for_component(component)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class LoggedWrapper
|
51
|
+
include ::Shoes::Log
|
52
|
+
def initialize(instance, component = instance)
|
53
|
+
log_init(component)
|
54
|
+
|
55
|
+
@instance = instance
|
56
|
+
end
|
57
|
+
|
58
|
+
def method_missing(method, ...)
|
59
|
+
self.singleton_class.define_method(method) do |*args, **kwargs, &block|
|
60
|
+
ret = @instance.send(method, *args, **kwargs, &block)
|
61
|
+
@log.info("Method: #{method} Args: #{args.inspect} KWargs: #{kwargs.inspect} Block: #{block ? "y" : "n"} Return: #{ret.inspect}")
|
62
|
+
ret
|
63
|
+
end
|
64
|
+
send(method, ...)
|
65
|
+
end
|
66
|
+
|
67
|
+
def respond_to_missing?(method_name, include_private = false)
|
68
|
+
@instance.respond_to_missing?(method_name, include_private)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
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
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# We're separating Shoes from Scarpe, a little at a time. This should be requirable
|
4
|
+
# without using Scarpe at all.
|
5
|
+
#
|
6
|
+
# The Lacci gem is like the old Shoes-core from Shoes4: a way
|
7
|
+
# to handle the DSL and command-line parts of Shoes without knowing anything about how the
|
8
|
+
# display side works at all.
|
9
|
+
|
10
|
+
if RUBY_VERSION[0..2] < "3.2"
|
11
|
+
Shoes::Log.logger("Shoes").error("Lacci (Scarpe, Shoes) requires Ruby 3.2 or higher!")
|
12
|
+
exit(-1)
|
13
|
+
end
|
14
|
+
|
15
|
+
class Shoes; end
|
16
|
+
class Shoes::Error < StandardError; end
|
17
|
+
require_relative "shoes/errors"
|
18
|
+
|
19
|
+
require_relative "shoes/constants"
|
20
|
+
require_relative "shoes/ruby_extensions"
|
21
|
+
|
22
|
+
# Shoes adds some top-level methods and constants that can be used everywhere. Kernel is where they go.
|
23
|
+
module Kernel
|
24
|
+
include Shoes::Constants
|
25
|
+
end
|
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"
|
35
|
+
require_relative "shoes/colors"
|
36
|
+
|
37
|
+
require_relative "shoes/builtins"
|
38
|
+
|
39
|
+
require_relative "shoes/background"
|
40
|
+
require_relative "shoes/border"
|
41
|
+
require_relative "shoes/spacing"
|
42
|
+
|
43
|
+
require_relative "shoes/drawable"
|
44
|
+
require_relative "shoes/app"
|
45
|
+
require_relative "shoes/drawables"
|
46
|
+
|
47
|
+
require_relative "shoes/download"
|
48
|
+
|
49
|
+
# No easy way to tell at this point whether
|
50
|
+
# we will later load Shoes-Spec code, e.g.
|
51
|
+
# by running a segmented app with test code.
|
52
|
+
require_relative "shoes-spec"
|
53
|
+
|
54
|
+
# The module containing Shoes in all its glory.
|
55
|
+
# Shoes is a platform-independent GUI library, designed to create
|
56
|
+
# small visual applications in Ruby.
|
57
|
+
#
|
58
|
+
class Shoes
|
59
|
+
class << self
|
60
|
+
# Creates a Shoes app with a new window. The block parameter is used to create
|
61
|
+
# drawables and set up handlers. Arguments are passed to Shoes::App.new internally.
|
62
|
+
#
|
63
|
+
# @incompatibility In Shoes3, this method will return normally.
|
64
|
+
# In Scarpe, after the block is executed, the method will not return and Scarpe
|
65
|
+
# will retain control of execution until the window is closed and the app quits.
|
66
|
+
#
|
67
|
+
# @incompatibility In Shoes3 the parameters were a hash of options, not keyword arguments.
|
68
|
+
#
|
69
|
+
# @example Simple one-button app
|
70
|
+
# Shoes.app(title: "Button!", width: 200, height: 200) do
|
71
|
+
# @p = para "Press it NOW!"
|
72
|
+
# button("clicky") { @p.replace("You pressed it! CELEBRATION!") }
|
73
|
+
# end
|
74
|
+
#
|
75
|
+
# @param title [String] The new app window title
|
76
|
+
# @param width [Integer] The new app window width
|
77
|
+
# @param height [Integer] The new app window height
|
78
|
+
# @param resizable [Boolean] Whether the app window should be resizeable
|
79
|
+
# @return [void]
|
80
|
+
# @see Shoes::App#new
|
81
|
+
def app(
|
82
|
+
title: "Shoes!",
|
83
|
+
width: 480,
|
84
|
+
height: 420,
|
85
|
+
resizable: true,
|
86
|
+
&app_code_body
|
87
|
+
)
|
88
|
+
app = Shoes::App.new(title:, width:, height:, resizable:, &app_code_body)
|
89
|
+
app.init
|
90
|
+
app.run
|
91
|
+
nil
|
92
|
+
end
|
93
|
+
|
94
|
+
# Load a Shoes app from a file. By default, this will load old-style Shoes apps
|
95
|
+
# from a .rb file with all the appropriate libraries loaded. By setting one or
|
96
|
+
# more loaders, a Lacci-based display library can accept new file formats as
|
97
|
+
# well, not just raw Shoes .rb files.
|
98
|
+
#
|
99
|
+
# @param relative_path [String] The current-dir-relative path to the file
|
100
|
+
# @return [void]
|
101
|
+
# @see Shoes.add_file_loader
|
102
|
+
def run_app(relative_path)
|
103
|
+
path = File.expand_path relative_path
|
104
|
+
dir = File.dirname(path)
|
105
|
+
|
106
|
+
# Shoes assumes we're starting from the app code's path
|
107
|
+
Dir.chdir(dir)
|
108
|
+
|
109
|
+
loaded = false
|
110
|
+
file_loaders.each do |loader|
|
111
|
+
if loader.call(path)
|
112
|
+
loaded = true
|
113
|
+
break
|
114
|
+
end
|
115
|
+
end
|
116
|
+
raise "Could not find a file loader for #{path.inspect}!" unless loaded
|
117
|
+
|
118
|
+
nil
|
119
|
+
end
|
120
|
+
|
121
|
+
def default_file_loaders
|
122
|
+
[
|
123
|
+
# By default we will always try to load any file, regardless of extension, as a Shoes Ruby file.
|
124
|
+
proc do |path|
|
125
|
+
load path
|
126
|
+
true
|
127
|
+
end,
|
128
|
+
]
|
129
|
+
end
|
130
|
+
|
131
|
+
def file_loaders
|
132
|
+
@file_loaders ||= default_file_loaders
|
133
|
+
end
|
134
|
+
|
135
|
+
def add_file_loader(loader)
|
136
|
+
file_loaders.prepend(loader)
|
137
|
+
end
|
138
|
+
|
139
|
+
def reset_file_loaders
|
140
|
+
@file_loaders = default_file_loaders
|
141
|
+
end
|
142
|
+
|
143
|
+
def set_file_loaders(loaders)
|
144
|
+
@file_loaders = loaders
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class TestColors < Minitest::Test
|
6
|
+
class Dummy
|
7
|
+
include Shoes::Colors
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_default_colors_are_accessible_via_methods
|
11
|
+
assert_equal [0, 0, 0, 255], Dummy.new.black
|
12
|
+
assert_equal [255, 255, 255, 255], Dummy.new.white
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_default_colors_can_accept_alpha
|
16
|
+
assert_equal [0, 0, 0, 0.5], Dummy.new.black(0.5)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_gray_accepts_single_value_for_darkness
|
20
|
+
assert_equal [0, 0, 0, 255], Dummy.new.gray(0)
|
21
|
+
assert_equal [255, 255, 255, 255], Dummy.new.gray(255)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_gray_accepts_darkness_and_alpha
|
25
|
+
assert_equal [0, 0, 0, 128], Dummy.new.gray(0, 128)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_gray_defaults_to_50_percent_darkness
|
29
|
+
assert_equal [128, 128, 128, 255], Dummy.new.gray
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_rgb_accepts_three_values
|
33
|
+
assert_equal [255, 0, 0, 255], Dummy.new.rgb(255, 0, 0)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_rgb_accepts_alpha
|
37
|
+
assert_equal [255, 0, 0, 128], Dummy.new.rgb(255, 0, 0, 128)
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
4
|
+
require "shoes"
|
5
|
+
|
6
|
+
require "scarpe/components/unit_test_helpers"
|
7
|
+
|
8
|
+
require "minitest/autorun"
|
9
|
+
|
10
|
+
require "minitest/reporters"
|
11
|
+
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
|
12
|
+
|
13
|
+
# For testing Lacci, it's kind of silly to start a Webview application.
|
14
|
+
# They're slow, unreliable and memory-hungry. So instead we start a
|
15
|
+
# Niente do-nothing application for a simple API test. It's a lot like
|
16
|
+
# mocking.
|
17
|
+
class NienteTest < Minitest::Test
|
18
|
+
include ::Scarpe::Test::Helpers
|
19
|
+
|
20
|
+
SCARPE_EXE = File.expand_path("../../exe/scarpe", __dir__)
|
21
|
+
|
22
|
+
def run_test_niente_code(
|
23
|
+
scarpe_app_code,
|
24
|
+
test_extension: ".rb",
|
25
|
+
**opts
|
26
|
+
)
|
27
|
+
with_tempfile(["scarpe_test_app", test_extension], scarpe_app_code) do |test_app_location|
|
28
|
+
run_test_niente_app(test_app_location, **opts)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def run_test_niente_app(
|
33
|
+
test_app_location,
|
34
|
+
app_test_code: "",
|
35
|
+
timeout: 5.0,
|
36
|
+
class_name: self.class,
|
37
|
+
method_name: self.name,
|
38
|
+
display_service: "niente"
|
39
|
+
)
|
40
|
+
with_tempfiles([
|
41
|
+
#["scarpe_log_config.json", JSON.dump(log_config_for_test)],
|
42
|
+
[["shoes_spec_code", ".rb"], app_test_code],
|
43
|
+
]) do |shoes_spec_path,_|
|
44
|
+
system(
|
45
|
+
"LOCALAPPDATA=\"#{Dir.tmpdir}\" " +
|
46
|
+
"SHOES_SPEC_TEST=\"#{shoes_spec_path}\" " +
|
47
|
+
"SCARPE_DISPLAY_SERVICE=\"#{display_service}\" " +
|
48
|
+
"SHOES_MINITEST_EXPORT_FILE=niente_test.json " +
|
49
|
+
"SHOES_MINITEST_CLASS_NAME=\"#{class_name}\" " +
|
50
|
+
"SHOES_MINITEST_METHOD_NAME=\"#{method_name}\" " +
|
51
|
+
"ruby #{SCARPE_EXE} --dev #{test_app_location}"
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Check if the process exited normally or crashed (segfault, failure, timeout)
|
56
|
+
unless $?.success?
|
57
|
+
assert(false, "Niente app failed with exit code: #{$?.exitstatus}")
|
58
|
+
return
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "test_helper"
|
4
|
+
|
5
|
+
class TestLacci < NienteTest
|
6
|
+
def test_simple_button_click
|
7
|
+
run_test_niente_code(<<~SHOES_APP, app_test_code: <<~SHOES_SPEC)
|
8
|
+
Shoes.app do
|
9
|
+
@b = button "OK" do
|
10
|
+
@b.text = "Yup"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
SHOES_APP
|
14
|
+
button().trigger_click
|
15
|
+
assert_equal "Yup", button().text
|
16
|
+
SHOES_SPEC
|
17
|
+
end
|
18
|
+
end
|