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
@@ -1,40 +0,0 @@
|
|
1
|
-
Shoes.app do
|
2
|
-
background "#eee"
|
3
|
-
@list = stack do
|
4
|
-
para "Enter a URL to download:", :margin => [10, 8, 10, 0]
|
5
|
-
flow :margin => 10 do
|
6
|
-
@url = edit_line :width => -120
|
7
|
-
@url.text ='http://walkabout.mvmanila.com/public/share/Ytm-2.exe'
|
8
|
-
st_time = 0
|
9
|
-
end_time = 0
|
10
|
-
totalsz = 0
|
11
|
-
button "Download", :width => 120 do
|
12
|
-
st_time = Time.now
|
13
|
-
@list.append do
|
14
|
-
stack do
|
15
|
-
background "#eee".."#ccd"
|
16
|
-
stack :margin => 10 do
|
17
|
-
dld = nil
|
18
|
-
para @url.text, " [", link("cancel") { @dld.abort }, "]", :margin => 0
|
19
|
-
d = inscription "Beginning transfer.", :margin => 0
|
20
|
-
p = progress :width => 1.0, :height => 14
|
21
|
-
@dld = download @url.text, :save => File.basename(@url.text),
|
22
|
-
:pause => 0.02,
|
23
|
-
:progress => proc { |dl|
|
24
|
-
d.text = "Transferred #{dl.transferred} of #{dl.length} bytes (#{dl.percent.to_s[0..6]}%)"
|
25
|
-
p.fraction = dl.percent
|
26
|
-
},
|
27
|
-
:finish => proc { |dl|
|
28
|
-
end_time = Time.now
|
29
|
-
secs = (end_time.to_i - st_time.to_i)
|
30
|
-
kb = dl.length < 1024 ? 1: dl.length / 1024
|
31
|
-
d.text = "Download completed KB/s: #{kb/secs} seconds:#{secs}"
|
32
|
-
}
|
33
|
-
para "Should appear after button press"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
Shoes.app do
|
2
|
-
background black
|
3
|
-
|
4
|
-
stack :top => 0.4, :left => 0.2 do
|
5
|
-
@stripes = stack
|
6
|
-
|
7
|
-
mask do
|
8
|
-
title "Shoes", :weight => "bold", :size => 82
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
animate 10 do
|
13
|
-
@stripes.clear do
|
14
|
-
20.times do |i|
|
15
|
-
strokewidth 4
|
16
|
-
stroke rgb((0.0..0.5).rand, (0.0..1.0).rand, (0.0..0.3).rand)
|
17
|
-
line 0, i * 5, 400, i * 8
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# mimicking the mootools demo for Fx.Slide
|
3
|
-
# http://demos.mootools.net/Fx.Slide
|
4
|
-
#
|
5
|
-
Shoes.app do
|
6
|
-
def stop_anim
|
7
|
-
@anim.stop
|
8
|
-
@anim = nil
|
9
|
-
end
|
10
|
-
def slide_anim &blk
|
11
|
-
stop_anim if @anim
|
12
|
-
@anim = animate 30, &blk
|
13
|
-
end
|
14
|
-
def slide_out slot
|
15
|
-
slide_anim do |i|
|
16
|
-
slot.height = 150 - (i * 3)
|
17
|
-
slot.contents[0].top = -i * 3
|
18
|
-
if slot.height == 0
|
19
|
-
stop_anim
|
20
|
-
slot.hide
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
def slide_in slot
|
25
|
-
slot.show
|
26
|
-
slide_anim do |i|
|
27
|
-
slot.height = i * 6
|
28
|
-
slot.contents[0].top = slot.height - 150
|
29
|
-
stop_anim if slot.height == 150
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
background white
|
34
|
-
stack :margin => 10 do
|
35
|
-
para link("slide out") { slide_out @lipsum }, " | ",
|
36
|
-
link("slide in") { slide_in @lipsum }
|
37
|
-
@lipsum = stack :width => 1.0, :height => 150 do
|
38
|
-
stack do
|
39
|
-
background "#ddd"
|
40
|
-
border "#eee", :strokewidth => 5
|
41
|
-
para "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", :margin => 10
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
Shoes.app :width => 500, :height => 500, :resizable => false do
|
2
|
-
image 400, 470, :top => 30, :left => 50 do
|
3
|
-
nostroke
|
4
|
-
fill "#127"
|
5
|
-
image :top => 230, :left => 0 do
|
6
|
-
oval 70, 130, 260, 40
|
7
|
-
blur 30
|
8
|
-
end
|
9
|
-
oval 10, 10, 380, 380
|
10
|
-
image :top => 0, :left => 0 do
|
11
|
-
fill "#46D"
|
12
|
-
oval 30, 30, 338, 338
|
13
|
-
blur 10
|
14
|
-
end
|
15
|
-
fill gradient(rgb(1.0, 1.0, 1.0, 0.7), rgb(1.0, 1.0, 1.0, 0.0))
|
16
|
-
oval 80, 14, 240, 176
|
17
|
-
image :top => 0, :left => 0 do
|
18
|
-
fill "#79F"
|
19
|
-
oval 134, 134, 130, 130
|
20
|
-
blur 40
|
21
|
-
end
|
22
|
-
image :top => 150, :left => 40, :width => 320, :height => 260 do
|
23
|
-
fill gradient(rgb(0.7, 0.9, 1.0, 0.0), rgb(0.7, 0.9, 1.0, 0.6))
|
24
|
-
oval 60, 60, 200, 136
|
25
|
-
blur 20
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/lib/constants.rb
DELETED
data/lib/scarpe/alert.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Scarpe
|
4
|
-
class Alert < Scarpe::Widget
|
5
|
-
display_property :text
|
6
|
-
|
7
|
-
def initialize(text)
|
8
|
-
@text = text
|
9
|
-
|
10
|
-
super
|
11
|
-
|
12
|
-
bind_self_event("click") do
|
13
|
-
destroy_self
|
14
|
-
end
|
15
|
-
|
16
|
-
create_display_widget
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/lib/scarpe/app.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Scarpe
|
4
|
-
class App < Scarpe::Widget
|
5
|
-
class << self
|
6
|
-
attr_accessor :next_test_code
|
7
|
-
end
|
8
|
-
include Scarpe::Log
|
9
|
-
|
10
|
-
display_properties :title, :width, :height, :resizable, :debug
|
11
|
-
|
12
|
-
def initialize(
|
13
|
-
title: "Scarpe!",
|
14
|
-
width: 480,
|
15
|
-
height: 420,
|
16
|
-
resizable: true,
|
17
|
-
debug: ENV["SCARPE_DEBUG"] ? true : false,
|
18
|
-
test_code: nil,
|
19
|
-
&app_code_body
|
20
|
-
)
|
21
|
-
log_init("Scarpe::App")
|
22
|
-
|
23
|
-
@do_shutdown = false
|
24
|
-
|
25
|
-
if Scarpe::App.next_test_code
|
26
|
-
test_code = Scarpe::App.next_test_code
|
27
|
-
Scarpe::App.next_test_code = nil
|
28
|
-
end
|
29
|
-
|
30
|
-
super
|
31
|
-
|
32
|
-
test_code&.call(self)
|
33
|
-
|
34
|
-
# This creates the DocumentRoot, including its corresponding display widget
|
35
|
-
@document_root = Scarpe::DocumentRoot.new
|
36
|
-
|
37
|
-
create_display_widget
|
38
|
-
|
39
|
-
@app_code_body = app_code_body
|
40
|
-
|
41
|
-
# Try to de-dup as much as possible and not send repeat or multiple
|
42
|
-
# destroy events
|
43
|
-
@watch_for_destroy = bind_shoes_event(event_name: "destroy") do
|
44
|
-
DisplayService.unsub_from_events(@watch_for_destroy) if @watch_for_destroy
|
45
|
-
@watch_for_destroy = nil
|
46
|
-
self.destroy(send_event: false)
|
47
|
-
end
|
48
|
-
|
49
|
-
Signal.trap("INT") do
|
50
|
-
@log.warning("App interrupted by signal, stopping...")
|
51
|
-
puts "\nStopping Scarpe app..."
|
52
|
-
destroy
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def init
|
57
|
-
send_shoes_event(event_name: "init")
|
58
|
-
return if @do_shutdown
|
59
|
-
|
60
|
-
@document_root.instance_eval(&@app_code_body)
|
61
|
-
end
|
62
|
-
|
63
|
-
# This isn't supposed to return. The display service should take control
|
64
|
-
# of the main thread. Local Webview even stops any background threads.
|
65
|
-
def run
|
66
|
-
if @do_shutdown
|
67
|
-
$stderr.puts "Destroy has already been signaled, but we just called Shoes::App.run!"
|
68
|
-
return
|
69
|
-
end
|
70
|
-
send_shoes_event(event_name: "run")
|
71
|
-
end
|
72
|
-
|
73
|
-
def destroy(send_event: true)
|
74
|
-
@do_shutdown = true
|
75
|
-
send_shoes_event(event_name: "destroy") if send_event
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
data/lib/scarpe/arc.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Scarpe
|
4
|
-
class InvalidAttributeValueError < Scarpe::Error; end
|
5
|
-
|
6
|
-
class Arc < Scarpe::Widget
|
7
|
-
display_properties :left, :top, :width, :height, :angle1, :angle2
|
8
|
-
|
9
|
-
def initialize(*args)
|
10
|
-
@left, @top, @width, @height, @angle1, @angle2 = args
|
11
|
-
|
12
|
-
@left = convert_to_integer(@left, "left")
|
13
|
-
@top = convert_to_integer(@top, "top")
|
14
|
-
@width = convert_to_integer(@width, "width")
|
15
|
-
@height = convert_to_integer(@height, "height")
|
16
|
-
@angle1 = convert_to_float(@angle1, "angle1")
|
17
|
-
@angle2 = convert_to_float(@angle2, "angle2")
|
18
|
-
|
19
|
-
super()
|
20
|
-
create_display_widget
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def convert_to_integer(value, attribute_name)
|
26
|
-
begin
|
27
|
-
value = Integer(value)
|
28
|
-
raise InvalidAttributeValueError, "Negative number '#{value}' not allowed for attribute '#{attribute_name}'" if value < 0
|
29
|
-
|
30
|
-
value
|
31
|
-
rescue ArgumentError
|
32
|
-
error_message = "Invalid value '#{value}' provided for attribute '#{attribute_name}'. The value should be a number."
|
33
|
-
raise InvalidAttributeValueError, error_message
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def convert_to_float(value, attribute_name)
|
38
|
-
begin
|
39
|
-
value = Float(value)
|
40
|
-
raise InvalidAttributeValueError, "Negative number '#{value}' not allowed for attribute '#{attribute_name}'" if value < 0
|
41
|
-
|
42
|
-
value
|
43
|
-
rescue ArgumentError
|
44
|
-
error_message = "Invalid value '#{value}' provided for attribute '#{attribute_name}'. The value should be a number."
|
45
|
-
raise InvalidAttributeValueError, error_message
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
data/lib/scarpe/button.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Scarpe
|
4
|
-
class Button < Scarpe::Widget
|
5
|
-
include Scarpe::Log
|
6
|
-
display_properties :text, :width, :height, :top, :left, :color, :padding_top, :padding_bottom, :text_color, :size, :font_size
|
7
|
-
|
8
|
-
def initialize(text, width: nil, height: nil, top: nil, left: nil, color: nil, padding_top: nil, padding_bottom: nil, size: 12, text_color: nil,
|
9
|
-
font_size: nil, & block)
|
10
|
-
|
11
|
-
log_init("Button")
|
12
|
-
|
13
|
-
# Properties passed as positional args, not keywords, don't get auto-set
|
14
|
-
@text = text
|
15
|
-
@color = color
|
16
|
-
|
17
|
-
@block = block
|
18
|
-
|
19
|
-
super
|
20
|
-
|
21
|
-
# Bind to a handler named "click"
|
22
|
-
bind_self_event("click") do
|
23
|
-
@log.debug("Button clicked, calling handler") if @block
|
24
|
-
@block&.call
|
25
|
-
end
|
26
|
-
|
27
|
-
create_display_widget
|
28
|
-
end
|
29
|
-
|
30
|
-
# Set the click handler
|
31
|
-
def click(&block)
|
32
|
-
@block = block
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
data/lib/scarpe/document_root.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Scarpe
|
4
|
-
class DocumentRoot < Scarpe::Widget
|
5
|
-
include Scarpe::Background
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
super
|
9
|
-
|
10
|
-
create_display_widget
|
11
|
-
end
|
12
|
-
|
13
|
-
# This can be absolutely huge in console output, and it's frequently printed.
|
14
|
-
def inspect
|
15
|
-
"<Scarpe::DocumentRoot>"
|
16
|
-
end
|
17
|
-
|
18
|
-
alias_method :info, :puts
|
19
|
-
end
|
20
|
-
end
|
data/lib/scarpe/edit_box.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Scarpe
|
4
|
-
class EditBox < Scarpe::Widget
|
5
|
-
display_properties :text, :height, :width
|
6
|
-
|
7
|
-
def initialize(text = nil, height: nil, width: nil, &block)
|
8
|
-
@text = text.nil? ? block&.call : text || ""
|
9
|
-
|
10
|
-
super
|
11
|
-
|
12
|
-
bind_self_event("change") do |new_text|
|
13
|
-
self.text = new_text
|
14
|
-
@callback&.call(new_text)
|
15
|
-
end
|
16
|
-
|
17
|
-
create_display_widget
|
18
|
-
end
|
19
|
-
|
20
|
-
def change(&block)
|
21
|
-
@callback = block
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/lib/scarpe/fill.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Scarpe
|
4
|
-
class Fill < Scarpe::Widget
|
5
|
-
display_properties :color
|
6
|
-
|
7
|
-
def initialize(color)
|
8
|
-
@color = color
|
9
|
-
super
|
10
|
-
create_display_widget
|
11
|
-
end
|
12
|
-
|
13
|
-
def element
|
14
|
-
HTML.render do |h|
|
15
|
-
h.style(<<~CSS)
|
16
|
-
##{html_id} {
|
17
|
-
background-color: #{@color};
|
18
|
-
}
|
19
|
-
CSS
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/scarpe/flow.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Scarpe
|
4
|
-
class Flow < Scarpe::Widget
|
5
|
-
include Scarpe::Background
|
6
|
-
include Scarpe::Border
|
7
|
-
|
8
|
-
display_properties :width, :height, :margin, :padding
|
9
|
-
|
10
|
-
def initialize(width: nil, height: "100%", margin: nil, padding: nil, &block)
|
11
|
-
super
|
12
|
-
|
13
|
-
# Create the display-side widget *before* instance_eval, which will add child widgets with their display widgets
|
14
|
-
create_display_widget
|
15
|
-
|
16
|
-
instance_eval(&block)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/lib/scarpe/line.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "wv/shape_helper"
|
4
|
-
|
5
|
-
class Scarpe
|
6
|
-
class Line < Scarpe::Widget
|
7
|
-
include ShapeHelper
|
8
|
-
|
9
|
-
display_properties :left, :top, :x2, :y2, :color
|
10
|
-
|
11
|
-
def initialize(left, top, x2, y2)
|
12
|
-
validate_coordinates(x2, y2)
|
13
|
-
@left = left
|
14
|
-
@top = top
|
15
|
-
@x2 = x2
|
16
|
-
@y2 = y2
|
17
|
-
@color = color_for_fill
|
18
|
-
|
19
|
-
# validate_coordinates(x2, y2)
|
20
|
-
|
21
|
-
super()
|
22
|
-
create_display_widget
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/scarpe/link.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Scarpe
|
4
|
-
class Link < Scarpe::TextWidget
|
5
|
-
display_properties :text, :click, :has_block
|
6
|
-
|
7
|
-
def initialize(text, click: nil, &block)
|
8
|
-
@text = text
|
9
|
-
@block = block
|
10
|
-
# We can't send a block to the display widget, but we can send a boolean
|
11
|
-
@has_block = !block.nil?
|
12
|
-
|
13
|
-
super
|
14
|
-
|
15
|
-
# The click property should be changed before it gets sent to the display widget
|
16
|
-
@click ||= "#"
|
17
|
-
|
18
|
-
bind_self_event("click") do
|
19
|
-
@block&.call
|
20
|
-
end
|
21
|
-
|
22
|
-
create_display_widget
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/scarpe/list_box.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Scarpe
|
4
|
-
class ListBox < Scarpe::Widget
|
5
|
-
display_properties :selected_item, :items, :height, :width
|
6
|
-
|
7
|
-
def initialize(args = {}, &block)
|
8
|
-
@items = args[:items] || []
|
9
|
-
@selected_item = args[:selected_item]
|
10
|
-
super()
|
11
|
-
|
12
|
-
bind_self_event("change") do |new_item|
|
13
|
-
self.selected_item = new_item
|
14
|
-
@callback&.call(new_item)
|
15
|
-
end
|
16
|
-
|
17
|
-
create_display_widget
|
18
|
-
end
|
19
|
-
|
20
|
-
def change(&block)
|
21
|
-
@callback = block
|
22
|
-
self # Allow chaining calls
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/scarpe/logger.rb
DELETED
@@ -1,155 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "logging"
|
4
|
-
require "json"
|
5
|
-
|
6
|
-
class Scarpe
|
7
|
-
LOG_LEVELS = [:debug, :info, :warning, :error, :fatal].freeze
|
8
|
-
|
9
|
-
# Include this module to get a @log instance variable to log as your
|
10
|
-
# configured component.
|
11
|
-
module Log
|
12
|
-
DEFAULT_LOG_CONFIG = {
|
13
|
-
"default" => "info",
|
14
|
-
}
|
15
|
-
DEFAULT_DEBUG_LOG_CONFIG = {
|
16
|
-
"default" => "debug",
|
17
|
-
}
|
18
|
-
|
19
|
-
def log_init(component = self)
|
20
|
-
@log = Logging.logger[component]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class Logger
|
25
|
-
DEFAULT_COMPONENT = "default"
|
26
|
-
|
27
|
-
class << self
|
28
|
-
attr_reader :current_log_config
|
29
|
-
|
30
|
-
def logger(component = self)
|
31
|
-
Logging.logger[component]
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def name_to_severity(data)
|
37
|
-
case data
|
38
|
-
when "debug"
|
39
|
-
:debug
|
40
|
-
when "info"
|
41
|
-
:info
|
42
|
-
when "warn", "warning"
|
43
|
-
:warn
|
44
|
-
when "err", "error"
|
45
|
-
:error
|
46
|
-
when "fatal"
|
47
|
-
:fatal
|
48
|
-
else
|
49
|
-
raise "Don't know how to treat #{data.inspect} as a logger severity!"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def json_to_appender(data)
|
54
|
-
case data.downcase
|
55
|
-
when "stdout"
|
56
|
-
Logging.appenders.stdout layout: @custom_log_layout
|
57
|
-
when "stderr"
|
58
|
-
Logging.appenders.stderr layout: @custom_log_layout
|
59
|
-
when String
|
60
|
-
Logging.appenders.file data, layout: @custom_log_layout
|
61
|
-
else
|
62
|
-
raise "Don't know how to convert #{data.inspect} to an appender!"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def json_configure_logger(logger, data)
|
67
|
-
case data
|
68
|
-
in String
|
69
|
-
sev = name_to_severity(data)
|
70
|
-
logger.level = sev
|
71
|
-
in [level, *locations]
|
72
|
-
if logger.name != "root"
|
73
|
-
# The Logging gem doesn't have an additive property on the root logger
|
74
|
-
logger.additive = false # Don't also log to parent/root loggers
|
75
|
-
end
|
76
|
-
|
77
|
-
logger.appenders = locations.map { |where| json_to_appender(where) }
|
78
|
-
|
79
|
-
logger.level = name_to_severity(level)
|
80
|
-
else
|
81
|
-
raise "Don't know how to use #{data.inspect} to specify a logger!"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def freeze_log_config(log_config)
|
86
|
-
log_config.each do |k, v|
|
87
|
-
k.freeze
|
88
|
-
v.freeze
|
89
|
-
v.each(&:freeze) if v.is_a?(Array)
|
90
|
-
end
|
91
|
-
log_config.freeze
|
92
|
-
end
|
93
|
-
|
94
|
-
public
|
95
|
-
|
96
|
-
def configure_logger(log_config)
|
97
|
-
# TODO: custom coloring? https://github.com/TwP/logging/blob/master/examples/colorization.rb
|
98
|
-
@custom_log_layout = Logging.layouts.pattern pattern: '[%r] %-5l %c: %m\n'
|
99
|
-
|
100
|
-
if log_config.is_a?(String) && File.exist?(log_config)
|
101
|
-
log_config = JSON.load_file(log_config)
|
102
|
-
end
|
103
|
-
|
104
|
-
log_config = freeze_log_config(log_config) unless log_config.nil?
|
105
|
-
@current_log_config = log_config # Save a copy for later
|
106
|
-
|
107
|
-
Logging.reset # Reset all Logging settings to defaults
|
108
|
-
Logging.reopen # For log-reconfig (e.g. test failures), often important to *not* store an open handle to a moved file
|
109
|
-
return if log_config.nil?
|
110
|
-
|
111
|
-
Logging.logger.root.appenders = [Logging.appenders.stdout]
|
112
|
-
|
113
|
-
default_logger = log_config[DEFAULT_COMPONENT] || "info"
|
114
|
-
json_configure_logger(Logging.logger.root, default_logger)
|
115
|
-
|
116
|
-
log_config.each do |component, logger_data|
|
117
|
-
next if component == DEFAULT_COMPONENT
|
118
|
-
|
119
|
-
sublogger = Logging.logger[component]
|
120
|
-
json_configure_logger(sublogger, logger_data)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
class LoggedWrapper
|
127
|
-
include ::Scarpe::Log
|
128
|
-
def initialize(instance, component = instance)
|
129
|
-
log_init(component)
|
130
|
-
|
131
|
-
@instance = instance
|
132
|
-
end
|
133
|
-
|
134
|
-
def method_missing(method, ...)
|
135
|
-
self.singleton_class.define_method(method) do |*args, **kwargs, &block|
|
136
|
-
ret = @instance.send(method, *args, **kwargs, &block)
|
137
|
-
@log.info("Method: #{method} Args: #{args.inspect} KWargs: #{kwargs.inspect} Block: #{block ? "y" : "n"} Return: #{ret.inspect}")
|
138
|
-
ret
|
139
|
-
end
|
140
|
-
send(method, ...)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
class Logging::Logger
|
146
|
-
alias_method :warning, :warn
|
147
|
-
end
|
148
|
-
|
149
|
-
log_config = if ENV["SCARPE_LOG_CONFIG"]
|
150
|
-
JSON.load_file(ENV["SCARPE_LOG_CONFIG"])
|
151
|
-
else
|
152
|
-
ENV["SCARPE_DEBUG"] ? Scarpe::Log::DEFAULT_DEBUG_LOG_CONFIG : Scarpe::Log::DEFAULT_LOG_CONFIG
|
153
|
-
end
|
154
|
-
|
155
|
-
Scarpe::Logger.configure_logger(log_config)
|