From f2bfd090fb6444d3fab33a1bc832186bc35bfd8d Mon Sep 17 00:00:00 2001 From: Docs Builder Date: Mon, 6 May 2024 17:16:01 +0000 Subject: [PATCH] New docs build --- .nojekyll | 0 FontHelper.html | 357 ++ Kernel.html | 150 + Lacci.html | 138 + MarginHelper.html | 325 ++ Minitest.html | 115 + Minitest/Reporters.html | 115 + Minitest/Reporters/ShoesExportReporter.html | 559 ++ Niente.html | 130 + Niente/App.html | 403 ++ Niente/DisplayService.html | 597 ++ Niente/Drawable.html | 757 +++ Niente/ShoesSpecProxy.html | 595 ++ Niente/ShoesSpecTest.html | 221 + Niente/Test.html | 238 + Range.html | 192 + Scarpe.html | 145 + Scarpe/AppShutdownError.html | 142 + Scarpe/BadDisplayClassType.html | 132 + Scarpe/CCInstance.html | 1263 +++++ Scarpe/CLI.html | 520 ++ Scarpe/CatsCradle.html | 488 ++ Scarpe/Components.html | 140 + Scarpe/Components/AssetServer.html | 1200 ++++ .../Components/AssetServer/FileServlet.html | 393 ++ Scarpe/Components/Base64.html | 355 ++ Scarpe/Components/Calzini.html | 2852 ++++++++++ Scarpe/Components/FileHelpers.html | 455 ++ Scarpe/Components/HTML.html | 822 +++ Scarpe/Components/ImportRunnables.html | 115 + .../ImportRunnables/ImportRunnable.html | 452 ++ Scarpe/Components/MinitestResult.html | 1222 +++++ Scarpe/Components/ModularLogImpl.html | 312 ++ Scarpe/Components/PrintLogImpl.html | 274 + .../Components/PrintLogImpl/PrintLogger.html | 592 ++ Scarpe/Components/ProcessHelpers.html | 277 + Scarpe/Components/SegmentedFileLoader.html | 1028 ++++ Scarpe/Components/StringHelpers.html | 187 + Scarpe/Components/Tiranti.html | 713 +++ Scarpe/ConnectionError.html | 132 + Scarpe/DatagramSendError.html | 132 + Scarpe/DuplicateCallbackError.html | 132 + Scarpe/DuplicateFileError.html | 132 + Scarpe/EmptyPageNotSetError.html | 132 + Scarpe/Error.html | 140 + Scarpe/FileContentError.html | 132 + Scarpe/IllegalDispatchEventError.html | 132 + Scarpe/IllegalSubscribeEventError.html | 132 + Scarpe/InternalError.html | 132 + Scarpe/InvalidClassError.html | 132 + Scarpe/InvalidHTMLTag.html | 132 + Scarpe/InvalidOperationError.html | 132 + Scarpe/InvalidPromiseError.html | 132 + Scarpe/JSBindingError.html | 132 + Scarpe/JSEvalError.html | 228 + Scarpe/JSInitError.html | 132 + Scarpe/JSInternalError.html | 161 + Scarpe/JSRedrawError.html | 132 + Scarpe/JSRuntimeError.html | 161 + Scarpe/JSTimeoutError.html | 161 + Scarpe/MissingAppError.html | 132 + Scarpe/MissingAttributeError.html | 132 + Scarpe/MissingBlockError.html | 132 + Scarpe/MissingClassError.html | 132 + Scarpe/MissingDocRootError.html | 132 + Scarpe/MissingWranglerError.html | 132 + Scarpe/MustOverrideMethod.html | 132 + Scarpe/NoOperationError.html | 132 + Scarpe/NoSuchFile.html | 132 + Scarpe/NonexistentEvalResultError.html | 132 + Scarpe/OperationNotAllowedError.html | 132 + Scarpe/PeriodicHandlerSetupError.html | 132 + Scarpe/Promise.html | 1885 +++++++ Scarpe/ShoesSpecProxy.html | 657 +++ Scarpe/ShoesSpecTest.html | 483 ++ Scarpe/Test.html | 282 + Scarpe/Test/HTMLAssertions.html | 419 ++ Scarpe/Test/Helpers.html | 264 + Scarpe/Test/LoggedTest.html | 1079 ++++ Scarpe/UnexpectedFiberTransferError.html | 132 + Scarpe/UnknownBuiltinCommandError.html | 132 + Scarpe/UnknownEventTypeError.html | 132 + Scarpe/UnknownShapeCommandError.html | 132 + Scarpe/UnknownShoesEventAPIError.html | 132 + Scarpe/WVRelayUtil.html | 734 +++ Scarpe/WebWranglerNotRunningError.html | 132 + Scarpe/Webview.html | 310 ++ Scarpe/Webview/App.html | 996 ++++ Scarpe/Webview/Arc.html | 249 + Scarpe/Webview/Arrow.html | 249 + Scarpe/Webview/Border.html | 323 ++ Scarpe/Webview/Button.html | 334 ++ Scarpe/Webview/Check.html | 460 ++ Scarpe/Webview/ContainedService.html | 441 ++ Scarpe/Webview/ControlInterface.html | 953 ++++ Scarpe/Webview/DisplayService.html | 949 ++++ Scarpe/Webview/DocumentRoot.html | 405 ++ Scarpe/Webview/Drawable.html | 1908 +++++++ Scarpe/Webview/EditBox.html | 750 +++ Scarpe/Webview/EditLine.html | 750 +++ Scarpe/Webview/Flow.html | 197 + Scarpe/Webview/Image.html | 322 ++ Scarpe/Webview/Line.html | 312 ++ Scarpe/Webview/Link.html | 337 ++ Scarpe/Webview/ListBox.html | 670 +++ Scarpe/Webview/Oval.html | 312 ++ Scarpe/Webview/Para.html | 459 ++ Scarpe/Webview/Progress.html | 328 ++ Scarpe/Webview/Radio.html | 470 ++ Scarpe/Webview/Rect.html | 312 ++ Scarpe/Webview/RelayDisplayService.html | 618 +++ Scarpe/Webview/Shape.html | 418 ++ Scarpe/Webview/Slot.html | 643 +++ Scarpe/Webview/Stack.html | 193 + Scarpe/Webview/Star.html | 312 ++ Scarpe/Webview/SubscriptionItem.html | 554 ++ Scarpe/Webview/TextDrawable.html | 493 ++ Scarpe/Webview/Video.html | 353 ++ Scarpe/Webview/WebWrangler.html | 2522 +++++++++ Scarpe/Webview/WebWrangler/DOMWrangler.html | 1186 ++++ .../Webview/WebWrangler/ElementWrangler.html | 1204 ++++ Shoes.html | 926 ++++ Shoes/App.html | 1882 +++++++ Shoes/Arc.html | 300 + Shoes/Arrow.html | 300 + Shoes/Background.html | 190 + Shoes/Border.html | 298 + Shoes/Builtins.html | 643 +++ Shoes/Button.html | 588 ++ Shoes/Changelog.html | 327 ++ Shoes/Check.html | 490 ++ Shoes/Colors.html | 396 ++ Shoes/Constants.html | 344 ++ Shoes/DisplayService.html | 1178 ++++ Shoes/DocumentRoot.html | 398 ++ Shoes/Drawable.html | 4630 ++++++++++++++++ Shoes/Drawable/ResponseWrapper.html | 391 ++ Shoes/EditBox.html | 418 ++ Shoes/EditLine.html | 366 ++ Shoes/Error.html | 140 + Shoes/Errors.html | 115 + Shoes/Errors/BadArgumentListError.html | 132 + Shoes/Errors/BadFilenameError.html | 132 + Shoes/Errors/BadLinkableIdError.html | 132 + .../DoubleRegisteredShoesEventError.html | 132 + .../Errors/DuplicateCreateDrawableError.html | 132 + Shoes/Errors/InvalidAttributeValueError.html | 132 + Shoes/Errors/MultipleDrawablesFoundError.html | 132 + Shoes/Errors/MultipleShoesSpecRunsError.html | 132 + Shoes/Errors/NoDrawablesFoundError.html | 132 + Shoes/Errors/NoSuchLinkableIdError.html | 132 + Shoes/Errors/NoSuchListItemError.html | 132 + Shoes/Errors/NoSuchStyleError.html | 132 + Shoes/Errors/SingletonError.html | 132 + Shoes/Errors/TooManyInstancesError.html | 132 + Shoes/Errors/UnknownEventsForClassError.html | 132 + Shoes/Errors/UnregisteredShoesEventError.html | 132 + Shoes/Errors/UnsupportedFeatureError.html | 132 + Shoes/Flow.html | 340 ++ Shoes/Image.html | 418 ++ Shoes/Line.html | 300 + Shoes/Link.html | 331 ++ Shoes/LinkHover.html | 330 ++ Shoes/Linkable.html | 583 ++ Shoes/ListBox.html | 591 ++ Shoes/Log.html | 497 ++ Shoes/LoggedWrapper.html | 377 ++ Shoes/Oval.html | 348 ++ Shoes/Para.html | 786 +++ Shoes/Progress.html | 296 + Shoes/Radio.html | 500 ++ Shoes/Rect.html | 300 + Shoes/Shape.html | 427 ++ Shoes/Slot.html | 1634 ++++++ Shoes/Spec.html | 247 + Shoes/SpecInstance.html | 286 + Shoes/SpecProxy.html | 416 ++ Shoes/Stack.html | 338 ++ Shoes/Star.html | 300 + Shoes/SubscriptionItem.html | 505 ++ Shoes/TextDrawable.html | 738 +++ Shoes/Video.html | 296 + Shoes/Widget.html | 267 + _index.html | 1530 ++++++ class_list.html | 55 + css/common.css | 1 + css/full_list.css | 58 + css/style.css | 497 ++ file.README.html | 325 ++ file.catscradle.html | 109 + file.manual.html | 3547 ++++++++++++ file_list.html | 70 + frames.html | 17 + index.html | 325 ++ js/app.js | 314 ++ js/full_list.js | 216 + js/jquery.js | 4 + method_list.html | 4839 +++++++++++++++++ top-level-namespace.html | 159 + 199 files changed, 91486 insertions(+) create mode 100644 .nojekyll create mode 100644 FontHelper.html create mode 100644 Kernel.html create mode 100644 Lacci.html create mode 100644 MarginHelper.html create mode 100644 Minitest.html create mode 100644 Minitest/Reporters.html create mode 100644 Minitest/Reporters/ShoesExportReporter.html create mode 100644 Niente.html create mode 100644 Niente/App.html create mode 100644 Niente/DisplayService.html create mode 100644 Niente/Drawable.html create mode 100644 Niente/ShoesSpecProxy.html create mode 100644 Niente/ShoesSpecTest.html create mode 100644 Niente/Test.html create mode 100644 Range.html create mode 100644 Scarpe.html create mode 100644 Scarpe/AppShutdownError.html create mode 100644 Scarpe/BadDisplayClassType.html create mode 100644 Scarpe/CCInstance.html create mode 100644 Scarpe/CLI.html create mode 100644 Scarpe/CatsCradle.html create mode 100644 Scarpe/Components.html create mode 100644 Scarpe/Components/AssetServer.html create mode 100644 Scarpe/Components/AssetServer/FileServlet.html create mode 100644 Scarpe/Components/Base64.html create mode 100644 Scarpe/Components/Calzini.html create mode 100644 Scarpe/Components/FileHelpers.html create mode 100644 Scarpe/Components/HTML.html create mode 100644 Scarpe/Components/ImportRunnables.html create mode 100644 Scarpe/Components/ImportRunnables/ImportRunnable.html create mode 100644 Scarpe/Components/MinitestResult.html create mode 100644 Scarpe/Components/ModularLogImpl.html create mode 100644 Scarpe/Components/PrintLogImpl.html create mode 100644 Scarpe/Components/PrintLogImpl/PrintLogger.html create mode 100644 Scarpe/Components/ProcessHelpers.html create mode 100644 Scarpe/Components/SegmentedFileLoader.html create mode 100644 Scarpe/Components/StringHelpers.html create mode 100644 Scarpe/Components/Tiranti.html create mode 100644 Scarpe/ConnectionError.html create mode 100644 Scarpe/DatagramSendError.html create mode 100644 Scarpe/DuplicateCallbackError.html create mode 100644 Scarpe/DuplicateFileError.html create mode 100644 Scarpe/EmptyPageNotSetError.html create mode 100644 Scarpe/Error.html create mode 100644 Scarpe/FileContentError.html create mode 100644 Scarpe/IllegalDispatchEventError.html create mode 100644 Scarpe/IllegalSubscribeEventError.html create mode 100644 Scarpe/InternalError.html create mode 100644 Scarpe/InvalidClassError.html create mode 100644 Scarpe/InvalidHTMLTag.html create mode 100644 Scarpe/InvalidOperationError.html create mode 100644 Scarpe/InvalidPromiseError.html create mode 100644 Scarpe/JSBindingError.html create mode 100644 Scarpe/JSEvalError.html create mode 100644 Scarpe/JSInitError.html create mode 100644 Scarpe/JSInternalError.html create mode 100644 Scarpe/JSRedrawError.html create mode 100644 Scarpe/JSRuntimeError.html create mode 100644 Scarpe/JSTimeoutError.html create mode 100644 Scarpe/MissingAppError.html create mode 100644 Scarpe/MissingAttributeError.html create mode 100644 Scarpe/MissingBlockError.html create mode 100644 Scarpe/MissingClassError.html create mode 100644 Scarpe/MissingDocRootError.html create mode 100644 Scarpe/MissingWranglerError.html create mode 100644 Scarpe/MustOverrideMethod.html create mode 100644 Scarpe/NoOperationError.html create mode 100644 Scarpe/NoSuchFile.html create mode 100644 Scarpe/NonexistentEvalResultError.html create mode 100644 Scarpe/OperationNotAllowedError.html create mode 100644 Scarpe/PeriodicHandlerSetupError.html create mode 100644 Scarpe/Promise.html create mode 100644 Scarpe/ShoesSpecProxy.html create mode 100644 Scarpe/ShoesSpecTest.html create mode 100644 Scarpe/Test.html create mode 100644 Scarpe/Test/HTMLAssertions.html create mode 100644 Scarpe/Test/Helpers.html create mode 100644 Scarpe/Test/LoggedTest.html create mode 100644 Scarpe/UnexpectedFiberTransferError.html create mode 100644 Scarpe/UnknownBuiltinCommandError.html create mode 100644 Scarpe/UnknownEventTypeError.html create mode 100644 Scarpe/UnknownShapeCommandError.html create mode 100644 Scarpe/UnknownShoesEventAPIError.html create mode 100644 Scarpe/WVRelayUtil.html create mode 100644 Scarpe/WebWranglerNotRunningError.html create mode 100644 Scarpe/Webview.html create mode 100644 Scarpe/Webview/App.html create mode 100644 Scarpe/Webview/Arc.html create mode 100644 Scarpe/Webview/Arrow.html create mode 100644 Scarpe/Webview/Border.html create mode 100644 Scarpe/Webview/Button.html create mode 100644 Scarpe/Webview/Check.html create mode 100644 Scarpe/Webview/ContainedService.html create mode 100644 Scarpe/Webview/ControlInterface.html create mode 100644 Scarpe/Webview/DisplayService.html create mode 100644 Scarpe/Webview/DocumentRoot.html create mode 100644 Scarpe/Webview/Drawable.html create mode 100644 Scarpe/Webview/EditBox.html create mode 100644 Scarpe/Webview/EditLine.html create mode 100644 Scarpe/Webview/Flow.html create mode 100644 Scarpe/Webview/Image.html create mode 100644 Scarpe/Webview/Line.html create mode 100644 Scarpe/Webview/Link.html create mode 100644 Scarpe/Webview/ListBox.html create mode 100644 Scarpe/Webview/Oval.html create mode 100644 Scarpe/Webview/Para.html create mode 100644 Scarpe/Webview/Progress.html create mode 100644 Scarpe/Webview/Radio.html create mode 100644 Scarpe/Webview/Rect.html create mode 100644 Scarpe/Webview/RelayDisplayService.html create mode 100644 Scarpe/Webview/Shape.html create mode 100644 Scarpe/Webview/Slot.html create mode 100644 Scarpe/Webview/Stack.html create mode 100644 Scarpe/Webview/Star.html create mode 100644 Scarpe/Webview/SubscriptionItem.html create mode 100644 Scarpe/Webview/TextDrawable.html create mode 100644 Scarpe/Webview/Video.html create mode 100644 Scarpe/Webview/WebWrangler.html create mode 100644 Scarpe/Webview/WebWrangler/DOMWrangler.html create mode 100644 Scarpe/Webview/WebWrangler/ElementWrangler.html create mode 100644 Shoes.html create mode 100644 Shoes/App.html create mode 100644 Shoes/Arc.html create mode 100644 Shoes/Arrow.html create mode 100644 Shoes/Background.html create mode 100644 Shoes/Border.html create mode 100644 Shoes/Builtins.html create mode 100644 Shoes/Button.html create mode 100644 Shoes/Changelog.html create mode 100644 Shoes/Check.html create mode 100644 Shoes/Colors.html create mode 100644 Shoes/Constants.html create mode 100644 Shoes/DisplayService.html create mode 100644 Shoes/DocumentRoot.html create mode 100644 Shoes/Drawable.html create mode 100644 Shoes/Drawable/ResponseWrapper.html create mode 100644 Shoes/EditBox.html create mode 100644 Shoes/EditLine.html create mode 100644 Shoes/Error.html create mode 100644 Shoes/Errors.html create mode 100644 Shoes/Errors/BadArgumentListError.html create mode 100644 Shoes/Errors/BadFilenameError.html create mode 100644 Shoes/Errors/BadLinkableIdError.html create mode 100644 Shoes/Errors/DoubleRegisteredShoesEventError.html create mode 100644 Shoes/Errors/DuplicateCreateDrawableError.html create mode 100644 Shoes/Errors/InvalidAttributeValueError.html create mode 100644 Shoes/Errors/MultipleDrawablesFoundError.html create mode 100644 Shoes/Errors/MultipleShoesSpecRunsError.html create mode 100644 Shoes/Errors/NoDrawablesFoundError.html create mode 100644 Shoes/Errors/NoSuchLinkableIdError.html create mode 100644 Shoes/Errors/NoSuchListItemError.html create mode 100644 Shoes/Errors/NoSuchStyleError.html create mode 100644 Shoes/Errors/SingletonError.html create mode 100644 Shoes/Errors/TooManyInstancesError.html create mode 100644 Shoes/Errors/UnknownEventsForClassError.html create mode 100644 Shoes/Errors/UnregisteredShoesEventError.html create mode 100644 Shoes/Errors/UnsupportedFeatureError.html create mode 100644 Shoes/Flow.html create mode 100644 Shoes/Image.html create mode 100644 Shoes/Line.html create mode 100644 Shoes/Link.html create mode 100644 Shoes/LinkHover.html create mode 100644 Shoes/Linkable.html create mode 100644 Shoes/ListBox.html create mode 100644 Shoes/Log.html create mode 100644 Shoes/LoggedWrapper.html create mode 100644 Shoes/Oval.html create mode 100644 Shoes/Para.html create mode 100644 Shoes/Progress.html create mode 100644 Shoes/Radio.html create mode 100644 Shoes/Rect.html create mode 100644 Shoes/Shape.html create mode 100644 Shoes/Slot.html create mode 100644 Shoes/Spec.html create mode 100644 Shoes/SpecInstance.html create mode 100644 Shoes/SpecProxy.html create mode 100644 Shoes/Stack.html create mode 100644 Shoes/Star.html create mode 100644 Shoes/SubscriptionItem.html create mode 100644 Shoes/TextDrawable.html create mode 100644 Shoes/Video.html create mode 100644 Shoes/Widget.html create mode 100644 _index.html create mode 100644 class_list.html create mode 100644 css/common.css create mode 100644 css/full_list.css create mode 100644 css/style.css create mode 100644 file.README.html create mode 100644 file.catscradle.html create mode 100644 file.manual.html create mode 100644 file_list.html create mode 100644 frames.html create mode 100644 index.html create mode 100644 js/app.js create mode 100644 js/full_list.js create mode 100644 js/jquery.js create mode 100644 method_list.html create mode 100644 top-level-namespace.html diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 000000000..e69de29bb diff --git a/FontHelper.html b/FontHelper.html new file mode 100644 index 000000000..562a801c8 --- /dev/null +++ b/FontHelper.html @@ -0,0 +1,357 @@ + + + + + + + Module: FontHelper + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: FontHelper + + + +

+
+ + + + + + + + + +
+
Included in:
+
Shoes::Para
+
+ + + +
+
Defined in:
+
lacci/lib/shoes/drawables/font_helper.rb
+
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #contains_number?(str) ⇒ Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+57
+58
+59
+60
+61
+
+
# File 'lacci/lib/shoes/drawables/font_helper.rb', line 57
+
+def contains_number?(str)
+
+  !!(str =~ /\d/)
+
+end
+
+
+ +
+

+ + #parse_font(font) ⇒ Object + + + + + +

+ + + + +
+
+
+
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+
+
# File 'lacci/lib/shoes/drawables/font_helper.rb', line 3
+
+def parse_font(font)
+    
+    input = font
+    regex = /\s+(?=(?:[^']*'[^']*')*[^']*$)(?![^']*,[^']*')/
+    result = input.split(regex)
+   
+    fs = nil
+    fv = nil
+    fw = nil
+    fss = nil
+    ff = ""
+    
+    fos = ["italic", "oblique"]
+    fov = ["small-caps", "initial", "inherit"]
+    fow = ["bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900"]
+    foss = ["xx-small", "x-small", "small","large", "x-large", "xx-large", "smaller", "larger"]
+    
+    result.each do |i|
+      if fos.include?(i)
+        fs = i
+        next
+      elsif fov.include?(i)
+        fv = i
+        next
+      elsif fow.include?(i)
+        fw = i
+        next
+      elsif foss.include?(i)
+        fss = i
+        next
+      else
+        if contains_number?(i)
+          
+          fss=i;
+
+        elsif i != "normal" && i != "medium" && i.strip != ""
+
+          if ff == "Arial"
+
+            ff = i
+
+          else
+            
+            ff = ff+" "+i
+
+          end
+        end
+      end
+      
+    end
+    
+      [fs, fv , fw , fss , ff.strip]
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Kernel.html b/Kernel.html new file mode 100644 index 000000000..475bd949e --- /dev/null +++ b/Kernel.html @@ -0,0 +1,150 @@ + + + + + + + Module: Kernel + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Kernel + + + +

+
+ + + + + + +
+
Includes:
+
Shoes::Builtins, Shoes::Constants
+
+ + + + + + +
+
Defined in:
+
lacci/lib/shoes.rb,
+ lacci/lib/shoes/builtins.rb
+
+
+ +
+ +

Overview

+
+

Shoes adds some top-level methods and constants that can be used everywhere. Kernel is where they go.

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants included + from Shoes::Constants

+

Shoes::Constants::DIR, Shoes::Constants::EXTENSIONS, Shoes::Constants::FEATURES, Shoes::Constants::FONTS, Shoes::Constants::HALF_PI, Shoes::Constants::KNOWN_FEATURES, Shoes::Constants::LIB_DIR, Shoes::Constants::PI, Shoes::Constants::RAD2PI, Shoes::Constants::TWO_PI

+ + + + + + + + + + + + +

Method Summary

+ +

Methods included from Shoes::Builtins

+

#alert, #ask, #ask_color, #ask_open_file, #ask_open_folder, #ask_save_file, #ask_save_folder, #confirm, #font

+ + + + + + + + + +

Methods included from Shoes::Constants

+

find_lib_dir

+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Lacci.html b/Lacci.html new file mode 100644 index 000000000..5c91cd7ec --- /dev/null +++ b/Lacci.html @@ -0,0 +1,138 @@ + + + + + + + Module: Lacci + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Lacci + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/lacci/version.rb
+
+ +
+ +

Overview

+
+

The name "scarpe" means "shoes" in Italian. "Lacci" +means "laces." Lacci is the display-independent part +of Scarpe, tying the Shoes API to the display service +of your choice.

+ +

Almost nothing is called Lacci in your program. It's +mostly invisible. Instead, look at the Shoes module +to see what's in Lacci.

+ + +
+
+
+ + +
+ +

+ Constant Summary + collapse +

+ +
+ +
VERSION = + +
+
"0.4.0"
+ +
+ + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/MarginHelper.html b/MarginHelper.html new file mode 100644 index 000000000..3f78fba5d --- /dev/null +++ b/MarginHelper.html @@ -0,0 +1,325 @@ + + + + + + + Module: MarginHelper + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: MarginHelper + + + +

+
+ + + + + + + + + +
+
Included in:
+
Shoes::Drawable
+
+ + + +
+
Defined in:
+
lacci/lib/shoes/margin_helper.rb
+
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #margin_parse(kwargs) ⇒ Object + + + + + +

+ + + + +
+
+
+
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+
+
# File 'lacci/lib/shoes/margin_helper.rb', line 3
+
+def margin_parse(kwargs)
+
+    if kwargs[:margin]
+
+      if kwargs[:margin].is_a?(Numeric)
+
+        if !kwargs[:margin_top]
+          kwargs[:margin_top] = kwargs[:margin]
+        end
+        if !kwargs[:margin_bottom]
+          kwargs[:margin_bottom] = kwargs[:margin]
+        end
+        if !kwargs[:margin_left]
+          kwargs[:margin_left] = kwargs[:margin]
+        end
+        if !kwargs[:margin_right]
+          kwargs[:margin_right] = kwargs[:margin]
+        end
+
+      elsif kwargs[:margin].is_a?(Hash)
+
+        kwargs[:margin].each do |key,value|
+          kwargs[:"margin_#{key}"] = value
+        end
+
+      else
+        margin_props = kwargs[:margin].is_a?(String) ? kwargs[:margin].split(/\s+|\,|-/) : kwargs[:margin]
+        if margin_props.length == 1
+
+          if !kwargs[:margin_top]
+            kwargs[:margin_top] = margin_props[0]
+          end
+          if !kwargs[:margin_bottom]
+            kwargs[:margin_bottom] = margin_props[0]
+          end
+          if !kwargs[:margin_left]
+            kwargs[:margin_left] = margin_props[0]
+          end
+          if !kwargs[:margin_right]
+            kwargs[:margin_right] = margin_props[0]
+          end
+
+        elsif margin_props.length == 2
+
+          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}'")
+
+        elsif margin_props.length == 3
+
+          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}'")
+        
+        else
+
+          if !kwargs[:margin_top]
+            kwargs[:margin_top] = margin_props[1]
+          end
+          if !kwargs[:margin_bottom]
+            kwargs[:margin_bottom] = margin_props[3]
+          end
+          if !kwargs[:margin_left]
+            kwargs[:margin_left] = margin_props[0]
+          end
+          if !kwargs[:margin_right]
+            kwargs[:margin_right] = margin_props[2]
+          end
+
+        end
+      end
+      kwargs[:margin] = nil
+    end
+    if kwargs["options"] && !kwargs[:margin] && !kwargs[:margin_left] && !kwargs[:margin_right] && !kwargs[:margin_top] && !kwargs[:margin_bottom]
+      kwargs[options].each do |key,value|
+        kwargs[key] = value
+      end
+    end
+    kwargs
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Minitest.html b/Minitest.html new file mode 100644 index 000000000..04f40929d --- /dev/null +++ b/Minitest.html @@ -0,0 +1,115 @@ + + + + + + + Module: Minitest + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Minitest + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/minitest_export_reporter.rb
+
+ +
+ +

Defined Under Namespace

+

+ + + Modules: Reporters + + + + +

+ + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Minitest/Reporters.html b/Minitest/Reporters.html new file mode 100644 index 000000000..489e3c5ee --- /dev/null +++ b/Minitest/Reporters.html @@ -0,0 +1,115 @@ + + + + + + + Module: Minitest::Reporters + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Minitest::Reporters + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/minitest_export_reporter.rb
+
+ +
+ +

Defined Under Namespace

+

+ + + + + Classes: ShoesExportReporter + + +

+ + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Minitest/Reporters/ShoesExportReporter.html b/Minitest/Reporters/ShoesExportReporter.html new file mode 100644 index 000000000..7a5a16550 --- /dev/null +++ b/Minitest/Reporters/ShoesExportReporter.html @@ -0,0 +1,559 @@ + + + + + + + Class: Minitest::Reporters::ShoesExportReporter + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Minitest::Reporters::ShoesExportReporter + + + +

+
+ +
+
Inherits:
+
+ BaseReporter + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/minitest_export_reporter.rb
+
+ +
+ +

Overview

+
+

To use this Scarpe component, you'll need minitest-reporters in your Gemfile, +probably in the "test" group. You'll need to require and activate ShoesExportReporter +to register it as Minitest's reporter:

+ +
require "scarpe/components/minitest_export_reporter"
+Minitest::Reporters::ShoesExportReporter.activate!
+
+ +

Select a destination to export JSON test results to:

+ +
export SHOES_MINITEST_EXPORT_FILE=/tmp/shoes_test_export.json
+
+ +

This class overrides the MINITEST_REPORTER environment variable when you call activate. +If MINITEST_REPORTER isn't set then when you run via Vim, TextMate, RubyMine, etc, +the reporter will be automatically overridden and print to console instead.

+ +

Based on https://gist.github.com/davidwessman/09a13840a8a80080e3842ac3051714c7

+ + +
+
+
+ + +
+ + + +

Class Attribute Summary collapse

+
    + +
  • + + + .export_file ⇒ Object + + + + + + + + + + + + + + + + +

    Returns the value of attribute export_file.

    +
    + +
  • + + +
  • + + + .metadata ⇒ Object + + + + + + + + + + + + + + + + +

    Returns the value of attribute metadata.

    +
    + +
  • + + +
+ + + + + +

+ Class Method Summary + collapse +

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Class Attribute Details

+ + + +
+

+ + .export_fileObject + + + + + +

+
+

Returns the value of attribute export_file.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+30
+31
+32
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_export_reporter.rb', line 30
+
+def export_file
+  @export_file
+end
+
+
+ + + +
+

+ + .metadataObject + + + + + +

+
+

Returns the value of attribute metadata.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+29
+30
+31
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_export_reporter.rb', line 29
+
+def 
+  @metadata
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + .activate!Object + + + + + +

+ + + + +
+
+
+
+33
+34
+35
+36
+37
+38
+39
+40
+41
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_export_reporter.rb', line 33
+
+def self.activate!
+  unless ENV["SHOES_MINITEST_EXPORT_FILE"]
+    raise "ShoesExportReporter is available, but no export file was specified! Set SHOES_MINITEST_EXPORT_FILE!"
+  end
+  ShoesExportReporter.export_file = File.expand_path(ENV["SHOES_MINITEST_EXPORT_FILE"])
+  ShoesExportReporter. ||= {}
+
+  Minitest::Reporters.use!
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + #reportObject + + + + + +

+ + + + +
+
+
+
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_export_reporter.rb', line 56
+
+def report
+  super
+
+  results = tests.map do |result|
+    failures = serialize_failures result.failures
+    {
+      name: result.name,
+      klass: test_class(result),
+      assertions: result.assertions,
+      failures: failures,
+      time: result.time,
+      metadata: result.respond_to?(:metadata) ? result. : {},
+      exporter_metadata: ShoesExportReporter.,
+      source_location: begin
+        result.source_location
+      rescue
+        ["unknown", -1]
+      end,
+    }
+  end
+
+  out_file = ShoesExportReporter.export_file
+  #puts "Writing Minitest results to #{out_file.inspect}."
+  File.write(out_file, JSON.dump(results))
+end
+
+
+ +
+

+ + #serialize_failures(failures) ⇒ Object + + + + + +

+ + + + +
+
+
+
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_export_reporter.rb', line 43
+
+def serialize_failures(failures)
+  failures.map do |fail|
+    case fail
+    when Minitest::UnexpectedError
+      ["unexpected", fail.to_json, fail.error.to_json]
+    when Exception
+      ["exception", fail.to_json]
+    else
+      raise "Not sure how to serialize failure object! #{fail.inspect}"
+    end
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Niente.html b/Niente.html new file mode 100644 index 000000000..dd1b5d70d --- /dev/null +++ b/Niente.html @@ -0,0 +1,130 @@ + + + + + + + Module: Niente + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Niente + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/scarpe/niente.rb,
+ lacci/lib/scarpe/niente/app.rb,
lacci/lib/scarpe/niente/drawable.rb,
lacci/lib/scarpe/niente/shoes_spec.rb,
lacci/lib/scarpe/niente/display_service.rb
+
+
+ +
+ +

Overview

+
+

Niente -- Italian for "nothing" -- is a null display service +that doesn't display anything. It does very little, while +keeping a certain amount of "mental model" or schema of +how a real display service should act.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + + + Classes: App, DisplayService, Drawable, ShoesSpecProxy, ShoesSpecTest, Test + + +

+ + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Niente/App.html b/Niente/App.html new file mode 100644 index 000000000..ad9c9d905 --- /dev/null +++ b/Niente/App.html @@ -0,0 +1,403 @@ + + + + + + + Class: Niente::App + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Niente::App + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/scarpe/niente/app.rb
+
+ +
+ + + + + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id, #shoes_type

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #remove_child, #set_parent

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ App + + + + + +

+
+

Returns a new instance of App.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+8
+9
+10
+11
+
+
# File 'lacci/lib/scarpe/niente/app.rb', line 5
+
+def initialize(properties)
+  super
+
+  bind_shoes_event(event_name: "init") { init }
+  bind_shoes_event(event_name: "run") { run }
+  bind_shoes_event(event_name: "destroy") { destroy }
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #destroyObject + + + + + +

+ + + + +
+
+
+
+20
+21
+
+
# File 'lacci/lib/scarpe/niente/app.rb', line 20
+
+def destroy
+end
+
+
+ +
+

+ + #initObject + + + + + +

+ + + + +
+
+
+
+13
+14
+
+
# File 'lacci/lib/scarpe/niente/app.rb', line 13
+
+def init
+end
+
+
+ +
+

+ + #runObject + + + + + +

+ + + + +
+
+
+
+16
+17
+18
+
+
# File 'lacci/lib/scarpe/niente/app.rb', line 16
+
+def run
+  send_shoes_event("wait", event_name: "custom_event_loop")
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Niente/DisplayService.html b/Niente/DisplayService.html new file mode 100644 index 000000000..c2d264b2e --- /dev/null +++ b/Niente/DisplayService.html @@ -0,0 +1,597 @@ + + + + + + + Class: Niente::DisplayService + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Niente::DisplayService + + + +

+
+ +
+
Inherits:
+
+ Shoes::DisplayService + + + show all + +
+
+ + + + + + +
+
Includes:
+
Shoes::Log
+
+ + + + + + +
+
Defined in:
+
lacci/lib/scarpe/niente/display_service.rb
+
+ +
+ +

Overview

+
+

This is a "null" DisplayService, doing as little as it +can get away with.

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + +

Class Attribute Summary collapse

+
    + +
  • + + + .instance ⇒ Object + + + + + + + + + + + + + + + + +

    Returns the value of attribute instance.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::DisplayService

+

dispatch_event, display_service, full_reset!, #query_display_drawable_for, set_display_service_class, #set_drawable_pairing, subscribe_to_event, unsub_from_events

+
+

Constructor Details

+ +
+

+ + #initializeDisplayService + + + + + +

+
+

Returns a new instance of DisplayService.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+
+
# File 'lacci/lib/scarpe/niente/display_service.rb', line 13
+
+def initialize
+  if Niente::DisplayService.instance
+    raise Shoes::SingletonError, "ERROR! This is meant to be a singleton!"
+  end
+
+  Niente::DisplayService.instance = self
+
+  log_init("Niente::DisplayService")
+  super()
+end
+
+
+ +
+ +
+

Class Attribute Details

+ + + +
+

+ + .instanceObject + + + + + +

+
+

Returns the value of attribute instance.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lacci/lib/scarpe/niente/display_service.rb', line 10
+
+def instance
+  @instance
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #create_display_drawable_for(drawable_class_name, drawable_id, properties, parent_id:, is_widget:) ⇒ Webview::Drawable + + + + + +

+
+

Create a fake display drawable for a specific Shoes drawable, and pair it with +the linkable ID for this Shoes drawable.

+ + +
+
+
+

Parameters:

+
    + +
  • + + drawable_class_name + + + (String) + + + + — +

    The class name of the Shoes drawable, e.g. Shoes::Button

    +
    + +
  • + +
  • + + drawable_id + + + (String) + + + + — +

    the linkable ID for drawable events

    +
    + +
  • + +
  • + + properties + + + (Hash) + + + + — +

    a JSON-serialisable Hash with the drawable's Shoes styles

    +
    + +
  • + +
  • + + is_widget + + + (Boolean) + + + + — +

    whether the class is a user-defined Shoes::Widget subclass

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Webview::Drawable) + + + + — +

    the newly-created Webview drawable

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+
+
# File 'lacci/lib/scarpe/niente/display_service.rb', line 32
+
+def create_display_drawable_for(drawable_class_name, drawable_id, properties, parent_id:, is_widget:)
+  existing = query_display_drawable_for(drawable_id, nil_ok: true)
+  if existing
+    @log.warn("There is already a display drawable for #{drawable_id.inspect}! Returning #{existing.class.name}.")
+    return existing
+  end
+
+  if drawable_class_name == "App"
+    @app = Niente::App.new(properties)
+    set_drawable_pairing(drawable_id, @app)
+
+    return @app
+  end
+
+  display_drawable = Niente::Drawable.new(properties)
+  display_drawable.shoes_type = drawable_class_name
+  set_drawable_pairing(drawable_id, display_drawable)
+
+  # Nil parent is okay for DocumentRoot and TextDrawables, so we have to specify it.
+  parent = DisplayService.instance.query_display_drawable_for(parent_id, nil_ok: true)
+  display_drawable.set_parent(parent)
+
+  return display_drawable
+end
+
+
+ +
+

+ + #destroyvoid + + + + + +

+
+

This method returns an undefined value.

Destroy the display service and the app. Quit the process (eventually.)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+60
+61
+62
+63
+
+
# File 'lacci/lib/scarpe/niente/display_service.rb', line 60
+
+def destroy
+  @app.destroy
+  DisplayService.instance = nil
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Niente/Drawable.html b/Niente/Drawable.html new file mode 100644 index 000000000..d457d654b --- /dev/null +++ b/Niente/Drawable.html @@ -0,0 +1,757 @@ + + + + + + + Class: Niente::Drawable + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Niente::Drawable + + + +

+
+ +
+
Inherits:
+
+ Shoes::Linkable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/scarpe/niente/drawable.rb
+
+ +
+ +
+

Direct Known Subclasses

+

App

+
+ + + + +

Instance Attribute Summary collapse

+
    + +
  • + + + #children ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute children.

    +
    + +
  • + + +
  • + + + #parent ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute parent.

    +
    + +
  • + + +
  • + + + #shoes_linkable_id ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute shoes_linkable_id.

    +
    + +
  • + + +
  • + + + #shoes_type ⇒ Object + + + + + + + + + + + + + + + + +

    Returns the value of attribute shoes_type.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(props) ⇒ Drawable + + + + + +

+
+

Returns a new instance of Drawable.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+
+
# File 'lacci/lib/scarpe/niente/drawable.rb', line 9
+
+def initialize(props)
+  @shoes_linkable_id = props.delete("shoes_linkable_id") || props.delete(:shoes_linkable_id)
+  @data = props
+
+  super(linkable_id: @shoes_linkable_id)
+
+  # This should only be used for reparenting after a drawable was initially created.
+  bind_shoes_event(event_name: "parent", target: shoes_linkable_id) do |new_parent_id|
+    display_parent = DisplayService.instance.query_display_drawable_for(new_parent_id)
+    if @parent != display_parent
+      set_parent(display_parent)
+    end
+  end
+
+  # When Shoes drawables change properties, we get a change notification here
+  bind_shoes_event(event_name: "prop_change", target: shoes_linkable_id) do |prop_changes|
+    prop_changes.each do |k, v|
+      instance_variable_set("@" + k, v)
+    end
+    properties_changed(prop_changes) if respond_to?(:properties_changed)
+  end
+
+  bind_shoes_event(event_name: "destroy", target: shoes_linkable_id) do
+    set_parent(nil)
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #childrenObject (readonly) + + + + + +

+
+

Returns the value of attribute children.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lacci/lib/scarpe/niente/drawable.rb', line 5
+
+def children
+  @children
+end
+
+
+ + + +
+

+ + #parentObject (readonly) + + + + + +

+
+

Returns the value of attribute parent.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+4
+5
+6
+
+
# File 'lacci/lib/scarpe/niente/drawable.rb', line 4
+
+def parent
+  @parent
+end
+
+
+ + + +
+

+ + #shoes_linkable_idObject (readonly) + + + + + +

+
+

Returns the value of attribute shoes_linkable_id.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+3
+4
+5
+
+
# File 'lacci/lib/scarpe/niente/drawable.rb', line 3
+
+def shoes_linkable_id
+  @shoes_linkable_id
+end
+
+
+ + + +
+

+ + #shoes_typeObject + + + + + +

+
+

Returns the value of attribute shoes_type.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+
+
# File 'lacci/lib/scarpe/niente/drawable.rb', line 7
+
+def shoes_type
+  @shoes_type
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #add_child(child) ⇒ Object + + + + + +

+
+

Do not call directly, use set_parent

+ + +
+
+
+ + +
+ + + + +
+
+
+
+53
+54
+55
+56
+
+
# File 'lacci/lib/scarpe/niente/drawable.rb', line 53
+
+def add_child(child)
+  @children ||= []
+  @children << child
+end
+
+
+ +
+

+ + #remove_child(child) ⇒ Object + + + + + +

+
+

Do not call directly, use set_parent

+ + +
+
+
+ + +
+ + + + +
+
+
+
+43
+44
+45
+46
+47
+48
+49
+50
+
+
# File 'lacci/lib/scarpe/niente/drawable.rb', line 43
+
+def remove_child(child)
+  @children ||= []
+  unless @children.include?(child)
+    STDERR.puts("remove_child: no such child(#{child.inspect}) for"\
+      " parent(#{parent.inspect})!")
+  end
+  @children.delete(child)
+end
+
+
+ +
+

+ + #set_parent(new_parent) ⇒ Object + + + + + +

+ + + + +
+
+
+
+36
+37
+38
+39
+40
+
+
# File 'lacci/lib/scarpe/niente/drawable.rb', line 36
+
+def set_parent(new_parent)
+  @parent&.remove_child(self)
+  new_parent&.add_child(self)
+  @parent = new_parent
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Niente/ShoesSpecProxy.html b/Niente/ShoesSpecProxy.html new file mode 100644 index 000000000..4b4f33de2 --- /dev/null +++ b/Niente/ShoesSpecProxy.html @@ -0,0 +1,595 @@ + + + + + + + Class: Niente::ShoesSpecProxy + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Niente::ShoesSpecProxy + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/scarpe/niente/shoes_spec.rb
+
+ +
+ + + +

+ Constant Summary + collapse +

+ +
+ +
JS_EVENTS = + +
+
[:click, :hover, :leave]
+ +
+ + + + + +

Instance Attribute Summary collapse

+
    + +
  • + + + #display ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute display.

    +
    + +
  • + + +
  • + + + #linkable_id ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute linkable_id.

    +
    + +
  • + + +
  • + + + #obj ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute obj.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + collapse +

+ + + + +
+

Constructor Details

+ +
+

+ + #initialize(obj) ⇒ ShoesSpecProxy + + + + + +

+
+

Returns a new instance of ShoesSpecProxy.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+66
+67
+68
+69
+70
+
+
# File 'lacci/lib/scarpe/niente/shoes_spec.rb', line 66
+
+def initialize(obj)
+  @obj = obj
+  @linkable_id = obj.linkable_id
+  @display = ::Shoes::DisplayService.display_service.query_display_drawable_for(obj.linkable_id)
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + +

+ +
+

+ + #method_missing(method) ⇒ Object + + + + + +

+ + + + +
+
+
+
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+
+
# File 'lacci/lib/scarpe/niente/shoes_spec.rb', line 72
+
+def method_missing(method, ...)
+  if @obj.respond_to?(method)
+    self.singleton_class.define_method(method) do |*args, **kwargs, &block|
+      @obj.send(method, *args, **kwargs, &block)
+    end
+    send(method, ...)
+  else
+    super # raise an exception
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #displayObject (readonly) + + + + + +

+
+

Returns the value of attribute display.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+64
+65
+66
+
+
# File 'lacci/lib/scarpe/niente/shoes_spec.rb', line 64
+
+def display
+  @display
+end
+
+
+ + + +
+

+ + #linkable_idObject (readonly) + + + + + +

+
+

Returns the value of attribute linkable_id.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+63
+64
+65
+
+
# File 'lacci/lib/scarpe/niente/shoes_spec.rb', line 63
+
+def linkable_id
+  @linkable_id
+end
+
+
+ + + +
+

+ + #objObject (readonly) + + + + + +

+
+

Returns the value of attribute obj.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+62
+63
+64
+
+
# File 'lacci/lib/scarpe/niente/shoes_spec.rb', line 62
+
+def obj
+  @obj
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #respond_to_missing?(method_name, include_private = false) ⇒ Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+90
+91
+92
+
+
# File 'lacci/lib/scarpe/niente/shoes_spec.rb', line 90
+
+def respond_to_missing?(method_name, include_private = false)
+  @obj.respond_to_missing?(method_name, include_private)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Niente/ShoesSpecTest.html b/Niente/ShoesSpecTest.html new file mode 100644 index 000000000..83e1cf8a6 --- /dev/null +++ b/Niente/ShoesSpecTest.html @@ -0,0 +1,221 @@ + + + + + + + Class: Niente::ShoesSpecTest + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Niente::ShoesSpecTest + + + +

+
+ +
+
Inherits:
+
+ Minitest::Test + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/scarpe/niente/shoes_spec.rb
+
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + +
+

Instance Method Details

+ + +
+

+ + #drawable(*specs) ⇒ Object + + + + + +

+
+ + +
+
+
+ +

Raises:

+ + +
+ + + + +
+
+
+
+53
+54
+55
+56
+57
+58
+
+
# File 'lacci/lib/scarpe/niente/shoes_spec.rb', line 53
+
+def drawable(*specs)
+  drawables = Shoes::App.instance.find_drawables_by(*specs)
+  raise Shoes::Errors::MultipleDrawablesFoundError, "Found more than one #{finder_name} matching #{args.inspect}!" if drawables.size > 1
+  raise Shoes::Errors::NoDrawablesFoundError, "Found no #{finder_name} matching #{args.inspect}!" if drawables.empty?
+  Niente::ShoesSpecProxy.new(drawables[0])
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Niente/Test.html b/Niente/Test.html new file mode 100644 index 000000000..c7442085b --- /dev/null +++ b/Niente/Test.html @@ -0,0 +1,238 @@ + + + + + + + Class: Niente::Test + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Niente::Test + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/scarpe/niente/shoes_spec.rb
+
+ +
+ + + + + + + + + +

+ Class Method Summary + collapse +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + .run_shoes_spec_test_code(code, class_name: nil, test_name: nil) ⇒ Object + + + + + +

+ + + + +
+
+
+
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+
+
# File 'lacci/lib/scarpe/niente/shoes_spec.rb', line 9
+
+def self.run_shoes_spec_test_code(code, class_name: nil, test_name: nil)
+  if @shoes_spec_init
+    raise Shoes::Errors::MultipleShoesSpecRunsError, "Scarpe-Webview can only run a single Shoes spec per process!"
+  end
+  @shoes_spec_init = true
+
+  require "scarpe/components/minitest_export_reporter"
+  Minitest::Reporters::ShoesExportReporter.activate!
+
+  class_name ||= ENV["SHOES_MINITEST_CLASS_NAME"] || "TestShoesSpecCode"
+  test_name ||= ENV["SHOES_MINITEST_METHOD_NAME"] || "test_shoes_spec"
+
+  Shoes::DisplayService.subscribe_to_event("heartbeat", nil) do
+    unless @hb_init
+      Minitest.run []
+      Shoes::App.instance.destroy
+    end
+    @hb_init = true
+  end
+
+  test_class = Class.new(Niente::ShoesSpecTest)
+  Object.const_set(Scarpe::Components::StringHelpers.camelize(class_name), test_class)
+  test_name = "test_" + test_name unless test_name.start_with?("test_")
+  test_class.define_method(test_name) do
+    eval(code)
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Range.html b/Range.html new file mode 100644 index 000000000..cedd1e218 --- /dev/null +++ b/Range.html @@ -0,0 +1,192 @@ + + + + + + + Class: Range + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Range + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/ruby_extensions.rb
+
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #randObject + + + + + +

+ + + + +
+
+
+
+3
+4
+5
+6
+
+
# File 'lacci/lib/shoes/ruby_extensions.rb', line 3
+
+def rand
+  conv = (Integer === self.end && Integer === self.begin ? :to_i : :to_f)
+  ((Kernel.rand * (self.end - self.begin)) + self.begin).send(conv)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe.html b/Scarpe.html new file mode 100644 index 000000000..dd7bc56e9 --- /dev/null +++ b/Scarpe.html @@ -0,0 +1,145 @@ + + + + + + + Module: Scarpe + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/errors.rb,
+ lib/scarpe/errors.rb,
lib/scarpe/version.rb,
lib/scarpe/cats_cradle.rb,
lib/scarpe/wv/webview_relay_util.rb,
lib/scarpe/wv/webview_local_display.rb,
lib/scarpe/wv/webview_relay_display.rb,
lacci/lib/lacci/scarpe_cli.rb,
lacci/lib/lacci/scarpe_core.rb,
scarpe-components/lib/scarpe/components/base64.rb,
scarpe-components/lib/scarpe/components/base64.rb,
scarpe-components/lib/scarpe/components/version.rb,
scarpe-components/lib/scarpe/components/promises.rb,
scarpe-components/lib/scarpe/components/promises.rb,
scarpe-components/lib/scarpe/components/asset_server.rb,
scarpe-components/lib/scarpe/components/file_helpers.rb,
scarpe-components/lib/scarpe/components/print_logger.rb,
scarpe-components/lib/scarpe/components/modular_logger.rb,
scarpe-components/lib/scarpe/components/modular_logger.rb,
scarpe-components/lib/scarpe/components/string_helpers.rb,
scarpe-components/lib/scarpe/components/minitest_result.rb,
scarpe-components/lib/scarpe/components/minitest_import_runnable.rb
+
+
+ +
+ +

Overview

+
+

require "json/add/exception"

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: CLI, CatsCradle, Components, ShoesSpecTest, Test, WVRelayUtil, Webview + + + + Classes: AppShutdownError, BadDisplayClassType, CCInstance, ConnectionError, DatagramSendError, DuplicateCallbackError, DuplicateFileError, EmptyPageNotSetError, Error, FileContentError, IllegalDispatchEventError, IllegalSubscribeEventError, InternalError, InvalidClassError, InvalidHTMLTag, InvalidOperationError, InvalidPromiseError, JSBindingError, JSEvalError, JSInitError, JSInternalError, JSRedrawError, JSRuntimeError, JSTimeoutError, MissingAppError, MissingAttributeError, MissingBlockError, MissingClassError, MissingDocRootError, MissingWranglerError, MustOverrideMethod, NoOperationError, NoSuchFile, NonexistentEvalResultError, OperationNotAllowedError, PeriodicHandlerSetupError, Promise, ShoesSpecProxy, UnexpectedFiberTransferError, UnknownBuiltinCommandError, UnknownEventTypeError, UnknownShapeCommandError, UnknownShoesEventAPIError, WebWranglerNotRunningError + + +

+ + +

+ Constant Summary + collapse +

+ +
+ +
VERSION = + +
+
"0.4.0"
+ +
+ + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/AppShutdownError.html b/Scarpe/AppShutdownError.html new file mode 100644 index 000000000..41b91f686 --- /dev/null +++ b/Scarpe/AppShutdownError.html @@ -0,0 +1,142 @@ + + + + + + + Exception: Scarpe::AppShutdownError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::AppShutdownError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ +

Overview

+
+

An error occurred which would normally be handled by shutting down the app

+ + +
+
+
+ + +
+ + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/BadDisplayClassType.html b/Scarpe/BadDisplayClassType.html new file mode 100644 index 000000000..72bbe297b --- /dev/null +++ b/Scarpe/BadDisplayClassType.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::BadDisplayClassType + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::BadDisplayClassType + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/CCInstance.html b/Scarpe/CCInstance.html new file mode 100644 index 000000000..f6a863b43 --- /dev/null +++ b/Scarpe/CCInstance.html @@ -0,0 +1,1263 @@ + + + + + + + Class: Scarpe::CCInstance + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::CCInstance + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + +
+
Includes:
+
Test::Helpers, Shoes::Log
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/cats_cradle.rb
+
+ +
+ +

Overview

+
+

This class defines the CatsCradle DSL. It also holds a "bag of fibers" +with promises for when they should next resume.

+ + +
+
+
+ + +
+ +

+ Constant Summary + collapse +

+ +
+ +
EVENT_TYPES = +
+
+

If we add "every" events, that's likely to complicate timing and event_promise handling.

+ + +
+
+
+ + +
+
+
[:init, :next_heartbeat, :next_redraw, :every_heartbeat, :every_redraw]
+ +
+ + + + + + +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + + + +

+ Class Method Summary + collapse +

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Test::Helpers

+

#with_env_vars

+ + + + + + + + + +

Methods included from Scarpe::Components::ProcessHelpers

+

#run_out_err_result

+ + + + + + + + + +

Methods included from Scarpe::Components::FileHelpers

+

#with_tempfile, #with_tempfiles

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+
+

Constructor Details

+ +
+

+ + #initializeCCInstance + + + + + +

+
+

Returns a new instance of CCInstance.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+
+
# File 'lib/scarpe/cats_cradle.rb', line 18
+
+def initialize
+  log_init("CatsCradle")
+
+  @waiting_fibers = []
+  @event_promises = {}
+  @shutdown = false
+
+  @manager_fiber = Fiber.new do
+    Fiber[:catscradle] = true
+
+    loop do
+      # A fiber can run briefly and then exit. It can run and then block on an API call.
+      # These fibers return promises to indicate to CatsCradle when they can run again.
+      # A fiber that is no longer #alive? is assumed to be successfully finished.
+      @waiting_fibers.each do |fiber_data|
+        next if !fiber_data[:promise].fulfilled? || !fiber_data[:fiber].alive? || @shutdown
+
+        @log.debug("Resuming fiber with value #{fiber_data[:promise].returned_value.inspect}")
+        result = fiber_data[:fiber].transfer fiber_data[:promise].returned_value
+
+        # Dead fibers will be removed later, just leave it
+        next unless fiber_data[:fiber].alive?
+
+        case result
+        when ::Scarpe::Promise
+          fiber_data[:promise] = result
+        else
+          raise Scarpe::UnexpectedFiberTransferError, "Unexpected object returned from Fiber#transfer for still-living Fiber! #{result.inspect}"
+        end
+      end
+
+      # Throw out dead fibers or those that will never wake
+      @waiting_fibers.select! do |fiber_data|
+        fiber_data[:fiber].alive? && !fiber_data[:promise].rejected?
+      end
+
+      # Done with this iteration
+      Fiber.yield
+    end
+  end
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + .instanceObject + + + + + +

+ + + + +
+
+
+
+14
+15
+16
+
+
# File 'lib/scarpe/cats_cradle.rb', line 14
+
+def self.instance
+  @instance ||= CCInstance.new
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + #active_fiber(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+140
+141
+142
+143
+144
+145
+146
+
+
# File 'lib/scarpe/cats_cradle.rb', line 140
+
+def active_fiber(&block)
+  return if @shutdown
+
+  p = ::Scarpe::Promise.new
+  p.fulfilled!
+  @waiting_fibers << { promise: p, fiber: cc_fiber(&block), on_event: nil, block: }
+end
+
+
+ +
+

+ + #dom_html(timeout: 1.0) ⇒ Object + + + + + +

+ + + + +
+
+
+
+166
+167
+168
+
+
# File 'lib/scarpe/cats_cradle.rb', line 166
+
+def dom_html(timeout: 1.0)
+  query_js_value("document.getElementById('wrapper-wvroot').innerHTML", timeout:)
+end
+
+
+ +
+

+ + #event_initObject + + + + + +

+
+

This needs to be called after the basic display service objects exist +and we can find the control interface.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+
+
# File 'lib/scarpe/cats_cradle.rb', line 76
+
+def event_init
+  return if @cc_init_done
+
+  @cc_init_done = true
+
+  @control_interface = ::Shoes::DisplayService.display_service.control_interface
+  @wrangler = @control_interface.wrangler
+
+  cc_instance = self # ControlInterface#on_event does an instance eval. We'll reset self with another.
+
+  @control_interface.on_event(:every_heartbeat) do
+    cc_instance.instance_eval do
+      p = @event_promises.delete(:next_heartbeat)
+      p&.fulfilled!
+
+      p = @event_promises.delete(:every_heartbeat)
+      p&.fulfilled!
+
+      # Reschedule on_every_heartbeat fibers for next heartbeat, too.
+      # This fiber won't be called again by a heartbeat, though it may
+      # continue if it waits on another promise.
+      @waiting_fibers.select { |f| f[:on_event] == :every_heartbeat }.each do |f|
+        on_event(:every_heartbeat, &f[:block])
+      end
+
+      # Give every ready fiber a chance to run once.
+      @manager_fiber.resume unless @shutdown
+    end unless @shutdown
+  end
+
+  @control_interface.on_event(:every_redraw) do
+    cc_instance.instance_eval do
+      p = @event_promises.delete(:next_redraw)
+      p&.fulfilled!
+
+      p = @event_promises.delete(:every_redraw)
+      p&.fulfilled!
+
+      # Reschedule on_every_redraw fibers for next redraw, too.
+      @waiting_fibers.select { |f| f[:on_event] == :every_redraw }.each do |f|
+        on_event(:every_redraw, &f[:block])
+      end
+
+      # Give every ready fiber a chance to run once.
+      @manager_fiber.resume unless @shutdown
+    end unless @shutdown
+  end
+end
+
+
+ +
+

+ + #event_promise(event) ⇒ Object + + + + + +

+ + + + +
+
+
+
+129
+130
+131
+
+
# File 'lib/scarpe/cats_cradle.rb', line 129
+
+def event_promise(event)
+  @event_promises[event] ||= ::Scarpe::Promise.new
+end
+
+
+ +
+

+ + #fiber_startObject + + + + + +

+ + + + +
+
+
+
+125
+126
+127
+
+
# File 'lib/scarpe/cats_cradle.rb', line 125
+
+def fiber_start
+  @manager_fiber.resume unless @shutdown
+end
+
+
+ +
+

+ + #fully_updatedObject + + + + + +

+
+

This returns a promise, which can be waited on using wait()

+ + +
+
+
+ + +
+ + + + +
+
+
+
+162
+163
+164
+
+
# File 'lib/scarpe/cats_cradle.rb', line 162
+
+def fully_updated
+  @wrangler.promise_dom_fully_updated
+end
+
+
+ +
+

+ + #on_event(event, &block) ⇒ Object + + + + + +

+
+ + +
+
+
+ +

Raises:

+ + +
+ + + + +
+
+
+
+133
+134
+135
+136
+137
+138
+
+
# File 'lib/scarpe/cats_cradle.rb', line 133
+
+def on_event(event, &block)
+  raise Scarpe::UnknownEventTypeError, "Unknown event type: #{event.inspect}!" unless EVENT_TYPES.include?(event)
+  return if @shutdown
+
+  @waiting_fibers << { promise: event_promise(event), fiber: cc_fiber(&block), on_event: event, block: }
+end
+
+
+ +
+

+ + #query_js_promise(js_code, timeout: 1.0) ⇒ Object + + + + + +

+ + + + +
+
+
+
+177
+178
+179
+
+
# File 'lib/scarpe/cats_cradle.rb', line 177
+
+def query_js_promise(js_code, timeout: 1.0)
+  @wrangler.eval_js_async(js_code, timeout:)
+end
+
+
+ +
+

+ + #query_js_value(js_code, timeout: 1.0) ⇒ Object + + + + + +

+ + + + +
+
+
+
+170
+171
+172
+173
+174
+175
+
+
# File 'lib/scarpe/cats_cradle.rb', line 170
+
+def query_js_value(js_code, timeout: 1.0)
+  js_promise = @wrangler.eval_js_async(js_code, timeout:)
+
+  # This promise will return the string, so we can just pass it to #transfer
+  @manager_fiber.transfer(js_promise)
+end
+
+
+ +
+

+ + #shut_down_shoes_codeObject + + + + + +

+ + + + +
+
+
+
+181
+182
+183
+184
+185
+186
+187
+188
+
+
# File 'lib/scarpe/cats_cradle.rb', line 181
+
+def shut_down_shoes_code
+  if @shutdown
+    exit 0
+  end
+
+  @shutdown = true
+  ::Shoes::DisplayService.dispatch_event("destroy", nil)
+end
+
+
+ +
+

+ + #wait(promise) ⇒ Object + + + + + +

+
+ + +
+
+
+ +

Raises:

+ + +
+ + + + +
+
+
+
+148
+149
+150
+151
+152
+153
+
+
# File 'lib/scarpe/cats_cradle.rb', line 148
+
+def wait(promise)
+  raise(Scarpe::InvalidPromiseError, "Must supply a promise to wait!") unless promise.is_a?(::Scarpe::Promise)
+
+  # Wait until this promise is complete before running again
+  @manager_fiber.transfer(promise)
+end
+
+
+ +
+

+ + #yieldObject + + + + + +

+ + + + +
+
+
+
+155
+156
+157
+158
+159
+
+
# File 'lib/scarpe/cats_cradle.rb', line 155
+
+def yield
+  p = ::Scarpe::Promise.new
+  p.fulfilled!
+  @manager_fiber.transfer(p)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/CLI.html b/Scarpe/CLI.html new file mode 100644 index 000000000..29399012a --- /dev/null +++ b/Scarpe/CLI.html @@ -0,0 +1,520 @@ + + + + + + + Module: Scarpe::CLI + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::CLI + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/lacci/scarpe_cli.rb
+
+ +
+ + + +

+ Constant Summary + collapse +

+ +
+ +
DEFAULT_USAGE = + +
+
<<~'USAGE'
+  Usage: scarpe_core [OPTIONS] <scarpe app file>           # Same as "scarpe run"
+         scarpe_core [OPTIONS] run <scarpe app file>
+         scarpe_core [OPTIONS] env                         # print Scarpe environment settings
+         scarpe_core -v                                    # print the Scarpe gem version and exit
+    Options:
+        --dev                          Use development local scarpe, not an installed gem
+        --debug                        Turn on application debug mode
+USAGE
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #add_env_categories(categories) ⇒ Object + + + + + +

+ + + + +
+
+
+
+52
+53
+54
+55
+56
+57
+58
+59
+
+
# File 'lacci/lib/lacci/scarpe_cli.rb', line 52
+
+def add_env_categories(categories)
+  unless categories.is_a?(Hash)
+    raise("Please supply a hash with categories names as keys and an array of two-elt arrays as values!")
+  end
+
+  # Try to get categories into the *start* of the hash, insertion-order-wise
+  @env_categories = categories.merge(env_categories)
+end
+
+
+ +
+

+ + #default_env_categoriesObject + + + + + +

+ + + + +
+
+
+
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+
+
# File 'lacci/lib/lacci/scarpe_cli.rb', line 25
+
+def default_env_categories
+  require "shoes"
+  {
+    "Lacci" => [
+      env_or_default("SCARPE_DISPLAY_SERVICE", "(none)"),
+      env_or_default("SCARPE_LOG_CONFIG", "(default)#{Shoes::Log::DEFAULT_LOG_CONFIG.inspect}"),
+    ],
+    "Ruby and Shell" => [
+      ["RUBY_DESCRIPTION", RUBY_DESCRIPTION],
+      ["RUBY_PLATFORM", RUBY_PLATFORM],
+      ["RUBY_ENGINE", RUBY_ENGINE],
+      env_or_default("SHELL", "(none)"),
+      env_or_default("PATH", "(none)"),
+      env_or_default("LD_LIBRARY_PATH", "(none)"),
+      env_or_default("DYLD_LIBRARY_PATH", "(none)"),
+      env_or_default("GEM_ROOT", "(none)"),
+      env_or_default("GEM_HOME", "(none)"),
+      env_or_default("GEM_PATH", "(none)"),
+    ],
+  }
+end
+
+
+ +
+

+ + #env_categoriesObject + + + + + +

+ + + + +
+
+
+
+47
+48
+49
+50
+
+
# File 'lacci/lib/lacci/scarpe_cli.rb', line 47
+
+def env_categories
+  @env_categories ||= default_env_categories
+  @env_categories
+end
+
+
+ +
+

+ + #env_or_default(env_var, default_val) ⇒ Object + + + + + +

+ + + + +
+
+
+
+21
+22
+23
+
+
# File 'lacci/lib/lacci/scarpe_cli.rb', line 21
+
+def env_or_default(env_var, default_val)
+  [env_var, ENV[env_var] ? ENV[env_var].inspect : default_val]
+end
+
+
+ +
+ + + + + +
+
+
+
+61
+62
+63
+64
+65
+66
+67
+68
+
+
# File 'lacci/lib/lacci/scarpe_cli.rb', line 61
+
+def print_env
+  env_categories.each do |category, entries|
+    puts "#{category} environment:"
+    entries.each do |name, val|
+      puts "  #{name}: #{val}"
+    end
+  end
+end
+
+
+ +
+

+ + #version_checkObject + + + + + +

+ + + + +
+
+
+
+15
+16
+17
+18
+19
+
+
# File 'lacci/lib/lacci/scarpe_cli.rb', line 15
+
+def version_check
+  if RUBY_VERSION[0..2] < "3.2"
+    raise "Scarpe and Lacci require Ruby 3.2 or higher!"
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/CatsCradle.html b/Scarpe/CatsCradle.html new file mode 100644 index 000000000..3d8c5409e --- /dev/null +++ b/Scarpe/CatsCradle.html @@ -0,0 +1,488 @@ + + + + + + + Module: Scarpe::CatsCradle + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::CatsCradle + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/cats_cradle.rb
+
+ +
+ +

Overview

+
+

"Cat's Cradle" is a children's game where they interlace string between +their fingers to make beautiful complicated shapes. The interlacing +of fibers made it a good name for a prototype.

+ +

An attempt at an experimental Fiber-based control-flow system to deal with +Shoes, Display and JS all at the same time.

+ +

In general, we'll use Fiber.transfer to bounce control back and forth +between the evented implementations (e.g. waiting for redraw) that +need to return control to Webview, and the procedural test flows +that look far better if we don't do that explicitly.

+ +

Ruby Fiber basic docs: https://ruby-doc.org/core-3.0.0/Fiber.html

+ +

This module is mixed into an object to coordinate fibers app-wide.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary collapse

+
    + +
  • + + + #cc_instance ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute cc_instance.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + collapse +

+ + + + + +
+

Instance Attribute Details

+ + + +
+

+ + #cc_instanceObject (readonly) + + + + + +

+
+

Returns the value of attribute cc_instance.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+207
+208
+209
+
+
# File 'lib/scarpe/cats_cradle.rb', line 207
+
+def cc_instance
+  @cc_instance
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #event_initObject + + + + + +

+ + + + +
+
+
+
+209
+210
+211
+212
+
+
# File 'lib/scarpe/cats_cradle.rb', line 209
+
+def event_init
+  @cc_instance ||= CCInstance.instance
+  @cc_instance.event_init
+end
+
+
+ +
+

+ + #on_every_heartbeat(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+218
+219
+220
+
+
# File 'lib/scarpe/cats_cradle.rb', line 218
+
+def on_every_heartbeat(&block)
+  @cc_instance.on_event(:every_heartbeat, &block)
+end
+
+
+ +
+

+ + #on_heartbeat(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+214
+215
+216
+
+
# File 'lib/scarpe/cats_cradle.rb', line 214
+
+def on_heartbeat(&block)
+  @cc_instance.on_event(:next_heartbeat, &block)
+end
+
+
+ +
+

+ + #on_init(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+222
+223
+224
+
+
# File 'lib/scarpe/cats_cradle.rb', line 222
+
+def on_init(&block)
+  @cc_instance.on_event(:init, &block)
+end
+
+
+ +
+

+ + #on_next_redraw(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+226
+227
+228
+
+
# File 'lib/scarpe/cats_cradle.rb', line 226
+
+def on_next_redraw(&block)
+  @cc_instance.on_event(:next_redraw, &block)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Components.html b/Scarpe/Components.html new file mode 100644 index 000000000..6b39eb7ef --- /dev/null +++ b/Scarpe/Components.html @@ -0,0 +1,140 @@ + + + + + + + Module: Scarpe::Components + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::Components + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/base64.rb,
+ scarpe-components/lib/scarpe/components/version.rb,
scarpe-components/lib/scarpe/components/promises.rb,
scarpe-components/lib/scarpe/components/asset_server.rb,
scarpe-components/lib/scarpe/components/file_helpers.rb,
scarpe-components/lib/scarpe/components/print_logger.rb,
scarpe-components/lib/scarpe/components/modular_logger.rb,
scarpe-components/lib/scarpe/components/string_helpers.rb,
scarpe-components/lib/scarpe/components/minitest_result.rb,
scarpe-components/lib/scarpe/components/segmented_file_loader.rb,
scarpe-components/lib/scarpe/components/minitest_import_runnable.rb
+
+
+ +
+ +

Defined Under Namespace

+

+ + + Modules: Base64, Calzini, FileHelpers, ImportRunnables, ProcessHelpers, StringHelpers, Tiranti + + + + Classes: AssetServer, HTML, MinitestResult, ModularLogImpl, PrintLogImpl, SegmentedFileLoader + + +

+ + +

+ Constant Summary + collapse +

+ +
+ +
VERSION = + +
+
"0.4.0"
+ +
Promise = + +
+
Promise
+ +
+ + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Components/AssetServer.html b/Scarpe/Components/AssetServer.html new file mode 100644 index 000000000..09823f452 --- /dev/null +++ b/Scarpe/Components/AssetServer.html @@ -0,0 +1,1200 @@ + + + + + + + Class: Scarpe::Components::AssetServer + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Components::AssetServer + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + +
+
Includes:
+
Base64, Shoes::Log
+
+ + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/asset_server.rb
+
+ +
+ +

Defined Under Namespace

+

+ + + + + Classes: FileServlet + + +

+ + +

+ Constant Summary + collapse +

+ +
+ +
URL_TYPES = + +
+
[:auto, :asset, :data]
+ +
+ + + + + + +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #dir ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute dir.

    +
    + +
  • + + +
  • + + + #port ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute port.

    +
    + +
  • + + +
  • + + + #server_started ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute server_started.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods included from Base64

+

#encode_file_to_base64, #mime_type_for_filename, #valid_url?

+
+

Constructor Details

+ +
+

+ + #initialize(port: 0, app_dir:, never_start_server: false, connect_timeout: 5) ⇒ AssetServer + + + + + +

+
+

Port 0 will auto-assign a free port

+ + +
+
+
+ + +
+ + + + +
+
+
+
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+
+
# File 'scarpe-components/lib/scarpe/components/asset_server.rb', line 17
+
+def initialize(port: 0, app_dir:, never_start_server: false, connect_timeout: 5)
+  log_init("AssetServer")
+
+  require "scarpe/components/base64"
+
+  @server_started = false
+  @server_thread = nil
+  @port = port != 0 ? port : find_open_port
+  @app_dir = File.expand_path app_dir
+  @components_dir = File.expand_path "#{__dir__}/../../.."
+  @connect_timeout = connect_timeout
+  @never_start_server = never_start_server
+
+  # For now, always use 16kb as the cutoff for preferring to serve a file with the asset server
+  @auto_asset_url_size = 16 * 1024
+
+  # Make sure the child process is dead
+  at_exit do
+    kill_server
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #dirObject (readonly) + + + + + +

+
+

Returns the value of attribute dir.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+12
+13
+14
+
+
# File 'scarpe-components/lib/scarpe/components/asset_server.rb', line 12
+
+def dir
+  @dir
+end
+
+
+ + + +
+

+ + #portObject (readonly) + + + + + +

+
+

Returns the value of attribute port.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'scarpe-components/lib/scarpe/components/asset_server.rb', line 10
+
+def port
+  @port
+end
+
+
+ + + +
+

+ + #server_startedObject (readonly) + + + + + +

+
+

Returns the value of attribute server_started.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+
+
# File 'scarpe-components/lib/scarpe/components/asset_server.rb', line 11
+
+def server_started
+  @server_started
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #asset_url(url, url_type: :auto) ⇒ Object + + + + + +

+
+

Get an asset URL for the given url or filename. +The asset server can return a data URL, which encodes +the entire file into the URL. It can return an asset +server URL, which will serve the file via a local +webrick server (@see AssetServer).

+ +

If url_type is auto, asset_url will return a data URL +or asset server URL depending on file size and whether +it's local to the asset server. Remote URLs will always +be returned verbatim.

+ + +
+
+
+

Parameters:

+
    + +
  • + + url + + + (String) + + + + — +

    the filename or URL

    +
    + +
  • + +
  • + + url_type + + + (Symbol) + + + (defaults to: :auto) + + + — +

    the type of URL to return - one of :auto, :asset, :data

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+
+
# File 'scarpe-components/lib/scarpe/components/asset_server.rb', line 52
+
+def asset_url(url, url_type: :auto)
+  unless URL_TYPES.include?(url_type)
+    raise ArgumentError, "The url_type arg must be one of #{URL_TYPES.inspect}!"
+  end
+
+  if valid_url?(url)
+    # This is already not local, use it directly
+    return url
+  end
+
+  # Invalid URLs are assumed to be file paths.
+  url = File.expand_path url
+  file_size = File.size(url)
+
+  # Calculate the app-relative path to the file. If it's not outside the app
+  # dir, great, use that. If it *is* outside the app dir, see if the
+  # scarpe-components dir is better (e.g. for Tiranti Bootstrap CSS assets.)
+  relative_app_path = relative_path_from_to(@app_dir, url)
+  relative_path = relative_app_path
+  if relative_app_path.start_with?("../")
+    relative_comp_path = relative_path_from_to(@components_dir, url)
+    relative_path = relative_comp_path unless relative_comp_path.start_with?("../")
+  end
+
+  # If url_type is :auto, we will use a data URL for small files and files that
+  # would be outside the asset server's directory. Data URLs are less efficient
+  # for large files, but we'll try to always serve *something* if we can.
+  if url_type == :data ||
+    (url_type == :auto && file_size < @auto_asset_url_size) ||
+    (url_type == :auto && relative_path.start_with?("../"))
+
+    # The MIME media type for this file
+    file_type = mime_type_for_filename(url)
+
+    # Up to 16kb per file, inline it directly to avoid an extra HTTP request
+    return "data:#{file_type};base64,#{encode_file_to_base64(url)}"
+  end
+
+  # Start the server if we're returning an asset-server URL
+  unless @server_started || @never_start_server
+    start_server_thread
+  end
+
+  if relative_path.start_with?("../")
+    raise Scarpe::OperationNotAllowedError, "Large asset is outside of application directory and asset URL was requested: #{url.inspect}"
+  end
+  if relative_path == relative_app_path
+    "http://127.0.0.1:#{@port}/app/#{relative_path}"
+  else
+    "http://127.0.0.1:#{@port}/comp/#{relative_path}"
+  end
+end
+
+
+ +
+

+ + #find_open_portObject + + + + + +

+ + + + +
+
+
+
+105
+106
+107
+108
+109
+110
+111
+
+
# File 'scarpe-components/lib/scarpe/components/asset_server.rb', line 105
+
+def find_open_port
+  require "socket"
+  s = TCPServer.new('127.0.0.1', port)
+  port = s.addr[1]
+  s.close
+  port
+end
+
+
+ +
+

+ + #kill_serverObject + + + + + +

+ + + + +
+
+
+
+167
+168
+169
+170
+171
+172
+173
+174
+
+
# File 'scarpe-components/lib/scarpe/components/asset_server.rb', line 167
+
+def kill_server
+  return unless @server_started && @server_thread
+
+  @server.shutdown
+  @server_thread.join if @server_thread.alive?
+  @server_started = false
+  @server_thread = nil
+end
+
+
+ +
+

+ + #port_is_responding?(port, timeout: 0.1) ⇒ Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+113
+114
+115
+
+
# File 'scarpe-components/lib/scarpe/components/asset_server.rb', line 113
+
+def port_is_responding?(port, timeout: 0.1)
+  Socket.tcp("127.0.0.1", port, connect_timeout: timeout) { true } rescue false
+end
+
+
+ +
+

+ + #relative_path_from_to(from, to) ⇒ Object + + + + + +

+ + + + +
+
+
+
+128
+129
+130
+131
+
+
# File 'scarpe-components/lib/scarpe/components/asset_server.rb', line 128
+
+def relative_path_from_to(from, to)
+  require 'pathname'
+  Pathname.new(to).relative_path_from(Pathname.new from).to_s
+end
+
+
+ +
+

+ + #retry_port(port, timeout: 2.0) ⇒ Object + + + + + +

+ + + + +
+
+
+
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+
+
# File 'scarpe-components/lib/scarpe/components/asset_server.rb', line 117
+
+def retry_port(port, timeout: 2.0)
+  t = Time.now
+  loop do
+    resp = port_is_responding?(port)
+
+    return true if resp
+    return false if Time.now - t > timeout
+    sleep 0.1
+  end
+end
+
+
+ +
+

+ + #start_server_threadObject + + + + + +

+ + + + +
+
+
+
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+
+
# File 'scarpe-components/lib/scarpe/components/asset_server.rb', line 133
+
+def start_server_thread
+  return if @server_started
+
+  @server_thread = Thread.new do
+    start_webrick
+  end
+  @server_started = true
+
+  # Give the asset server a couple of seconds to respond
+  retry_port(@port, timeout: @connect_timeout)
+  unless port_is_responding?(@port, timeout: 0.1)
+    @log.warn "Asset server port doesn't seem to be responding after #{@connect_timeout} seconds!"
+  end
+end
+
+
+ +
+

+ + #start_webrickObject + + + + + +

+ + + + +
+
+
+
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+
+
# File 'scarpe-components/lib/scarpe/components/asset_server.rb', line 148
+
+def start_webrick
+  require "tempfile"
+  log = WEBrick::Log.new Tempfile.new("scarpe_asset_server_log")
+  access_log = [
+    [Tempfile.new("scarpe_asset_server_access_log"), WEBrick::AccessLog::COMBINED_LOG_FORMAT]
+  ]
+
+  @server = WEBrick::HTTPServer.new(Port: @port, DocumentRoot: @app_dir, Logger: log, AccessLog: access_log)
+  @server.mount('/app', FileServlet, { Type: :app, Prefix: "/app", DocumentRoot: @app_dir })
+  @server.mount('/comp', FileServlet, { Type: :scarpe_components, Prefix: "/comp", DocumentRoot: @components_dir })
+
+  @server.start
+
+  # Set up a signal trap to gracefully shut down the server on interrupt (e.g., Ctrl+C)
+  trap('INT') do
+    @server.shutdown
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Components/AssetServer/FileServlet.html b/Scarpe/Components/AssetServer/FileServlet.html new file mode 100644 index 000000000..927885350 --- /dev/null +++ b/Scarpe/Components/AssetServer/FileServlet.html @@ -0,0 +1,393 @@ + + + + + + + Class: Scarpe::Components::AssetServer::FileServlet + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Components::AssetServer::FileServlet + + + +

+
+ +
+
Inherits:
+
+ WEBrick::HTTPServlet::AbstractServlet + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/asset_server.rb
+
+ +
+ +

Overview

+
+

Define a custom servlet to handle file requests +Webrick config adapted from ChetankumarSB's local_file_server example

+ + +
+
+
+ + +
+ +

+ Constant Summary + collapse +

+ +
+ +
FS_TYPES = + +
+
[:app, :scarpe_components]
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + +
+

Constructor Details

+ +
+

+ + #initialize(server, options) ⇒ FileServlet + + + + + +

+
+

Returns a new instance of FileServlet.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+
+
# File 'scarpe-components/lib/scarpe/components/asset_server.rb', line 185
+
+def initialize(server, options)
+  @fs_opts = options
+  unless options[:Type]
+    raise "Internal error! FileServlet expects to know what root it's serving!"
+  end
+  unless FS_TYPES.include?(options[:Type])
+    raise "Internal error! Unknown FileServlet root type #{options[:Type].inspect}!"
+  end
+
+  super
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #do_GET(request, response) ⇒ Object + + + + + +

+ + + + +
+
+
+
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+
+
# File 'scarpe-components/lib/scarpe/components/asset_server.rb', line 197
+
+def do_GET(request, response)
+  relative_path = request.path.delete_prefix(@fs_opts[:Prefix])
+  path = File.join(@fs_opts[:DocumentRoot], relative_path)
+
+  if File.exist?(path) && !File.directory?(path)
+    begin
+      file_content = File.read(path)
+
+      response.status = 200
+      response['Content-Type'] = WEBrick::HTTPUtils.mime_type(path, WEBrick::HTTPUtils::DefaultMimeTypes)
+      response.body = file_content
+    rescue StandardError => e
+      STDERR.puts "Error serving asset: #{e.inspect}"
+      response.status = 500
+      response.body = 'Internal Server Error'
+    end
+  else
+    response.status = 404
+    response.body = 'File not found'
+  end
+end
+
+
+ +
+

+ + #inspectObject + + + + + +

+ + + + +
+
+
+
+181
+182
+183
+
+
# File 'scarpe-components/lib/scarpe/components/asset_server.rb', line 181
+
+def inspect
+  "<FileServlet #{@fs_opts[:Type].inspect}>"
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Components/Base64.html b/Scarpe/Components/Base64.html new file mode 100644 index 000000000..f00966516 --- /dev/null +++ b/Scarpe/Components/Base64.html @@ -0,0 +1,355 @@ + + + + + + + Module: Scarpe::Components::Base64 + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::Components::Base64 + + + +

+
+ + + + + + + + + +
+
Included in:
+
AssetServer, Calzini
+
+ + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/base64.rb
+
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #encode_file_to_base64(image_path) ⇒ Object + + + + + +

+ + + + +
+
+
+
+39
+40
+41
+42
+43
+44
+45
+
+
# File 'scarpe-components/lib/scarpe/components/base64.rb', line 39
+
+def encode_file_to_base64(image_path)
+  image_data = File.binread(image_path)
+
+  encoded_data = ::Base64.strict_encode64(image_data)
+
+  encoded_data
+end
+
+
+ +
+

+ + #mime_type_for_filename(filename) ⇒ Object + + + + + +

+ + + + +
+
+
+
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+
+
# File 'scarpe-components/lib/scarpe/components/base64.rb', line 17
+
+def mime_type_for_filename(filename)
+  ext = File.extname(filename)[1..-1] # Cut off leading dot
+
+  case ext
+  when "jpg", "jpeg"
+    "image/jpeg"
+  when "gif"
+    "image/gif"
+  when "png"
+    "image/png"
+  when "js"
+    "text/javascript"
+  when "css"
+    "text/css"
+  when "rb"
+    "text/ruby" # Don't think this is standard
+  else
+    # Don't recognise it, call it random binary
+    "application/octet-stream"
+  end
+end
+
+
+ +
+

+ + #valid_url?(string) ⇒ Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+10
+11
+12
+13
+14
+15
+
+
# File 'scarpe-components/lib/scarpe/components/base64.rb', line 10
+
+def valid_url?(string)
+  uri = URI.parse(string)
+  uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
+rescue URI::InvalidURIError, URI::BadURIError
+  false
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Components/Calzini.html b/Scarpe/Components/Calzini.html new file mode 100644 index 000000000..e982ce934 --- /dev/null +++ b/Scarpe/Components/Calzini.html @@ -0,0 +1,2852 @@ + + + + + + + Module: Scarpe::Components::Calzini + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::Components::Calzini + + + +

+
+ + + + +
+
Extended by:
+
Calzini
+
+ + + +
+
Includes:
+
Base64
+
+ + + + +
+
Included in:
+
Calzini, Tiranti
+
+ + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/calzini.rb,
+ scarpe-components/lib/scarpe/components/calzini/misc.rb,
scarpe-components/lib/scarpe/components/calzini/para.rb,
scarpe-components/lib/scarpe/components/calzini/alert.rb,
scarpe-components/lib/scarpe/components/calzini/slots.rb,
scarpe-components/lib/scarpe/components/calzini/border.rb,
scarpe-components/lib/scarpe/components/calzini/button.rb,
scarpe-components/lib/scarpe/components/calzini/art_drawables.rb
+
+
+ +
+ +

Overview

+
+

The Calzini module expects to be included by a class defining +the following methods:

+ +
* html_id - the HTML ID for the specific rendered DOM object
+* handler_js_code(event_name) - the JS handler code for this DOM object and event name
+* (optional) shoes_styles - the Shoes styles for this object, unless overridden in render()
+
+ + +
+
+
+ + +
+ +

+ Constant Summary + collapse +

+ +
+ +
HTML = + +
+
Scarpe::Components::HTML
+ +
SPACING_DIRECTIONS = + +
+
[:left, :right, :top, :bottom]
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Base64

+

#encode_file_to_base64, #mime_type_for_filename, #valid_url?

+ + +
+

Instance Method Details

+ + +
+

+ + #alert_element(props) ⇒ Object + + + + + +

+ + + + +
+
+
+
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/alert.rb', line 4
+
+def alert_element(props)
+  event = props["event_name"] || "click"
+  onclick = handler_js_code(event)
+
+  HTML.render do |h|
+    h.div(id: html_id, style: alert_overlay_style(props)) do
+      h.div(style: alert_modal_style) do
+        h.div(style: {}) { props["text"] }
+        h.button(style: {}, onclick: onclick) { "OK" }
+      end
+    end
+  end
+end
+
+
+ +
+

+ + #arc_element(props, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/art_drawables.rb', line 4
+
+def arc_element(props, &block)
+  dc = props["draw_context"] || {}
+  rotate = dc["rotate"]
+  HTML.render do |h|
+    h.div(id: html_id, style: arc_style(props)) do
+      h.svg(width: props["width"], height: props["height"]) do
+        h.path(d: arc_path(props), transform: "rotate(#{rotate}, #{props["width"] / 2}, #{props["height"] / 2})")
+      end
+      block.call(h) if block_given?
+    end
+  end
+end
+
+
+ +
+

+ + #border_element(props) ⇒ Object + + + + + +

+ + + + +
+
+
+
+2
+3
+4
+5
+6
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/border.rb', line 2
+
+def border_element(props)
+  HTML.render do |h|
+    h.div(id: html_id, style: style(props))
+  end
+end
+
+
+ +
+

+ + #button_element(props) ⇒ Object + + + + + +

+ + + + +
+
+
+
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/button.rb', line 4
+
+def button_element(props)
+  HTML.render do |h|
+    button_props = {
+      id: html_id,
+      onclick: handler_js_code("click"),
+      onmouseover: handler_js_code("hover"),
+      style: button_style(props),
+      class: props["html_class"],
+      title: props["tooltip"],
+    }.compact
+    h.button(**button_props) do
+      props["text"]
+    end
+  end
+end
+
+
+ +
+

+ + #check_element(props) ⇒ Object + + + + + +

+ + + + +
+
+
+
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/misc.rb', line 4
+
+def check_element(props)
+  HTML.render do |h|
+    h.input type: :checkbox,
+      id: html_id,
+      onclick: handler_js_code("click"),
+      value: props["text"],
+      checked: props["checked"],
+      style: drawable_style(props)
+  end
+end
+
+
+ +
+

+ + #contains_number?(str) ⇒ Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+100
+101
+102
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/para.rb', line 100
+
+def contains_number?(str)
+  !!(str =~ /\d/)
+end
+
+
+ +
+

+ + #contains_only_numbers?(string) ⇒ Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+103
+104
+105
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/para.rb', line 103
+
+def contains_only_numbers?(string)
+  /^\d+\z/ =~ string
+end
+
+
+ +
+

+ + #degrees_to_radians(degrees) ⇒ Object + + + + + +

+ + + + +
+
+
+
+229
+230
+231
+
+
# File 'scarpe-components/lib/scarpe/components/calzini.rb', line 229
+
+def degrees_to_radians(degrees)
+  degrees * Math::PI / 180
+end
+
+
+ +
+

+ + #dimensions_length(value) ⇒ Object + + + + + +

+ + + + +
+
+
+
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+
+
# File 'scarpe-components/lib/scarpe/components/calzini.rb', line 97
+
+def dimensions_length(value)
+  case value
+  when Integer
+    if value < 0
+      "calc(100% - #{value.abs}px)"
+    else
+      "#{value}px"
+    end
+  when Float
+    "#{value * 100}%"
+  else
+    value
+  end
+end
+
+
+ +
+

+ + #documentroot_element(props, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+28
+29
+30
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/slots.rb', line 28
+
+def documentroot_element(props, &block)
+  flow_element(props, &block)
+end
+
+
+ +
+

+ + #drawable_style(props) ⇒ Object + + + + + +

+ + + + +
+
+
+
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+
+
# File 'scarpe-components/lib/scarpe/components/calzini.rb', line 112
+
+def drawable_style(props)
+  styles = {}
+  if props["hidden"]
+    styles[:display] = "none"
+  end
+
+  # Do we need to set CSS positioning here, especially if displace is set? Position: relative maybe?
+  # We need some Shoes3 screenshots and HTML-based tests here...
+
+  if props["top"] || props["left"]
+    styles[:position] = "absolute"
+  end
+
+  styles[:top] = dimensions_length(props["top"]) if props["top"]
+  styles[:left] = dimensions_length(props["left"]) if props["left"]
+  styles[:width] = dimensions_length(props["width"]) if props["width"]
+  styles[:height] = dimensions_length(props["height"]) if props["height"]
+  styles[:"margin-left"] = dimensions_length(props["margin_left"]) if props["margin_left"]
+  styles[:"margin-right"] = dimensions_length(props["margin_right"]) if props["margin_right"]
+  styles[:"margin-top"] = dimensions_length(props["margin_top"]) if props["margin_top"]
+  styles[:"margin-bottom"] = dimensions_length(props["margin_bottom"]) if props["margin_bottom"]
+
+
+  
+  styles = spacing_styles_for_attr("padding", props, styles)
+
+  styles
+end
+
+
+ +
+

+ + #edit_box_element(props) ⇒ Object + + + + + +

+ + + + +
+
+
+
+15
+16
+17
+18
+19
+20
+21
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/misc.rb', line 15
+
+def edit_box_element(props)
+  oninput = handler_js_code("change", "this.value")
+
+  HTML.render do |h|
+    h.textarea(id: html_id, oninput: oninput,onmouseover: handler_js_code("hover"), style: edit_box_style(props),title: props["tooltip"]) { props["text"] }
+  end
+end
+
+
+ +
+

+ + #edit_line_element(props) ⇒ Object + + + + + +

+ + + + +
+
+
+
+23
+24
+25
+26
+27
+28
+29
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/misc.rb', line 23
+
+def edit_line_element(props)
+  oninput = handler_js_code("change", "this.value")
+  
+  HTML.render do |h|
+    h.input(id: html_id, oninput: oninput, onmouseover: handler_js_code("hover"), value: props["text"], style: edit_line_style(props),title: props["tooltip"])
+  end
+end
+
+
+ +
+

+ + #empty_page_elementString + + + + + +

+
+

Return HTML for an empty page element, to be filled with HTML +renderings of the DOM tree.

+ +

The wrapper-wvroot element is where Scarpe will fill in the +DOM element.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +

    the rendered HTML for the empty page object.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+
+
# File 'scarpe-components/lib/scarpe/components/calzini.rb', line 56
+
+def empty_page_element
+  <<~HTML
+    <html>
+      <head id='head-wvroot'>
+        <style id='style-wvroot'>
+          /** Style resets **/
+          body {
+            font-family: arial, Helvetica, sans-serif;
+            margin: 0;
+            height: 100%;
+            overflow: hidden;
+          }
+          p {
+            margin: 0;
+          }
+          #wrapper-wvroot {
+            height: 100%;
+            width: 100%;
+          }
+        </style>
+      </head>
+      <body id='body-wvroot'>
+        <div id='wrapper-wvroot'></div>
+      </body>
+    </html>
+  HTML
+end
+
+
+ +
+

+ + #first_color_of(*colors) ⇒ Object + + + + + +

+ + + + +
+
+
+
+192
+193
+194
+195
+196
+
+
# File 'scarpe-components/lib/scarpe/components/calzini.rb', line 192
+
+def first_color_of(*colors)
+  colors.compact!
+  colors.select! { |c| c != "" }
+  rgb_to_hex(colors[0])
+end
+
+
+ +
+

+ + #flow_element(props, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+12
+13
+14
+15
+16
+17
+18
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/slots.rb', line 12
+
+def flow_element(props, &block)
+  HTML.render do |h|
+    h.div((props["html_attributes"] || {}).merge(id: html_id, style: flow_style(props))) do
+      h.div(style: { height: "100%", width: "100%", position: "relative" }, &block)
+    end
+  end
+end
+
+
+ +
+

+ + #image_element(props) ⇒ Object + + + + + +

+ + + + +
+
+
+
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/misc.rb', line 31
+
+def image_element(props)
+  style = drawable_style(props)
+
+  if props["click"]
+    HTML.render do |h|
+      h.a(id: html_id, href: props["click"]) { h.img(id: html_id, src: props["url"], style:) }
+    end
+  else
+    HTML.render do |h|
+      h.img(id: html_id, src: props["url"], style:)
+    end
+  end
+end
+
+
+ +
+

+ + #line_element(props) ⇒ Object + + + + + +

+ + + + +
+
+
+
+38
+39
+40
+41
+42
+43
+44
+45
+46
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/art_drawables.rb', line 38
+
+def line_element(props)
+  HTML.render do |h|
+    h.div(id: html_id, style: line_div_style(props)) do
+      h.svg(width: props["x2"], height: props["y2"]) do
+        h.line(x1: props["left"], y1: props["top"], x2: props["x2"], y2: props["y2"], style: line_svg_style(props))
+      end
+    end
+  end
+end
+
+
+ +
+

+ + #list_box_element(props) ⇒ Object + + + + + +

+ + + + +
+
+
+
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/misc.rb', line 45
+
+def list_box_element(props)
+  onchange = handler_js_code("change", "this.options[this.selectedIndex].value")
+
+  # Is this useful at all? Is it overridden below completely?
+  option_attrs = { value: nil, selected: false }
+
+  HTML.render do |h|
+    h.select(id: html_id, onchange:, style: list_box_style(props)) do
+      (props["items"] || []).each do |item|
+        option_attrs = {
+          value: item,
+        }
+        if item == props["choose"]
+          option_attrs[:selected] = "true"
+        end
+        h.option(**option_attrs) do
+          item
+        end
+      end
+    end
+  end
+end
+
+
+ +
+

+ + #oval_element(props, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/art_drawables.rb', line 62
+
+def oval_element(props, &block)
+  dc = props["draw_context"] || {}
+  fill = first_color_of(props["fill"], dc["fill"], "black")
+  stroke = first_color_of(props["stroke"], dc["stroke"], "black")
+  strokewidth = props["strokewidth"] || dc["strokewidth"] || "2"
+  radius = props["radius"]
+  width = radius * 2
+  height = props["height"] || radius * 2 # If there's a height, it's an oval, if not, circle
+  center = props["center"] || false
+  HTML.render do |h|
+    h.div(id: html_id, style: oval_style(props)) do
+      h.svg(width: width, height: height, style: "fill:#{fill};") do
+        h.ellipse(
+          cx: center ? radius : 0,
+          cy: center ? height / 2 : 0,
+          rx: width ? width / 2 : radius,
+          ry: height ? height / 2 : radius,
+          style: "stroke:#{stroke};stroke-width:#{strokewidth};",
+        )
+      end
+      block.call(h) if block_given?
+    end
+  end
+end
+
+
+ +
+

+ + #para_element(props, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/para.rb', line 4
+
+def para_element(props, &block)
+  # Align requires an extra wrapping div.
+
+  # Stacking strikethrough with underline requires multiple elements.
+  # We handle this by making strikethrough part of the main element,
+  # but using an extra wrapping element for underline.
+
+  tag = props["tag"] || "p"
+
+  para_styles, extra_styles = para_style(props)
+
+  HTML.render do |h|
+    if extra_styles.empty?
+      h.send(tag, id: html_id, style: para_styles, &block)
+    else
+      h.div(id: html_id, style: extra_styles.merge(width: "100%")) do
+        h.send(tag, style: para_styles, &block)
+      end
+    end
+  end
+end
+
+
+ +
+

+ + #progress_element(props) ⇒ Object + + + + + +

+ + + + +
+
+
+
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/misc.rb', line 93
+
+def progress_element(props)
+  HTML.render do |h|
+    h.progress(
+      id: html_id,
+      style: drawable_style(props),
+      role: "progressbar",
+      "aria-valuenow": props["fraction"],
+      "aria-valuemin": 0.0,
+      "aria-valuemax": 1.0,
+      max: 1,
+      value: props["fraction"],
+    )
+  end
+end
+
+
+ +
+

+ + #radians_to_degrees(radians) ⇒ Object + + + + + +

+ + + + +
+
+
+
+233
+234
+235
+
+
# File 'scarpe-components/lib/scarpe/components/calzini.rb', line 233
+
+def radians_to_degrees(radians)
+  radians * (180.0 / Math::PI)
+end
+
+
+ +
+

+ + #radio_element(props) ⇒ Object + + + + + +

+ + + + +
+
+
+
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/misc.rb', line 68
+
+def radio_element(props)
+  # This is wrong - need to default to the parent slot -- maybe its linkable ID?
+  group_name = props["group"] || "no_group"
+
+  HTML.render do |h|
+    h.input(
+      type: :radio,
+      id: html_id,
+      onclick: handler_js_code("click"),
+      name: group_name,
+      value: props["text"],
+      checked: props["checked"],
+      style: drawable_style(props),
+    )
+  end
+end
+
+
+ +
+

+ + #rect_element(props) ⇒ Object + + + + + +

+ + + + +
+
+
+
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/art_drawables.rb', line 17
+
+def rect_element(props)
+  dc = props["draw_context"] || {}
+  rotate = dc["rotate"]
+  HTML.render do |h|
+    h.div(id: html_id, style: drawable_style(props)) do
+      width = props["width"].to_i
+      height = props["height"].to_i
+      if props["curve"]
+        width += 2 * props["curve"].to_i
+        height += 2 * props["curve"].to_i
+      end
+      h.svg(width:, height:) do
+        attrs = { x: props["left"], y: props["top"], width: props["width"], height: props["height"], style: rect_svg_style(props) }
+        attrs[:rx] = props["curve"] if props["curve"]
+
+        h.rect(**attrs, transform: "rotate(#{rotate} #{width / 2} #{height / 2})")
+      end
+    end
+  end
+end
+
+
+ +
+

+ + #render(drawable_name, properties = shoes_styles, &block) ⇒ String + + + + + +

+
+

Render the Shoes drawable of type drawable_name with +the given properties to HTML and return it. If the +drawable type takes a block (e.g. Stack or Flow) then +the block will be properly rendered.

+ + +
+
+
+

Parameters:

+
    + +
  • + + drawable_name + + + (String) + + + + — +

    the drawable name like "alert", "button" or "rect"

    +
    + +
  • + +
  • + + properties + + + (Hash) + + + (defaults to: shoes_styles) + + + — +

    a drawable-specific hash of property names to values

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +

    the rendered HTML

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+45
+46
+47
+
+
# File 'scarpe-components/lib/scarpe/components/calzini.rb', line 45
+
+def render(drawable_name, properties = shoes_styles, &block)
+  send("#{drawable_name}_element", properties, &block)
+end
+
+
+ +
+

+ + #rgb_to_hex(color) ⇒ Object + + + + + +

+
+

Convert an [r, g, b, a] array to an HTML hex color code +Arrays support alpha. HTML hex does not. So premultiply.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+
+
# File 'scarpe-components/lib/scarpe/components/calzini.rb', line 200
+
+def rgb_to_hex(color)
+  return nil if color.nil?
+  return "#000000" if color == ""
+
+  # TODO: need to figure out if it's a color name like "aquamarine"
+  # or a hex code or an image file to use as a pattern or what.
+  return color if color.is_a?(String)
+
+  r, g, b, a = *color
+  if r.is_a?(Float)
+    a ||= 1.0
+    r_float = r * a
+    g_float = g * a
+    b_float = b * a
+  else
+    a ||= 255
+    a_float = (a / 255.0)
+    r_float = (r.to_f / 255.0) * a_float
+    g_float = (g.to_f / 255.0) * a_float
+    b_float = (b.to_f / 255.0) * a_float
+  end
+
+  r_int = (r_float * 255.0).to_i.clamp(0, 255)
+  g_int = (g_float * 255.0).to_i.clamp(0, 255)
+  b_int = (b_float * 255.0).to_i.clamp(0, 255)
+
+  "#%0.2X%0.2X%0.2X" % [r_int, g_int, b_int]
+end
+
+
+ +
+

+ + #slot_element(props, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+4
+5
+6
+7
+8
+9
+10
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/slots.rb', line 4
+
+def slot_element(props, &block)
+  HTML.render do |h|
+    h.div((props["html_attributes"] || {}).merge(id: html_id, style: slot_style(props))) do
+      h.div(style: { height: "100%", width: "100%" }, &block)
+    end
+  end
+end
+
+
+ +
+

+ + #spacing_styles_for_attr(attr, props, styles, with_options: true) ⇒ Object + + + + + +

+
+

We extract the appropriate margin and padding from the margin and +padding properties. If there are no margin or padding properties, +we fall back to props["options"] margin or padding, if it exists.

+ +

Margin or padding (in either props or props["options"]) can be +a Hash with directions as keys, or an Array of left/right/top/bottom, +or a constant, which means all four are that constant. You can +also specify a "margin" plus "margin-top" which is constant but +margin-top is overridden, or similar.

+ +

If any margin or padding property exists in props then we don't +check props["options"].

+ + +
+
+
+ + +
+ + + + +
+
+
+
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+
+
# File 'scarpe-components/lib/scarpe/components/calzini.rb', line 155
+
+def spacing_styles_for_attr(attr, props, styles, with_options: true)
+  spacing_styles = {}
+
+  case props[attr]
+  when Hash
+    props[attr].each do |dir, value|
+      spacing_styles[:"#{attr}-#{dir}"] = dimensions_length value
+    end
+  when Array
+    SPACING_DIRECTIONS.zip(props[attr]).to_h.compact.each do |dir, value|
+      spacing_styles[:"#{attr}-#{dir}"] = dimensions_length(value)
+    end
+  when String, Numeric
+    spacing_styles[attr.to_sym] = dimensions_length(props[attr])
+  end
+
+  SPACING_DIRECTIONS.each do |dir|
+    if props["#{attr}_#{dir}"]
+      spacing_styles[:"#{attr}-#{dir}"] = dimensions_length props["#{attr}_#{dir}"]
+    end
+  end
+
+  unless spacing_styles.empty?
+    return styles.merge(spacing_styles)
+  end
+
+  # We should see if there are spacing properties in props["options"],
+  # unless we're currently doing that.
+  if with_options && props["options"]
+    spacing_styles = spacing_styles_for_attr(attr, props["options"], {}, with_options: false)
+    styles.merge spacing_styles
+  else
+    # No "options" or we already checked it? Return the styles we were given.
+    styles
+  end
+end
+
+
+ +
+

+ + #stack_element(props, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+20
+21
+22
+23
+24
+25
+26
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/slots.rb', line 20
+
+def stack_element(props, &block)
+  HTML.render do |h|
+    h.div((props["html_attributes"] || {}).merge(id: html_id, style: stack_style(props))) do
+      h.div(style: { height: "100%", width: "100%", position: "relative" }, &block)
+    end
+  end
+end
+
+
+ +
+

+ + #star_element(props, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/art_drawables.rb', line 48
+
+def star_element(props, &block)
+  dc = props["draw_context"] || {}
+  fill = first_color_of(props["fill"], dc["fill"], "black")
+  stroke = first_color_of(props["stroke"], dc["stroke"], "black")
+  HTML.render do |h|
+    h.div(id: html_id, style: star_style(props)) do
+      h.svg(width: props["outer"], height: props["outer"], style: "fill:#{fill}") do
+        h.polygon(points: star_points(props), style: "stroke:#{stroke};stroke-width:2")
+      end
+      block.call(h) if block_given?
+    end
+  end
+end
+
+
+ +
+

+ + #text_drawable_element(prop_array) ⇒ Object + + + + + +

+
+

The text element is used to render the equivalent of Shoes cText, +which includes em, strong, span, link and so on. We use a +"content" tag for it which alternates plaintext with a hash of +properties.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/para.rb', line 181
+
+def text_drawable_element(prop_array)
+  out = String.new # Need unfrozen string
+
+  # Each item should be a String or a property Hash
+  # :items, :html_id, :tag, :props
+  prop_array.each do |item|
+    if item.is_a?(String)
+      out << item.gsub("\n", "<br/>")
+    else
+      s, extra = text_drawable_style(item[:props])
+      out << HTML.render do |h|
+        if extra.empty?
+          h.send(
+            item[:tag] || "span",
+            class: "id_#{item[:html_id]}",
+            style: s,
+            **text_drawable_attrs(item[:props])
+          ) do
+            text_drawable_element(item[:items])
+          end
+        else
+          h.span(class: "id_#{item[:html_id]}", style: extra) do
+            h.send(
+              item[:tag] || "span",
+              class: "id_#{item[:html_id]}",
+              style: s,
+              **text_drawable_attrs(item[:props])
+            ) do
+              text_drawable_element(item[:items])
+            end
+          end
+        end
+      end
+    end
+  end
+
+  out
+end
+
+
+ +
+

+ + #text_size(sz) ⇒ Object + + + + + +

+ + + + +
+
+
+
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+
+
# File 'scarpe-components/lib/scarpe/components/calzini.rb', line 84
+
+def text_size(sz)
+  case sz
+  when Numeric
+    sz
+  when Symbol
+    SIZES[sz]
+  when String
+    SIZES[sz.to_sym] || sz.to_i
+  else
+    raise "Unexpected text size object: #{sz.inspect}"
+  end
+end
+
+
+ +
+

+ + #video_element(props) ⇒ Object + + + + + +

+ + + + +
+
+
+
+85
+86
+87
+88
+89
+90
+91
+
+
# File 'scarpe-components/lib/scarpe/components/calzini/misc.rb', line 85
+
+def video_element(props)
+  HTML.render do |h|
+    h.video(id: html_id, style: drawable_style(props), controls: true) do
+      h.source(src: @url, type: props["format"])
+    end
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Components/FileHelpers.html b/Scarpe/Components/FileHelpers.html new file mode 100644 index 000000000..81e49f288 --- /dev/null +++ b/Scarpe/Components/FileHelpers.html @@ -0,0 +1,455 @@ + + + + + + + Module: Scarpe::Components::FileHelpers + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::Components::FileHelpers + + + +

+
+ + + + + + + + + +
+
Included in:
+
ProcessHelpers, SegmentedFileLoader, Test::Helpers
+
+ + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/file_helpers.rb
+
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #with_tempfile(prefix, contents, dir: Dir.tmpdir) {|the| ... } ⇒ Object + + + + + +

+
+

Create a temporary file with the given prefix and contents. +Execute the block of code with it in place. Make sure +it gets cleaned up afterward.

+ + +
+
+
+

Parameters:

+
    + +
  • + + prefix + + + (String) + + + + — +

    the prefix passed to Tempfile to identify this file on disk

    +
    + +
  • + +
  • + + contents + + + (String) + + + + — +

    the file contents that should be written to Tempfile

    +
    + +
  • + +
  • + + dir + + + (String) + + + (defaults to: Dir.tmpdir) + + + — +

    the directory to create the tempfile in

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +

    The code to execute with the tempfile present

    +
    + +
  • + +
+

Yield Parameters:

+
    + +
  • + + the + + + + + + + — +

    path of the new tempfile

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+
+
# File 'scarpe-components/lib/scarpe/components/file_helpers.rb', line 18
+
+def with_tempfile(prefix, contents, dir: Dir.tmpdir)
+  t = Tempfile.new(prefix, dir)
+  t.write(contents)
+  t.flush # Make sure the contents are written out
+
+  yield(t.path)
+ensure
+  t.close
+  t.unlink
+end
+
+
+ +
+

+ + #with_tempfiles(tf_specs) {|An| ... } ⇒ Object + + + + + +

+
+

Create multiple tempfiles, with given contents, in given +directories, and execute the block in that context. +When the block is finished, make sure all tempfiles are +deleted.

+ +

Pass an array of arrays, where each array is of the form: +[prefix, contents, (optional)dir]

+ +

I don't love inlining with_tempfile's contents into here. +But calling it iteratively or recursively was difficult +when I tried it the obvious ways.

+ +

This method should be equivalent to calling with_tempfile +once for each entry in the array, in a set of nested +blocks.

+ + +
+
+
+

Parameters:

+
    + +
  • + + tf_specs + + + (Array<Array>) + + + + — +

    The array of tempfile prefixes, contents and directories

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +

    The code to execute with those tempfiles present

    +
    + +
  • + +
+

Yield Parameters:

+
    + +
  • + + An + + + + + + + — +

    array of paths to tempfiles, in the same order as tf_specs

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+
+
# File 'scarpe-components/lib/scarpe/components/file_helpers.rb', line 48
+
+def with_tempfiles(tf_specs, &block)
+  tempfiles = []
+  tf_specs.each do |prefix, contents, dir|
+    dir ||= Dir.tmpdir
+    t = Tempfile.new(prefix, dir)
+    tempfiles << t
+    t.write(contents)
+    t.flush # Make sure the contents are written out
+  end
+
+  args = tempfiles.map(&:path)
+  yield(args)
+ensure
+  tempfiles.each do |t|
+    t.close
+    t.unlink
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Components/HTML.html b/Scarpe/Components/HTML.html new file mode 100644 index 000000000..fdee4f267 --- /dev/null +++ b/Scarpe/Components/HTML.html @@ -0,0 +1,822 @@ + + + + + + + Class: Scarpe::Components::HTML + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Components::HTML + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/html.rb
+
+ +
+ + + +

+ Constant Summary + collapse +

+ +
+ +
CONTENT_TAGS = + +
+
[
+  :div,
+  :p,
+  :button,
+  :ul,
+  :li,
+  :textarea,
+  :a,
+  :video,
+  :strong,
+  :style,
+  :progress,
+  :em,
+  :code,
+  :defs,
+  :marker,
+  :u,
+  :line,
+  :span,
+  :sub,
+  :sup,
+  :del,
+  :svg,
+  :h1,
+  :h2,
+  :h3,
+  :h4,
+  :h5,
+].freeze
+ +
VOID_TAGS = + +
+
[:input, :img, :polygon, :source, :link, :path, :rect, :ellipse].freeze
+ +
TAGS = + +
+
(CONTENT_TAGS + VOID_TAGS).freeze
+ +
+ + + + + + + + + +

+ Class Method Summary + collapse +

+ + + +

+ Instance Method Summary + collapse +

+ + + + +
+

Constructor Details

+ +
+

+ + #initialize(&block) ⇒ HTML + + + + + +

+
+

Returns a new instance of HTML.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+43
+44
+45
+46
+
+
# File 'scarpe-components/lib/scarpe/components/html.rb', line 43
+
+def initialize(&block)
+  @buffer = ""
+  block.call(self)
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + +

+ +
+

+ + #method_missing(name, *args, &block) ⇒ Object + + + + + +

+
+ + +
+
+
+ +

Raises:

+ + +
+ + + + +
+
+
+
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+
+
# File 'scarpe-components/lib/scarpe/components/html.rb', line 90
+
+def method_missing(name, *args, &block)
+  raise Scarpe::InvalidHTMLTag, "no method #{name} for #{self.class.name}" unless TAGS.include?(name)
+
+  if VOID_TAGS.include?(name)
+    raise Shoes::Errors::InvalidAttributeValueError, "void tag #{name} cannot have content" if block_given?
+
+    @buffer += "<#{name}#{render_attributes(*args)} />"
+  else
+    @buffer += "<#{name}#{render_attributes(*args)}>"
+
+    if block_given?
+      result = block.call(self)
+    else
+      result = args.first
+      @buffer += result if result.is_a?(String)
+    end
+    @buffer += result if result.is_a?(String)
+
+    @buffer += "</#{name}>"
+  end
+
+  nil
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + .render(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+38
+39
+40
+
+
# File 'scarpe-components/lib/scarpe/components/html.rb', line 38
+
+def render(&block)
+  new(&block).value
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + #option(**attrs, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+60
+61
+62
+
+
# File 'scarpe-components/lib/scarpe/components/html.rb', line 60
+
+def option(**attrs, &block)
+  tag(:option, **attrs, &block)
+end
+
+
+ +
+

+ + #p(*args, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+56
+57
+58
+
+
# File 'scarpe-components/lib/scarpe/components/html.rb', line 56
+
+def p(*args, &block)
+  method_missing(:p, *args, &block)
+end
+
+
+ +
+

+ + #respond_to_missing?(name, include_all = false) ⇒ Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+52
+53
+54
+
+
# File 'scarpe-components/lib/scarpe/components/html.rb', line 52
+
+def respond_to_missing?(name, include_all = false)
+  TAGS.include?(name) || super(name, include_all)
+end
+
+
+ +
+

+ + #select(**attrs, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+86
+87
+88
+
+
# File 'scarpe-components/lib/scarpe/components/html.rb', line 86
+
+def select(**attrs, &block)
+  tag(:select, **attrs, &block)
+end
+
+
+ +
+

+ + #tag(name, **attrs, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+
+
# File 'scarpe-components/lib/scarpe/components/html.rb', line 64
+
+def tag(name, **attrs, &block)
+  if VOID_TAGS.include?(name)
+    raise Shoes::Errors::InvalidAttributeValueError, "void tag #{name} cannot have content" if block_given?
+
+    @buffer += "<#{name}#{render_attributes(attrs)} />"
+  else
+    @buffer += "<#{name}#{render_attributes(attrs)}>"
+
+    if block_given?
+      result = block.call(self)
+    else
+      result = attrs[:content]
+      @buffer += result if result.is_a?(String)
+    end
+    @buffer += result if result.is_a?(String)
+
+    @buffer += "</#{name}>"
+  end
+
+  nil
+end
+
+
+ +
+

+ + #valueObject + + + + + +

+ + + + +
+
+
+
+48
+49
+50
+
+
# File 'scarpe-components/lib/scarpe/components/html.rb', line 48
+
+def value
+  @buffer
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Components/ImportRunnables.html b/Scarpe/Components/ImportRunnables.html new file mode 100644 index 000000000..17841c457 --- /dev/null +++ b/Scarpe/Components/ImportRunnables.html @@ -0,0 +1,115 @@ + + + + + + + Module: Scarpe::Components::ImportRunnables + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::Components::ImportRunnables + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/minitest_import_runnable.rb
+
+ +
+ +

Defined Under Namespace

+

+ + + + + Classes: ImportRunnable + + +

+ + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Components/ImportRunnables/ImportRunnable.html b/Scarpe/Components/ImportRunnables/ImportRunnable.html new file mode 100644 index 000000000..e40a62627 --- /dev/null +++ b/Scarpe/Components/ImportRunnables/ImportRunnable.html @@ -0,0 +1,452 @@ + + + + + + + Class: Scarpe::Components::ImportRunnables::ImportRunnable + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Components::ImportRunnables::ImportRunnable + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/minitest_import_runnable.rb
+
+ +
+ +

Overview

+
+

Minitest Runnables are unusual - we expect to declare a class (like a Test) with +a lot of methods to run. The ImportRunnable is a single Runnable. But whenever +you tell it to import a JSON file, it will add all of the described tests to +its runnable methods.

+ +

Normally that means that your subclass tests will run up front and produce +JSON files, then Minitest will autorun at the end and report all their +results.

+ +

It wouldn't really make sense to create these runnables during the testing +phase, because Minitest has already decided what to run at that point.

+ + +
+
+
+ + +
+ + + + + + + +

+ Class Method Summary + collapse +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + .deserialize_failures(failures) ⇒ Object + + + + + +

+ + + + +
+
+
+
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_import_runnable.rb', line 80
+
+def self.deserialize_failures(failures)
+  failures.map do |fail|
+    # Instantiate the Minitest::Assertion or Minitest::UnexpectedError
+    if fail[0] == "exception"
+      exc_json = JSON.parse(fail[1])
+      json_to_err exc_json
+    elsif fail[0] == "unexpected"
+      unexpected_json = JSON.parse(fail[1])
+      inner_json = JSON.parse(fail[2])
+      outer_err = json_to_err unexpected_json
+      inner_err = json_to_err inner_json
+      outer_err.error = inner_err
+    else
+      raise "Unknown exception data when trying to deserialize! #{fail.inspect}"
+    end
+  end
+end
+
+
+ +
+

+ + .import_json_data(data) ⇒ Object + + + + + +

+
+

Import JSON from an exported Minitest run. Note that running this multiple +times with overlapping class names may be really bad.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_import_runnable.rb', line 23
+
+def self.import_json_data(data)
+  @imported_classes ||= {}
+  @imported_tests ||= {}
+
+  JSON.parse(data).each do |item|
+    klass = item["klass"]
+    meth = item["name"]
+    @imported_tests[klass] ||= {}
+    @imported_tests[klass][meth] = item
+  end
+
+  @imported_tests.each do |klass_name, test_method_hash|
+    klass = @imported_classes[klass_name]
+    unless klass
+      new_klass = Class.new(Minitest::Runnable)
+      @imported_classes[klass_name] = new_klass
+      ImportRunnable.const_set(klass_name, new_klass)
+      klass = new_klass
+
+      klass.define_singleton_method(:run_one_method) do |klass, method_name, reporter|
+        reporter.prerecord klass, method_name
+        imp = test_method_hash[method_name]
+
+        res = Minitest::Result.new imp["name"]
+        res.klass = imp["klass"]
+        res.assertions = imp["assertions"]
+        res.time = imp["time"]
+        res.failures = ImportRunnable.deserialize_failures imp["failures"]
+        res. = imp["metadata"] if imp["metadata"]
+
+        # Record the synthetic result built from imported data
+        reporter.record res
+      end
+    end
+
+    # Update "runnables" method to reflect all current known runnable tests
+    klass_methods = test_method_hash.keys
+    klass.define_singleton_method(:runnable_methods) do
+      klass_methods
+    end
+  end
+end
+
+
+ +
+

+ + .json_to_err(err_json) ⇒ Object + + + + + +

+ + + + +
+
+
+
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_import_runnable.rb', line 66
+
+def self.json_to_err(err_json)
+  klass = begin
+    Object.const_get(err_json["json_class"])
+  rescue
+    nil
+  end
+  if klass && klass <= Minitest::Assertion
+    klass.json_create(err_json)
+  else
+    err = Exception.json_create(err_json)
+    Minitest::UnexpectedError.new(err)
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Components/MinitestResult.html b/Scarpe/Components/MinitestResult.html new file mode 100644 index 000000000..39a597c09 --- /dev/null +++ b/Scarpe/Components/MinitestResult.html @@ -0,0 +1,1222 @@ + + + + + + + Class: Scarpe::Components::MinitestResult + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Components::MinitestResult + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/minitest_result.rb
+
+ +
+ +

Overview

+
+

A MinitestResult imports a JSON file from a minitest_export_reporter. +But instead of creating a Minitest::Test to report the result, the +MinitestResult is just a queryable Ruby object.

+ +

MinitestResult assumes there will be only one class and one method +in the JSON, which is true for Scarpe but not necessarily in general.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary collapse

+
    + +
  • + + + #assertions ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute assertions.

    +
    + +
  • + + +
  • + + + #class_name ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute class_name.

    +
    + +
  • + + +
  • + + + #method_name ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute method_name.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + collapse +

+ + + + +
+

Constructor Details

+ +
+

+ + #initialize(filename) ⇒ MinitestResult + + + + + +

+
+

Returns a new instance of MinitestResult.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_result.rb', line 20
+
+def initialize(filename)
+  data = JSON.parse File.read(filename)
+
+  unless data.size == 1
+    # We would want a different interface to support this in general. For now we don't
+    # need it to work in general.
+    raise "Scarpe::Components::MinitestResult only supports one class and method in results!"
+  end
+
+  item = data.first
+
+  @assertions = item["assertions"]
+  @method_name = item["name"]
+  @class_name = item["klass"]
+  @time = item["time"]
+  @metadata = item.key?("metadata") ? item["metadata"]: {}
+
+  @skip = false
+  @exceptions = []
+  @failures = []
+  item["failures"].each do |f|
+    # JSON.parse ignores json_class and won't create an arbitrary object. That's good
+    # because Minitest::UnexpectedError seems to load in a bad way, so we don't want
+    # it to auto-instantiate.
+    d = JSON.parse f[1]
+    msg = d["m"]
+    case d["json_class"]
+    when "Minitest::UnexpectedError"
+      @exceptions << msg
+    when "Minitest::Skip"
+      @skip = msg
+    when "Minitest::Assertion"
+      @failures << msg
+    else
+      raise Scarpe::InternalError, "Didn't expect type #{t.inspect} as exception type when importing Minitest tests!"
+    end
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #assertionsObject (readonly) + + + + + +

+
+

Returns the value of attribute assertions.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+16
+17
+18
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_result.rb', line 16
+
+def assertions
+  @assertions
+end
+
+
+ + + +
+

+ + #class_nameObject (readonly) + + + + + +

+
+

Returns the value of attribute class_name.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+18
+19
+20
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_result.rb', line 18
+
+def class_name
+  @class_name
+end
+
+
+ + + +
+

+ + #method_nameObject (readonly) + + + + + +

+
+

Returns the value of attribute method_name.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+17
+18
+19
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_result.rb', line 17
+
+def method_name
+  @method_name
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #check(expect_result: :success, min_asserts: nil, max_asserts: nil) ⇒ Object + + + + + +

+ + + + +
+
+
+
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_result.rb', line 80
+
+def check(expect_result: :success, min_asserts: nil, max_asserts: nil)
+  unless [:error, :fail, :skip, :success].include?(expect_result)
+    raise Scarpe::InternalError, "Expected test result should be one of [:success, :fail, :error, :skip]!"
+  end
+
+  res, msg = result_and_message
+  if expect_result.to_s != res
+    return [false, "Expected #{expect_result} but got #{res}: #{msg}!"]
+  end
+
+  if min_asserts && @assertions < min_asserts
+    return [false, "Expected success with at least #{min_asserts} assertions but found only #{@assertions}!"]
+  end
+  if max_asserts && @assertions > max_asserts
+    return [false, "Expected success with no more than #{max_asserts} assertions but found only #{@assertions}!"]
+  end
+
+  [true, ""]
+end
+
+
+ +
+

+ + #console_summaryObject + + + + + +

+ + + + +
+
+
+
+73
+74
+75
+76
+77
+78
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_result.rb', line 73
+
+def console_summary
+  return "Error(s): #{@exceptions.inspect}" if self.error?
+  return "Failure: #{@failures.inspect}" if self.fail?
+  return "Skip: #{skip_message.inspect}" if self.skip?
+  "Success!"
+end
+
+
+ +
+

+ + #error?Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+100
+101
+102
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_result.rb', line 100
+
+def error?
+  !@exceptions.empty?
+end
+
+
+ +
+

+ + #error_messageObject + + + + + +

+ + + + +
+
+
+
+116
+117
+118
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_result.rb', line 116
+
+def error_message
+  @exceptions[0]
+end
+
+
+ +
+

+ + #fail?Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+104
+105
+106
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_result.rb', line 104
+
+def fail?
+  !@failures.empty?
+end
+
+
+ +
+

+ + #fail_messageObject + + + + + +

+ + + + +
+
+
+
+120
+121
+122
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_result.rb', line 120
+
+def fail_message
+  @failures[0]
+end
+
+
+ +
+

+ + #one_word_resultObject + + + + + +

+ + + + +
+
+
+
+59
+60
+61
+62
+63
+64
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_result.rb', line 59
+
+def one_word_result
+  return "error" if self.error?
+  return "fail" if self.fail?
+  return "skip" if self.skip?
+  "success"
+end
+
+
+ +
+

+ + #passed?Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+112
+113
+114
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_result.rb', line 112
+
+def passed?
+  @exceptions.empty? && @failures.empty? && !@skip
+end
+
+
+ +
+

+ + #result_and_messageObject + + + + + +

+ + + + +
+
+
+
+66
+67
+68
+69
+70
+71
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_result.rb', line 66
+
+def result_and_message
+  return ["error", error_message] if self.error?
+  return ["fail", fail_message] if self.fail?
+  return ["skip", skip_message] if self.skip?
+  ["success", "OK"]
+end
+
+
+ +
+

+ + #skip?Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+108
+109
+110
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_result.rb', line 108
+
+def skip?
+  @skip ? true : false
+end
+
+
+ +
+

+ + #skip_messageObject + + + + + +

+ + + + +
+
+
+
+124
+125
+126
+
+
# File 'scarpe-components/lib/scarpe/components/minitest_result.rb', line 124
+
+def skip_message
+  @skip
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Components/ModularLogImpl.html b/Scarpe/Components/ModularLogImpl.html new file mode 100644 index 000000000..72118f08e --- /dev/null +++ b/Scarpe/Components/ModularLogImpl.html @@ -0,0 +1,312 @@ + + + + + + + Class: Scarpe::Components::ModularLogImpl + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Components::ModularLogImpl + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + +
+
Includes:
+
Shoes::Log
+
+ + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/modular_logger.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + +
+

Instance Method Details

+ + +
+

+ + #configure_logger(log_config) ⇒ Object + + + + + +

+ + + + +
+
+
+
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+
+
# File 'scarpe-components/lib/scarpe/components/modular_logger.rb', line 82
+
+def configure_logger(log_config)
+  # TODO: custom coloring? https://github.com/TwP/logging/blob/master/examples/colorization.rb
+  @custom_log_layout = Logging.layouts.pattern pattern: '[%r] %-5l %c: %m\n'
+
+  if log_config.is_a?(String) && File.exist?(log_config)
+    log_config = JSON.load_file(log_config)
+  end
+
+  log_config = freeze_log_config(log_config) unless log_config.nil?
+  @current_log_config = log_config # Save a copy for later
+
+  Logging.reset # Reset all Logging settings to defaults
+  Logging.reopen # For log-reconfig (e.g. test failures), often important to *not* store an open handle to a moved file
+  return if log_config.nil?
+
+  Logging.logger.root.appenders = [Logging.appenders.stdout]
+
+  default_logger = log_config[DEFAULT_COMPONENT] || "info"
+  json_configure_logger(Logging.logger.root, default_logger)
+
+  log_config.each do |component, logger_data|
+    next if component == DEFAULT_COMPONENT
+
+    sublogger = Logging.logger[component]
+    json_configure_logger(sublogger, logger_data)
+  end
+end
+
+
+ +
+

+ + #logger_for_component(component) ⇒ Object + + + + + +

+ + + + +
+
+
+
+16
+17
+18
+
+
# File 'scarpe-components/lib/scarpe/components/modular_logger.rb', line 16
+
+def logger_for_component(component)
+  Logging.logger[component]
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Components/PrintLogImpl.html b/Scarpe/Components/PrintLogImpl.html new file mode 100644 index 000000000..72f40c4d1 --- /dev/null +++ b/Scarpe/Components/PrintLogImpl.html @@ -0,0 +1,274 @@ + + + + + + + Class: Scarpe::Components::PrintLogImpl + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Components::PrintLogImpl + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + +
+
Includes:
+
Shoes::Log
+
+ + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/print_logger.rb
+
+ +
+ +

Defined Under Namespace

+

+ + + + + Classes: PrintLogger + + +

+ + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + +
+

Instance Method Details

+ + +
+

+ + #configure_logger(log_config) ⇒ Object + + + + + +

+ + + + +
+
+
+
+56
+57
+58
+
+
# File 'scarpe-components/lib/scarpe/components/print_logger.rb', line 56
+
+def configure_logger(log_config)
+  # For now, ignore
+end
+
+
+ +
+

+ + #logger_for_component(component) ⇒ Object + + + + + +

+ + + + +
+
+
+
+52
+53
+54
+
+
# File 'scarpe-components/lib/scarpe/components/print_logger.rb', line 52
+
+def logger_for_component(component)
+  PrintLogger.new(component.to_s)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Components/PrintLogImpl/PrintLogger.html b/Scarpe/Components/PrintLogImpl/PrintLogger.html new file mode 100644 index 000000000..203154c57 --- /dev/null +++ b/Scarpe/Components/PrintLogImpl/PrintLogger.html @@ -0,0 +1,592 @@ + + + + + + + Class: Scarpe::Components::PrintLogImpl::PrintLogger + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Components::PrintLogImpl::PrintLogger + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/print_logger.rb
+
+ +
+ + + +

+ Constant Summary + collapse +

+ +
+ +
LEVELS = + +
+
{
+  :never => 1000,
+  :error => 4,
+  :warn => 3,
+  :info => 2,
+  :debug => 1,
+  :always => -1,
+}
+ +
+ + + + + +

Class Attribute Summary collapse

+
    + +
  • + + + .min_level ⇒ Object + + + + + + + + + + + + + + + + +

    Returns the value of attribute min_level.

    +
    + +
  • + + +
  • + + + .silence ⇒ Object + + + + + + + + + + + + + + + + +

    Returns the value of attribute silence.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + collapse +

+ + + + +
+

Constructor Details

+ +
+

+ + #initialize(component_name) ⇒ PrintLogger + + + + + +

+
+

Returns a new instance of PrintLogger.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+27
+28
+29
+
+
# File 'scarpe-components/lib/scarpe/components/print_logger.rb', line 27
+
+def initialize(component_name)
+  @comp_name = component_name
+end
+
+
+ +
+ +
+

Class Attribute Details

+ + + +
+

+ + .min_levelObject + + + + + +

+
+

Returns the value of attribute min_level.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+14
+15
+16
+
+
# File 'scarpe-components/lib/scarpe/components/print_logger.rb', line 14
+
+def min_level
+  @min_level
+end
+
+
+ + + +
+

+ + .silenceObject + + + + + +

+
+

Returns the value of attribute silence.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+13
+14
+15
+
+
# File 'scarpe-components/lib/scarpe/components/print_logger.rb', line 13
+
+def silence
+  @silence
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #debug(msg) ⇒ Object + + + + + +

+ + + + +
+
+
+
+41
+42
+43
+44
+
+
# File 'scarpe-components/lib/scarpe/components/print_logger.rb', line 41
+
+def debug(msg)
+  return if PrintLogger.silence || PrintLogger.min_level > LEVELS[:debug]
+  puts "#{@comp_name} debug: #{msg}" unless PrintLogger.silence
+end
+
+
+ +
+

+ + #error(msg) ⇒ Object + + + + + +

+ + + + +
+
+
+
+31
+32
+33
+34
+
+
# File 'scarpe-components/lib/scarpe/components/print_logger.rb', line 31
+
+def error(msg)
+  return if PrintLogger.silence || PrintLogger.min_level > LEVELS[:error]
+  puts "#{@comp_name} error: #{msg}"
+end
+
+
+ +
+

+ + #info(msg) ⇒ Object + + + + + +

+ + + + +
+
+
+
+46
+47
+48
+49
+
+
# File 'scarpe-components/lib/scarpe/components/print_logger.rb', line 46
+
+def info(msg)
+  return if PrintLogger.silence || PrintLogger.min_level > LEVELS[:info]
+  puts "#{@comp_name} info: #{msg}"
+end
+
+
+ +
+

+ + #warn(msg) ⇒ Object + + + + + +

+ + + + +
+
+
+
+36
+37
+38
+39
+
+
# File 'scarpe-components/lib/scarpe/components/print_logger.rb', line 36
+
+def warn(msg)
+  return if PrintLogger.silence || PrintLogger.min_level > LEVELS[:warn]
+  puts "#{@comp_name} warn: #{msg}" unless PrintLogger.silence
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Components/ProcessHelpers.html b/Scarpe/Components/ProcessHelpers.html new file mode 100644 index 000000000..47bc61fd3 --- /dev/null +++ b/Scarpe/Components/ProcessHelpers.html @@ -0,0 +1,277 @@ + + + + + + + Module: Scarpe::Components::ProcessHelpers + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::Components::ProcessHelpers + + + +

+
+ + + + + + +
+
Includes:
+
FileHelpers
+
+ + + + +
+
Included in:
+
Test::Helpers
+
+ + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/process_helpers.rb
+
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from FileHelpers

+

#with_tempfile, #with_tempfiles

+ + +
+

Instance Method Details

+ + +
+

+ + #run_out_err_result(cmd) ⇒ Array(String,String,bool) + + + + + +

+
+

Run the command and capture its stdout and stderr output, and whether +it succeeded or failed. Return after the command has completed. +The awkward name is because this is normally a component of another +library. Ordinarily you'd want to raise a library-specific exception +on failure, print a library-specific message or delimiter, or otherwise +handle success and failure. This is too general as-is.

+ + +
+
+
+

Parameters:

+
    + +
  • + + cmd + + + (String, Array<String>) + + + + — +

    the command to run in Kernel#spawn format

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Array(String,String,bool)) + + + + — +

    the stdout output, stderr output and success/failure of the command in a 3-element Array

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+
+
# File 'scarpe-components/lib/scarpe/components/process_helpers.rb', line 19
+
+def run_out_err_result(cmd)
+  out_str = ""
+  err_str = ""
+  success = nil
+
+  with_tempfiles([
+    ["scarpe_cmd_stdout", ""],
+    ["scarpe_cmd_stderr", ""],
+  ]) do |stdout_file, stderr_file|
+    pid = Kernel.spawn(cmd, out: stdout_file, err: stderr_file)
+    Process.wait(pid)
+    success = $?.success?
+    out_str = File.read stdout_file
+    err_str = File.read stderr_file
+  end
+
+  [out_str, err_str, success]
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Components/SegmentedFileLoader.html b/Scarpe/Components/SegmentedFileLoader.html new file mode 100644 index 000000000..89c438a67 --- /dev/null +++ b/Scarpe/Components/SegmentedFileLoader.html @@ -0,0 +1,1028 @@ + + + + + + + Class: Scarpe::Components::SegmentedFileLoader + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Components::SegmentedFileLoader + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + +
+
Includes:
+
FileHelpers
+
+ + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/segmented_file_loader.rb
+
+ +
+ + + + + + + + + +

+ Class Method Summary + collapse +

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from FileHelpers

+

#with_tempfile, #with_tempfiles

+ + +
+

Class Method Details

+ + +
+

+ + .front_matter_and_segments_from_file(contents) ⇒ Object + + + + + +

+ + + + +
+
+
+
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+
+
# File 'scarpe-components/lib/scarpe/components/segmented_file_loader.rb', line 75
+
+def self.front_matter_and_segments_from_file(contents)
+  require "yaml" # Only load when needed
+  require "English"
+
+  segments = contents.split(/\n-{5,}/)
+  front_matter = {}
+
+  # The very first segment can start with front matter, or with a divider, or with no divider.
+  if segments[0].start_with?("---\n") || segments[0] == "---"
+    # We have YAML front matter at the start. All later segments will have a divider.
+    front_matter = YAML.load segments[0]
+    front_matter ||= {} # If the front matter is just the three dashes it returns nil
+    segments = segments[1..-1]
+  elsif segments[0].start_with?("-----")
+    # We have a divider at the start. Great! We're already well set up for this case.
+  elsif segments.size == 1
+    # No front matter, no divider, a single unnamed segment. No more parsing needed.
+    return [{}, { "" => segments[0] }]
+  else
+    # No front matter, no divider before the first segment, multiple segments.
+    # We'll add an artificial divider to the first segment for uniformity.
+    segments = ["-----\n" + segments[0]] + segments[1..-1]
+  end
+
+  segmap = {}
+  segments.each do |segment|
+    if segment =~ /\A-* +(.*?)\n/
+      # named segment with separator
+      name = ::Regexp.last_match(1)
+
+      raise("Duplicate segment name: #{name.inspect}!") if segmap.key?(name)
+
+      segmap[name] = ::Regexp.last_match.post_match
+    elsif segment =~ /\A-* *\n/
+      # unnamed segment with separator
+      segmap[gen_name(segmap)] = ::Regexp.last_match.post_match
+    else
+      raise Scarpe::InternalError, "Internal error when parsing segments in segmented app file! seg: #{segment.inspect}"
+    end
+  end
+
+  [front_matter, segmap]
+end
+
+
+ +
+

+ + .gen_name(segmap) ⇒ Object + + + + + +

+ + + + +
+
+
+
+70
+71
+72
+73
+
+
# File 'scarpe-components/lib/scarpe/components/segmented_file_loader.rb', line 70
+
+def self.gen_name(segmap)
+  ctr = (1..10_000).detect { |i| !segmap.key?("%5d" % i) }
+  "%5d" % ctr
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + #add_segment_type(type, handler) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Add a new segment type (e.g. "catscradle") with a different +file handler.

+ + +
+
+
+

Parameters:

+
    + +
  • + + type + + + (String) + + + + — +

    the new name for this segment type

    +
    + +
  • + +
  • + + handler + + + (Object) + + + + — +

    an object that will be called as obj.call(filename) - often a proc

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+15
+16
+17
+18
+19
+20
+21
+
+
# File 'scarpe-components/lib/scarpe/components/segmented_file_loader.rb', line 15
+
+def add_segment_type(type, handler)
+  if segment_type_hash.key?(type)
+    raise Shoes::Errors::InvalidAttributeValueError, "Segment type #{type.inspect} already exists!"
+  end
+
+  segment_type_hash[type] = handler
+end
+
+
+ +
+

+ + #after_load(&block) ⇒ Object + + + + + +

+
+

Segment type handlers can call this to perform an operation after the load +has completed. This is important for ordering, and because loading a Shoes +app often doesn't return. So to have a later section (e.g. tests, additional +data) do something that affects Shoes app loading (e.g. set an env var, +affect the display service) it's important that app loading take place later +in the sequence.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+65
+66
+67
+68
+
+
# File 'scarpe-components/lib/scarpe/components/segmented_file_loader.rb', line 65
+
+def after_load(&block)
+  @after_load ||= []
+  @after_load << block
+end
+
+
+ +
+

+ + #call(path) ⇒ Boolean + + + + + +

+
+

Load a .sca file with an optional YAML frontmatter prefix and +multiple file sections which can be treated differently.

+ +

The file loader acts like a proc, being called with .call() +and returning true or false for whether it has handled the +file load. This allows chaining loaders in order and the +first loader to recognise a file will run it.

+ + +
+
+
+

Parameters:

+
    + +
  • + + path + + + (String) + + + + — +

    the file or directory to treat as a Scarpe app

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    return true if the file is loaded as a segmented Scarpe app file

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+52
+53
+54
+55
+56
+57
+
+
# File 'scarpe-components/lib/scarpe/components/segmented_file_loader.rb', line 52
+
+def call(path)
+  return false unless path.end_with?(".scas") || path.end_with?(".sspec")
+
+  file_load(path)
+  true
+end
+
+
+ +
+

+ + #file_load(path) ⇒ Object + + + + + +

+ + + + +
+
+
+
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+
+
# File 'scarpe-components/lib/scarpe/components/segmented_file_loader.rb', line 119
+
+def file_load(path)
+  contents = File.read(path)
+
+  front_matter, segmap = self.class.front_matter_and_segments_from_file(contents)
+
+  if segmap.empty?
+    raise Scarpe::FileContentError, "Illegal segmented Scarpe file: must have at least one code segment, not just front matter!"
+  end
+
+  if front_matter[:segments]
+    if front_matter[:segments].size != segmap.size
+      raise Scarpe::FileContentError, "Number of front matter :segments must equal number of file segments!"
+    end
+  else
+    if segmap.size > 2
+      raise Scarpe::FileContentError, "Segmented files with more than two segments have to specify what they're for!"
+    end
+
+    # Set to default of shoes code only or shoes code and app test code.
+    front_matter[:segments] = segmap.size == 2 ? ["shoes", "app_test"] : ["shoes"]
+  end
+
+  # Match up front_matter[:segments] with the segments, or use the default of shoes and app_test.
+
+  sth = segment_type_hash
+  sv = segmap.values
+
+  tf_specs = []
+  front_matter[:segments].each.with_index do |seg_type, idx|
+    unless sth.key?(seg_type)
+      raise Scarpe::FileContentError, "Unrecognized segment type #{seg_type.inspect}! No matching segment type available!"
+    end
+
+    tf_specs << ["scarpe_#{seg_type}_segment_contents", sv[idx]]
+  end
+
+  with_tempfiles(tf_specs) do |filenames|
+    filenames.each.with_index do |filename, idx|
+      seg_name = front_matter[:segments][idx]
+      sth[seg_name].call(filename)
+    end
+
+    # Need to call @after_load hooks while tempfiles still exist
+    if @after_load && !@after_load.empty?
+      @after_load.each(&:call)
+      @after_load = []
+    end
+  end
+end
+
+
+ +
+

+ + #remove_all_segment_types!void + + + + + +

+
+

This method returns an undefined value.

Normally a Shoes application will want to keep the default segment types, +which allow loading a Shoes app and running a test inside. But sometimes +the default handler will be wrong and a library will want to register +its own "shoes" and "app_test" segment handlers, or not have any at all. +For those applications, it makes sense to clear all segment types before +registering its own.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+38
+39
+40
+
+
# File 'scarpe-components/lib/scarpe/components/segmented_file_loader.rb', line 38
+
+def remove_all_segment_types!
+  @segment_type_hash = {}
+end
+
+
+ +
+

+ + #segment_type_hashHash<String, Object> + + + + + +

+
+

The hash of segment type labels mapped to handlers which will be called. +This could be called by a display service, a test framework or similar +code that wants to define a non-Scarpe-standard file format.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Hash<String, Object>) + + + + — +

    the name/handler pairs

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+174
+175
+176
+177
+178
+179
+180
+181
+182
+
+
# File 'scarpe-components/lib/scarpe/components/segmented_file_loader.rb', line 174
+
+def segment_type_hash
+  @segment_handlers ||= {
+    "shoes" => proc { |seg_file| after_load { load seg_file } },
+    "app_test" => proc do |seg_file|
+      ENV["SHOES_SPEC_TEST"] = seg_file
+      ENV["SHOES_MINITEST_EXPORT_FILE"] ||= "sspec.json"
+    end,
+  }
+end
+
+
+ +
+

+ + #segment_typesArray<String> + + + + + +

+
+

Return an Array of segment type labels, such as "code" and "app_test".

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array<String>) + + + + — +

    the segment type labels

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+26
+27
+28
+
+
# File 'scarpe-components/lib/scarpe/components/segmented_file_loader.rb', line 26
+
+def segment_types
+  segment_type_hash.keys
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Components/StringHelpers.html b/Scarpe/Components/StringHelpers.html new file mode 100644 index 000000000..1cfb18ea7 --- /dev/null +++ b/Scarpe/Components/StringHelpers.html @@ -0,0 +1,187 @@ + + + + + + + Module: Scarpe::Components::StringHelpers + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::Components::StringHelpers + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/string_helpers.rb
+
+ +
+ + + + + + + + + +

+ Class Method Summary + collapse +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + .camelize(string) ⇒ Object + + + + + +

+
+

Cut down from Rails camelize

+ + +
+
+
+ + +
+ + + + +
+
+
+
+6
+7
+8
+9
+
+
# File 'scarpe-components/lib/scarpe/components/string_helpers.rb', line 6
+
+def self.camelize(string)
+  string = string.sub(/^[a-z\d]*/, &:capitalize)
+  string.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{::Regexp.last_match(1)}#{::Regexp.last_match(2).capitalize}" }
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Components/Tiranti.html b/Scarpe/Components/Tiranti.html new file mode 100644 index 000000000..0559873dd --- /dev/null +++ b/Scarpe/Components/Tiranti.html @@ -0,0 +1,713 @@ + + + + + + + Module: Scarpe::Components::Tiranti + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::Components::Tiranti + + + +

+
+ + + + +
+
Extended by:
+
Tiranti
+
+ + + +
+
Includes:
+
Calzini
+
+ + + + +
+
Included in:
+
Tiranti
+
+ + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/tiranti.rb
+
+ +
+ +

Overview

+
+

The Tiranti module expects to be included by a class defining +the following methods:

+ +
* html_id - the HTML ID for the specific rendered DOM object
+* handler_js_code(event_name) - the JS handler code for this DOM object and event name
+* (optional) display_properties - the display properties for this object, unless overridden in render()
+
+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants included + from Calzini

+

Calzini::HTML, Calzini::SPACING_DIRECTIONS

+ + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Calzini

+

#arc_element, #border_element, #contains_number?, #contains_only_numbers?, #degrees_to_radians, #dimensions_length, #documentroot_element, #drawable_style, #edit_box_element, #edit_line_element, #first_color_of, #flow_element, #image_element, #line_element, #list_box_element, #oval_element, #radians_to_degrees, #radio_element, #rect_element, #render, #rgb_to_hex, #slot_element, #spacing_styles_for_attr, #stack_element, #star_element, #text_drawable_element, #text_size, #video_element

+ + + + + + + + + +

Methods included from Base64

+

#encode_file_to_base64, #mime_type_for_filename, #valid_url?

+ + +
+

Instance Method Details

+ + +
+

+ + #alert_element(props) ⇒ Object + + + + + +

+ + + + +
+
+
+
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+
+
# File 'scarpe-components/lib/scarpe/components/tiranti.rb', line 89
+
+def alert_element(props)
+  onclick = handler_js_code(props["event_name"] || "click")
+
+  HTML.render do |h|
+    h.div(id: html_id, class: "modal", tabindex: -1, role: "dialog", style: alert_overlay_style(props)) do
+      h.div(class: "modal-dialog", role: "document") do
+        h.div(class: "modal-content", style: alert_modal_style) do
+          h.div(class: "modal-header") do
+            h.h5(class: "modal-title") { "Alert" }
+            h.button(type: "button", class: "close", data_dismiss: "modal", aria_label: "Close") do
+              h.span(aria_hidden: "true") { "&times;" }
+            end
+          end
+          h.div(class: "modal-body") do
+            h.p { props["text"] }
+          end
+          h.div(class: "modal-footer") do
+            h.button(type: "button", onclick:, class: "btn btn-primary") { "OK" }
+            #h.button(type: "button", class: "btn btn-secondary") { "Close" }
+          end
+        end
+      end
+    end
+  end
+end
+
+
+ +
+

+ + #button_element(props) ⇒ Object + + + + + +

+
+

How do we want to handle theme-specific colours and primary/secondary buttons in Bootstrap? +"Disabled" could be checked in properties. Is there any way we can/should use "outline" buttons?

+ + +
+
+
+ + +
+ + + + +
+
+
+
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+
+
# File 'scarpe-components/lib/scarpe/components/tiranti.rb', line 55
+
+def button_element(props)
+  HTML.render do |h|
+    h.button(
+      id: html_id,
+      type: "button",
+      class: props["html_class"] ? "btn #{props["html_class"]}" : "btn btn-primary",
+        onclick: handler_js_code("click"), style: button_style(props)
+    ) do
+      props["text"]
+    end
+  end
+end
+
+
+ +
+

+ + #check_element(props) ⇒ Object + + + + + +

+ + + + +
+
+
+
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+
+
# File 'scarpe-components/lib/scarpe/components/tiranti.rb', line 115
+
+def check_element(props)
+  HTML.render do |h|
+    h.div class: "form-check" do
+      h.input type: :checkbox,
+        id: html_id,
+        class: "form-check-input",
+        onclick: handler_js_code("click"),
+        value: props["text"],
+        checked: props["checked"],
+        style: drawable_style(props)
+    end
+  end
+end
+
+
+ +
+

+ + #empty_page_element(theme: ENV["SCARPE_BOOTSTRAP_THEME"] || "sketchy") ⇒ Object + + + + + +

+
+

Currently we're using Bootswatch 5. +Bootswatch themes downloaded from https://bootswatch.com/5/THEME_NAME/bootstrap.css

+ + +
+
+
+ + +
+ + + + +
+
+
+
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+
+
# File 'scarpe-components/lib/scarpe/components/tiranti.rb', line 23
+
+def empty_page_element(theme: ENV["SCARPE_BOOTSTRAP_THEME"] || "sketchy")
+  comp_dir = File.expand_path("#{__dir__}/../../..")
+  bootstrap_js_url = Scarpe::Webview.asset_server.asset_url("#{comp_dir}/assets/bootstrap-themes/bootstrap.bundle.min.js", url_type: :asset)
+  theme_url = Scarpe::Webview.asset_server.asset_url("#{comp_dir}/assets/bootstrap-themes/bootstrap-#{theme}.css", url_type: :asset)
+  icons_url = Scarpe::Webview.asset_server.asset_url("#{comp_dir}/assets/bootstrap-themes/bootstrap-icons.min.css", url_type: :asset)
+
+  <<~HTML
+    <html>
+      <head id='head-wvroot'>
+        <meta charset="utf-8">
+        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+        <link rel="stylesheet" href=#{theme_url.inspect}>
+        <link rel="stylesheet" href=#{icons_url.inspect}>
+        <style id='style-wvroot'>
+          /** Style resets **/
+          body {
+            height: 100%;
+            overflow: hidden;
+          }
+        </style>
+      </head>
+      <body id='body-wvroot'>
+        <div id='wrapper-wvroot'></div>
+
+        <script src=#{bootstrap_js_url}></script>
+      </body>
+    </html>
+  HTML
+end
+
+
+ +
+

+ + #para_element(props, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+
+
# File 'scarpe-components/lib/scarpe/components/tiranti.rb', line 148
+
+def para_element(props, &block)
+  ps, _extra = para_style(props)
+  size = ps[:"font-size"] || "12px"
+  size_int = size.to_i # Mostly useful if it's something like "12px"
+  if size.include?("calc") || size.end_with?("%")
+    # Very big text!
+    props["tag"] = "h2"
+  elsif size_int >= 48
+    props["tag"] = "h1"
+  elsif size_int >= 34
+    props["tag"] = "h2"
+  elsif size_int >= 26
+    props["tag"] = "h3"
+  else
+    props["tag"] = "p"
+  end
+
+  super
+end
+
+
+ +
+

+ + #progress_element(props) ⇒ Object + + + + + +

+ + + + +
+
+
+
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+
+
# File 'scarpe-components/lib/scarpe/components/tiranti.rb', line 129
+
+def progress_element(props)
+  progress_style = drawable_style(props).merge({
+    width: "90%",
+  })
+  HTML.render do |h|
+    h.div(id: html_id, class: "progress", style: progress_style) do
+      pct = "%.1f" % ((props["fraction"] || 0.0) * 100.0)
+      h.div(
+        class: "progress-bar progress-bar-striped progress-bar-animated",
+        role: "progressbar",
+        "aria-valuenow": pct,
+        "aria-valuemin": 0,
+        "aria-valuemax": 100,
+        style: "width: #{pct}%",
+      )
+    end
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/ConnectionError.html b/Scarpe/ConnectionError.html new file mode 100644 index 000000000..1c19ccf94 --- /dev/null +++ b/Scarpe/ConnectionError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::ConnectionError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::ConnectionError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/DatagramSendError.html b/Scarpe/DatagramSendError.html new file mode 100644 index 000000000..bc092b58a --- /dev/null +++ b/Scarpe/DatagramSendError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::DatagramSendError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::DatagramSendError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/DuplicateCallbackError.html b/Scarpe/DuplicateCallbackError.html new file mode 100644 index 000000000..6a39ecce0 --- /dev/null +++ b/Scarpe/DuplicateCallbackError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::DuplicateCallbackError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::DuplicateCallbackError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/DuplicateFileError.html b/Scarpe/DuplicateFileError.html new file mode 100644 index 000000000..551e577d2 --- /dev/null +++ b/Scarpe/DuplicateFileError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::DuplicateFileError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::DuplicateFileError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/EmptyPageNotSetError.html b/Scarpe/EmptyPageNotSetError.html new file mode 100644 index 000000000..e174f7b65 --- /dev/null +++ b/Scarpe/EmptyPageNotSetError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::EmptyPageNotSetError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::EmptyPageNotSetError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Error.html b/Scarpe/Error.html new file mode 100644 index 000000000..4186a6963 --- /dev/null +++ b/Scarpe/Error.html @@ -0,0 +1,140 @@ + + + + + + + Exception: Scarpe::Error + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ + \ No newline at end of file diff --git a/Scarpe/FileContentError.html b/Scarpe/FileContentError.html new file mode 100644 index 000000000..12611676b --- /dev/null +++ b/Scarpe/FileContentError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::FileContentError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::FileContentError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/IllegalDispatchEventError.html b/Scarpe/IllegalDispatchEventError.html new file mode 100644 index 000000000..3c5f8a1c9 --- /dev/null +++ b/Scarpe/IllegalDispatchEventError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::IllegalDispatchEventError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::IllegalDispatchEventError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/IllegalSubscribeEventError.html b/Scarpe/IllegalSubscribeEventError.html new file mode 100644 index 000000000..31fa2a702 --- /dev/null +++ b/Scarpe/IllegalSubscribeEventError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::IllegalSubscribeEventError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::IllegalSubscribeEventError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/InternalError.html b/Scarpe/InternalError.html new file mode 100644 index 000000000..4f40d52f3 --- /dev/null +++ b/Scarpe/InternalError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::InternalError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::InternalError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/InvalidClassError.html b/Scarpe/InvalidClassError.html new file mode 100644 index 000000000..5062e2e8a --- /dev/null +++ b/Scarpe/InvalidClassError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::InvalidClassError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::InvalidClassError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/InvalidHTMLTag.html b/Scarpe/InvalidHTMLTag.html new file mode 100644 index 000000000..f42041760 --- /dev/null +++ b/Scarpe/InvalidHTMLTag.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::InvalidHTMLTag + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::InvalidHTMLTag + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/InvalidOperationError.html b/Scarpe/InvalidOperationError.html new file mode 100644 index 000000000..355f81487 --- /dev/null +++ b/Scarpe/InvalidOperationError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::InvalidOperationError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::InvalidOperationError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/InvalidPromiseError.html b/Scarpe/InvalidPromiseError.html new file mode 100644 index 000000000..fa78db7a3 --- /dev/null +++ b/Scarpe/InvalidPromiseError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::InvalidPromiseError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::InvalidPromiseError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/JSBindingError.html b/Scarpe/JSBindingError.html new file mode 100644 index 000000000..b3407fa49 --- /dev/null +++ b/Scarpe/JSBindingError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::JSBindingError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::JSBindingError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/JSEvalError.html b/Scarpe/JSEvalError.html new file mode 100644 index 000000000..051b2ea1a --- /dev/null +++ b/Scarpe/JSEvalError.html @@ -0,0 +1,228 @@ + + + + + + + Exception: Scarpe::JSEvalError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::JSEvalError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ +

Overview

+
+

This error indicates a problem when running ConfirmedEval

+ + +
+
+
+ + +
+

Direct Known Subclasses

+

JSInternalError, JSRuntimeError, JSTimeoutError

+
+ + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + +
+

Constructor Details

+ +
+

+ + #initialize(data) ⇒ JSEvalError + + + + + +

+
+

Returns a new instance of JSEvalError.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+52
+53
+54
+55
+
+
# File 'lib/scarpe/errors.rb', line 52
+
+def initialize(data)
+  @data = data
+  super(data[:msg] || (self.class.name + "!"))
+end
+
+
+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/JSInitError.html b/Scarpe/JSInitError.html new file mode 100644 index 000000000..81c0c06e5 --- /dev/null +++ b/Scarpe/JSInitError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::JSInitError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::JSInitError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/JSInternalError.html b/Scarpe/JSInternalError.html new file mode 100644 index 000000000..afaa3e9af --- /dev/null +++ b/Scarpe/JSInternalError.html @@ -0,0 +1,161 @@ + + + + + + + Exception: Scarpe::JSInternalError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::JSInternalError + + + +

+
+ +
+
Inherits:
+
+ JSEvalError + +
    +
  • Object
  • + + + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ +

Overview

+
+

We got weird or nonsensical results that seem like an error on WebWrangler's part

+ + +
+
+
+ + +
+ + + + + + + + + + + + + +

Method Summary

+ +

Methods inherited from JSEvalError

+

#initialize

+ + + + + + + +
+

Constructor Details

+ +

This class inherits a constructor from Scarpe::JSEvalError

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/JSRedrawError.html b/Scarpe/JSRedrawError.html new file mode 100644 index 000000000..0ae04ffdb --- /dev/null +++ b/Scarpe/JSRedrawError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::JSRedrawError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::JSRedrawError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/JSRuntimeError.html b/Scarpe/JSRuntimeError.html new file mode 100644 index 000000000..730a3d815 --- /dev/null +++ b/Scarpe/JSRuntimeError.html @@ -0,0 +1,161 @@ + + + + + + + Exception: Scarpe::JSRuntimeError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::JSRuntimeError + + + +

+
+ +
+
Inherits:
+
+ JSEvalError + +
    +
  • Object
  • + + + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ +

Overview

+
+

An error running the supplied JS code string in confirmed_eval

+ + +
+
+
+ + +
+ + + + + + + + + + + + + +

Method Summary

+ +

Methods inherited from JSEvalError

+

#initialize

+ + + + + + + +
+

Constructor Details

+ +

This class inherits a constructor from Scarpe::JSEvalError

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/JSTimeoutError.html b/Scarpe/JSTimeoutError.html new file mode 100644 index 000000000..9112301ab --- /dev/null +++ b/Scarpe/JSTimeoutError.html @@ -0,0 +1,161 @@ + + + + + + + Exception: Scarpe::JSTimeoutError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::JSTimeoutError + + + +

+
+ +
+
Inherits:
+
+ JSEvalError + +
    +
  • Object
  • + + + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ +

Overview

+
+

The code timed out for some reason

+ + +
+
+
+ + +
+ + + + + + + + + + + + + +

Method Summary

+ +

Methods inherited from JSEvalError

+

#initialize

+ + + + + + + +
+

Constructor Details

+ +

This class inherits a constructor from Scarpe::JSEvalError

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/MissingAppError.html b/Scarpe/MissingAppError.html new file mode 100644 index 000000000..5cfd1974b --- /dev/null +++ b/Scarpe/MissingAppError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::MissingAppError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::MissingAppError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/MissingAttributeError.html b/Scarpe/MissingAttributeError.html new file mode 100644 index 000000000..2a9876868 --- /dev/null +++ b/Scarpe/MissingAttributeError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::MissingAttributeError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::MissingAttributeError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/MissingBlockError.html b/Scarpe/MissingBlockError.html new file mode 100644 index 000000000..a57fc7828 --- /dev/null +++ b/Scarpe/MissingBlockError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::MissingBlockError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::MissingBlockError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/MissingClassError.html b/Scarpe/MissingClassError.html new file mode 100644 index 000000000..6ffe5dc1d --- /dev/null +++ b/Scarpe/MissingClassError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::MissingClassError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::MissingClassError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/MissingDocRootError.html b/Scarpe/MissingDocRootError.html new file mode 100644 index 000000000..9f8101436 --- /dev/null +++ b/Scarpe/MissingDocRootError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::MissingDocRootError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::MissingDocRootError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/MissingWranglerError.html b/Scarpe/MissingWranglerError.html new file mode 100644 index 000000000..a952fbd62 --- /dev/null +++ b/Scarpe/MissingWranglerError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::MissingWranglerError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::MissingWranglerError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/MustOverrideMethod.html b/Scarpe/MustOverrideMethod.html new file mode 100644 index 000000000..f7e6b7f52 --- /dev/null +++ b/Scarpe/MustOverrideMethod.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::MustOverrideMethod + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::MustOverrideMethod + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/NoOperationError.html b/Scarpe/NoOperationError.html new file mode 100644 index 000000000..1eb25eb47 --- /dev/null +++ b/Scarpe/NoOperationError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::NoOperationError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::NoOperationError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/NoSuchFile.html b/Scarpe/NoSuchFile.html new file mode 100644 index 000000000..85071d38b --- /dev/null +++ b/Scarpe/NoSuchFile.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::NoSuchFile + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::NoSuchFile + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/NonexistentEvalResultError.html b/Scarpe/NonexistentEvalResultError.html new file mode 100644 index 000000000..2b6c03750 --- /dev/null +++ b/Scarpe/NonexistentEvalResultError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::NonexistentEvalResultError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::NonexistentEvalResultError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/OperationNotAllowedError.html b/Scarpe/OperationNotAllowedError.html new file mode 100644 index 000000000..ed4fa8a2b --- /dev/null +++ b/Scarpe/OperationNotAllowedError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::OperationNotAllowedError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::OperationNotAllowedError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/PeriodicHandlerSetupError.html b/Scarpe/PeriodicHandlerSetupError.html new file mode 100644 index 000000000..bc4a9e0dd --- /dev/null +++ b/Scarpe/PeriodicHandlerSetupError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::PeriodicHandlerSetupError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::PeriodicHandlerSetupError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Promise.html b/Scarpe/Promise.html new file mode 100644 index 000000000..a71d1c548 --- /dev/null +++ b/Scarpe/Promise.html @@ -0,0 +1,1885 @@ + + + + + + + Class: Scarpe::Promise + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Promise + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + +
+
Includes:
+
Shoes::Log
+
+ + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/promises.rb
+
+ +
+ +

Overview

+
+

Scarpe::Promise is a promises library, but one with no form of built-in +concurrency. Instead, promise callbacks are executed synchronously. +Even execution is usually synchronous, but can also be handled manually +for forms of execution not controlled in Ruby (like Webview.)

+ +

Funny thing... We need promises as an API concept since we have a JS event +loop doing its thing, and we need to respond to actions that it takes. +But there's not really a Ruby implementation of Promises without an +attached form of concurrency. So here we are, writing our own :-/

+ +

In theory you could probably write some kind of "no-op thread pool" +for the ruby-concurrency gem, pass it manually to every promise we +created and then raise an exception any time we tried to do something +in the background. That's probably more code than writing our own, though, +and we'd be fighting it constantly.

+ +

This class is inspired by concurrent-ruby Promise +which is inspired by Javascript Promises, which is what we actually need +for our use case. We can't easily tell when our WebView begins processing +our request, which removes the :processing state. This can be used for +executing JS, but also generally waiting on events.

+ +

We don't fully control ordering here, so it is conceivable that a +child waiting on a parent can be randomly fulfilled, even if we didn't +expect it. We don't consider that an error. Similarly, we'll call +on_scheduled callbacks if a promise is fulfilled, even though we +never explicitly scheduled it. If a promise is rejected without +ever being scheduled, we won't call those callbacks.

+ + +
+
+
+ + +
+ +

+ Constant Summary + collapse +

+ +
+ +
PROMISE_STATES = +
+
+

The unscheduled promise state means it's waiting on a parent promise that +hasn't completed yet. The pending state means it's waiting to execute. +Fulfilled means it has completed successfully and returned a value, +while rejected means it has failed, normally producing a reason.

+ + +
+
+
+ + +
+
+
[:unscheduled, :pending, :fulfilled, :rejected]
+ +
+ + + + + + +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #parents ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    The parent promises of this promise, sometimes an empty array.

    +
    + +
  • + + +
  • + + + #reason ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    If the promise is rejected, this is the reason, sometimes an exception.

    +
    + +
  • + + +
  • + + + #returned_value ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    If the promise is fulfilled, this is the value returned.

    +
    + +
  • + + +
  • + + + #state ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    The state of the promise, which should be one of PROMISE_STATES.

    +
    + +
  • + + +
+ + + + + +

+ Class Method Summary + collapse +

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+
+

Constructor Details

+ +
+

+ + #initialize(state: nil, parents: []) { ... } ⇒ Promise + + + + + +

+
+

The Promise.new method, along with all the various handlers, +are pretty raw. They'll do what promises do, but they're not +the prettiest. However, they ensure that guarantees are made +and so on, so they're great as plumbing under the syntactic +sugar above.

+ +

Note that the state passed in may not be the actual initial +state. If a parent is rejected, the state will become +rejected. If no parents are waiting or failed then a state +of nil or :unscheduled will become :pending.

+ + +
+
+
+

Parameters:

+
    + +
  • + + state + + + (Symbol) + + + (defaults to: nil) + + + — +

    One of PROMISE_STATES for the initial state

    +
    + +
  • + +
  • + + parents + + + (Array) + + + (defaults to: []) + + + — +

    A list of promises that must be fulfilled before this one is scheduled

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +

    A block that executes when this promise is scheduled - when its parents, if any, are all fulfilled

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+
+
# File 'scarpe-components/lib/scarpe/components/promises.rb', line 99
+
+def initialize(state: nil, parents: [], &scheduler)
+  log_init("Promise")
+
+  # These are as initially specified, and effectively immutable
+  @state = state
+  @parents = parents
+
+  # These are what we're waiting on, and will be
+  # removed as time goes forward.
+  @waiting_on = parents.select { |p| !p.complete? }
+  @on_fulfilled = []
+  @on_rejected = []
+  @on_scheduled = []
+  @scheduler = scheduler
+  @executor = nil
+  @returned_value = nil
+  @reason = nil
+
+  if complete?
+    # Did we start out already fulfilled or rejected?
+    # If so, we can skip a lot of fiddly checking.
+    # Don't need a scheduler or to care about parents
+    # or anything.
+    @waiting_on = []
+    @scheduler = nil
+  elsif @parents.any? { |p| p.state == :rejected }
+    @state = :rejected
+    @waiting_on = []
+    @scheduler =  nil
+  elsif @state == :pending
+    # Did we get an explicit :pending? Then we don't need
+    # to schedule ourselves, or care about the scheduler
+    # in general.
+    @scheduler = nil
+  elsif @state.nil? || @state == :unscheduled
+    # If no state was given or we're unscheduled, we'll
+    # wait until our parents have all completed to
+    # schedule ourselves.
+
+    if @waiting_on.empty?
+      # No further dependencies, we can schedule ourselves
+      @state = :pending
+
+      # We have no on_scheduled handlers yet, but this will
+      # call and clear the scheduler.
+      call_handlers_for(:pending)
+    else
+      # We're still waiting on somebody, no scheduling yet
+      @state = :unscheduled
+      @waiting_on.each do |dep|
+        dep.on_fulfilled { parent_fulfilled!(dep) }
+        dep.on_rejected { parent_rejected!(dep) }
+      end
+    end
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #parentsObject (readonly) + + + + + +

+
+

The parent promises of this promise, sometimes an empty array

+ + +
+
+
+ + +
+ + + + +
+
+
+
+47
+48
+49
+
+
# File 'scarpe-components/lib/scarpe/components/promises.rb', line 47
+
+def parents
+  @parents
+end
+
+
+ + + +
+

+ + #reasonObject (readonly) + + + + + +

+
+

If the promise is rejected, this is the reason, sometimes an exception

+ + +
+
+
+ + +
+ + + + +
+
+
+
+53
+54
+55
+
+
# File 'scarpe-components/lib/scarpe/components/promises.rb', line 53
+
+def reason
+  @reason
+end
+
+
+ + + +
+

+ + #returned_valueObject (readonly) + + + + + +

+
+

If the promise is fulfilled, this is the value returned

+ + +
+
+
+ + +
+ + + + +
+
+
+
+50
+51
+52
+
+
# File 'scarpe-components/lib/scarpe/components/promises.rb', line 50
+
+def returned_value
+  @returned_value
+end
+
+
+ + + +
+

+ + #stateObject (readonly) + + + + + +

+
+

The state of the promise, which should be one of PROMISE_STATES

+ + +
+
+
+ + +
+ + + + +
+
+
+
+44
+45
+46
+
+
# File 'scarpe-components/lib/scarpe/components/promises.rb', line 44
+
+def state
+  @state
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + .fulfilled(return_val = nil, parents: [], &block) ⇒ Object + + + + + +

+
+

Create a promise and then instantly fulfill it.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+56
+57
+58
+59
+60
+
+
# File 'scarpe-components/lib/scarpe/components/promises.rb', line 56
+
+def self.fulfilled(return_val = nil, parents: [], &block)
+  p = Promise.new(parents: parents, &block)
+  p.fulfilled!(return_val)
+  p
+end
+
+
+ +
+

+ + .rejected(reason = nil, parents: []) ⇒ Object + + + + + +

+
+

Create a promise and then instantly reject it.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+63
+64
+65
+66
+67
+
+
# File 'scarpe-components/lib/scarpe/components/promises.rb', line 63
+
+def self.rejected(reason = nil, parents: [])
+  p = Promise.new(parents: parents)
+  p.rejected!(reason)
+  p
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + #complete?Boolean + + + + + +

+
+

Return true if the Promise is either fulfilled or rejected.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    true if the promise is fulfilled or rejected

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+159
+160
+161
+
+
# File 'scarpe-components/lib/scarpe/components/promises.rb', line 159
+
+def complete?
+  @state == :fulfilled || @state == :rejected
+end
+
+
+ +
+

+ + #fulfilled!(value = nil) ⇒ Object + + + + + +

+
+

Fulfill the promise, setting the returned_value to value

+ + +
+
+
+ + +
+ + + + +
+
+
+
+70
+71
+72
+
+
# File 'scarpe-components/lib/scarpe/components/promises.rb', line 70
+
+def fulfilled!(value = nil)
+  set_state(:fulfilled, value)
+end
+
+
+ +
+

+ + #fulfilled?Boolean + + + + + +

+
+

Return true if the promise is already fulfilled.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    true if the promise is fulfilled

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+166
+167
+168
+
+
# File 'scarpe-components/lib/scarpe/components/promises.rb', line 166
+
+def fulfilled?
+  @state == :fulfilled
+end
+
+
+ +
+

+ + #inspectObject + + + + + +

+
+

An inspect method to give slightly smaller output, for ease of reading in irb

+ + +
+
+
+ + +
+ + + + +
+
+
+
+178
+179
+180
+181
+182
+183
+184
+185
+186
+
+
# File 'scarpe-components/lib/scarpe/components/promises.rb', line 178
+
+def inspect
+  "#<Scarpe::Promise:#{object_id} " +
+    "@state=#{@state.inspect} @parents=#{@parents.inspect} " +
+    "@waiting_on=#{@waiting_on.inspect} @on_fulfilled=#{@on_fulfilled.size} " +
+    "@on_rejected=#{@on_rejected.size} @on_scheduled=#{@on_scheduled.size} " +
+    "@scheduler=#{@scheduler ? "Y" : "N"} @executor=#{@executor ? "Y" : "N"} " +
+    "@returned_value=#{@returned_value.inspect} @reason=#{@reason.inspect}" +
+    ">"
+end
+
+
+ +
+

+ + #on_fulfilled { ... } ⇒ Scarpe::Promise + + + + + +

+
+

Register a handler to be called when the promise is fulfilled. +If called on a fulfilled promise, the handler will be called immediately.

+ + +
+
+
+ +

Yields:

+
    + +
  • + + + + + + + +

    Handler to be called on fulfilled

    +
    + +
  • + +
+

Returns:

+ + +
+ + + + +
+
+
+
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+
+
# File 'scarpe-components/lib/scarpe/components/promises.rb', line 390
+
+def on_fulfilled(&handler)
+  unless handler
+    raise Shoes::Errors::InvalidAttributeValueError, "You must pass a block to on_fulfilled!"
+  end
+
+  case @state
+  when :fulfilled
+    handler.call(*@parents.map(&:returned_value))
+  when :pending, :unscheduled
+    @on_fulfilled << handler
+  when :rejected
+    # Do nothing
+  end
+
+  self
+end
+
+
+ +
+

+ + #on_rejected { ... } ⇒ Scarpe::Promise + + + + + +

+
+

Register a handler to be called when the promise is rejected. +If called on a rejected promise, the handler will be called immediately.

+ + +
+
+
+ +

Yields:

+
    + +
  • + + + + + + + +

    Handler to be called on rejected

    +
    + +
  • + +
+

Returns:

+ + +
+ + + + +
+
+
+
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+
+
# File 'scarpe-components/lib/scarpe/components/promises.rb', line 412
+
+def on_rejected(&handler)
+  unless handler
+    raise Shoes::Errors::InvalidAttributeValueError, "You must pass a block to on_rejected!"
+  end
+
+  case @state
+  when :rejected
+    handler.call(*@parents.map(&:returned_value))
+  when :pending, :unscheduled
+    @on_rejected << handler
+  when :fulfilled
+    # Do nothing
+  end
+
+  self
+end
+
+
+ +
+

+ + #on_scheduled { ... } ⇒ Scarpe::Promise + + + + + +

+
+

Register a handler to be called when the promise is scheduled. +If called on a promise that was scheduled earlier, the handler +will be called immediately.

+ + +
+
+
+ +

Yields:

+
    + +
  • + + + + + + + +

    Handler to be called on scheduled

    +
    + +
  • + +
+

Returns:

+ + +
+ + + + +
+
+
+
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+
+
# File 'scarpe-components/lib/scarpe/components/promises.rb', line 435
+
+def on_scheduled(&handler)
+  unless handler
+    raise Shoes::Errors::InvalidAttributeValueError, "You must pass a block to on_scheduled!"
+  end
+
+  # Add a pending handler or call it now
+  case @state
+  when :fulfilled, :pending
+    handler.call(*@parents.map(&:returned_value))
+  when :unscheduled
+    @on_scheduled << handler
+  when :rejected
+    # Do nothing
+  end
+
+  self
+end
+
+
+ +
+

+ + #rejected!(reason = nil) ⇒ Object + + + + + +

+
+

Reject the promise, setting the reason to reason

+ + +
+
+
+ + +
+ + + + +
+
+
+
+75
+76
+77
+
+
# File 'scarpe-components/lib/scarpe/components/promises.rb', line 75
+
+def rejected!(reason = nil)
+  set_state(:rejected, reason)
+end
+
+
+ +
+

+ + #rejected?Boolean + + + + + +

+
+

Return true if the promise is already rejected.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    true if the promise is rejected

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+173
+174
+175
+
+
# File 'scarpe-components/lib/scarpe/components/promises.rb', line 173
+
+def rejected?
+  @state == :rejected
+end
+
+
+ +
+

+ + #then(&block) ⇒ Object + + + + + +

+
+

Create a new promise with this promise as a parent. It runs the +specified code in block when scheduled.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+81
+82
+83
+
+
# File 'scarpe-components/lib/scarpe/components/promises.rb', line 81
+
+def then(&block)
+  Promise.new(parents: [self], &block)
+end
+
+
+ +
+

+ + #to_execute(&block) ⇒ Object + + + + + +

+
+

These promises are mostly designed for external execution. +You could put together your own thread-pool, or use RPC, +a WebView, a database or similar source of external calculation. +But in many cases it's reasonable to execute locally. +In those cases, you can register an executor which will be +called when the promise is ready to execute but has not yet +done so. Registering an executor on a promise that is +already fulfilled is an error. Registering an executor on +a promise that has already rejected is a no-op.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+
+
# File 'scarpe-components/lib/scarpe/components/promises.rb', line 197
+
+def to_execute(&block)
+  case @state
+  when :fulfilled
+    # Should this be a no-op instead?
+    raise Scarpe::NoOperationError, "Registering an executor on an already fulfilled promise means it will never run!"
+  when :rejected
+    return
+  when :unscheduled
+    @executor = block # save for later
+  when :pending
+    @executor = block
+    call_executor
+  else
+    raise Scarpe::InternalError, "Internal error, illegal state!"
+  end
+
+  self
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/ShoesSpecProxy.html b/Scarpe/ShoesSpecProxy.html new file mode 100644 index 000000000..f7f4d9d2d --- /dev/null +++ b/Scarpe/ShoesSpecProxy.html @@ -0,0 +1,657 @@ + + + + + + + Class: Scarpe::ShoesSpecProxy + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::ShoesSpecProxy + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/shoes_spec.rb
+
+ +
+ + + +

+ Constant Summary + collapse +

+ +
+ +
JS_EVENTS = + +
+
[:click, :hover, :leave, :change]
+ +
+ + + + + +

Instance Attribute Summary collapse

+
    + +
  • + + + #display ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute display.

    +
    + +
  • + + +
  • + + + #linkable_id ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute linkable_id.

    +
    + +
  • + + +
  • + + + #obj ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute obj.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + collapse +

+ + + + +
+

Constructor Details

+ +
+

+ + #initialize(obj) ⇒ ShoesSpecProxy + + + + + +

+
+

Returns a new instance of ShoesSpecProxy.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+64
+65
+66
+67
+68
+69
+70
+71
+72
+
+
# File 'lib/scarpe/shoes_spec.rb', line 64
+
+def initialize(obj)
+  @obj = obj
+  @linkable_id = obj.linkable_id
+  @display = ::Shoes::DisplayService.display_service.query_display_drawable_for(obj.linkable_id)
+
+  unless @display
+    raise "Can't find display widget for #{obj.inspect}!"
+  end
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + +

+ +
+

+ + #method_missing(method) ⇒ Object + + + + + +

+ + + + +
+
+
+
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+
+
# File 'lib/scarpe/shoes_spec.rb', line 74
+
+def method_missing(method, ...)
+  if @obj.respond_to?(method)
+    self.singleton_class.define_method(method) do |*args, **kwargs, &block|
+      @obj.send(method, *args, **kwargs, &block)
+    end
+    send(method, ...)
+  else
+    super # raise an exception
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #displayObject (readonly) + + + + + +

+
+

Returns the value of attribute display.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+60
+61
+62
+
+
# File 'lib/scarpe/shoes_spec.rb', line 60
+
+def display
+  @display
+end
+
+
+ + + +
+

+ + #linkable_idObject (readonly) + + + + + +

+
+

Returns the value of attribute linkable_id.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+59
+60
+61
+
+
# File 'lib/scarpe/shoes_spec.rb', line 59
+
+def linkable_id
+  @linkable_id
+end
+
+
+ + + +
+

+ + #objObject (readonly) + + + + + +

+
+

Returns the value of attribute obj.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+58
+59
+60
+
+
# File 'lib/scarpe/shoes_spec.rb', line 58
+
+def obj
+  @obj
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #respond_to_missing?(method_name, include_private = false) ⇒ Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+96
+97
+98
+
+
# File 'lib/scarpe/shoes_spec.rb', line 96
+
+def respond_to_missing?(method_name, include_private = false)
+  @obj.respond_to_missing?(method_name, include_private)
+end
+
+
+ +
+

+ + #trigger(event_name, *args) ⇒ Object + + + + + +

+ + + + +
+
+
+
+85
+86
+87
+88
+
+
# File 'lib/scarpe/shoes_spec.rb', line 85
+
+def trigger(event_name, *args)
+  name = "#{@linkable_id}-#{event_name}"
+  Scarpe::Webview::DisplayService.instance.app.handle_callback(name, *args)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/ShoesSpecTest.html b/Scarpe/ShoesSpecTest.html new file mode 100644 index 000000000..63e7d9dd1 --- /dev/null +++ b/Scarpe/ShoesSpecTest.html @@ -0,0 +1,483 @@ + + + + + + + Module: Scarpe::ShoesSpecTest + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::ShoesSpecTest + + + +

+
+ + + + + + +
+
Includes:
+
Test::HTMLAssertions
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/shoes_spec.rb
+
+ +
+ +

Overview

+
+

When running ShoesSpec tests, we create a parent class for all of them +with the appropriate convenience methods and accessors.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Test::HTMLAssertions

+

#assert_contains_html, #assert_html

+ + +
+

Instance Method Details

+ + +
+

+ + #catscradle_dsl(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+127
+128
+129
+
+
# File 'lib/scarpe/shoes_spec.rb', line 127
+
+def catscradle_dsl(&block)
+  Scarpe::CCInstance.instance.instance_eval(&block)
+end
+
+
+ +
+

+ + #dom_htmlObject + + + + + +

+ + + + +
+
+
+
+131
+132
+133
+134
+135
+136
+
+
# File 'lib/scarpe/shoes_spec.rb', line 131
+
+def dom_html
+  catscradle_dsl do
+    wait fully_updated
+    dom_html
+  end
+end
+
+
+ +
+

+ + #drawable(*specs) ⇒ Object + + + + + +

+
+ + +
+
+
+ +

Raises:

+
    + +
  • + + + (Scarpe::MultipleDrawablesFoundError) + + + +
  • + +
+ +
+ + + + +
+
+
+
+119
+120
+121
+122
+123
+124
+125
+
+
# File 'lib/scarpe/shoes_spec.rb', line 119
+
+def drawable(*specs)
+  drawables = app.find_drawables_by(*specs)
+  raise Scarpe::MultipleDrawablesFoundError, "Found more than one #{finder_name} matching #{args.inspect}!" if drawables.size > 1
+  raise Scarpe::NoDrawablesFoundError, "Found no #{finder_name} matching #{args.inspect}!" if drawables.empty?
+
+  Scarpe::ShoesSpecProxy.new(drawables[0])
+end
+
+
+ +
+

+ + #exit_on_first_heartbeatObject + + + + + +

+ + + + +
+
+
+
+152
+153
+154
+155
+156
+157
+158
+159
+
+
# File 'lib/scarpe/shoes_spec.rb', line 152
+
+def exit_on_first_heartbeat
+  catscradle_dsl do
+    on_event(:next_heartbeat) do
+      @log.info "Exiting on first heartbeat (exit code #{exit_code})"
+      exit 0
+    end
+  end
+end
+
+
+ +
+

+ + #timeout(t_timeout = 5.0) ⇒ Object + + + + + +

+
+

A timeout won't cause an error by itself. If you want an error, make sure +to check for a minimum number of assertions or otherwise look for progress.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+
+
# File 'lib/scarpe/shoes_spec.rb', line 140
+
+def timeout(t_timeout = 5.0)
+  catscradle_dsl do
+    t0 = Time.now
+    on_event(:every_heartbeat) do
+      if Time.now - t0 >= t_timeout
+        @log.info "Timed out after #{t_timeout} seconds!"
+        shut_down_shoes_code
+      end
+    end
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Test.html b/Scarpe/Test.html new file mode 100644 index 000000000..8291f94bf --- /dev/null +++ b/Scarpe/Test.html @@ -0,0 +1,282 @@ + + + + + + + Module: Scarpe::Test + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::Test + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/shoes_spec.rb,
+ scarpe-components/lib/scarpe/components/unit_test_helpers.rb
+
+
+ +
+ +

Overview

+
+

Test framework code to allow Scarpe to execute Shoes-Spec test code. +This will run inside the exe/scarpe child process, then send +results back to the parent Minitest process.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: HTMLAssertions, Helpers, LoggedTest + + + + +

+ + + + + + + + +

+ Class Method Summary + collapse +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + .run_shoes_spec_test_code(code, class_name: nil, test_name: nil) ⇒ Object + + + + + +

+
+

Is it at all reasonable to define more than one test to run in the same Shoes run? Probably not. +They'll leave in-memory residue.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+
+
# File 'lib/scarpe/shoes_spec.rb', line 16
+
+def self.run_shoes_spec_test_code(code, class_name: nil, test_name: nil)
+  if @shoes_spec_init
+    raise Shoes::Errors::MultipleShoesSpecRunsError, "Scarpe-Webview can only run a single Shoes spec per process!"
+  end
+
+  @shoes_spec_init = true
+
+  require "scarpe/components/minitest_export_reporter"
+  Minitest::Reporters::ShoesExportReporter.activate!
+
+  class_name ||= ENV["SHOES_MINITEST_CLASS_NAME"] || "TestShoesSpecCode"
+  test_name ||= ENV["SHOES_MINITEST_METHOD_NAME"] || "test_shoes_spec"
+
+  Scarpe::CCInstance.include Scarpe::ShoesSpecTest
+
+  Scarpe::CCInstance.instance.instance_eval do
+    event_init
+
+    t_timeout = ENV["SCARPE_SSPEC_TIMEOUT"] || "30"
+    timeout(t_timeout.to_f) unless t_timeout.downcase == "none"
+
+    on_event(:next_heartbeat) do
+      Minitest.run ARGV
+
+      wait_after = ENV["SCARPE_SSPEC_TIMEOUT_WAIT_AFTER_TEST"]
+      if !(wait_after && wait_after.downcase != "n" && wait_after.downcase != "no")
+        shut_down_shoes_code
+      end
+    end
+  end
+
+  test_class = Class.new(Minitest::Test)
+  test_class.include Scarpe::ShoesSpecTest
+  Object.const_set(Scarpe::Components::StringHelpers.camelize(class_name), test_class)
+  test_name = "test_" + test_name unless test_name.start_with?("test_")
+  test_class.define_method(test_name) do
+    eval(code)
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Test/HTMLAssertions.html b/Scarpe/Test/HTMLAssertions.html new file mode 100644 index 000000000..46241dac1 --- /dev/null +++ b/Scarpe/Test/HTMLAssertions.html @@ -0,0 +1,419 @@ + + + + + + + Module: Scarpe::Test::HTMLAssertions + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::Test::HTMLAssertions + + + +

+
+ + + + + + + + + +
+
Included in:
+
ShoesSpecTest
+
+ + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/unit_test_helpers.rb
+
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #assert_contains_html(actual_html, expected_tag, **opts) { ... } ⇒ void + + + + + +

+
+

This method returns an undefined value.

Assert that actual_html includes expected_tag with opts. +This uses Scarpe's HTML tag-based renderer to render the tag and options +into text, and valides that the full HTML contains that tag.

+ + +
+
+
+

Parameters:

+
    + +
  • + + actual_html + + + (String) + + + + — +

    the html to compare to

    +
    + +
  • + +
  • + + expected_tag + + + (String, Symbol) + + + + — +

    the HTML tag, used to send a method call

    +
    + +
  • + +
  • + + opts + + + + + + + — +

    keyword options passed to the tag method call

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +

    block passed to the tag method call.

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+252
+253
+254
+255
+256
+257
+258
+
+
# File 'scarpe-components/lib/scarpe/components/unit_test_helpers.rb', line 252
+
+def assert_contains_html(actual_html, expected_tag, **opts, &block)
+  expected_html = Scarpe::Components::HTML.render do |h|
+    h.public_send(expected_tag, opts, &block)
+  end
+
+  assert actual_html.include?(expected_html), "Expected #{actual_html.inspect} to include #{expected_html.inspect}!"
+end
+
+
+ +
+

+ + #assert_html(actual_html, expected_tag, **opts) { ... } ⇒ void + + + + + +

+
+

This method returns an undefined value.

Assert that actual_html is the same as expected_tag with opts. +This uses Scarpe's HTML tag-based renderer to render the tag and options +into text, and valides that the text is the same.

+ + +
+
+
+

Parameters:

+
    + +
  • + + actual_html + + + (String) + + + + — +

    the html to compare to

    +
    + +
  • + +
  • + + expected_tag + + + (String, Symbol) + + + + — +

    the HTML tag, used to send a method call

    +
    + +
  • + +
  • + + opts + + + + + + + — +

    keyword options passed to the tag method call

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +

    block passed to the tag method call.

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+233
+234
+235
+236
+237
+238
+239
+
+
# File 'scarpe-components/lib/scarpe/components/unit_test_helpers.rb', line 233
+
+def assert_html(actual_html, expected_tag, **opts, &block)
+  expected_html = Scarpe::Components::HTML.render do |h|
+    h.public_send(expected_tag, opts, &block)
+  end
+
+  assert_equal expected_html, actual_html
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Test/Helpers.html b/Scarpe/Test/Helpers.html new file mode 100644 index 000000000..420f0a088 --- /dev/null +++ b/Scarpe/Test/Helpers.html @@ -0,0 +1,264 @@ + + + + + + + Module: Scarpe::Test::Helpers + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::Test::Helpers + + + +

+
+ + + + + + +
+
Includes:
+
Components::FileHelpers, Components::ProcessHelpers
+
+ + + + +
+
Included in:
+
CCInstance
+
+ + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/unit_test_helpers.rb
+
+ +
+ +

Overview

+
+

General helpers for general usage. +Helpers here should not use Webview-specific functionality. +The intention is that these are helpers for various Scarpe display +services that do not necessarily use Webview.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Components::ProcessHelpers

+

#run_out_err_result

+ + + + + + + + + +

Methods included from Components::FileHelpers

+

#with_tempfile, #with_tempfiles

+ + +
+

Instance Method Details

+ + +
+

+ + #with_env_vars(envs) ⇒ Object + + + + + +

+
+

Temporarily set env vars for the block of code inside. The old environment +variable values will be restored after the block finishes.

+ + +
+
+
+

Parameters:

+
    + +
  • + + envs + + + (Hash<String,String>) + + + + — +

    A hash of environment variable names and values

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+
+
# File 'scarpe-components/lib/scarpe/components/unit_test_helpers.rb', line 30
+
+def with_env_vars(envs)
+  old_env = {}
+  envs.each do |k, v|
+    old_env[k] = ENV[k]
+    ENV[k] = v
+  end
+  yield
+ensure
+  old_env.each { |k, v| ENV[k] = v }
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Test/LoggedTest.html b/Scarpe/Test/LoggedTest.html new file mode 100644 index 000000000..81d116d28 --- /dev/null +++ b/Scarpe/Test/LoggedTest.html @@ -0,0 +1,1079 @@ + + + + + + + Module: Scarpe::Test::LoggedTest + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::Test::LoggedTest + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
scarpe-components/lib/scarpe/components/unit_test_helpers.rb
+
+ +
+ +

Overview

+
+

This test will save extensive logs in case of test failure. +Note that it defines setup/teardown methods. If you want +multiple setup/teardowns from multiple places to happen you +may need to explictly call (e.g. with logged_test_setup/teardown) +to ensure everything you want happens.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #extra_log_config=(additional_log_config) ⇒ Object + + + + + +

+
+

Set additional LoggedTest configuration for specific logs to separate or save. +This is normally going to be display-service-specific log components. +Note that this only really works with the modular logger or another logger +that does something useful with the log config. The simple print logger +doesn't do a lot with it.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+116
+117
+118
+
+
# File 'scarpe-components/lib/scarpe/components/unit_test_helpers.rb', line 116
+
+def extra_log_config=(additional_log_config)
+  @additional_log_config = additional_log_config
+end
+
+
+ +
+

+ + #file_idObject + + + + + +

+ + + + +
+
+
+
+54
+55
+56
+
+
# File 'scarpe-components/lib/scarpe/components/unit_test_helpers.rb', line 54
+
+def file_id
+  "#{self.class.name}_#{self.name}"
+end
+
+
+ +
+

+ + #log_config_for_testHash + + + + + +

+
+

This is the log config that LoggedTests use. It makes sure all components keep all +logs, but also splits the logs into several different files for later ease of scanning.

+ +

TODO: this shouldn't directly include any Webview entries like WebviewAPI or + CatsCradle. Those should be overridden in Webview.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Hash) + + + + — +

    the log config

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+127
+128
+129
+130
+131
+132
+
+
# File 'scarpe-components/lib/scarpe/components/unit_test_helpers.rb', line 127
+
+def log_config_for_test
+  {
+    "default" => ["debug", "logger/test_failure_#{file_id}.log"],
+    "DisplayService" => ["debug", "logger/test_failure_display_service_#{file_id}.log"],
+  }.merge(@additional_log_config || {})
+end
+
+
+ +
+

+ + #logfail_out_loc(filepath) ⇒ String + + + + + +

+
+

Failure log output location for a given file path. This is normally used internally to this +class, not externally.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +

    the output path

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+
+
# File 'scarpe-components/lib/scarpe/components/unit_test_helpers.rb', line 181
+
+def logfail_out_loc(filepath)
+  # Add a .out prefix before final .log
+  out_loc = filepath.gsub(%r{.log\Z}, ".out.log")
+
+  if out_loc == filepath
+    raise Shoes::Errors::InvalidAttributeValueError, "Something is wrong! Could not figure out failure-log output path for #{filepath.inspect}!"
+  end
+
+  if File.exist?(out_loc)
+    raise Scarpe::DuplicateFileError, "Duplicate test file #{out_loc.inspect}? This file should *not* already exist!"
+  end
+
+  out_loc
+end
+
+
+ +
+

+ + #logged_test_setupvoid + + + + + +

+
+

This method returns an undefined value.

This should be called by the test during setup to make sure that +failure logs will be saved if this test fails. It makes sure the +log config will save all logs from all sources, but keeps a copy +of the old log config to restore after the test is finished.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+
+
# File 'scarpe-components/lib/scarpe/components/unit_test_helpers.rb', line 64
+
+def logged_test_setup
+  # Make sure test failures will be saved at the end of the run.
+  # Delete stale test failures and logging only the *first* time this is called.
+  set_up_test_failures
+
+  @normal_log_config = Shoes::Log.current_log_config
+  Shoes::Log.configure_logger(log_config_for_test)
+
+  Shoes::Log.logger("LoggedTest").info("Test: #{self.class.name}##{self.name}")
+end
+
+
+ +
+

+ + #logged_test_teardownvoid + + + + + +

+
+

This method returns an undefined value.

After the test has finished, this will restore the old log configuration. +It will also save the logfiles, but only if the test failed, not if it +succeeded or was skipped.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+
+
# File 'scarpe-components/lib/scarpe/components/unit_test_helpers.rb', line 91
+
+def logged_test_teardown
+  # Restore previous log config
+  Shoes::Log.configure_logger(@normal_log_config)
+
+  if self.failure
+    save_failure_logs
+  else
+    remove_unsaved_logs
+  end
+end
+
+
+ +
+

+ + #remove_unsaved_logsvoid + + + + + +

+
+

This method returns an undefined value.

Remove unsaved failure logs. This is normally used internally, not externally.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+212
+213
+214
+215
+216
+217
+218
+
+
# File 'scarpe-components/lib/scarpe/components/unit_test_helpers.rb', line 212
+
+def remove_unsaved_logs
+  Dir["#{self.class.logger_dir}/test_failure*.log"].each do |f|
+    next if f.include?(".out.log") # Don't delete saved logs
+
+    File.unlink(f)
+  end
+end
+
+
+ +
+

+ + #save_failure_logsvoid + + + + + +

+
+

This method returns an undefined value.

Save the failure logs in the appropriate place(s). This is normally used internally, not externally.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+199
+200
+201
+202
+203
+204
+205
+206
+207
+
+
# File 'scarpe-components/lib/scarpe/components/unit_test_helpers.rb', line 199
+
+def save_failure_logs
+  saved_log_files.each do |log_file|
+    full_loc = File.expand_path("#{self.class.logger_dir}/#{log_file}")
+    # TODO: we'd like to skip 0-length logfiles. But also Logging doesn't flush. For now, ignore.
+    next unless File.exist?(full_loc)
+
+    FileUtils.mv full_loc, logfail_out_loc(full_loc)
+  end
+end
+
+
+ +
+

+ + #saved_log_filesObject + + + + + +

+
+

The list of logfiles that should be saved. Normally this is called internally by the +class, not externally from elsewhere.

+ +

This could be a lot simpler except I want to only update the file list in one place, +log_config_for_test(). Having a single spot should (I hope) make it a lot friendlier to +add more logfiles for different components, logged API objects, etc.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+140
+141
+142
+143
+144
+
+
# File 'scarpe-components/lib/scarpe/components/unit_test_helpers.rb', line 140
+
+def saved_log_files
+  lc = log_config_for_test
+  log_outfiles = lc.values.map { |_level, loc| loc }
+  log_outfiles.select { |s| s.start_with?("logger/") }.map { |s| s.delete_prefix("logger/") }
+end
+
+
+ +
+

+ + #set_up_test_failuresvoid + + + + + +

+
+

This method returns an undefined value.

Make sure that test failure logs will be noticed, and a message will be printed, +if any logged tests fail. This needs to be called at least once in any Minitest-enabled +process using logged tests.

+ + +
+
+
+ +

Raises:

+ + +
+ + + + +
+
+
+
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+
+
# File 'scarpe-components/lib/scarpe/components/unit_test_helpers.rb', line 151
+
+def set_up_test_failures
+  return if ALREADY_SET_UP_LOGGED_TEST_FAILURES[:setup]
+
+  log_dir = self.class.logger_dir
+  raise(Scarpe::MustOverrideMethod, "Must set logger directory!") unless log_dir
+  raise(Scarpe::NoSuchFile, "Can't find logger directory!") unless File.directory?(log_dir)
+
+  ALREADY_SET_UP_LOGGED_TEST_FAILURES[:setup] = true
+  # Delete stale test failures, if any, before starting the first failure-logged test
+  Dir["#{log_dir}/test_failure*.log"].each { |fn| File.unlink(fn) }
+
+  Minitest.after_run do
+    # Print test failure notice to console
+    unless Dir["#{log_dir}/test_failure*.out.log"].empty?
+      puts "Some tests have failed! See #{log_dir}/test_failure*.out.log for test logs!"
+    end
+
+    # Remove un-saved test logs
+    Dir["#{log_dir}/test_failure*.log"].each do |f|
+      next if f.include?(".out.log")
+
+      File.unlink(f) if File.exist?(f)
+    end
+  end
+end
+
+
+ +
+

+ + #setupvoid + + + + + +

+
+

This method returns an undefined value.

If you include this module and don't override setup/teardown, everything will +work fine. But if you need more setup/teardown steps, you can do that too.

+ +

The setup method guarantees that just including this module will do setup +automatically. If you override it, be sure to call super or logged_test_setup.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+82
+83
+84
+
+
# File 'scarpe-components/lib/scarpe/components/unit_test_helpers.rb', line 82
+
+def setup
+  logged_test_setup
+end
+
+
+ +
+

+ + #teardownvoid + + + + + +

+
+

This method returns an undefined value.

Make sure that, by default, #logged_test_teardown will be called for teardown. +If a class overrides teardown, it should also call super or logged_test_teardown +to make sure this still happens.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+107
+108
+109
+
+
# File 'scarpe-components/lib/scarpe/components/unit_test_helpers.rb', line 107
+
+def teardown
+  logged_test_teardown
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/UnexpectedFiberTransferError.html b/Scarpe/UnexpectedFiberTransferError.html new file mode 100644 index 000000000..4672d5915 --- /dev/null +++ b/Scarpe/UnexpectedFiberTransferError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::UnexpectedFiberTransferError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::UnexpectedFiberTransferError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/UnknownBuiltinCommandError.html b/Scarpe/UnknownBuiltinCommandError.html new file mode 100644 index 000000000..de7152e6d --- /dev/null +++ b/Scarpe/UnknownBuiltinCommandError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::UnknownBuiltinCommandError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::UnknownBuiltinCommandError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/UnknownEventTypeError.html b/Scarpe/UnknownEventTypeError.html new file mode 100644 index 000000000..f73fad536 --- /dev/null +++ b/Scarpe/UnknownEventTypeError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::UnknownEventTypeError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::UnknownEventTypeError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/UnknownShapeCommandError.html b/Scarpe/UnknownShapeCommandError.html new file mode 100644 index 000000000..1d8a51fb8 --- /dev/null +++ b/Scarpe/UnknownShapeCommandError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::UnknownShapeCommandError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::UnknownShapeCommandError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/UnknownShoesEventAPIError.html b/Scarpe/UnknownShoesEventAPIError.html new file mode 100644 index 000000000..78ecdf615 --- /dev/null +++ b/Scarpe/UnknownShoesEventAPIError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::UnknownShoesEventAPIError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::UnknownShoesEventAPIError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WVRelayUtil.html b/Scarpe/WVRelayUtil.html new file mode 100644 index 000000000..0ba902d0a --- /dev/null +++ b/Scarpe/WVRelayUtil.html @@ -0,0 +1,734 @@ + + + + + + + Module: Scarpe::WVRelayUtil + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::WVRelayUtil + + + +

+
+ + + + + + + + + +
+
Included in:
+
Scarpe::Webview::ContainedService, Scarpe::Webview::RelayDisplayService
+
+ + + +
+
Defined in:
+
lib/scarpe/wv/webview_relay_util.rb
+
+ +
+ +

Overview

+
+

WVRelayUtil defines the datagram format for the sockets that connect a parent +Shoes application with a child display server.

+ +

The class including this module should also include Shoes::Log so that it can +be used.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #event_loop_for(t = 1.5) ⇒ Object + + + + + +

+
+

Loop for up to t seconds, reading data and waiting.

+ + +
+
+
+

Parameters:

+
    + +
  • + + t + + + (Float) + + + (defaults to: 1.5) + + + — +

    the number of seconds to loop for

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+
+
# File 'lib/scarpe/wv/webview_relay_util.rb', line 127
+
+def event_loop_for(t = 1.5)
+  t_start = Time.now
+  delay_time = t
+
+  while Time.now - t_start < delay_time
+    if ready_to_read?(0.1)
+      respond_to_datagram
+    else
+      sleep 0.1
+    end
+  end
+end
+
+
+ +
+

+ + #ready_to_read?(timeout = 0.0) ⇒ Boolean + + + + + +

+
+

Checks whether the internal socket is ready to be read from. +If timeout is greater than 0, this will block for up to that long.

+ + +
+
+
+

Parameters:

+
    + +
  • + + timeout + + + (Float) + + + (defaults to: 0.0) + + + — +

    the longest to wait for more input to read

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    whether the socket has data ready for reading

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+
+
# File 'lib/scarpe/wv/webview_relay_util.rb', line 17
+
+def ready_to_read?(timeout = 0.0)
+  r, _, e = IO.select [@from], [], [@from, @to].uniq, timeout
+
+  # On timeout, select returns nil instead of arrays.
+  return if r.nil?
+
+  unless e.empty?
+    raise Scarpe::ConnectionError, "#{@i_am}: Got error on connection(s) from IO.select! Dying!"
+  end
+
+  !r.empty?
+end
+
+
+ +
+

+ + #receive_datagramString + + + + + +

+
+

Read data from the internal socket. Read until a whole datagram +has been received and then return it.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +

    the received datagram

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+
+
# File 'lib/scarpe/wv/webview_relay_util.rb', line 56
+
+def receive_datagram
+  @readbuf ||= String.new.encode(Encoding::BINARY)
+  to_read = nil
+
+  loop do
+    # Have we read a packet length already, sitting in @readbuf?
+    a_idx = @readbuf.index("a")
+    if a_idx
+      to_read = @readbuf[0..a_idx].to_i
+      @readbuf = @readbuf[(a_idx + 1)..-1]
+      break
+    end
+
+    # If not, read more bytes
+    new_bytes = @from.read(10)
+    if new_bytes.nil?
+      # This is perfectly normal, if the connection closed
+      raise Scarpe::AppShutdownError, "Got an unexpected EOF reading datagram! " +
+        "Did the #{@i_am == :child ? "parent" : "child"} process die?"
+    end
+    @readbuf << new_bytes
+  end
+
+  loop do
+    if @readbuf.bytesize >= to_read
+      out = @readbuf.byteslice(0, to_read)
+      @readbuf = @readbuf.byteslice(to_read, -1)
+      return out
+    end
+
+    new_bytes = @from.read(to_read - @readbuf.bytesize)
+    @readbuf << new_bytes
+  end
+rescue
+  raise Scarpe::AppShutdownError, "Got exception #{$!.class} when receiving datagram... #{$!.inspect}"
+end
+
+
+ +
+

+ + #respond_to_datagramObject + + + + + +

+
+

Read a datagram from the internal buffer and then dispatch it to the +appropriate handler.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+
+
# File 'lib/scarpe/wv/webview_relay_util.rb', line 95
+
+def respond_to_datagram
+  message = receive_datagram
+  m_data = JSON.parse(message)
+
+  if m_data["type"] == "event"
+    kwargs_hash = {}
+    m_data["kwargs"].each { |k, v| kwargs_hash[k.to_sym] = v }
+    send_shoes_event(
+      *m_data["args"],
+      event_name: m_data["kwargs"]["event_name"],
+      target: m_data["kwargs"]["event_target"],
+      **kwargs_hash,
+    )
+  elsif m_data["type"] == "create"
+    raise Scarpe::InvalidOperationError, "Parent process should never receive :create datagram!" if @i_am == :parent
+
+    @wv_display.create_display_drawable_for(m_data["class_name"], m_data["id"], m_data["properties"])
+  elsif m_data["type"] == "destroy"
+    if @i_am == :parent
+      @shutdown = true
+    else
+      @log.info("Shutting down...")
+      exit 0
+    end
+  else
+    @log.error("Unrecognized datagram type:event: #{m_data.inspect}!")
+  end
+end
+
+
+ +
+

+ + #send_datagram(contents) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Send bytes on the internal socket to the opposite side.

+ + +
+
+
+

Parameters:

+
    + +
  • + + contents + + + (String) + + + + — +

    data to send

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+
+
# File 'lib/scarpe/wv/webview_relay_util.rb', line 34
+
+def send_datagram(contents)
+  str_data = JSON.dump contents
+  dgram_str = (str_data.length.to_s + "a" + str_data).encode(Encoding::BINARY)
+  to_write = dgram_str.bytesize
+  written = 0
+
+  until written == to_write
+    count = @to.write(dgram_str.byteslice(written..-1))
+    if count.nil? || count == 0
+      raise Scarpe::DatagramSendError, "Something was wrong in send_datagram! Write returned #{count.inspect}!"
+    end
+
+    written += count
+  end
+
+  nil
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebWranglerNotRunningError.html b/Scarpe/WebWranglerNotRunningError.html new file mode 100644 index 000000000..d0110c976 --- /dev/null +++ b/Scarpe/WebWranglerNotRunningError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Scarpe::WebWranglerNotRunningError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::WebWranglerNotRunningError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview.html b/Scarpe/Webview.html new file mode 100644 index 000000000..1c5253c24 --- /dev/null +++ b/Scarpe/Webview.html @@ -0,0 +1,310 @@ + + + + + + + Module: Scarpe::Webview + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::Webview + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/web_wrangler.rb,
+ lib/scarpe/wv/app.rb,
lib/scarpe/wv/arc.rb,
lib/scarpe/wv/flow.rb,
lib/scarpe/wv/line.rb,
lib/scarpe/wv/link.rb,
lib/scarpe/wv/oval.rb,
lib/scarpe/wv/para.rb,
lib/scarpe/wv/rect.rb,
lib/scarpe/wv/slot.rb,
lib/scarpe/wv/star.rb,
lib/scarpe/wv/arrow.rb,
lib/scarpe/wv/check.rb,
lib/scarpe/wv/image.rb,
lib/scarpe/wv/radio.rb,
lib/scarpe/wv/shape.rb,
lib/scarpe/wv/stack.rb,
lib/scarpe/wv/video.rb,
lib/scarpe/wv/border.rb,
lib/scarpe/wv/button.rb,
lib/scarpe/wv/drawable.rb,
lib/scarpe/wv/edit_box.rb,
lib/scarpe/wv/list_box.rb,
lib/scarpe/wv/progress.rb,
lib/scarpe/wv/edit_line.rb,
lib/scarpe/wv/document_root.rb,
lib/scarpe/wv/text_drawable.rb,
lib/scarpe/wv/control_interface.rb,
lib/scarpe/assets.rb,
lib/scarpe/wv.rb
+
+
+ +
+ +

Overview

+
+

Module to contain the various Scarpe Webview classes

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + + + Classes: App, Arc, Arrow, Border, Button, Check, ContainedService, ControlInterface, DisplayService, DocumentRoot, Drawable, EditBox, EditLine, Flow, Image, Line, Link, ListBox, Oval, Para, Progress, Radio, Rect, RelayDisplayService, Shape, Slot, Stack, Star, SubscriptionItem, TextDrawable, Video, WebWrangler + + +

+ + +

+ Constant Summary + collapse +

+ +
+ +
HTML = + +
+
Scarpe::Components::HTML
+ +
+ + + + + + + + + +

+ Class Method Summary + collapse +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + .asset_serverObject + + + + + +

+ + + + +
+
+
+
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+
+
# File 'lib/scarpe/assets.rb', line 6
+
+def self.asset_server
+  return @asset_server if @asset_server
+
+  @asset_server = Scarpe::Components::AssetServer.new app_dir: Shoes::App.instance.dir
+
+  # at_exit doesn't work reliably under webview. Give this a try.
+  ::Scarpe::Webview::DisplayService.instance.control_interface.on_event(:shutdown) do
+    @asset_server&.kill_server
+  end
+
+  @asset_server
+end
+
+
+ +
+

+ + .default_wv_text_drawable_with_tag(shoes_tag, html_tag = nil) ⇒ Object + + + + + +

+ + + + +
+
+
+
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+
+
# File 'lib/scarpe/wv/text_drawable.rb', line 63
+
+def default_wv_text_drawable_with_tag(shoes_tag, html_tag = nil)
+  html_tag ||= shoes_tag
+  webview_class_name = shoes_tag.capitalize
+  webview_drawable_class = Class.new(Scarpe::Webview::TextDrawable) do
+    class << self
+      attr_accessor :html_tag
+    end
+
+    def to_calzini_hash
+      h = super
+      h[:tag] = self.class.html_tag
+      h
+    end
+  end
+  Scarpe::Webview.const_set webview_class_name, webview_drawable_class
+  webview_drawable_class.html_tag = html_tag
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/App.html b/Scarpe/Webview/App.html new file mode 100644 index 000000000..b569ff1d4 --- /dev/null +++ b/Scarpe/Webview/App.html @@ -0,0 +1,996 @@ + + + + + + + Class: Scarpe::Webview::App + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::App + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/app.rb
+
+ +
+ +

Overview

+
+

Scarpe::Webview::App must only be used from the main thread, due to GTK+ limitations.

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + +

Instance Attribute Summary collapse

+ + + + + + +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ App + + + + + +

+
+

Returns a new instance of App.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+
+
# File 'lib/scarpe/wv/app.rb', line 10
+
+def initialize(properties)
+  super
+
+  # Scarpe's ControlInterface sets up event handlers
+  # for the display service that aren't sent to
+  # Lacci (Shoes). In general it's used for setup
+  # and additional control or testing, outside the
+  # Shoes app. This is how CatsCradle and Shoes-Spec
+  # set up testing, for instance.
+  @control_interface = ControlInterface.new
+
+  # TODO: rename @view
+  @view = Scarpe::Webview::WebWrangler.new title: @title,
+    width: @width,
+    height: @height,
+    resizable: @resizable
+
+  @callbacks = {}
+
+  # The control interface has to exist to get callbacks like "override Scarpe app opts".
+  # But the Scarpe App needs those options to be created. So we can't pass these to
+  # ControlInterface.new.
+  @control_interface.set_system_components app: self, doc_root: nil, wrangler: @view
+
+  bind_shoes_event(event_name: "init") { init }
+  bind_shoes_event(event_name: "run") { run }
+  bind_shoes_event(event_name: "destroy") { destroy }
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #control_interfaceObject (readonly) + + + + + +

+
+

App inherits from Drawable to set up linkable IDs and event methods

+ + +
+
+
+ + +
+ + + + +
+
+
+
+6
+7
+8
+
+
# File 'lib/scarpe/wv/app.rb', line 6
+
+def control_interface
+  @control_interface
+end
+
+
+ + + +
+

+ + #document_root=(value) ⇒ Object (writeonly) + + + + + +

+
+

Sets the attribute document_root

+ + +
+
+
+

Parameters:

+
    + +
  • + + value + + + + + + + — +

    the value to set the attribute document_root to.

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+39
+40
+41
+
+
# File 'lib/scarpe/wv/app.rb', line 39
+
+def document_root=(value)
+  @document_root = value
+end
+
+
+ + + +
+

+ + #shoes_linkable_id=(value) ⇒ Object (writeonly) + + + + + +

+
+

Sets the attribute shoes_linkable_id

+ + +
+
+
+

Parameters:

+
    + +
  • + + value + + + + + + + — +

    the value to set the attribute shoes_linkable_id to.

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lib/scarpe/wv/app.rb', line 8
+
+def shoes_linkable_id=(value)
+  @shoes_linkable_id = value
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #bind(name, &block) ⇒ Object + + + + + +

+
+

Bind a Scarpe callback name; see handle_callback above. +See Scarpe::Drawable for how the naming is set up

+ + +
+
+
+ + +
+ + + + +
+
+
+
+92
+93
+94
+
+
# File 'lib/scarpe/wv/app.rb', line 92
+
+def bind(name, &block)
+  @callbacks[name] = block
+end
+
+
+ +
+

+ + #destroyObject + + + + + +

+ + + + +
+
+
+
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+
+
# File 'lib/scarpe/wv/app.rb', line 69
+
+def destroy
+  if @document_root || @view
+    @control_interface.dispatch_event :shutdown
+  end
+  @document_root = nil
+  if @view
+    @view.destroy
+    @view = nil
+  end
+end
+
+
+ +
+

+ + #handle_callback(name, *args) ⇒ Object + + + + + +

+
+

All JS callbacks to Scarpe drawables are dispatched +via this handler

+ + +
+
+
+ + +
+ + + + +
+
+
+
+82
+83
+84
+85
+86
+87
+88
+
+
# File 'lib/scarpe/wv/app.rb', line 82
+
+def handle_callback(name, *args)
+  if @callbacks.key?(name)
+    @callbacks[name].call(*args)
+  else
+    raise Scarpe::UnknownEventTypeError, "No such Webview callback: #{name.inspect}!"
+  end
+end
+
+
+ +
+

+ + #initObject + + + + + +

+ + + + +
+
+
+
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+
+
# File 'lib/scarpe/wv/app.rb', line 41
+
+def init
+  scarpe_app = self
+
+  @view.init_code("scarpeInit") do
+    request_redraw!
+  end
+
+  @view.bind("scarpeHandler") do |*args|
+    handle_callback(*args)
+  end
+
+  @view.bind("scarpeExit") do
+    scarpe_app.destroy
+  end
+end
+
+
+ +
+

+ + #request_redraw!void + + + + + +

+
+

This method returns an undefined value.

Request a full redraw if Webview is running. Otherwise +this is a no-op.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+100
+101
+102
+103
+104
+105
+106
+
+
# File 'lib/scarpe/wv/app.rb', line 100
+
+def request_redraw!
+  wrangler = DisplayService.instance.wrangler
+  if wrangler.is_running
+    wrangler.replace(@document_root.to_html)
+  end
+  nil
+end
+
+
+ +
+

+ + #runObject + + + + + +

+ + + + +
+
+
+
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+
+
# File 'lib/scarpe/wv/app.rb', line 57
+
+def run
+  # This is run before the Webview event loop is up and running
+  @control_interface.dispatch_event(:init)
+
+  @view.empty_page = empty_page_element
+
+  # This takes control of the main thread and never returns. And it *must* be run from
+  # the main thread. And it stops any Ruby background threads.
+  # That's totally cool and normal, right?
+  @view.run
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Arc.html b/Scarpe/Webview/Arc.html new file mode 100644 index 000000000..c3a555b65 --- /dev/null +++ b/Scarpe/Webview/Arc.html @@ -0,0 +1,249 @@ + + + + + + + Class: Scarpe::Webview::Arc + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Arc + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/arc.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #initialize, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #initialize, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +

This class inherits a constructor from Scarpe::Webview::Drawable

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/arc.rb', line 5
+
+def element
+  render("arc")
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Arrow.html b/Scarpe/Webview/Arrow.html new file mode 100644 index 000000000..b79cd780b --- /dev/null +++ b/Scarpe/Webview/Arrow.html @@ -0,0 +1,249 @@ + + + + + + + Class: Scarpe::Webview::Arrow + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Arrow + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/arrow.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #initialize, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #initialize, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +

This class inherits a constructor from Scarpe::Webview::Drawable

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/arrow.rb', line 5
+
+def element
+  render("arrow")
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Border.html b/Scarpe/Webview/Border.html new file mode 100644 index 000000000..069d3090f --- /dev/null +++ b/Scarpe/Webview/Border.html @@ -0,0 +1,323 @@ + + + + + + + Class: Scarpe::Webview::Border + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Border + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/border.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ +
    + +
  • + + + #element ⇒ Object + + + + + + + + + + + + + +

    If the drawable is intended to be overridable, add element and style to Calzini instead.

    +
    + +
  • + + +
  • + + + #initialize(properties) ⇒ Border + + + + + + + constructor + + + + + + + + +

    A new instance of Border.

    +
    + +
  • + + +
+ + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ Border + + + + + +

+
+

Returns a new instance of Border.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+6
+7
+8
+
+
# File 'lib/scarpe/wv/border.rb', line 6
+
+def initialize(properties)
+  super(properties)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+
+

If the drawable is intended to be overridable, add element and style to Calzini instead

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+
+
# File 'lib/scarpe/wv/border.rb', line 11
+
+def element
+  render('border')
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Button.html b/Scarpe/Webview/Button.html new file mode 100644 index 000000000..afda7d5ee --- /dev/null +++ b/Scarpe/Webview/Button.html @@ -0,0 +1,334 @@ + + + + + + + Class: Scarpe::Webview::Button + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Button + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/button.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ Button + + + + + +

+
+

Returns a new instance of Button.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+
+
# File 'lib/scarpe/wv/button.rb', line 5
+
+def initialize(properties)
+  super
+
+  # Bind to display-side handler for "click"
+  bind("click") do
+    # This will be sent to the bind_self_event in Button
+    send_self_event(event_name: "click")
+  end
+
+  bind("hover") do
+    # This will be sent to the bind_self_event in Button
+    send_self_event(event_name: "hover")
+  end
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+20
+21
+22
+
+
# File 'lib/scarpe/wv/button.rb', line 20
+
+def element
+  render("button")
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Check.html b/Scarpe/Webview/Check.html new file mode 100644 index 000000000..ac873039d --- /dev/null +++ b/Scarpe/Webview/Check.html @@ -0,0 +1,460 @@ + + + + + + + Class: Scarpe::Webview::Check + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Check + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/check.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #text ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute text.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ Check + + + + + +

+
+

Returns a new instance of Check.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+
+
# File 'lib/scarpe/wv/check.rb', line 7
+
+def initialize(properties)
+  super
+
+  bind("click") do
+    send_self_event(event_name: "click", target: shoes_linkable_id)
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #textObject (readonly) + + + + + +

+
+

Returns the value of attribute text.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/check.rb', line 5
+
+def text
+  @text
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+23
+24
+25
+
+
# File 'lib/scarpe/wv/check.rb', line 23
+
+def element
+  render("check")
+end
+
+
+ +
+

+ + #properties_changed(changes) ⇒ Object + + + + + +

+ + + + +
+
+
+
+15
+16
+17
+18
+19
+20
+21
+
+
# File 'lib/scarpe/wv/check.rb', line 15
+
+def properties_changed(changes)
+  checked = changes.delete("checked")
+
+  html_element.toggle_input_button(checked)
+
+  super
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/ContainedService.html b/Scarpe/Webview/ContainedService.html new file mode 100644 index 000000000..3de0664bf --- /dev/null +++ b/Scarpe/Webview/ContainedService.html @@ -0,0 +1,441 @@ + + + + + + + Class: Scarpe::Webview::ContainedService + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::ContainedService + + + +

+
+ +
+
Inherits:
+
+ Shoes::Linkable + + + show all + +
+
+ + + + + + +
+
Includes:
+
Scarpe::WVRelayUtil, Shoes::Log
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/wv/wv_display_worker.rb
+
+ +
+ +

Overview

+
+

This is the implementation of a freestanding Scarpe Webview display server, +which connects via sockets and sends events and properties back and forth +with a display-less Shoes app. The interface is designed to allow fork-based +usage, where a parent process could create a paired sockets and start the +child server. It can also be used via TCP sockets or similar, where a single +socket is both input and output.

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #log ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute log.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Scarpe::WVRelayUtil

+

#event_loop_for, #ready_to_read?, #receive_datagram, #respond_to_datagram, #send_datagram

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(from, to) ⇒ ContainedService + + + + + +

+
+

Create a new DisplayService.

+ + +
+
+
+

Parameters:

+
    + +
  • + + from + + + (Socket) + + + + — +

    a readable socket to get input from the Shoes process

    +
    + +
  • + +
  • + + to + + + (Socket) + + + + — +

    a writable socket on which to send output to the Shoes process

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+
+
# File 'lib/scarpe/wv/wv_display_worker.rb', line 39
+
+def initialize(from, to)
+  super()
+  log_init("Webview::DisplayWorker")
+
+  @i_am = :child
+  @event_subs = []
+  @wv_display = Scarpe::Webview::DisplayService.new
+
+  @from = from
+  @to = to
+
+  @init_done = false
+
+  # Wait to register our periodic_code until the wrangler exists
+  @event_subs << bind_shoes_event(event_name: "init") do
+    @wv_display.wrangler.periodic_code("datagramProcessor", 0.1) do
+      respond_to_datagram while ready_to_read?(0.0)
+    end
+    @init_done = true
+  end
+
+  # Subscribe to all event notifications and relay them to the opposite side
+  @event_subs << bind_shoes_event(event_name: :any, target: :any) do |*args, **kwargs|
+    unless kwargs[:relayed] || kwargs["relayed"]
+      kwargs[:relayed] = true
+      send_datagram({ type: :event, args:, kwargs: })
+    end
+  end
+
+  # Run for 2.5 seconds to let the app be created and "run" to get called.
+  # Once that happens, Webview will take over the event loop.
+  event_loop_for(2.5)
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #logObject (readonly) + + + + + +

+
+

Returns the value of attribute log.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+33
+34
+35
+
+
# File 'lib/scarpe/wv/wv_display_worker.rb', line 33
+
+def log
+  @log
+end
+
+
+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/ControlInterface.html b/Scarpe/Webview/ControlInterface.html new file mode 100644 index 000000000..2a44355c0 --- /dev/null +++ b/Scarpe/Webview/ControlInterface.html @@ -0,0 +1,953 @@ + + + + + + + Class: Scarpe::Webview::ControlInterface + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::ControlInterface + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + +
+
Includes:
+
Shoes::Log
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/wv/control_interface.rb
+
+ +
+ + + +

+ Constant Summary + collapse +

+ +
+ +
SUBSCRIBE_EVENTS = + +
+
[:init, :shutdown, :next_redraw, :every_redraw, :next_heartbeat, :every_heartbeat]
+ +
DISPATCH_EVENTS = + +
+
[:init, :shutdown, :redraw, :heartbeat]
+ +
INVALID_SYSTEM_COMPONENTS_MESSAGE = + +
+
"Must pass non-nil app and wrangler to ControlInterface#set_system_components!"
+ +
CONTROL_INTERFACE_INIT_MESSAGE = + +
+
"ControlInterface code needs to be wrapped in handlers like on_event(:init) " +
+"to make sure they have access to app, doc_root, wrangler, etc!"
+ +
+ + + + + + +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + +

Instance Attribute Summary collapse

+ + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+
+

Constructor Details

+ +
+

+ + #initializeControlInterface + + + + + +

+
+

The control interface needs to see major system components to hook into their events

+ + +
+
+
+ + +
+ + + + +
+
+
+
+19
+20
+21
+22
+23
+24
+25
+
+
# File 'lib/scarpe/wv/control_interface.rb', line 19
+
+def initialize
+  log_init("Webview::ControlInterface")
+
+  @do_shutdown = false
+  @event_handlers = {}
+  (SUBSCRIBE_EVENTS | DISPATCH_EVENTS).each { |e| @event_handlers[e] = [] }
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #do_shutdownObject (readonly) + + + + + +

+
+

Returns the value of attribute do_shutdown.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+16
+17
+18
+
+
# File 'lib/scarpe/wv/control_interface.rb', line 16
+
+def do_shutdown
+  @do_shutdown
+end
+
+
+ + + +
+

+ + #doc_rootObject + + + + + +

+
+ + +
+
+
+ +

Raises:

+ + +
+ + + + +
+
+
+
+57
+58
+59
+60
+61
+
+
# File 'lib/scarpe/wv/control_interface.rb', line 57
+
+def doc_root
+  raise Scarpe::MissingDocRootError, CONTROL_INTERFACE_INIT_MESSAGE unless @doc_root
+
+  @doc_root
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #appObject + + + + + +

+
+ + +
+
+
+ +

Raises:

+ + +
+ + + + +
+
+
+
+51
+52
+53
+54
+55
+
+
# File 'lib/scarpe/wv/control_interface.rb', line 51
+
+def app
+  raise Scarpe::MissingAppError, CONTROL_INTERFACE_INIT_MESSAGE unless @app
+
+  @app
+end
+
+
+ +
+

+ + #dispatch_event(event, *args, **keywords) ⇒ Object + + + + + +

+
+

Send out the specified event

+ + +
+
+
+ + +
+ + + + +
+
+
+
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+
+
# File 'lib/scarpe/wv/control_interface.rb', line 86
+
+def dispatch_event(event, *args, **keywords)
+  @log.debug("CTL event #{event.inspect} #{args.inspect} #{keywords.inspect}")
+
+  unless DISPATCH_EVENTS.include?(event)
+    raise Scarpe::IllegalDispatchEventError, "Illegal dispatch of event #{event.inspect}! Valid values are: #{DISPATCH_EVENTS.inspect}"
+  end
+
+  if @do_shutdown
+    @log.debug("CTL: Shutting down - not dispatching #{event}!")
+    return
+  end
+
+  if event == :redraw
+    dumb_dispatch_event(:every_redraw, *args, **keywords)
+
+    # Next redraw is interesting. We can add new handlers
+    # when dispatching a next_redraw handler. But we want
+    # each handler to run only once.
+    handlers = @event_handlers[:next_redraw]
+    dumb_dispatch_event(:next_redraw, *args, **keywords)
+    @event_handlers[:next_redraw] -= handlers
+    return
+  end
+
+  if event == :heartbeat
+    dumb_dispatch_event(:every_heartbeat, *args, **keywords)
+
+    # Next heartbeat is interesting. We can add new handlers
+    # when dispatching a next_heartbeat handler. But we want
+    # each handler to run only once.
+    handlers = @event_handlers[:next_heartbeat]
+    dumb_dispatch_event(:next_heartbeat, *args, **keywords)
+    @event_handlers[:next_heartbeat] -= handlers
+    return
+  end
+
+  if event == :shutdown
+    @do_shutdown = true
+  end
+
+  dumb_dispatch_event(event, *args, **keywords)
+end
+
+
+ +
+

+ + #inspectObject + + + + + +

+ + + + +
+
+
+
+27
+28
+29
+
+
# File 'lib/scarpe/wv/control_interface.rb', line 27
+
+def inspect
+  "<#ControlInterface>"
+end
+
+
+ +
+

+ + #on_event(event, &block) ⇒ Object + + + + + +

+
+

On recognised events, this sets a handler for that event

+ + +
+
+
+ + +
+ + + + +
+
+
+
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+
+
# File 'lib/scarpe/wv/control_interface.rb', line 73
+
+def on_event(event, &block)
+  unless SUBSCRIBE_EVENTS.include?(event)
+    raise Scarpe::IllegalSubscribeEventError, "Illegal subscribe to event #{event.inspect}! Valid values are: #{SUBSCRIBE_EVENTS.inspect}"
+  end
+
+  @unsub_id ||= 0
+  @unsub_id += 1
+
+  @event_handlers[event] << { handler: block, unsub: @unsub_id }
+  @unsub_id
+end
+
+
+ +
+

+ + #set_system_components(app:, doc_root:, wrangler:) ⇒ Object + + + + + +

+
+

This should get called once, from Shoes::App

+ + +
+
+
+ + +
+ + + + +
+
+
+
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+
+
# File 'lib/scarpe/wv/control_interface.rb', line 32
+
+def set_system_components(app:, doc_root:, wrangler:)
+  unless app
+    @log.error("False app passed to set_system_components!")
+    raise Scarpe::MissingAppError, INVALID_SYSTEM_COMPONENTS_MESSAGE
+  end
+  unless wrangler
+    @log.error("False wrangler passed to set_system_components!")
+    raise Scarpe::MissingWranglerError, INVALID_SYSTEM_COMPONENTS_MESSAGE
+  end
+
+  @app = app
+  @doc_root = doc_root # May be nil at this point
+  @wrangler = wrangler
+
+  @wrangler.control_interface = self
+
+  @wrangler.on_every_redraw { self.dispatch_event(:redraw) }
+end
+
+
+ +
+

+ + #wranglerObject + + + + + +

+
+ + +
+
+
+ +

Raises:

+ + +
+ + + + +
+
+
+
+63
+64
+65
+66
+67
+
+
# File 'lib/scarpe/wv/control_interface.rb', line 63
+
+def wrangler
+  raise Scarpe::MissingWranglerError, CONTROL_INTERFACE_INIT_MESSAGE unless @wrangler
+
+  @wrangler
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/DisplayService.html b/Scarpe/Webview/DisplayService.html new file mode 100644 index 000000000..64c49f86d --- /dev/null +++ b/Scarpe/Webview/DisplayService.html @@ -0,0 +1,949 @@ + + + + + + + Class: Scarpe::Webview::DisplayService + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::DisplayService + + + +

+
+ +
+
Inherits:
+
+ Shoes::DisplayService + + + show all + +
+
+ + + + + + +
+
Includes:
+
Shoes::Log
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/wv/webview_local_display.rb
+
+ +
+ +

Overview

+
+

This is the simplest type of Webview DisplayService. It creates Webview drawables +corresponding to Shoes drawables, manages the Webview and its DOM tree, and +generally keeps the Shoes/Webview connection working.

+ +

This is an in-process Webview-based display service, with all the limitations that +entails. Slow handlers will crash, ending this display service will end the +process, too many or too large evals can crash the process, etc. +Frequently it's better to use a RelayDisplayService to a second +process containing one of these.

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + +

Class Attribute Summary collapse

+
    + +
  • + + + .instance ⇒ Object + + + + + + + + + + + + + + + + +

    Returns the value of attribute instance.

    +
    + +
  • + + +
+ +

Instance Attribute Summary collapse

+
    + +
  • + + + #app ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    app is the Scarpe::Webview::App.

    +
    + +
  • + + +
  • + + + #control_interface ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    The ControlInterface is used to handle internal events in Webview Scarpe.

    +
    + +
  • + + +
  • + + + #doc_root ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    The DocumentRoot is the top drawable of the Webview-side drawable tree.

    +
    + +
  • + + +
  • + + + #wrangler ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    wrangler is the Scarpe::WebWrangler.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::DisplayService

+

dispatch_event, display_service, full_reset!, #query_display_drawable_for, set_display_service_class, #set_drawable_pairing, subscribe_to_event, unsub_from_events

+
+

Constructor Details

+ +
+

+ + #initializeDisplayService + + + + + +

+
+

This is called before any of the various Webview::Drawables are created, to be +able to create them and look them up.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+
+
# File 'lib/scarpe/wv/webview_local_display.rb', line 34
+
+def initialize
+  if Webview::DisplayService.instance
+    raise Shoes::Errors::SingletonError, "ERROR! This is meant to be a singleton!"
+  end
+
+  Webview::DisplayService.instance = self
+
+  super()
+  log_init("Webview::DisplayService")
+
+  @display_drawable_for = {}
+end
+
+
+ +
+ +
+

Class Attribute Details

+ + + +
+

+ + .instanceObject + + + + + +

+
+

Returns the value of attribute instance.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+17
+18
+19
+
+
# File 'lib/scarpe/wv/webview_local_display.rb', line 17
+
+def instance
+  @instance
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #appObject (readonly) + + + + + +

+
+

app is the Scarpe::Webview::App

+ + +
+
+
+ + +
+ + + + +
+
+
+
+27
+28
+29
+
+
# File 'lib/scarpe/wv/webview_local_display.rb', line 27
+
+def app
+  @app
+end
+
+
+ + + +
+

+ + #control_interfaceObject (readonly) + + + + + +

+
+

The ControlInterface is used to handle internal events in Webview Scarpe

+ + +
+
+
+ + +
+ + + + +
+
+
+
+21
+22
+23
+
+
# File 'lib/scarpe/wv/webview_local_display.rb', line 21
+
+def control_interface
+  @control_interface
+end
+
+
+ + + +
+

+ + #doc_rootObject (readonly) + + + + + +

+
+

The DocumentRoot is the top drawable of the Webview-side drawable tree

+ + +
+
+
+ + +
+ + + + +
+
+
+
+24
+25
+26
+
+
# File 'lib/scarpe/wv/webview_local_display.rb', line 24
+
+def doc_root
+  @doc_root
+end
+
+
+ + + +
+

+ + #wranglerObject (readonly) + + + + + +

+
+

wrangler is the Scarpe::WebWrangler

+ + +
+
+
+ + +
+ + + + +
+
+
+
+30
+31
+32
+
+
# File 'lib/scarpe/wv/webview_local_display.rb', line 30
+
+def wrangler
+  @wrangler
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #create_display_drawable_for(drawable_class_name, drawable_id, properties, parent_id:, is_widget:) ⇒ Webview::Drawable + + + + + +

+
+

Create a Webview display drawable for a specific Shoes drawable, and pair it with +the linkable ID for this Shoes drawable.

+ + +
+
+
+

Parameters:

+
    + +
  • + + drawable_class_name + + + (String) + + + + — +

    The class name of the Shoes drawable, e.g. Shoes::Button

    +
    + +
  • + +
  • + + drawable_id + + + (String) + + + + — +

    the linkable ID for drawable events

    +
    + +
  • + +
  • + + properties + + + (Hash) + + + + — +

    a JSON-serialisable Hash with the drawable's Shoes styles

    +
    + +
  • + +
  • + + is_widget + + + (Boolean) + + + + — +

    whether the class is a user-defined Shoes::Widget subclass

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Webview::Drawable) + + + + — +

    the newly-created Webview drawable

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+
+
# File 'lib/scarpe/wv/webview_local_display.rb', line 55
+
+def create_display_drawable_for(drawable_class_name, drawable_id, properties, parent_id:, is_widget:)
+  existing = query_display_drawable_for(drawable_id, nil_ok: true)
+  if existing
+    @log.warn("There is already a Scarpe drawable for #{drawable_id.inspect}! Returning #{existing.class.name} rather than creating a #{drawable_class_name}.")
+    return existing
+  end
+
+  if drawable_class_name == "App"
+    unless @doc_root
+      raise Scarpe::MissingDocRootError, "Webview::DocumentRoot is supposed to be created before Webview::App!"
+    end
+
+    display_app = Scarpe::Webview::App.new(properties)
+    display_app.document_root = @doc_root
+    @control_interface = display_app.control_interface
+    @control_interface.doc_root = @doc_root
+    @app = @control_interface.app
+    @wrangler = @control_interface.wrangler
+
+    set_drawable_pairing(drawable_id, display_app)
+
+    return display_app
+  end
+
+  # Create a corresponding display drawable
+
+  if is_widget
+    display_class = Scarpe::Webview::Flow
+  else
+    display_class = Scarpe::Webview::Drawable.display_class_for(drawable_class_name)
+    unless display_class < Scarpe::Webview::Drawable
+      raise Scarpe::BadDisplayClassType, "Wrong display class type #{display_class.inspect} for class name #{drawable_class_name.inspect}!"
+    end
+  end
+  display_drawable = display_class.new(properties)
+  set_drawable_pairing(drawable_id, display_drawable)
+
+  if drawable_class_name == "DocumentRoot"
+    # DocumentRoot is created before App. Mostly doc_root is just like any other drawable,
+    # but we'll want a reference to it when we create App.
+    @doc_root = display_drawable
+  end
+
+  # Nil parent is fine for DocumentRoot and any TextDrawable, so we have to specify it.
+  display_parent = Scarpe::Webview::DisplayService.instance.query_display_drawable_for(parent_id, nil_ok: true)
+  display_drawable.set_parent(display_parent)
+
+  display_drawable
+end
+
+
+ +
+

+ + #destroyvoid + + + + + +

+
+

This method returns an undefined value.

Destroy the display service and the app. Quit the process (eventually.)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+108
+109
+110
+111
+
+
# File 'lib/scarpe/wv/webview_local_display.rb', line 108
+
+def destroy
+  @app.destroy
+  Webview::DisplayService.instance = nil
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/DocumentRoot.html b/Scarpe/Webview/DocumentRoot.html new file mode 100644 index 000000000..c08dda1b0 --- /dev/null +++ b/Scarpe/Webview/DocumentRoot.html @@ -0,0 +1,405 @@ + + + + + + + Class: Scarpe::Webview::DocumentRoot + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::DocumentRoot + + + +

+
+ +
+
Inherits:
+
+ Flow + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/document_root.rb
+
+ +
+ +

Overview

+
+

A DocumentRoot is a Flow, with all the same properties +and basic behavior. It also reserves space for Builtins like fonts, alerts, +etc. which don't have individual Shoes::Drawable objects.

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + + + + + + + +

Methods inherited from Slot

+

#html_attributes, #remove_event_callback, #remove_event_callbacks, #set_event_callback, #update_dom_event

+ + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ DocumentRoot + + + + + +

+
+

Returns a new instance of DocumentRoot.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+
+
# File 'lib/scarpe/wv/document_root.rb', line 8
+
+def initialize(properties)
+  super
+
+  @fonts = []
+  @alerts = []
+
+  bind_shoes_event(event_name: "builtin") do |cmd_name, args|
+    case cmd_name
+    when "font"
+      @fonts << args[0]
+      # Can't just create font_updater and alert_updater on initialize - not everything is set up
+      @font_updater ||= Scarpe::Webview::WebWrangler::ElementWrangler.new(html_id: "root-fonts")
+      @font_updater.inner_html = font_contents
+    when "alert"
+      bind_ok_event
+      @alerts << args[0]
+      @alert_updater ||= Scarpe::Webview::WebWrangler::ElementWrangler.new(html_id: "root-alerts")
+      @alert_updater.inner_html = alert_contents
+    else
+      raise Scarpe::UnknownBuiltinCommandError, "Unexpected builtin command: #{cmd_name.inspect}!"
+    end
+  end
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #element(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+
+
# File 'lib/scarpe/wv/document_root.rb', line 32
+
+def element(&block)
+  contents = block ? block.call : ""
+  super do
+    contents + HTML.render do |h|
+      h.div(id: "root-fonts") do
+        font_contents
+      end
+      h.div(id: "root-alerts") do
+        alert_contents
+      end
+    end
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Drawable.html b/Scarpe/Webview/Drawable.html new file mode 100644 index 000000000..99feff07c --- /dev/null +++ b/Scarpe/Webview/Drawable.html @@ -0,0 +1,1908 @@ + + + + + + + Class: Scarpe::Webview::Drawable + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Drawable + + + +

+
+ +
+
Inherits:
+
+ Shoes::Linkable + + + show all + +
+
+ + + + + + +
+
Includes:
+
Shoes::Log
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/wv/drawable.rb,
+ lib/scarpe/wv.rb
+
+
+ +
+ +

Overview

+
+

The Webview::Drawable parent class helps connect a Webview drawable with +its Shoes equivalent, render itself to the Webview DOM, handle +Javascript events and generally keep things working in Webview.

+ + +
+
+
+ + +
+ + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #children ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    An array of Webview::Drawable children (possibly empty) of this drawable.

    +
    + +
  • + + +
  • + + + #parent ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    The Webview::Drawable parent of this drawable.

    +
    + +
  • + + +
  • + + + #shoes_linkable_id ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    The Shoes ID corresponding to the Shoes drawable for this Webview drawable.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Class Method Summary + collapse +

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ Drawable + + + + + +

+
+

Set instance variables for the Shoes styles of this drawable. Bind Shoes +events for changes of parent drawable and changes of property values.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+
+
# File 'lib/scarpe/wv/drawable.rb', line 40
+
+def initialize(properties)
+  log_init("Webview::Drawable")
+
+  @shoes_style_names = properties.keys.map(&:to_s) - ["shoes_linkable_id"]
+
+  @shoes_linkable_id = properties["shoes_linkable_id"] || properties[:shoes_linkable_id]
+  unless @shoes_linkable_id
+    raise Scarpe::MissingAttributeError, "Could not find property shoes_linkable_id in #{properties.inspect}!"
+  end
+
+  # Set the Shoes styles as instance variables
+  properties.each do |k, v|
+    next if k == "shoes_linkable_id"
+
+    instance_variable_set("@" + k.to_s, v)
+  end
+
+  # Must call this before bind
+  super(linkable_id: @shoes_linkable_id)
+
+  # This will only be used if moving a drawable from one parent to another.
+  # Shoes doesn't normally do that.
+  bind_shoes_event(event_name: "parent", target: shoes_linkable_id) do |new_parent_id|
+    display_parent = DisplayService.instance.query_display_drawable_for(new_parent_id)
+    if @parent != display_parent
+      set_parent(display_parent)
+    end
+  end
+
+  # When Shoes drawables change properties, we get a change notification here
+  bind_shoes_event(event_name: "prop_change", target: shoes_linkable_id) do |prop_changes|
+    prop_changes.each do |k, v|
+      instance_variable_set("@" + k, v)
+    end
+    properties_changed(prop_changes)
+  end
+
+  bind_shoes_event(event_name: "destroy", target: shoes_linkable_id) do
+    destroy_self
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #childrenObject (readonly) + + + + + +

+
+

An array of Webview::Drawable children (possibly empty) of this drawable

+ + +
+
+
+ + +
+ + + + +
+
+
+
+36
+37
+38
+
+
# File 'lib/scarpe/wv/drawable.rb', line 36
+
+def children
+  @children
+end
+
+
+ + + +
+

+ + #parentObject (readonly) + + + + + +

+
+

The Webview::Drawable parent of this drawable

+ + +
+
+
+ + +
+ + + + +
+
+
+
+33
+34
+35
+
+
# File 'lib/scarpe/wv/drawable.rb', line 33
+
+def parent
+  @parent
+end
+
+
+ + + +
+

+ + #shoes_linkable_idObject (readonly) + + + + + +

+
+

The Shoes ID corresponding to the Shoes drawable for this Webview drawable

+ + +
+
+
+ + +
+ + + + +
+
+
+
+30
+31
+32
+
+
# File 'lib/scarpe/wv/drawable.rb', line 30
+
+def shoes_linkable_id
+  @shoes_linkable_id
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + .display_class_for(scarpe_class_name) ⇒ Object + + + + + +

+
+

Return the corresponding Webview class for a particular Shoes class name

+ + +
+
+
+ + +
+ + + + +
+
+
+
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+
+
# File 'lib/scarpe/wv/drawable.rb', line 13
+
+def display_class_for(scarpe_class_name)
+  scarpe_class = Shoes.const_get(scarpe_class_name)
+  unless scarpe_class.ancestors.include?(Shoes::Linkable)
+    raise Scarpe::InvalidClassError, "Scarpe Webview can only get display classes for Shoes " +
+      "linkable drawables, not #{scarpe_class_name.inspect}!"
+  end
+
+  klass = Scarpe::Webview.const_get(scarpe_class_name.split("::")[-1])
+  if klass.nil?
+    raise Scarpe::MissingClassError, "Couldn't find corresponding Scarpe Webview class for #{scarpe_class_name.inspect}!"
+  end
+
+  klass
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + #add_child(child) ⇒ Object (protected) + + + + + +

+
+

Do not call directly, use set_parent

+ + +
+
+
+ + +
+ + + + +
+
+
+
+139
+140
+141
+142
+143
+144
+145
+
+
# File 'lib/scarpe/wv/drawable.rb', line 139
+
+def add_child(child)
+  @children ||= []
+  @children << child
+
+  # If we add a child, we should redraw ourselves
+  needs_update!
+end
+
+
+ +
+

+ + #bind(event) { ... } ⇒ Object + + + + + +

+
+

This binds a Scarpe JS callback, handled via a single dispatch point in the app

+ + +
+
+
+

Parameters:

+
    + +
  • + + event + + + (String) + + + + — +

    the Scarpe drawable event name

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +

    the block to call when the event occurs

    +
    + +
  • + +
+

Raises:

+ + +
+ + + + +
+
+
+
+189
+190
+191
+192
+193
+
+
# File 'lib/scarpe/wv/drawable.rb', line 189
+
+def bind(event, &block)
+  raise(Scarpe::MissingAttributeError, "Drawable has no linkable_id! #{inspect}") unless linkable_id
+
+  DisplayService.instance.app.bind("#{linkable_id}-#{event}", &block)
+end
+
+
+ +
+

+ + #destroy_selfScarpe::Promise + + + + + +

+
+

Removes the element from both the Ruby Drawable tree and the HTML DOM. +Unsubscribe from all Shoes events. +Return a promise for when that HTML change will be visible.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that is fulfilled when the HTML change is complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+200
+201
+202
+203
+204
+
+
# File 'lib/scarpe/wv/drawable.rb', line 200
+
+def destroy_self
+  @parent&.remove_child(self)
+  unsub_all_shoes_events
+  html_element.remove
+end
+
+
+ +
+

+ + #full_window_redraw!void + + + + + +

+
+

This method returns an undefined value.

Request a full redraw of the entire window, including the entire tree of +drawables and the outer "empty page" frame.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+210
+211
+212
+
+
# File 'lib/scarpe/wv/drawable.rb', line 210
+
+def full_window_redraw!
+  DisplayService.instance.app.request_redraw!
+end
+
+
+ +
+

+ + #handler_js_code(handler_function_name, *args) ⇒ String + + + + + +

+
+

Generate JS code to trigger a specific event name on this drawable with the supplies arguments.

+ + +
+
+
+

Parameters:

+
    + +
  • + + handler_function_name + + + (String) + + + + — +

    the event name - @see #bind

    +
    + +
  • + +
  • + + args + + + (Array) + + + + — +

    additional arguments that will be passed to the event in the generated JS

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +

    the generated JS code

    +
    + +
  • + +
+

Raises:

+ + +
+ + + + +
+
+
+
+232
+233
+234
+235
+236
+237
+
+
# File 'lib/scarpe/wv/drawable.rb', line 232
+
+def handler_js_code(handler_function_name, *args)
+  raise(Scarpe::MissingAttributeError, "Drawable has no linkable_id! #{inspect}") unless linkable_id
+
+  js_args = ["'#{linkable_id}-#{handler_function_name}'", *args].join(", ")
+  "scarpeHandler(#{js_args})"
+end
+
+
+ +
+

+ + #html_elementScarpe::WebWrangler::ElementWrangler + + + + + +

+
+

This gets an accessor for just this element's HTML ID. +It is normally called by the drawable itself to do its DOM management. +Drawables are required to use their html_id for their outermost element, +to make sure that remove(), hidden() etc. affect every part of the drawable.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Scarpe::WebWrangler::ElementWrangler) + + + + — +

    a DOM object manager

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+155
+156
+157
+
+
# File 'lib/scarpe/wv/drawable.rb', line 155
+
+def html_element
+  @elt_wrangler ||= Scarpe::Webview::WebWrangler::ElementWrangler.new(html_id:)
+end
+
+
+ +
+

+ + #html_idString + + + + + +

+
+

Get the object's HTML ID

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +

    the HTML ID

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+171
+172
+173
+
+
# File 'lib/scarpe/wv/drawable.rb', line 171
+
+def html_id
+  @linkable_id.to_s
+end
+
+
+ +
+

+ + #inspectObject + + + + + +

+
+

A shorter inspect text for prettier irb output

+ + +
+
+
+ + +
+ + + + +
+
+
+
+122
+123
+124
+
+
# File 'lib/scarpe/wv/drawable.rb', line 122
+
+def inspect
+  "#<#{self.class}:#{self.object_id} @shoes_linkable_id=#{@shoes_linkable_id} @children=#{@children.inspect}>"
+end
+
+
+ +
+

+ + #needs_update!void + + + + + +

+
+

This method returns an undefined value.

Request a full redraw of this drawable, including all its children. +Can be overridden in drawable subclasses if needed. An override would normally +only be needed if re-rendering the element with the given html_id +wasn't enough (and then remove would also need to be overridden.)

+ +

This occurs by default if a property is changed and the drawable +doesn't remove its change in property_changed.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+223
+224
+225
+
+
# File 'lib/scarpe/wv/drawable.rb', line 223
+
+def needs_update!
+  html_element.outer_html = to_html
+end
+
+
+ +
+

+ + #promise_updateScarpe::Promise + + + + + +

+
+

Return a promise that guarantees all currently-requested changes have completed

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when all pending changes have finished

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+162
+163
+164
+165
+166
+
+
# File 'lib/scarpe/wv/drawable.rb', line 162
+
+def promise_update
+  # Doesn't matter what ElementWrangler we use -- they all return an update promise
+  # that includes all pending updates, no matter who they're for.
+  html_element.promise_update
+end
+
+
+ +
+

+ + #properties_changed(changes) ⇒ Object + + + + + +

+
+

Properties_changed will be called automatically when properties change. +The drawable should delete any changes from the Hash that it knows how +to incrementally handle, and pass the rest to super. If any changes +go entirely un-handled, a full redraw will be scheduled. +This exists to be overridden by children watching for changes.

+ + +
+
+
+

Parameters:

+
    + +
  • + + changes + + + (Hash) + + + + — +

    a Hash of new values for properties that have changed

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+
+
# File 'lib/scarpe/wv/drawable.rb', line 97
+
+def properties_changed(changes)
+  # If a drawable does something really nonstandard with its html_id or element, it will
+  # need to override to prevent this from happening. That's easy enough, though.
+  if changes.key?("hidden")
+    hidden = changes.delete("hidden")
+    if hidden
+      html_element.set_style("display", "none")
+    else
+      # With Calzini we can't easily tell what the display property should be.
+      # Could be flex or inline, not only block or none. Re-render this drawable.
+      needs_update!
+    end
+  end
+
+  needs_update! unless changes.empty?
+end
+
+
+ +
+

+ + #remove_child(child) ⇒ Object (protected) + + + + + +

+
+

Do not call directly, use set_parent

+ + +
+
+
+ + +
+ + + + +
+
+
+
+129
+130
+131
+132
+133
+134
+135
+136
+
+
# File 'lib/scarpe/wv/drawable.rb', line 129
+
+def remove_child(child)
+  @children ||= []
+  unless @children.include?(child)
+    @log.error("remove_child: no such child(#{child.inspect}) for"\
+      " parent(#{parent.inspect})!")
+  end
+  @children.delete(child)
+end
+
+
+ +
+

+ + #set_parent(new_parent) ⇒ Object + + + + + +

+
+

Give this drawable a new parent, including managing the appropriate child lists for parent drawables.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+115
+116
+117
+118
+119
+
+
# File 'lib/scarpe/wv/drawable.rb', line 115
+
+def set_parent(new_parent)
+  @parent&.remove_child(self)
+  new_parent&.add_child(self)
+  @parent = new_parent
+end
+
+
+ +
+

+ + #shoes_stylesObject + + + + + +

+ + + + +
+
+
+
+82
+83
+84
+85
+86
+87
+88
+
+
# File 'lib/scarpe/wv/drawable.rb', line 82
+
+def shoes_styles
+  p = {}
+  @shoes_style_names.each do |prop_name|
+    p[prop_name] = instance_variable_get("@#{prop_name}")
+  end
+  p
+end
+
+
+ +
+

+ + #to_htmlString + + + + + +

+
+

to_html is intended to get the HTML DOM rendering of this object and its children. +Calling it should be side-effect-free and NOT update the webview.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +

    the rendered HTML

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+179
+180
+181
+182
+183
+
+
# File 'lib/scarpe/wv/drawable.rb', line 179
+
+def to_html
+  @children ||= []
+  child_markup = @children.map(&:to_html).join
+  element { child_markup }
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/EditBox.html b/Scarpe/Webview/EditBox.html new file mode 100644 index 000000000..fd56192e9 --- /dev/null +++ b/Scarpe/Webview/EditBox.html @@ -0,0 +1,750 @@ + + + + + + + Class: Scarpe::Webview::EditBox + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::EditBox + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/edit_box.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #font ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute font.

    +
    + +
  • + + +
  • + + + #height ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute height.

    +
    + +
  • + + +
  • + + + #text ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute text.

    +
    + +
  • + + +
  • + + + #tooltip ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute tooltip.

    +
    + +
  • + + +
  • + + + #width ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute width.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ EditBox + + + + + +

+
+

Returns a new instance of EditBox.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+
+
# File 'lib/scarpe/wv/edit_box.rb', line 7
+
+def initialize(properties)
+  super
+
+  # The JS handler sends a "change" event, which we forward to the Shoes drawable tree
+  bind("change") do |new_text|
+    send_self_event(new_text, event_name: "change")
+  end
+  bind("hover") do
+    send_self_event(event_name: "hover")
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #fontObject (readonly) + + + + + +

+
+

Returns the value of attribute font.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/edit_box.rb', line 5
+
+def font
+  @font
+end
+
+
+ + + +
+

+ + #heightObject (readonly) + + + + + +

+
+

Returns the value of attribute height.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/edit_box.rb', line 5
+
+def height
+  @height
+end
+
+
+ + + +
+

+ + #textObject (readonly) + + + + + +

+
+

Returns the value of attribute text.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/edit_box.rb', line 5
+
+def text
+  @text
+end
+
+
+ + + +
+

+ + #tooltipObject (readonly) + + + + + +

+
+

Returns the value of attribute tooltip.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/edit_box.rb', line 5
+
+def tooltip
+  @tooltip
+end
+
+
+ + + +
+

+ + #widthObject (readonly) + + + + + +

+
+

Returns the value of attribute width.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/edit_box.rb', line 5
+
+def width
+  @width
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+28
+29
+30
+
+
# File 'lib/scarpe/wv/edit_box.rb', line 28
+
+def element
+  render("edit_box")
+end
+
+
+ +
+

+ + #properties_changed(changes) ⇒ Object + + + + + +

+ + + + +
+
+
+
+19
+20
+21
+22
+23
+24
+25
+26
+
+
# File 'lib/scarpe/wv/edit_box.rb', line 19
+
+def properties_changed(changes)
+  t = changes.delete("text")
+  if t
+    html_element.value = t
+  end
+
+  super
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/EditLine.html b/Scarpe/Webview/EditLine.html new file mode 100644 index 000000000..498cf9342 --- /dev/null +++ b/Scarpe/Webview/EditLine.html @@ -0,0 +1,750 @@ + + + + + + + Class: Scarpe::Webview::EditLine + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::EditLine + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/edit_line.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #font ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute font.

    +
    + +
  • + + +
  • + + + #stroke ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute stroke.

    +
    + +
  • + + +
  • + + + #text ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute text.

    +
    + +
  • + + +
  • + + + #tooltip ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute tooltip.

    +
    + +
  • + + +
  • + + + #width ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute width.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ EditLine + + + + + +

+
+

Returns a new instance of EditLine.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+
+
# File 'lib/scarpe/wv/edit_line.rb', line 7
+
+def initialize(properties)
+  super
+
+  # The JS handler sends a "change" event, which we forward to the Shoes drawable tree
+  bind("change") do |new_text|
+    send_self_event(new_text, event_name: "change")
+  end
+  bind("hover") do |new_text|
+    send_self_event(new_text, event_name: "hover")
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #fontObject (readonly) + + + + + +

+
+

Returns the value of attribute font.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/edit_line.rb', line 5
+
+def font
+  @font
+end
+
+
+ + + +
+

+ + #strokeObject (readonly) + + + + + +

+
+

Returns the value of attribute stroke.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/edit_line.rb', line 5
+
+def stroke
+  @stroke
+end
+
+
+ + + +
+

+ + #textObject (readonly) + + + + + +

+
+

Returns the value of attribute text.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/edit_line.rb', line 5
+
+def text
+  @text
+end
+
+
+ + + +
+

+ + #tooltipObject (readonly) + + + + + +

+
+

Returns the value of attribute tooltip.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/edit_line.rb', line 5
+
+def tooltip
+  @tooltip
+end
+
+
+ + + +
+

+ + #widthObject (readonly) + + + + + +

+
+

Returns the value of attribute width.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/edit_line.rb', line 5
+
+def width
+  @width
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+28
+29
+30
+
+
# File 'lib/scarpe/wv/edit_line.rb', line 28
+
+def element
+  render("edit_line")
+end
+
+
+ +
+

+ + #properties_changed(changes) ⇒ Object + + + + + +

+ + + + +
+
+
+
+19
+20
+21
+22
+23
+24
+25
+26
+
+
# File 'lib/scarpe/wv/edit_line.rb', line 19
+
+def properties_changed(changes)
+  t = changes.delete("text")
+  if t
+    html_element.value = t
+  end
+
+  super
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Flow.html b/Scarpe/Webview/Flow.html new file mode 100644 index 000000000..977af3edb --- /dev/null +++ b/Scarpe/Webview/Flow.html @@ -0,0 +1,197 @@ + + + + + + + Class: Scarpe::Webview::Flow + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Flow + + + +

+
+ +
+
Inherits:
+
+ Slot + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/flow.rb
+
+ +
+ +
+

Direct Known Subclasses

+

DocumentRoot

+
+ + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + + + + + + + +

Method Summary

+ +

Methods inherited from Slot

+

#element, #html_attributes, #initialize, #remove_event_callback, #remove_event_callbacks, #set_event_callback, #update_dom_event

+ + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #initialize, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #initialize, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +

This class inherits a constructor from Scarpe::Webview::Slot

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Image.html b/Scarpe/Webview/Image.html new file mode 100644 index 000000000..7bc19e04d --- /dev/null +++ b/Scarpe/Webview/Image.html @@ -0,0 +1,322 @@ + + + + + + + Class: Scarpe::Webview::Image + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Image + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/image.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ Image + + + + + +

+
+

Returns a new instance of Image.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+8
+9
+10
+11
+12
+
+
# File 'lib/scarpe/wv/image.rb', line 5
+
+def initialize(properties)
+  super
+
+  unless valid_url?(@url)
+    # It's assumed to be a file path.
+    @url = Scarpe::Webview.asset_server.asset_url(File.expand_path @url)
+  end
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+14
+15
+16
+
+
# File 'lib/scarpe/wv/image.rb', line 14
+
+def element
+  render("image")
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Line.html b/Scarpe/Webview/Line.html new file mode 100644 index 000000000..93dbc34ff --- /dev/null +++ b/Scarpe/Webview/Line.html @@ -0,0 +1,312 @@ + + + + + + + Class: Scarpe::Webview::Line + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Line + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/line.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ Line + + + + + +

+
+

Returns a new instance of Line.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/line.rb', line 5
+
+def initialize(properties)
+  super(properties)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+9
+10
+11
+
+
# File 'lib/scarpe/wv/line.rb', line 9
+
+def element
+  render("line")
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Link.html b/Scarpe/Webview/Link.html new file mode 100644 index 000000000..0b0038f8d --- /dev/null +++ b/Scarpe/Webview/Link.html @@ -0,0 +1,337 @@ + + + + + + + Class: Scarpe::Webview::Link + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Link + + + +

+
+ +
+
Inherits:
+
+ TextDrawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/link.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from TextDrawable

+

#element, #html_element, #items_to_display_children

+ + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ Link + + + + + +

+
+

Returns a new instance of Link.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+8
+9
+10
+11
+
+
# File 'lib/scarpe/wv/link.rb', line 5
+
+def initialize(properties)
+  super
+
+  bind("click") do
+    send_self_event(event_name: "click")
+  end
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #to_calzini_hashObject + + + + + +

+ + + + +
+
+
+
+13
+14
+15
+16
+17
+
+
# File 'lib/scarpe/wv/link.rb', line 13
+
+def to_calzini_hash
+  h = super
+  h[:tag] = "a"
+  h
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/ListBox.html b/Scarpe/Webview/ListBox.html new file mode 100644 index 000000000..de6511912 --- /dev/null +++ b/Scarpe/Webview/ListBox.html @@ -0,0 +1,670 @@ + + + + + + + Class: Scarpe::Webview::ListBox + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::ListBox + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/list_box.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #chosen ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute chosen.

    +
    + +
  • + + +
  • + + + #height ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute height.

    +
    + +
  • + + +
  • + + + #items ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute items.

    +
    + +
  • + + +
  • + + + #width ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute width.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ ListBox + + + + + +

+
+

Returns a new instance of ListBox.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+
+
# File 'lib/scarpe/wv/list_box.rb', line 7
+
+def initialize(properties)
+  super
+
+  bind("change") do |new_item|
+    send_self_event(new_item, event_name: "change")
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #chosenObject (readonly) + + + + + +

+
+

Returns the value of attribute chosen.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/list_box.rb', line 5
+
+def chosen
+  @chosen
+end
+
+
+ + + +
+

+ + #heightObject (readonly) + + + + + +

+
+

Returns the value of attribute height.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/list_box.rb', line 5
+
+def height
+  @height
+end
+
+
+ + + +
+

+ + #itemsObject (readonly) + + + + + +

+
+

Returns the value of attribute items.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/list_box.rb', line 5
+
+def items
+  @items
+end
+
+
+ + + +
+

+ + #widthObject (readonly) + + + + + +

+
+

Returns the value of attribute width.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/list_box.rb', line 5
+
+def width
+  @width
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+23
+24
+25
+
+
# File 'lib/scarpe/wv/list_box.rb', line 23
+
+def element
+  render("list_box")
+end
+
+
+ +
+

+ + #properties_changed(changes) ⇒ Object + + + + + +

+ + + + +
+
+
+
+15
+16
+17
+18
+19
+20
+21
+
+
# File 'lib/scarpe/wv/list_box.rb', line 15
+
+def properties_changed(changes)
+  selected = changes.delete("chosen")
+  if selected
+    html_element.value = selected
+  end
+  super
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Oval.html b/Scarpe/Webview/Oval.html new file mode 100644 index 000000000..a81c268df --- /dev/null +++ b/Scarpe/Webview/Oval.html @@ -0,0 +1,312 @@ + + + + + + + Class: Scarpe::Webview::Oval + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Oval + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/oval.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ Oval + + + + + +

+
+

Returns a new instance of Oval.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/oval.rb', line 5
+
+def initialize(properties)
+  super(properties)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #element(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+9
+10
+11
+
+
# File 'lib/scarpe/wv/oval.rb', line 9
+
+def element(&block)
+  render("oval", &block)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Para.html b/Scarpe/Webview/Para.html new file mode 100644 index 000000000..43f0efd21 --- /dev/null +++ b/Scarpe/Webview/Para.html @@ -0,0 +1,459 @@ + + + + + + + Class: Scarpe::Webview::Para + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Para + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/para.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #initialize, #inspect, #needs_update!, #promise_update, #remove_child, #set_parent, #shoes_styles

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #initialize, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +

This class inherits a constructor from Scarpe::Webview::Drawable

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #element(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+49
+50
+51
+
+
# File 'lib/scarpe/wv/para.rb', line 49
+
+def element(&block)
+  render("para", &block)
+end
+
+
+ +
+

+ + #items_to_display_children(items) ⇒ Object + + + + + +

+ + + + +
+
+
+
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+
+
# File 'lib/scarpe/wv/para.rb', line 37
+
+def items_to_display_children(items)
+  return [] if items.nil?
+
+  items.map do |item|
+    if item.is_a?(String)
+      item
+    else
+      Scarpe::Webview::DisplayService.instance.query_display_drawable_for(item)
+    end
+  end
+end
+
+
+ +
+

+ + #properties_changed(changes) ⇒ Object + + + + + +

+ + + + +
+
+
+
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+
+
# File 'lib/scarpe/wv/para.rb', line 22
+
+def properties_changed(changes)
+  items = changes.delete("text_items")
+  if items
+    html_element.inner_html = to_html
+    return
+  end
+
+  # Not deleting, so this will re-render
+  if changes["size"] && SIZES[@size.to_sym]
+    @size = @size.to_sym
+  end
+
+  super
+end
+
+
+ +
+

+ + #to_htmlObject + + + + + +

+
+

Because para's to_html takes a block, and it needs to convert IDs into display +drawables, it needs to also override to_html

+ + +
+
+
+ + +
+ + + + +
+
+
+
+55
+56
+57
+58
+59
+
+
# File 'lib/scarpe/wv/para.rb', line 55
+
+def to_html
+  @children ||= []
+
+  element { child_markup }
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Progress.html b/Scarpe/Webview/Progress.html new file mode 100644 index 000000000..645fc3b25 --- /dev/null +++ b/Scarpe/Webview/Progress.html @@ -0,0 +1,328 @@ + + + + + + + Class: Scarpe::Webview::Progress + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Progress + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/progress.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ Progress + + + + + +

+
+

Returns a new instance of Progress.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/progress.rb', line 5
+
+def initialize(properties)
+  super
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+
+

For now do not catch properties_changed and do a small update. +Tiranti updates some additional fields (e.g. aria-valuenow) that +Calzini does not. We'll want Calzini and Tiranti to handle the +updates more for themselves. See issue #419 for updates on how +we'll handle this. But for right now we re-render the whole +drawable every time we change the progress fraction.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+15
+16
+17
+
+
# File 'lib/scarpe/wv/progress.rb', line 15
+
+def element
+  render("progress")
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Radio.html b/Scarpe/Webview/Radio.html new file mode 100644 index 000000000..c8ff969ad --- /dev/null +++ b/Scarpe/Webview/Radio.html @@ -0,0 +1,470 @@ + + + + + + + Class: Scarpe::Webview::Radio + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Radio + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/radio.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #text ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    TODO: is this needed?.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ Radio + + + + + +

+
+

Returns a new instance of Radio.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+11
+12
+13
+14
+
+
# File 'lib/scarpe/wv/radio.rb', line 8
+
+def initialize(properties)
+  super
+
+  bind("click") do
+    send_self_event(event_name: "click", target: shoes_linkable_id)
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #textObject (readonly) + + + + + +

+
+

TODO: is this needed?

+ + +
+
+
+ + +
+ + + + +
+
+
+
+6
+7
+8
+
+
# File 'lib/scarpe/wv/radio.rb', line 6
+
+def text
+  @text
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+23
+24
+25
+26
+27
+28
+29
+30
+31
+
+
# File 'lib/scarpe/wv/radio.rb', line 23
+
+def element
+  props = shoes_styles
+
+  # If a group isn't set, default to the linkable ID of the parent slot
+  unless @group
+    props["group"] = @parent ? @parent.shoes_linkable_id : "no_group"
+  end
+  render("radio", props)
+end
+
+
+ +
+

+ + #properties_changed(changes) ⇒ Object + + + + + +

+ + + + +
+
+
+
+16
+17
+18
+19
+20
+21
+
+
# File 'lib/scarpe/wv/radio.rb', line 16
+
+def properties_changed(changes)
+  items = changes.delete("checked")
+  html_element.toggle_input_button(items)
+
+  super
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Rect.html b/Scarpe/Webview/Rect.html new file mode 100644 index 000000000..7eea31e20 --- /dev/null +++ b/Scarpe/Webview/Rect.html @@ -0,0 +1,312 @@ + + + + + + + Class: Scarpe::Webview::Rect + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Rect + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/rect.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ Rect + + + + + +

+
+

Returns a new instance of Rect.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/rect.rb', line 5
+
+def initialize(properties)
+  super(properties)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #element(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+9
+10
+11
+
+
# File 'lib/scarpe/wv/rect.rb', line 9
+
+def element(&block)
+  render("rect", &block)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/RelayDisplayService.html b/Scarpe/Webview/RelayDisplayService.html new file mode 100644 index 000000000..a50a8fc88 --- /dev/null +++ b/Scarpe/Webview/RelayDisplayService.html @@ -0,0 +1,618 @@ + + + + + + + Class: Scarpe::Webview::RelayDisplayService + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::RelayDisplayService + + + +

+
+ +
+
Inherits:
+
+ Shoes::DisplayService + + + show all + +
+
+ + + + + + +
+
Includes:
+
Scarpe::WVRelayUtil, Shoes::Log
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/wv/webview_relay_display.rb
+
+ +
+ +

Overview

+
+

This display service creates a child process and sends events +back and forth, but creates no drawables of its own. The child +process will spawn a worker with its own Webview::DisplayService +where the real Webview exists. By splitting the Webview +process from the Shoes drawables, it can be easier to return +control to Webview's event handler promptly. Also, the Ruby +process could run background threads if it wanted, and +otherwise behave like a process not containing Webview.

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #shutdown ⇒ Object + + + + + + + + + + + + + + + + +

    Returns the value of attribute shutdown.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Scarpe::WVRelayUtil

+

#event_loop_for, #ready_to_read?, #receive_datagram, #respond_to_datagram, #send_datagram

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::DisplayService

+

dispatch_event, display_service, full_reset!, #query_display_drawable_for, set_display_service_class, #set_drawable_pairing, subscribe_to_event, unsub_from_events

+
+

Constructor Details

+ +
+

+ + #initializeRelayDisplayService + + + + + +

+
+

Create a Webview Relay Display Service

+ + +
+
+
+ + +
+ + + + +
+
+
+
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+
+
# File 'lib/scarpe/wv/webview_relay_display.rb', line 24
+
+def initialize
+  super()
+  log_init("Webview::RelayDisplayService")
+
+  @event_subs = []
+  @shutdown = false
+  @i_am = :parent
+
+  server = TCPServer.new("127.0.0.1", 0)
+  port = server.addr[1]
+
+  @pid = spawn(RbConfig.ruby, File.join(__dir__, "wv_display_worker.rb"), port.to_s)
+  @from = @to = server.accept
+
+  # Subscribe to all event notifications and relay them to the worker
+  @event_subs << bind_shoes_event(event_name: :any, target: :any) do |*args, **kwargs|
+    unless kwargs[:relayed]
+      kwargs[:relayed] = true
+      send_datagram({ type: :event, args:, kwargs: })
+    end
+
+    # Forward the run event to the child process before doing this
+    if event_name == "run"
+      run_event_loop
+    end
+  rescue Scarpe::AppShutdownError
+    @shutdown = true
+    @log.info("Attempting to shut down...")
+    self.destroy
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #shutdownObject + + + + + +

+
+

Returns the value of attribute shutdown.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+21
+22
+23
+
+
# File 'lib/scarpe/wv/webview_relay_display.rb', line 21
+
+def shutdown
+  @shutdown
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #create_display_drawable_for(drawable_class_name, drawable_id, properties) ⇒ Object + + + + + +

+
+

This method sends a message to the worker process to create a drawable. No actual +drawable is created or registered with the display service.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+70
+71
+72
+73
+
+
# File 'lib/scarpe/wv/webview_relay_display.rb', line 70
+
+def create_display_drawable_for(drawable_class_name, drawable_id, properties)
+  send_datagram({ type: :create, class_name: drawable_class_name, id: drawable_id, properties: })
+  # Don't need to return anything. It wouldn't be used anyway.
+end
+
+
+ +
+

+ + #destroyObject + + + + + +

+
+

Tell the worker process to quit, and set a flag telling the event loop to shut down.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+76
+77
+78
+79
+80
+81
+82
+
+
# File 'lib/scarpe/wv/webview_relay_display.rb', line 76
+
+def destroy
+  unless @shutdown
+    send_datagram({ type: :destroy })
+  end
+  @shutdown = true
+  (@events_subs || []).each { |unsub_id| DisplayService.unsub_from_events(unsub_id) }
+end
+
+
+ +
+

+ + #run_event_loopObject + + + + + +

+
+

Run, sending and responding to datagrams continuously.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+
+
# File 'lib/scarpe/wv/webview_relay_display.rb', line 57
+
+def run_event_loop
+  until @shutdown
+    respond_to_datagram while ready_to_read?
+    sleep 0.1
+  end
+rescue Scarpe::AppShutdownError
+  @shutdown = true
+  @log.info("Attempting to shut down...")
+  self.destroy
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Shape.html b/Scarpe/Webview/Shape.html new file mode 100644 index 000000000..0b030789e --- /dev/null +++ b/Scarpe/Webview/Shape.html @@ -0,0 +1,418 @@ + + + + + + + Class: Scarpe::Webview::Shape + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Shape + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/shape.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #initialize, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #initialize, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +

This class inherits a constructor from Scarpe::Webview::Drawable

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #element(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+
+
# File 'lib/scarpe/wv/shape.rb', line 25
+
+def element(&block)
+  color = @draw_context["fill"] || "black"
+  HTML.render do |h|
+    h.div(id: html_id, style: shape_style) do
+      h.svg(width: "400", height: "500") do
+        h.path(d: path_from_shape_commands, style: "fill:#{color};stroke-width:2;")
+      end
+      block.call(h) if block_given?
+    end
+  end
+end
+
+
+ +
+

+ + #shape_styleObject (protected) + + + + + +

+ + + + +
+
+
+
+61
+62
+63
+64
+65
+66
+67
+68
+
+
# File 'lib/scarpe/wv/shape.rb', line 61
+
+def shape_style
+  s = {
+    width: "400",
+    height: "900",
+  }
+  s[:display] = "none" if @hidden
+  s
+end
+
+
+ +
+

+ + #to_htmlObject + + + + + +

+
+

Shape is the only (?) remaining drawable that doesn't use Calzini. +It's also kind of broken - it doesn't do what a Shoes Shape is +supposed to do yet. This can really use a rework at some point.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+
+
# File 'lib/scarpe/wv/shape.rb', line 8
+
+def to_html
+  @children ||= []
+  child_markup = @children.map(&:to_html).join
+
+  color = @draw_context["fill"] || "black"
+  self_markup = HTML.render do |h|
+    h.div(id: html_id, style: shape_style) do
+      h.svg(width: "400", height: "500") do
+        h.path(d: path_from_shape_commands, style: "fill:#{color};stroke-width:2;")
+      end
+    end
+  end
+
+  # Put child markup first for backward compatibility, but I'm pretty sure this is wrong.
+  child_markup + self_markup
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Slot.html b/Scarpe/Webview/Slot.html new file mode 100644 index 000000000..fd414064a --- /dev/null +++ b/Scarpe/Webview/Slot.html @@ -0,0 +1,643 @@ + + + + + + + Class: Scarpe::Webview::Slot + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Slot + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/slot.rb
+
+ +
+ +
+

Direct Known Subclasses

+

Flow, Stack

+
+ + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ Slot + + + + + +

+
+

Returns a new instance of Slot.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+8
+9
+
+
# File 'lib/scarpe/wv/slot.rb', line 5
+
+def initialize(properties)
+  @event_callbacks = {}
+
+  super
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #element(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+11
+12
+13
+14
+15
+
+
# File 'lib/scarpe/wv/slot.rb', line 11
+
+def element(&block)
+  props = shoes_styles.merge("html_attributes" => html_attributes)
+  render_name = self.class.name.split("::")[-1].downcase # usually "stack" or "flow" or "documentroot"
+  render(render_name, props, &block)
+end
+
+
+ +
+

+ + #html_attributesObject (protected) + + + + + +

+
+

These get added for event handlers and passed to Calzini

+ + +
+
+
+ + +
+ + + + +
+
+
+
+54
+55
+56
+57
+58
+59
+60
+61
+62
+
+
# File 'lib/scarpe/wv/slot.rb', line 54
+
+def html_attributes
+  attr = {}
+
+  @event_callbacks.each do |event_name, handlers|
+    attr[event_name] = handlers.values.join(";")
+  end
+
+  attr
+end
+
+
+ +
+

+ + #remove_event_callback(obj, event_name) ⇒ Object + + + + + +

+ + + + +
+
+
+
+29
+30
+31
+32
+33
+34
+35
+
+
# File 'lib/scarpe/wv/slot.rb', line 29
+
+def remove_event_callback(obj, event_name)
+  event_name = event_name.to_s
+  @event_callbacks[event_name] ||= {}
+  @event_callbacks[event_name].delete(obj)
+
+  update_dom_event(event_name)
+end
+
+
+ +
+

+ + #remove_event_callbacks(obj) ⇒ Object + + + + + +

+ + + + +
+
+
+
+37
+38
+39
+40
+41
+42
+43
+44
+45
+
+
# File 'lib/scarpe/wv/slot.rb', line 37
+
+def remove_event_callbacks(obj)
+  changed = []
+
+  @event_callbacks.each do |event_name, items|
+    changed << event_name if items.delete(obj)
+  end
+
+  changed.each { |event_name| update_dom_event(event_name) }
+end
+
+
+ +
+

+ + #set_event_callback(obj, event_name, js_code) ⇒ Object + + + + + +

+ + + + +
+
+
+
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+
+
# File 'lib/scarpe/wv/slot.rb', line 17
+
+def set_event_callback(obj, event_name, js_code)
+  event_name = event_name.to_s
+  @event_callbacks[event_name] ||= {}
+  if @event_callbacks[event_name][obj]
+    raise Scarpe::DuplicateCallbackError, "Can't have two callbacks on the same event, from the same object, on the same parent!"
+  end
+
+  @event_callbacks[event_name][obj] = js_code
+
+  update_dom_event(event_name)
+end
+
+
+ +
+

+ + #update_dom_event(event_name) ⇒ Object (protected) + + + + + +

+ + + + +
+
+
+
+49
+50
+51
+
+
# File 'lib/scarpe/wv/slot.rb', line 49
+
+def update_dom_event(event_name)
+  html_element.set_attribute(event_name, @event_callbacks[event_name].values.join(";"))
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Stack.html b/Scarpe/Webview/Stack.html new file mode 100644 index 000000000..90beeceef --- /dev/null +++ b/Scarpe/Webview/Stack.html @@ -0,0 +1,193 @@ + + + + + + + Class: Scarpe::Webview::Stack + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Stack + + + +

+
+ +
+
Inherits:
+
+ Slot + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/stack.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + + + + + + + +

Method Summary

+ +

Methods inherited from Slot

+

#element, #html_attributes, #initialize, #remove_event_callback, #remove_event_callbacks, #set_event_callback, #update_dom_event

+ + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #initialize, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #initialize, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +

This class inherits a constructor from Scarpe::Webview::Slot

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Star.html b/Scarpe/Webview/Star.html new file mode 100644 index 000000000..1eb6272d7 --- /dev/null +++ b/Scarpe/Webview/Star.html @@ -0,0 +1,312 @@ + + + + + + + Class: Scarpe::Webview::Star + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Star + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/star.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ Star + + + + + +

+
+

Returns a new instance of Star.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/star.rb', line 5
+
+def initialize(properties)
+  super(properties)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #element(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+9
+10
+11
+
+
# File 'lib/scarpe/wv/star.rb', line 9
+
+def element(&block)
+  render("star", &block)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/SubscriptionItem.html b/Scarpe/Webview/SubscriptionItem.html new file mode 100644 index 000000000..d099ecbb8 --- /dev/null +++ b/Scarpe/Webview/SubscriptionItem.html @@ -0,0 +1,554 @@ + + + + + + + Class: Scarpe::Webview::SubscriptionItem + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::SubscriptionItem + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/subscription_item.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ SubscriptionItem + + + + + +

+
+

Returns a new instance of SubscriptionItem.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+
+
# File 'lib/scarpe/wv/subscription_item.rb', line 4
+
+def initialize(properties)
+  super
+
+  bind(@shoes_api_name) do |*args|
+    send_self_event(*args, event_name: @shoes_api_name)
+  end
+
+  @wrangler = Scarpe::Webview::DisplayService.instance.wrangler
+
+  case @shoes_api_name
+  when "animate"
+    frame_rate = (@args[0] || 10)
+    @counter = 0
+    @wrangler.periodic_code("animate_#{@shoes_linkable_id}", 1.0 / frame_rate) do
+      @counter += 1
+      send_self_event(@counter, event_name: @shoes_api_name)
+    end
+  when "every"
+    delay = @args[0]
+    @counter = 0
+    @wrangler.periodic_code("every_#{@shoes_linkable_id}", delay) do
+      @counter += 1
+      send_self_event(@counter, event_name: @shoes_api_name)
+    end
+  when "timer"
+    # JS setTimeout?
+    raise "Implement me!"
+  when "motion", "hover", "leave", "click", "release", "keypress"
+    # Wait for set_parent
+  else
+    raise Scarpe::UnknownShoesEventAPIError, "Unknown Shoes event API: #{@shoes_api_name}!"
+  end
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #destroy_selfObject + + + + + +

+ + + + +
+
+
+
+80
+81
+82
+83
+
+
# File 'lib/scarpe/wv/subscription_item.rb', line 80
+
+def destroy_self
+  @parent&.remove_event_callbacks(self)
+  super
+end
+
+
+ +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+38
+39
+40
+
+
# File 'lib/scarpe/wv/subscription_item.rb', line 38
+
+def element
+  ""
+end
+
+
+ +
+

+ + #set_parent(new_parent) ⇒ Object + + + + + +

+
+

This will get called once we know the parent, which is useful for events +like hover, where our subscription is likely to depend on what our parent is.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+
+
# File 'lib/scarpe/wv/subscription_item.rb', line 44
+
+def set_parent(new_parent)
+  super
+
+  case @shoes_api_name
+  when "motion"
+    # TODO: what do we do for whole-screen mousemove outside the window?
+    # Those should be set on body, which right now doesn't have a drawable.
+    # TODO: figure out how to handle alt and meta keys - does Shoes3 recognise those?
+    new_parent.set_event_callback(
+      self,
+      "onmousemove",
+      handler_js_code(
+        @shoes_api_name,
+        "arguments[0].x",
+        "arguments[0].y",
+        "arguments[0].ctrlKey",
+        "arguments[0].shiftKey",
+      ),
+    )
+  when "hover"
+    new_parent.set_event_callback(self, "onmouseenter", handler_js_code(@shoes_api_name))
+  when "leave"
+    new_parent.set_event_callback(self, "onmouseleave", handler_js_code(@shoes_api_name))
+  when "click"
+    new_parent.set_event_callback(self, "onclick", handler_js_code(@shoes_api_name, "arguments[0].button", "arguments[0].x", "arguments[0].y"))
+  when "release"
+    new_parent.set_event_callback(self, "onmouseup", handler_js_code(@shoes_api_name, "arguments[0].button", "arguments[0].x", "arguments[0].y"))
+  when "keypress"
+    raise "Implement me!"
+  when "animate", "every", "timer"
+    # These were handled in initialize(), ignore them here
+  else
+    raise Scarpe::UnknownShoesEventAPIError, "Unknown Shoes event API: #{@shoes_api_name}!"
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/TextDrawable.html b/Scarpe/Webview/TextDrawable.html new file mode 100644 index 000000000..77783100f --- /dev/null +++ b/Scarpe/Webview/TextDrawable.html @@ -0,0 +1,493 @@ + + + + + + + Class: Scarpe::Webview::TextDrawable + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::TextDrawable + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/text_drawable.rb
+
+ +
+ +

Overview

+
+

This class renders text tags like em, strong, link, etc.

+ + +
+
+
+ + +
+

Direct Known Subclasses

+

Link

+
+ + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_id, #initialize, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #initialize, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +

This class inherits a constructor from Scarpe::Webview::Drawable

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+39
+40
+41
+
+
# File 'lib/scarpe/wv/text_drawable.rb', line 39
+
+def element
+  render("text_drawable", [to_calzini_hash])
+end
+
+
+ +
+

+ + #html_elementObject + + + + + +

+
+

Usually we query by ID, but for TextDrawable it has to be by class. +That's how needs_update!, etc continue to work.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+57
+58
+59
+
+
# File 'lib/scarpe/wv/text_drawable.rb', line 57
+
+def html_element
+  @elt_wrangler ||= Scarpe::Webview::WebWrangler::ElementWrangler.new(selector: %{document.getElementsByClassName("id_#{html_id}")}, multi: true)
+end
+
+
+ +
+

+ + #items_to_display_children(items) ⇒ Object + + + + + +

+ + + + +
+
+
+
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+
+
# File 'lib/scarpe/wv/text_drawable.rb', line 43
+
+def items_to_display_children(items)
+  return [] if items.nil?
+
+  items.map do |item|
+    if item.is_a?(String)
+      item
+    else
+      Scarpe::Webview::DisplayService.instance.query_display_drawable_for(item)
+    end
+  end
+end
+
+
+ +
+

+ + #to_calzini_hashObject + + + + + +

+
+

Calzini renders based on properties, mostly Shoes styles. +To have Calzini render this for us, we convert to the format +Calzini expects and then let it render. See Webview::Para +for the specific Calzini call.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+
+
# File 'lib/scarpe/wv/text_drawable.rb', line 19
+
+def to_calzini_hash
+  text_array = items_to_display_children(@text_items).map do |item|
+    if item.respond_to?(:to_calzini_hash)
+      item.to_calzini_hash
+    elsif item.is_a?(String)
+      item
+    else
+      # This should normally be filtered out in Lacci, long before we see it
+      raise "Unrecognized item in TextDrawable! #{item.inspect}"
+    end
+  end
+
+  {
+    items: text_array,
+    html_id: @linkable_id.to_s,
+    tag: nil, # have Calzini assign a default unless a subclass overrides this
+    props: shoes_styles,
+  }
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/Video.html b/Scarpe/Webview/Video.html new file mode 100644 index 000000000..e8efaef18 --- /dev/null +++ b/Scarpe/Webview/Video.html @@ -0,0 +1,353 @@ + + + + + + + Class: Scarpe::Webview::Video + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::Video + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/video.rb
+
+ +
+ + + +

+ Constant Summary + collapse +

+ +
+ +
SUPPORTED_FORMATS = + +
+
{
+  "video/mp4" => [".mp4"],
+  "video/webp" => [".webp"],
+  "video/quicktime" => [".mov"],
+  "video/x-matroska" => [".mkv"],
+  # Add more formats and their associated file extensions if needed
+}.freeze
+ +
FORMAT_FOR_EXT = +
+
+

Add more formats and their associated file extensions if needed

+ + +
+
+
+ + +
+
+
{}
+ +
+ + + + + + +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ Video + + + + + +

+
+

Returns a new instance of Video.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+24
+25
+26
+27
+28
+
+
# File 'lib/scarpe/wv/video.rb', line 24
+
+def initialize(properties)
+  @url = properties[:url]
+  super
+  @format = FORMAT_FOR_EXT[File.extname(@url)]
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+30
+31
+32
+
+
# File 'lib/scarpe/wv/video.rb', line 30
+
+def element
+  render "video", shoes_styles.merge("format" => @format)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/WebWrangler.html b/Scarpe/Webview/WebWrangler.html new file mode 100644 index 000000000..2505979d9 --- /dev/null +++ b/Scarpe/Webview/WebWrangler.html @@ -0,0 +1,2522 @@ + + + + + + + Class: Scarpe::Webview::WebWrangler + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::WebWrangler + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + +
+
Includes:
+
Shoes::Log
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/wv/web_wrangler.rb,
+ lib/scarpe/wv/web_wrangler.rb
+
+
+ +
+ +

Overview

+
+

The Scarpe WebWrangler, for Webview, manages a lot of Webviews quirks. It provides +a simpler underlying abstraction for DOMWrangler and the Webview drawables. +Webview can be picky - if you send it too many messages, it can crash. If the +messages you send it are too large, it can crash. If you don't return control +to its event loop, it can crash. It doesn't save references to all event handlers, +so if you don't save references to them, garbage collection will cause it to +crash.

+ +

As well, Webview only supports asynchronous JS code evaluation with no value +being returned. One of WebWrangler's responsibilities is to make asynchronous +JS calls, detect when they return a value or time out, and make the result clear +to other Scarpe code.

+ +

Some Webview API functions will crash on some platforms if called from a +background thread. Webview will halt all background threads when it runs its +event loop. So it's best to assume no Ruby background threads will be available +while Webview is running. If a Ruby app wants ongoing work to occur, that work +should be registered via a heartbeat handler on the Webview.

+ +

A WebWrangler is initially in Setup mode, where the underlying Webview exists +but does not yet control the event loop. In Setup mode you can bind JS functions, +set up initialization code, but nothing is yet running.

+ +

Once run() is called on WebWrangler, we will hand control of the event loop to +the Webview. This will also stop any background threads in Ruby.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + + + Classes: DOMWrangler, ElementWrangler + + +

+ + +

+ Constant Summary + collapse +

+ +
+ +
EVAL_RESULT = +
+
+

This is the JS function name for eval results (internal-only)

+ + +
+
+
+ + +
+
+
"scarpeAsyncEvalResult"
+ +
EVAL_DEFAULT_TIMEOUT = +
+
+

Allow this many seconds for Webview to finish our JS eval before we decide it's not going to

+ + +
+
+
+ + +
+
+
0.5
+ +
+ + + + + + +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #control_interface ⇒ Object + + + + + + + + + + + + + + + + +

    A reference to the control_interface that manages internal Scarpe Webview events.

    +
    + +
  • + + +
  • + + + #empty_page ⇒ Object + + + + + + + + + + writeonly + + + + + + + + +

    Sets the attribute empty_page.

    +
    + +
  • + + +
  • + + + #heartbeat ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    This is the time between heartbeats in seconds, usually fractional.

    +
    + +
  • + + +
  • + + + #is_running ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Whether Webview has been started.

    +
    + +
  • + + +
  • + + + #is_terminated ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Once Webview is marked terminated, it's attempting to shut down.

    +
    + +
  • + + +
+ + + + + +

+ Class Method Summary + collapse +

+ +
    + +
  • + + + .js_wrapped_code(code, eval_id) ⇒ Object + + + + + + + + + + + + + +

    This method takes a piece of Javascript code and wraps it in the WebWrangler boilerplate to see if it parses successfully, run it, and see if it succeeds.

    +
    + +
  • + + +
+ +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+
+

Constructor Details

+ +
+

+ + #initialize(title:, width:, height:, resizable: false, heartbeat: 0.1) ⇒ WebWrangler + + + + + +

+
+

Create a new WebWrangler.

+ + +
+
+
+

Parameters:

+
    + +
  • + + title + + + (String) + + + + — +

    window title

    +
    + +
  • + +
  • + + width + + + (Integer) + + + + — +

    window width in pixels

    +
    + +
  • + +
  • + + height + + + (Integer) + + + + — +

    window height in pixels

    +
    + +
  • + +
  • + + resizable + + + (Boolean) + + + (defaults to: false) + + + — +

    whether the window should be resizable by the user

    +
    + +
  • + +
  • + + heartbeat + + + (Float) + + + (defaults to: 0.1) + + + — +

    time between heartbeats in seconds

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 67
+
+def initialize(title:, width:, height:, resizable: false, heartbeat: 0.1)
+  log_init("Webview::WebWrangler")
+
+  @log.debug("Creating WebWrangler...")
+
+  # For now, always allow inspect element, so pass debug: true
+  @webview = WebviewRuby::Webview.new debug: true
+  @webview = Shoes::LoggedWrapper.new(@webview, "WebviewAPI") if ENV["SCARPE_DEBUG"]
+  @init_refs = {} # Inits don't go away so keep a reference to them to prevent GC
+
+  @title = title
+  @width = width
+  @height = height
+  @resizable = resizable
+  @heartbeat = heartbeat
+
+  # JS setInterval uses RPC and is quite expensive. For many periodic operations
+  # we can group them under a single heartbeat handler and avoid extra JS calls or RPC.
+  @heartbeat_handlers = []
+
+  # Need to keep track of which WebView Javascript evals are still pending,
+  # what handlers to call when they return, etc.
+  @pending_evals = {}
+  @eval_counter = 0
+
+  @dom_wrangler = DOMWrangler.new(self)
+
+  bind("puts") do |*args|
+    puts(*args)
+  end
+
+  @webview.bind(EVAL_RESULT) do |*results|
+    receive_eval_result(*results)
+  end
+
+  # Ruby receives scarpeHeartbeat messages via the window library's main loop.
+  # So this is a way for Ruby to be notified periodically, in time with that loop.
+  @webview.bind("scarpeHeartbeat") do
+    return unless @webview # I think GTK+ may continue to deliver events after shutdown
+
+    periodic_js_callback
+    @heartbeat_handlers.each(&:call)
+    @control_interface.dispatch_event(:heartbeat)
+  end
+  js_interval = (heartbeat.to_f * 1_000.0).to_i
+  @webview.init("setInterval(scarpeHeartbeat,#{js_interval})")
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #control_interfaceObject + + + + + +

+
+

A reference to the control_interface that manages internal Scarpe Webview events.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+52
+53
+54
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 52
+
+def control_interface
+  @control_interface
+end
+
+
+ + + +
+

+ + #empty_page=(value) ⇒ Object (writeonly) + + + + + +

+
+

Sets the attribute empty_page

+ + +
+
+
+

Parameters:

+
    + +
  • + + value + + + + + + + — +

    the value to set the attribute empty_page to.

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+366
+367
+368
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 366
+
+def empty_page=(value)
+  @empty_page = value
+end
+
+
+ + + +
+

+ + #heartbeatObject (readonly) + + + + + +

+
+

This is the time between heartbeats in seconds, usually fractional

+ + +
+
+
+ + +
+ + + + +
+
+
+
+49
+50
+51
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 49
+
+def heartbeat
+  @heartbeat
+end
+
+
+ + + +
+

+ + #is_runningObject (readonly) + + + + + +

+
+

Whether Webview has been started. Once Webview is running you can't add new +Javascript bindings. Until it is running, you can't use eval to run Javascript.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+42
+43
+44
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 42
+
+def is_running
+  @is_running
+end
+
+
+ + + +
+

+ + #is_terminatedObject (readonly) + + + + + +

+
+

Once Webview is marked terminated, it's attempting to shut down. If we get +events (e.g. heartbeats) after that, we should ignore them.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+46
+47
+48
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 46
+
+def is_terminated
+  @is_terminated
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + .js_wrapped_code(code, eval_id) ⇒ Object + + + + + +

+
+

This method takes a piece of Javascript code and wraps it in the WebWrangler +boilerplate to see if it parses successfully, run it, and see if it succeeds. +This function would normally be used by testing code, to mock Webview and +watch for code being run. Javascript code containing backticks +could potentially break this abstraction layer, which would cause the resulting +code to fail to parse and Webview would return no error. This should not be +used for random or untrusted code.

+ + +
+
+
+

Parameters:

+
    + +
  • + + code + + + (String) + + + + — +

    the Javascript code to be wrapped

    +
    + +
  • + +
  • + + eval_id + + + (Integer) + + + + — +

    the tracking code to use when calling EVAL_RESULT

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 283
+
+def self.js_wrapped_code(code, eval_id)
+  <<~JS_CODE
+    (function() {
+      var code_string = #{JSON.dump code};
+      try {
+        result = eval(code_string);
+        #{EVAL_RESULT}("success", #{eval_id}, result);
+      } catch(error) {
+        #{EVAL_RESULT}("error", #{eval_id}, error.message);
+      }
+    })();
+  JS_CODE
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + #bind(name) { ... } ⇒ Object + + + + + +

+
+

Bind a Javascript-callable function by name. When JS calls the function, +an async message is sent to Ruby via RPC and will eventually cause the +block to be called. This method only works in setup mode, before the +underlying Webview has been told to run.

+ + +
+
+
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +

    the Javascript name for the new function

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +

    The Ruby block to be invoked when JS calls the function

    +
    + +
  • + +
+

Raises:

+ + +
+ + + + +
+
+
+
+131
+132
+133
+134
+135
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 131
+
+def bind(name, &block)
+  raise Scarpe::JSBindingError, "App is running, javascript binding no longer works because it uses WebView init!" if @is_running
+
+  @webview.bind(name, &block)
+end
+
+
+ +
+

+ + #destroyObject + + + + + +

+
+

Request destruction of WebWrangler, including terminating the underlying +Webview and (when possible) destroying it.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 399
+
+def destroy
+  @log.debug("Destroying WebWrangler...")
+  @log.debug("  (WebWrangler was already terminated)") if @is_terminated
+  @log.debug("  (WebWrangler was already destroyed)") unless @webview
+  if @webview && !@is_terminated
+    @bindings = {}
+    @webview.terminate
+    @is_terminated = true
+  end
+end
+
+
+ +
+

+ + #dom_change(js) ⇒ Scarpe::Promise + + + + + +

+
+

Request a DOM change - return a promise for when this has been done. +If a full replacement (see #replace) is requested, this change may +be lost. Only use it for changes that are preserved by a full update.

+ + +
+
+
+

Parameters:

+
    + +
  • + + js + + + (String) + + + + — +

    the JS to execute to alter the DOM

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when the update is complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+453
+454
+455
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 453
+
+def dom_change(js)
+  @dom_wrangler.request_change(js)
+end
+
+
+ +
+

+ + #dom_fully_updated?Boolean + + + + + +

+
+

Return whether the DOM is, right this moment, confirmed to be fully +up to date or not.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    true if the window is fully updated, false if changes are pending

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+461
+462
+463
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 461
+
+def dom_fully_updated?
+  @dom_wrangler.fully_updated?
+end
+
+
+ +
+

+ + #dom_promise_redrawScarpe::Promise + + + + + +

+
+

Return a promise that will be fulfilled when all current DOM changes +have committed. If other changes are requested before these +complete, the promise will not wait for them. If you wish to +wait until all changes from all sources have completed, use

+ +

promise_dom_fully_updated.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when all current changes complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+472
+473
+474
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 472
+
+def dom_promise_redraw
+  @dom_wrangler.promise_redraw
+end
+
+
+ +
+

+ + #eval_js_async(code, timeout: EVAL_DEFAULT_TIMEOUT, wait_for: []) ⇒ Object + + + + + +

+
+

Eval a chunk of JS code asynchronously. This method returns a +promise which will be fulfilled or rejected after the JS executes +or times out.

+ +

We both care whether the JS has finished after it was +scheduled and whether it ever got scheduled at all. If it +depends on tasks that never fulfill or reject then it will +raise a timed-out exception.

+ +

Right now we can't/don't pass arguments through from previous fulfilled +promises. To do that, you can schedule the JS to run after the +other promises succeed.

+ +

Webview does not allow interacting with a JS eval once it has +been scheduled. So there is no way to guarantee that a piece of JS has +not executed, or will not execute in the future. A timeout exception +only means that WebWrangler will no longer wait for confirmation or +fulfill the promise if the JS later completes.

+ + +
+
+
+

Parameters:

+
    + +
  • + + code + + + (String) + + + + — +

    the Javascript code to execute

    +
    + +
  • + +
  • + + timeout + + + (Float) + + + (defaults to: EVAL_DEFAULT_TIMEOUT) + + + — +

    how long to allow before raising a timeout exception

    +
    + +
  • + +
  • + + wait_for + + + (Array<Scarpe::Promise>) + + + (defaults to: []) + + + — +

    promises that must complete successfully before this JS is scheduled

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 228
+
+def eval_js_async(code, timeout: EVAL_DEFAULT_TIMEOUT, wait_for: [])
+  unless @is_running
+    raise Scarpe::WebWranglerNotRunningError, "WebWrangler isn't running, so evaluating JS won't work!"
+  end
+
+  this_eval_serial = @eval_counter
+  @eval_counter += 1
+
+  @pending_evals[this_eval_serial] = {
+    id: this_eval_serial,
+    code: code,
+    start_time: Time.now,
+    timeout_if_not_scheduled: Time.now + EVAL_DEFAULT_TIMEOUT,
+  }
+
+  # We'll need this inside the promise-scheduling block
+  pending_evals = @pending_evals
+
+  promise = Scarpe::Promise.new(parents: wait_for) do
+    # Are we mid-shutdown?
+    if @webview
+      wrapped_code = WebWrangler.js_wrapped_code(code, this_eval_serial)
+
+      # We've been scheduled!
+      t_now = Time.now
+      # Hard to be sure Webview keeps a proper reference to this, so we will
+      pending_evals[this_eval_serial][:wrapped_code] = wrapped_code
+
+      pending_evals[this_eval_serial][:scheduled_time] = t_now
+      pending_evals[this_eval_serial].delete(:timeout_if_not_scheduled)
+
+      pending_evals[this_eval_serial][:timeout_if_not_finished] = t_now + timeout
+      @webview.eval(wrapped_code)
+      @log.debug("Scheduled JS: (#{this_eval_serial})\n#{wrapped_code}")
+    else
+      # We're mid-shutdown. No more scheduling things.
+      @log.warn "Mid-shutdown JS eval. Not scheduling JS!"
+    end
+  end
+
+  @pending_evals[this_eval_serial][:promise] = promise
+
+  promise
+end
+
+
+ +
+

+ + #init_code(name) { ... } ⇒ Object + + + + + +

+
+

Request that this block of code be run initially when the Webview is run. +This operates via #init and will not work if Webview is already running.

+ + +
+
+
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +

    the Javascript name for the init function

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +

    The Ruby block to be invoked when Webview runs

    +
    + +
  • + +
+

Raises:

+ + +
+ + + + +
+
+
+
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 142
+
+def init_code(name, &block)
+  raise Scarpe::JSInitError, "App is running, javascript init no longer works!" if @is_running
+
+  # Save a reference to the init string so that it doesn't get GC'd
+  code_str = "#{name}();"
+  @init_refs[name] = code_str
+
+  bind(name, &block)
+  @webview.init(code_str)
+end
+
+
+ +
+

+ + #inspectObject + + + + + +

+
+

Shorter name for better stack trace messages

+ + +
+
+
+ + +
+ + + + +
+
+
+
+116
+117
+118
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 116
+
+def inspect
+  "Scarpe::WebWrangler:#{object_id}"
+end
+
+
+ +
+

+ + #js_eventually(code) ⇒ void + + + + + +

+
+

This method returns an undefined value.

js_eventually is a native Webview JS evaluation. On syntax error, nothing happens. +On runtime error, execution stops at the error with no further +effect or notification. This is rarely what you want. +The js_eventually code is run asynchronously, returning neither error +nor value.

+ +

This method does not return a promise, and there is no way to track +its progress or its success or failure.

+ + +
+
+
+

Parameters:

+
    + +
  • + + code + + + (String) + + + + — +

    the Javascript code to attempt to execute

    +
    + +
  • + +
+ +

Raises:

+ + +
+ + + + +
+
+
+
+198
+199
+200
+201
+202
+203
+204
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 198
+
+def js_eventually(code)
+  raise Scarpe::WebWranglerNotRunningError, "WebWrangler isn't running, eval doesn't work!" unless @is_running
+
+  @log.warn "Deprecated: please do NOT use js_eventually, it's basically never what you want!" unless ENV["CI"]
+
+  @webview.eval(code)
+end
+
+
+ +
+

+ + #on_every_redraw { ... } ⇒ void + + + + + +

+
+

This method returns an undefined value.

DOMWrangler will frequently schedule and confirm small JS updates. +A handler registered with on_every_redraw will be called after each +small update.

+ + +
+
+
+ +

Yields:

+
    + +
  • + + + + + + + +

    Called after each update or batch of updates is verified complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+499
+500
+501
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 499
+
+def on_every_redraw(&block)
+  @dom_wrangler.on_every_redraw(&block)
+end
+
+
+ +
+

+ + #periodic_code(name, interval = heartbeat) { ... } ⇒ Object + + + + + +

+
+

Run the specified code periodically, every "interval" seconds. +If interval is unspecified, run per-heartbeat. This avoids extra +RPC and Javascript overhead. This may use the #init mechanism, +so it should be invoked when the WebWrangler is in setup mode, +before the Webview is running.

+ +

TODO: add a way to stop this loop and unsubscribe.

+ + +
+
+
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +

    the name of the Javascript init function, if needed

    +
    + +
  • + +
  • + + interval + + + (Float) + + + (defaults to: heartbeat) + + + — +

    the duration between invoking this block

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +

    the Ruby block to invoke periodically

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 164
+
+def periodic_code(name, interval = heartbeat, &block)
+  if interval == heartbeat
+    @heartbeat_handlers << block
+  else
+    if @is_running
+      # I *think* we need to use init because we want this done for every
+      # new window. But will there ever be a new page/window? Can we just
+      # use eval instead of init to set up a periodic handler and call it
+      # good?
+      raise Scarpe::PeriodicHandlerSetupError, "App is running, can't set up new periodic handlers with init!"
+    end
+
+    js_interval = (interval.to_f * 1_000.0).to_i
+    code_str = "setInterval(#{name}, #{js_interval});"
+    @init_refs[name] = code_str
+
+    bind(name, &block)
+    @webview.init(code_str)
+  end
+end
+
+
+ +
+

+ + #promise_dom_fully_updatedScarpe::Promise + + + + + +

+
+

Return a promise which will be fulfilled the next time the DOM is +fully up to date. A slow trickle of changes can make this +take a long time, since it includes all current and future changes, +not just changes before this call.

+ +

If you want to know that some specific individual change is done, it's often +easiest to use the promise returned by #dom_change, which will +be fulfilled when that specific change is verified complete.

+ +

If no changes are pending, promise_dom_fully_updated will +return a promise that is already fulfilled.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when all changes are complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+489
+490
+491
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 489
+
+def promise_dom_fully_updated
+  @dom_wrangler.promise_fully_updated
+end
+
+
+ +
+

+ + #replace(html_text) ⇒ Scarpe::Promise + + + + + +

+
+

Replace the entire DOM - return a promise for when this has been done. +This will often get rid of smaller changes in the queue, which is +a good thing since they won't have to be run.

+ + +
+
+
+

Parameters:

+
    + +
  • + + html_text + + + (String) + + + + — +

    The new HTML for the new full DOM

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when the update is complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+443
+444
+445
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 443
+
+def replace(html_text)
+  @dom_wrangler.request_replace(html_text)
+end
+
+
+ +
+

+ + #runObject + + + + + +

+
+

After setup, we call run to go to "running" mode. +No more setup callbacks should be called, only running callbacks.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 370
+
+def run
+  @log.debug("Run...")
+
+  # From webview:
+  # 0 - Width and height are default size
+  # 1 - Width and height are minimum bounds
+  # 2 - Width and height are maximum bounds
+  # 3 - Window size can not be changed by a user
+  hint = @resizable ? 0 : 3
+
+  @webview.set_title(@title)
+  @webview.set_size(@width, @height, hint)
+  unless @empty_page
+    raise Scarpe::EmptyPageNotSetError, "No empty page markup was set!"
+  end
+
+  @webview.navigate("data:text/html, #{CGI.escape @empty_page}")
+
+  monkey_patch_console(@webview)
+
+  @is_running = true
+  @webview.run
+  @is_running = false
+  @webview.destroy
+  @webview = nil
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/WebWrangler/DOMWrangler.html b/Scarpe/Webview/WebWrangler/DOMWrangler.html new file mode 100644 index 000000000..3432ccc43 --- /dev/null +++ b/Scarpe/Webview/WebWrangler/DOMWrangler.html @@ -0,0 +1,1186 @@ + + + + + + + Class: Scarpe::Webview::WebWrangler::DOMWrangler + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::WebWrangler::DOMWrangler + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + +
+
Includes:
+
Shoes::Log
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/wv/web_wrangler.rb
+
+ +
+ +

Overview

+
+

Leaving DOM changes as "meh, async, we'll see when it happens" is terrible for testing. +Instead, we need to track whether particular changes have committed yet or not. +So we add a single gateway for all DOM changes, and we make sure its work is done +before we consider a redraw complete.

+ +

DOMWrangler batches up changes into fewer RPC calls. It's fine to have a redraw +"in flight" and have changes waiting to catch the next bus. But we don't want more +than one in flight, since it seems like having too many pending RPC requests can +crash Webview. So we allow one redraw scheduled and one redraw promise waiting, +at maximum.

+ +

A WebWrangler will create and wrap a DOMWrangler, serving as the interface +for all DOM operations.

+ +

A batch of DOMWrangler changes may be removed if a full update is scheduled. That +update is considered to replace the previous incremental changes. Any changes that +need to execute even if a full update happens should be scheduled through +WebWrangler#eval_js_async, not DOMWrangler.

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #pending_redraw_promise ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    A Scarpe::Promise for JS that has been scheduled to execute but is not yet verified complete.

    +
    + +
  • + + +
  • + + + #waiting_changes ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Changes that have not yet been executed.

    +
    + +
  • + + +
  • + + + #waiting_redraw_promise ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    A Scarpe::Promise for waiting changes - it will be fulfilled when all waiting changes have been verified complete, or when a full redraw that removed them has been verified complete.

    +
    + +
  • + + +
+ + + + + +

+ Class Method Summary + collapse +

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+
+

Constructor Details

+ +
+

+ + #initialize(web_wrangler) ⇒ DOMWrangler + + + + + +

+
+

Create a DOMWrangler that is paired with a WebWrangler. The WebWrangler is +treated as an underlying abstraction for reliable JS evaluation.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 541
+
+def initialize(web_wrangler)
+  log_init("Webview::WebWrangler::DOMWrangler")
+
+  @wrangler = web_wrangler
+
+  @waiting_changes = []
+  @pending_redraw_promise = nil
+  @waiting_redraw_promise = nil
+
+  @fully_up_to_date_promise = nil
+
+  # Initially we're waiting for a full replacement to happen.
+  # It's possible to request updates/changes before we have
+  # a DOM in place and before Webview is running. If we do
+  # that, we should discard those updates.
+  @first_draw_requested = false
+
+  @redraw_handlers = []
+
+  # The "fully up to date" logic is complicated and not
+  # as well tested as I'd like. This makes it far less
+  # likely that the event simply won't fire.
+  # With more comprehensive testing, this should be
+  # removable.
+  web_wrangler.periodic_code("scarpeDOMWranglerHeartbeat") do
+    if @fully_up_to_date_promise && fully_updated?
+      @log.info("Fulfilling up-to-date promise on heartbeat")
+      @fully_up_to_date_promise.fulfilled!
+      @fully_up_to_date_promise = nil
+    end
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #pending_redraw_promiseObject (readonly) + + + + + +

+
+

A Scarpe::Promise for JS that has been scheduled to execute but is not yet verified complete

+ + +
+
+
+ + +
+ + + + +
+
+
+
+531
+532
+533
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 531
+
+def pending_redraw_promise
+  @pending_redraw_promise
+end
+
+
+ + + +
+

+ + #waiting_changesObject (readonly) + + + + + +

+
+

Changes that have not yet been executed

+ + +
+
+
+ + +
+ + + + +
+
+
+
+528
+529
+530
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 528
+
+def waiting_changes
+  @waiting_changes
+end
+
+
+ + + +
+

+ + #waiting_redraw_promiseObject (readonly) + + + + + +

+
+

A Scarpe::Promise for waiting changes - it will be fulfilled when all waiting changes +have been verified complete, or when a full redraw that removed them has been +verified complete. If many small changes are scheduled, the same promise will be +returned for many of them.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+537
+538
+539
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 537
+
+def waiting_redraw_promise
+  @waiting_redraw_promise
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + .replacement_code(html_text) ⇒ Object + + + + + +

+ + + + +
+
+
+
+583
+584
+585
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 583
+
+def self.replacement_code(html_text)
+  "document.getElementById('wrapper-wvroot').innerHTML = `#{html_text}`; true"
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + #fully_updated?Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+702
+703
+704
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 702
+
+def fully_updated?
+  @pending_redraw_promise.nil? && @waiting_redraw_promise.nil? && @waiting_changes.empty?
+end
+
+
+ +
+

+ + #on_every_redraw(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+596
+597
+598
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 596
+
+def on_every_redraw(&block)
+  @redraw_handlers << block
+end
+
+
+ +
+

+ + #promise_fully_updatedObject + + + + + +

+
+

Return a promise which will be fulfilled when the DOM is fully up-to-date

+ + +
+
+
+ + +
+ + + + +
+
+
+
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 707
+
+def promise_fully_updated
+  if fully_updated?
+    # No changes to make, nothing in-process or waiting, so just return a pre-fulfilled promise
+    return ::Scarpe::Promise.fulfilled
+  end
+
+  # Do we already have a promise for this? Return it. Everybody can share one.
+  if @fully_up_to_date_promise
+    return @fully_up_to_date_promise
+  end
+
+  # We're not fully updated, so we need a promise. Create it, return it.
+  @fully_up_to_date_promise = ::Scarpe::Promise.new
+end
+
+
+ +
+

+ + #promise_redrawObject + + + + + +

+
+

promise_redraw returns a Scarpe::Promise which will be fulfilled after all current +pending or waiting changes have completed. This may require creating a new +promise.

+ +

What are the states of redraw? +"empty" - no waiting promise, no pending-redraw promise, no pending changes +"pending only" - no waiting promise, but we have a pending redraw with some changes; it hasn't committed yet +"pending and waiting" - we have a waiting promise for our unscheduled changes; we can add more unscheduled + changes since we haven't scheduled them yet.

+ +

This is often called after adding a new waiting change or replacing them, so the state may have just changed. +It can also be called when no changes have been made and no updates need to happen.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 612
+
+def promise_redraw
+  if fully_updated?
+    # No changes to make, nothing in-process or waiting, so just return a pre-fulfilled promise
+    @log.debug("Requesting redraw but there are no pending changes or promises, return pre-fulfilled")
+    return ::Scarpe::Promise.fulfilled
+  end
+
+  # Already have a redraw requested *and* one on deck? Then all current changes will have committed
+  # when we (eventually) fulfill the waiting_redraw_promise.
+  if @waiting_redraw_promise
+    @log.debug("Promising eventual redraw of #{@waiting_changes.size} waiting unscheduled changes.")
+    return @waiting_redraw_promise
+  end
+
+  if @waiting_changes.empty?
+    # There's no waiting_redraw_promise. There are no waiting changes. But we're not fully updated.
+    # So there must be a redraw in flight, and we don't need to schedule a new waiting_redraw_promise.
+    @log.debug("Returning in-flight redraw promise")
+    return @pending_redraw_promise
+  end
+
+  @log.debug("Requesting redraw with #{@waiting_changes.size} waiting changes and no waiting promise - need to schedule something!")
+
+  # We have at least one waiting change, possibly newly-added. We have no waiting_redraw_promise.
+  # Do we already have a redraw in-flight?
+  if @pending_redraw_promise
+    # Yes we do. Schedule a new waiting promise. When it turns into the pending_redraw_promise it will
+    # grab all waiting changes. In the mean time, it sits here and waits.
+    #
+    # We *could* do a fancy promise thing and have it update @waiting_changes for itself, etc, when it
+    # schedules itself. But we should always be calling promise_redraw or having a redraw fulfilled (see below)
+    # when these things change. I'd rather keep the logic in this method. It's easier to reason through
+    # all the cases.
+    @waiting_redraw_promise = ::Scarpe::Promise.new
+
+    @log.debug("Creating a new waiting promise since a pending promise is already in place")
+    return @waiting_redraw_promise
+  end
+
+  # We have no redraw in-flight and no pre-existing waiting line. The new change(s) are presumably right
+  # after things were fully up-to-date. We can schedule them for immediate redraw.
+
+  @log.debug("Requesting redraw with #{@waiting_changes.size} waiting changes - scheduling a new redraw for them!")
+  promise = schedule_waiting_changes # This clears the waiting changes
+  @pending_redraw_promise = promise
+
+  promise.on_fulfilled do
+    @redraw_handlers.each(&:call)
+    @pending_redraw_promise = nil
+
+    if @waiting_redraw_promise
+      # While this redraw was in flight, more waiting changes got added and we made a promise
+      # about when they'd complete. Now they get scheduled, and we'll fulfill the waiting
+      # promise when that redraw finishes. Clear the old waiting promise. We'll add a new one
+      # when/if more changes are scheduled during this redraw.
+      old_waiting_promise = @waiting_redraw_promise
+      @waiting_redraw_promise = nil
+
+      @log.debug "Fulfilled redraw with #{@waiting_changes.size} waiting changes - scheduling a new redraw for them!"
+
+      new_promise = promise_redraw
+      new_promise.on_fulfilled { old_waiting_promise.fulfilled! }
+    else
+      # The in-flight redraw completed, and there's still no waiting promise. Good! That means
+      # we should be fully up-to-date.
+      @log.debug "Fulfilled redraw with no waiting changes - marking us as up to date!"
+      if @waiting_changes.empty?
+        # We're fully up to date! Fulfill the promise. Now we don't need it again until somebody asks
+        # us for another.
+        if @fully_up_to_date_promise
+          @fully_up_to_date_promise.fulfilled!
+          @fully_up_to_date_promise = nil
+        end
+      else
+        @log.error "WHOAH, WHAT? My logic must be wrong, because there's " +
+          "no waiting promise, but waiting changes!"
+      end
+    end
+
+    @log.debug("Redraw is now fully up-to-date") if fully_updated?
+  end.on_rejected do
+    @log.error "Could not complete JS redraw! #{promise.reason.full_message}"
+    @log.debug("REDRAW FULLY UP TO DATE BUT JS FAILED") if fully_updated?
+
+    raise Scarpe::JSRedrawError, "JS Redraw failed! Bailing!"
+
+    # Later we should figure out how to handle this. Clear the promises and queues and request another redraw?
+  end
+end
+
+
+ +
+

+ + #request_change(js_code) ⇒ Object + + + + + +

+ + + + +
+
+
+
+574
+575
+576
+577
+578
+579
+580
+581
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 574
+
+def request_change(js_code)
+  # No updates until there's something to update
+  return unless @first_draw_requested
+
+  @waiting_changes << js_code
+
+  promise_redraw
+end
+
+
+ +
+

+ + #request_replace(html_text) ⇒ Object + + + + + +

+ + + + +
+
+
+
+587
+588
+589
+590
+591
+592
+593
+594
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 587
+
+def request_replace(html_text)
+  # Replace other pending changes, they're not needed any more
+  @waiting_changes = [DOMWrangler.replacement_code(html_text)]
+  @first_draw_requested = true
+
+  @log.debug("Requesting DOM replacement...")
+  promise_redraw
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/WebWrangler/ElementWrangler.html b/Scarpe/Webview/WebWrangler/ElementWrangler.html new file mode 100644 index 000000000..ac988f500 --- /dev/null +++ b/Scarpe/Webview/WebWrangler/ElementWrangler.html @@ -0,0 +1,1204 @@ + + + + + + + Class: Scarpe::Webview::WebWrangler::ElementWrangler + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::WebWrangler::ElementWrangler + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/web_wrangler.rb
+
+ +
+ +

Overview

+
+

An ElementWrangler provides a way for a Drawable to manipulate is DOM element(s) +via their HTML IDs. The most straightforward Drawables can have a single HTML ID +and use a single ElementWrangler to make any needed changes.

+ +

For now we don't need an ElementWrangler to add DOM elements, just to manipulate them +after initial render. New DOM objects for Drawables are normally added via full +redraws rather than incremental updates.

+ +

Any changes made via ElementWrangler may be cancelled if a full redraw occurs, +since it is assumed that small DOM manipulations are no longer needed. If a +change would need to be made even if a full redraw occurred, it should be +scheduled via WebWrangler#eval_js_async, not via an ElementWrangler.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary collapse

+
    + +
  • + + + #html_id ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute html_id.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + collapse +

+ + + + +
+

Constructor Details

+ +
+

+ + #initialize(html_id: nil, selector: nil, multi: false) ⇒ ElementWrangler + + + + + +

+
+

Create an ElementWrangler for the given HTML ID or selector. +The caller should provide exactly one of the html_id or selector.

+ + +
+
+
+

Parameters:

+
    + +
  • + + html_id + + + (String) + + + (defaults to: nil) + + + — +

    the HTML ID for the DOM element

    +
    + +
  • + +
+ +

Raises:

+ + +
+ + + + +
+
+
+
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 754
+
+def initialize(html_id: nil, selector: nil, multi: false)
+  @webwrangler = ::Scarpe::Webview::DisplayService.instance.wrangler
+  raise Scarpe::MissingWranglerError, "Can't get WebWrangler!" unless @webwrangler
+
+  if html_id && !selector
+    @selector = "document.getElementById('" + html_id + "')"
+  elsif selector && !html_id
+    @selector = selector
+  else
+    raise ArgumentError, "Must provide exactly one of html_id or selector!"
+  end
+
+  @multi = multi
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #html_idObject (readonly) + + + + + +

+
+

Returns the value of attribute html_id.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+748
+749
+750
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 748
+
+def html_id
+  @html_id
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #inner_html=(new_html) ⇒ Scarpe::Promise + + + + + +

+
+

Update the JS DOM element's inner_html. The given Ruby value will be converted to string and assigned in backquotes.

+ + +
+
+
+

Parameters:

+
    + +
  • + + new_html + + + (String) + + + + — +

    the new inner_html

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when the change is complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+809
+810
+811
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 809
+
+def inner_html=(new_html)
+  on_each(".innerHTML = `" + new_html + "`")
+end
+
+
+ +
+

+ + #inner_text=(new_text) ⇒ Scarpe::Promise + + + + + +

+
+

Update the JS DOM element's inner_text. The given Ruby value will be converted to string and assigned in single-quotes.

+ + +
+
+
+

Parameters:

+
    + +
  • + + new_text + + + (String) + + + + — +

    the new inner_text

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when the change is complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+801
+802
+803
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 801
+
+def inner_text=(new_text)
+  on_each(".innerText = '" + new_text + "'")
+end
+
+
+ +
+

+ + #outer_html=(new_html) ⇒ Scarpe::Promise + + + + + +

+
+

Update the JS DOM element's outer_html. The given Ruby value will be converted to string and assigned in backquotes.

+ + +
+
+
+

Parameters:

+
    + +
  • + + new_html + + + (String) + + + + — +

    the new outer_html

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when the change is complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+817
+818
+819
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 817
+
+def outer_html=(new_html)
+  on_each(".outerHTML = `" + new_html + "`")
+end
+
+
+ +
+

+ + #promise_updateScarpe::Promise + + + + + +

+
+

Return a promise that will be fulfilled when all changes scheduled via +this ElementWrangler are verified complete.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when scheduled changes are complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+785
+786
+787
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 785
+
+def promise_update
+  @webwrangler.dom_promise_redraw
+end
+
+
+ +
+

+ + #removeScarpe::Promise + + + + + +

+
+

Remove the specified DOM element

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that wil be fulfilled when the element is removed

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+842
+843
+844
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 842
+
+def remove
+  on_each(".remove()")
+end
+
+
+ +
+

+ + #set_attribute(attribute, value) ⇒ Scarpe::Promise + + + + + +

+
+

Update the JS DOM element's attribute. The given Ruby value will be inspected and assigned.

+ + +
+
+
+

Parameters:

+
    + +
  • + + attribute + + + (String) + + + + — +

    the attribute name

    +
    + +
  • + +
  • + + value + + + (String) + + + + — +

    the new attribute value

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when the change is complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+826
+827
+828
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 826
+
+def set_attribute(attribute, value)
+  on_each(".setAttribute(" + attribute.inspect + "," + value.inspect + ")")
+end
+
+
+ +
+

+ + #set_style(style_attr, value) ⇒ Scarpe::Promise + + + + + +

+
+

Update an attribute of the JS DOM element's style. The given Ruby value will be inspected and assigned.

+ + +
+
+
+

Parameters:

+
    + +
  • + + style_attr + + + (String) + + + + — +

    the style attribute name

    +
    + +
  • + +
  • + + value + + + (String) + + + + — +

    the new style attribute value

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when the change is complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+835
+836
+837
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 835
+
+def set_style(style_attr, value)
+  on_each(".style.#{style_attr} = " + value.inspect + ";")
+end
+
+
+ +
+

+ + #toggle_input_button(mark) ⇒ Object + + + + + +

+ + + + +
+
+
+
+846
+847
+848
+849
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 846
+
+def toggle_input_button(mark)
+  checked_value = mark ? "true" : "false"
+  on_each(".checked = #{checked_value}")
+end
+
+
+ +
+

+ + #value=(new_value) ⇒ Scarpe::Promise + + + + + +

+
+

Update the JS DOM element's value. The given Ruby value will be converted to string and assigned in backquotes.

+ + +
+
+
+

Parameters:

+
    + +
  • + + new_value + + + (String) + + + + — +

    the new value

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when the change is complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+793
+794
+795
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 793
+
+def value=(new_value)
+  on_each(".value = `" + new_value + "`")
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes.html b/Shoes.html new file mode 100644 index 000000000..4c52e114d --- /dev/null +++ b/Shoes.html @@ -0,0 +1,926 @@ + + + + + + + Class: Shoes + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes.rb,
+ lacci/lib/shoes.rb,
lacci/lib/shoes/app.rb,
lacci/lib/shoes/log.rb,
lacci/lib/shoes-spec.rb,
lacci/lib/shoes/border.rb,
lacci/lib/shoes/colors.rb,
lacci/lib/shoes/errors.rb,
lacci/lib/shoes/download.rb,
lacci/lib/shoes/drawable.rb,
lacci/lib/shoes/changelog.rb,
lacci/lib/shoes/constants.rb,
lacci/lib/shoes/background.rb,
lacci/lib/shoes/drawables/arc.rb,
lacci/lib/shoes/drawables/flow.rb,
lacci/lib/shoes/drawables/line.rb,
lacci/lib/shoes/drawables/link.rb,
lacci/lib/shoes/drawables/oval.rb,
lacci/lib/shoes/drawables/para.rb,
lacci/lib/shoes/drawables/para.rb,
lacci/lib/shoes/drawables/rect.rb,
lacci/lib/shoes/drawables/star.rb,
lacci/lib/shoes/display_service.rb,
lacci/lib/shoes/drawables/arrow.rb,
lacci/lib/shoes/drawables/check.rb,
lacci/lib/shoes/drawables/image.rb,
lacci/lib/shoes/drawables/radio.rb,
lacci/lib/shoes/drawables/shape.rb,
lacci/lib/shoes/drawables/stack.rb,
lacci/lib/shoes/drawables/video.rb,
lacci/lib/shoes/drawables/border.rb,
lacci/lib/shoes/drawables/button.rb,
lacci/lib/shoes/drawables/edit_box.rb,
lacci/lib/shoes/drawables/list_box.rb,
lacci/lib/shoes/drawables/progress.rb,
lacci/lib/shoes/drawables/edit_line.rb,
lacci/lib/shoes/drawables/document_root.rb,
lacci/lib/shoes/drawables/text_drawable.rb
+
+
+ +
+ +

Overview

+
+

Lacci Shoes apps operate in multiple layers. A Shoes drawable tree exists as fairly +plain, simple Ruby objects. And then a display-service drawable tree integrates with +the display technology. This lets us use Ruby as our API while +not tying it too closely to the limitations of Webview, WASM, LibUI, etc.

+ +

Choosing Display Services

+ +

Before running a Lacci app, you can set SCARPE_DISPLAY_SERVICE. If you +set it to "whatever_service", Scarpe will require "scarpe/whatever_service", +which can be supplied by the Scarpe gem or another Scarpe-based gem. +Currently leaving the environment variable empty is equivalent to requesting +local Webview.

+ +

Events

+ +

Events are a lot of what tie the Shoes drawables and the display service together.

+ +

Shoes drawables expect to operate in a fairly "hands off" mode where they record +to an event queue to send to the display service, and the display service records +events to send back.

+ +

When a Shoes handler takes an action (e.g. some_para.replace(),) the relevant +call will be dispatched as a :display event, to be sent to the display service. +And when a display-side event occurs (e.g. user pushes a button,) it will be +dispatched as a :shoes event, to be sent to the Shoes tree of drawables.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: Background, Builtins, Colors, Constants, Errors, Log, Spec + + + + Classes: App, Arc, Arrow, Border, Button, Changelog, Check, DisplayService, DocumentRoot, Drawable, EditBox, EditLine, Error, Flow, Image, Line, Link, LinkHover, Linkable, ListBox, LoggedWrapper, Oval, Para, Progress, Radio, Rect, Shape, Slot, SpecInstance, SpecProxy, Stack, Star, SubscriptionItem, TextDrawable, Video, Widget + + +

+ + +

+ Constant Summary + collapse +

+ +
+ +
LOG_LEVELS = + +
+
[:debug, :info, :warn, :error, :fatal].freeze
+ +
RELEASE_INFO = + +
+
changelog_instance.get_latest_release_info
+ +
RELEASE_NAME = + +
+
+ +
RELEASE_ID = + +
+
+ +
RELEASE_BUILD_DATE = + +
+
+ +
RELEASE_TYPE = +
+
+

This isn't really a thing any more

+ + +
+
+
+ + +
+
+
"LOOSE_SHOES"
+ +
REVISION = + +
+
+ +
+ + + + + + + + + +

+ Class Method Summary + collapse +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + .add_file_loader(loader) ⇒ Object + + + + + +

+ + + + +
+
+
+
+136
+137
+138
+
+
# File 'lacci/lib/shoes.rb', line 136
+
+def add_file_loader(loader)
+  file_loaders.prepend(loader)
+end
+
+
+ +
+

+ + .app(title: "Shoes!", width: 480, height: 420, resizable: true, features: [], &app_code_body) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Creates a Shoes app with a new window. The block parameter is used to create +drawables and set up handlers. Arguments are passed to Shoes::App.new internally.

+ + +
+
+
+ +
+

Examples:

+ + +

Simple one-button app

+

+ +
Shoes.app(title: "Button!", width: 200, height: 200) do
+  @p = para "Press it NOW!"
+  button("clicky") { @p.replace("You pressed it! CELEBRATION!") }
+end
+ +
+

Parameters:

+
    + +
  • + + title + + + (String) + + + (defaults to: "Shoes!") + + + — +

    The new app window title

    +
    + +
  • + +
  • + + width + + + (Integer) + + + (defaults to: 480) + + + — +

    The new app window width

    +
    + +
  • + +
  • + + height + + + (Integer) + + + (defaults to: 420) + + + — +

    The new app window height

    +
    + +
  • + +
  • + + resizable + + + (Boolean) + + + (defaults to: true) + + + — +

    Whether the app window should be resizeable

    +
    + +
  • + +
  • + + features + + + (Symbol, Array<Symbol>) + + + (defaults to: []) + + + — +

    Additional Shoes extensions requested by the app

    +
    + +
  • + +
+ + +

See Also:

+
    + +
  • Shoes::App#new
  • + +
+

Incompatibilities with Shoes:

+
    + +
  • + + + + + +

    In Shoes3, this method will return normally. +In Scarpe, after the block is executed, the method will not return and Scarpe +will retain control of execution until the window is closed and the app quits.

    +
    + +
  • + +
  • + + + + + +

    In Shoes3 the parameters were a hash of options, not keyword arguments.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+
+
# File 'lacci/lib/shoes.rb', line 80
+
+def app(
+  title: "Shoes!",
+  width: 480,
+  height: 420,
+  resizable: true,
+  features: [],
+  &app_code_body
+)
+  f = [features].flatten # Make sure this is a list, not a single symbol
+  app = Shoes::App.new(title:, width:, height:, resizable:, features: f, &app_code_body)
+  app.init
+  app.run
+  nil
+end
+
+
+ +
+

+ + .default_file_loadersObject + + + + + +

+ + + + +
+
+
+
+122
+123
+124
+125
+126
+127
+128
+129
+130
+
+
# File 'lacci/lib/shoes.rb', line 122
+
+def default_file_loaders
+  [
+    # By default we will always try to load any file, regardless of extension, as a Shoes Ruby file.
+    proc do |path|
+      load path
+      true
+    end,
+  ]
+end
+
+
+ +
+

+ + .default_text_drawable_with(element) ⇒ Object + + + + + +

+ + + + +
+
+
+
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+
+
# File 'lacci/lib/shoes/drawables/text_drawable.rb', line 98
+
+def default_text_drawable_with(element)
+  class_name = element.capitalize
+
+  drawable_class = Class.new(Shoes::TextDrawable) do
+    shoes_events # No specific events
+
+    init_args # We're going to pass an empty array to super
+  end
+  Shoes.const_set class_name, drawable_class
+end
+
+
+ +
+

+ + .file_loadersObject + + + + + +

+ + + + +
+
+
+
+132
+133
+134
+
+
# File 'lacci/lib/shoes.rb', line 132
+
+def file_loaders
+  @file_loaders ||= default_file_loaders
+end
+
+
+ +
+

+ + .reset_file_loadersObject + + + + + +

+ + + + +
+
+
+
+140
+141
+142
+
+
# File 'lacci/lib/shoes.rb', line 140
+
+def reset_file_loaders
+  @file_loaders = default_file_loaders
+end
+
+
+ +
+

+ + .run_app(relative_path) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Load a Shoes app from a file. By default, this will load old-style Shoes apps +from a .rb file with all the appropriate libraries loaded. By setting one or +more loaders, a Lacci-based display library can accept new file formats as +well, not just raw Shoes .rb files.

+ + +
+
+
+

Parameters:

+
    + +
  • + + relative_path + + + (String) + + + + — +

    The current-dir-relative path to the file

    +
    + +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+
+
# File 'lacci/lib/shoes.rb', line 103
+
+def run_app(relative_path)
+  path = File.expand_path relative_path
+  dir = File.dirname(path)
+
+  # Shoes assumes we're starting from the app code's path
+  Dir.chdir(dir)
+
+  loaded = false
+  file_loaders.each do |loader|
+    if loader.call(path)
+      loaded = true
+      break
+    end
+  end
+  raise "Could not find a file loader for #{path.inspect}!" unless loaded
+
+  nil
+end
+
+
+ +
+

+ + .set_file_loaders(loaders) ⇒ Object + + + + + +

+ + + + +
+
+
+
+144
+145
+146
+
+
# File 'lacci/lib/shoes.rb', line 144
+
+def set_file_loaders(loaders)
+  @file_loaders = loaders
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/App.html b/Shoes/App.html new file mode 100644 index 000000000..06dc9e522 --- /dev/null +++ b/Shoes/App.html @@ -0,0 +1,1882 @@ + + + + + + + Class: Shoes::App + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::App + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + +
+
Includes:
+
Log
+
+ + + + + + +
+
Defined in:
+
lacci/lib/shoes/app.rb,
+ lacci/lib/shoes/app.rb
+
+
+ +
+ +

Overview

+
+

These methods will need to be defined on Slots too, but probably need a rework in general.

+ + +
+
+
+ + +
+ +

+ Constant Summary + collapse +

+ +
+ +
CUSTOM_EVENT_LOOP_TYPES = + +
+
["displaylib", "return", "wait"]
+ +
+ + + + + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + +

Class Attribute Summary collapse

+
    + +
  • + + + .instance ⇒ Object + + + + + + + + + + + + + + + + +

    Returns the value of attribute instance.

    +
    + +
  • + + +
+ +

Instance Attribute Summary collapse

+
    + +
  • + + + #dir ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    The application directory for this app.

    +
    + +
  • + + +
  • + + + #document_root ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    The Shoes root of the drawable tree.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(title: "Shoes!", width: 480, height: 420, resizable: true, features: [], &app_code_body) ⇒ App + + + + + +

+
+

Returns a new instance of App.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+
+
# File 'lacci/lib/shoes/app.rb', line 28
+
+def initialize(
+  title: "Shoes!",
+  width: 480,
+  height: 420,
+  resizable: true,
+  features: [],
+  &app_code_body
+)
+  log_init("Shoes::App")
+
+  if Shoes::App.instance
+    @log.error("Trying to create a second Shoes::App in the same process! Fail!")
+    raise Shoes::Errors::TooManyInstancesError, "Cannot create multiple Shoes::App objects!"
+  else
+    Shoes::App.instance = self
+  end
+
+  # We cd to the app's containing dir when running the app
+  @dir = Dir.pwd
+
+  @do_shutdown = false
+  @event_loop_type = "displaylib" # the default
+
+  @features = features
+
+  unknown_ext = features - Shoes::FEATURES - Shoes::EXTENSIONS
+  unsupported_features = unknown_ext & Shoes::KNOWN_FEATURES
+  unless unsupported_features.empty?
+    @log.error("Shoes app requires feature(s) not supported by this display service: #{unsupported_features.inspect}!")
+    raise Shoes::Errors::UnsupportedFeatureError, "Shoes app needs features: #{unsupported_features.inspect}"
+  end
+  unless unknown_ext.empty?
+    @log.warn("Shoes app requested unknown features #{unknown_ext.inspect}! Known: #{(Shoes::FEATURES + Shoes::EXTENSIONS).inspect}")
+  end
+
+  @slots = []
+
+  super
+
+  # This creates the DocumentRoot, including its corresponding display drawable
+  @document_root = Shoes::DocumentRoot.new
+
+  # Now create the App display drawable
+  create_display_drawable
+
+  # Set up testing *after* Display Service basic objects exist
+
+  if ENV["SHOES_SPEC_TEST"]
+    test_code = File.read ENV["SHOES_SPEC_TEST"]
+    unless test_code.empty?
+      Shoes::Spec.instance.run_shoes_spec_test_code test_code
+    end
+  end
+
+  @app_code_body = app_code_body
+
+  # Try to de-dup as much as possible and not send repeat or multiple
+  # destroy events
+  @watch_for_destroy = bind_shoes_event(event_name: "destroy") do
+    Shoes::DisplayService.unsub_from_events(@watch_for_destroy) if @watch_for_destroy
+    @watch_for_destroy = nil
+    self.destroy(send_event: false)
+  end
+
+  @watch_for_event_loop = bind_shoes_event(event_name: "custom_event_loop") do |loop_type|
+    raise(Shoes::Errors::InvalidAttributeValueError, "Unknown event loop type: #{loop_type.inspect}!") unless CUSTOM_EVENT_LOOP_TYPES.include?(loop_type)
+
+    @event_loop_type = loop_type
+  end
+
+  Signal.trap("INT") do
+    @log.warn("App interrupted by signal, stopping...")
+    puts "\nStopping Shoes app..."
+    destroy
+  end
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + +

+ +
+

+ + #method_missing(name, *args, **kwargs, &block) ⇒ Object + + + + + +

+
+

We use method_missing for drawable-creating methods like "button". +The parent's method_missing will auto-create Shoes style getters and setters. +This is similar to the method_missing in Shoes::Slot, but different in +where the new drawable appears.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+
+
# File 'lacci/lib/shoes/app.rb', line 142
+
+def method_missing(name, *args, **kwargs, &block)
+  klass = ::Shoes::Drawable.drawable_class_by_name(name)
+  return super unless klass
+
+  ::Shoes::App.define_method(name) do |*args, **kwargs, &block|
+    klass.new(*args, **kwargs, &block)
+  end
+
+  send(name, *args, **kwargs, &block)
+end
+
+
+ +
+ +
+

Class Attribute Details

+ + + +
+

+ + .instanceObject + + + + + +

+
+

Returns the value of attribute instance.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lacci/lib/shoes/app.rb', line 8
+
+def instance
+  @instance
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #dirObject (readonly) + + + + + +

+
+

The application directory for this app. Often this will be the directory +containing the launched application file.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+16
+17
+18
+
+
# File 'lacci/lib/shoes/app.rb', line 16
+
+def dir
+  @dir
+end
+
+
+ + + +
+

+ + #document_rootObject (readonly) + + + + + +

+
+

The Shoes root of the drawable tree

+ + +
+
+
+ + +
+ + + + +
+
+
+
+12
+13
+14
+
+
# File 'lacci/lib/shoes/app.rb', line 12
+
+def document_root
+  @document_root
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #all_drawablesObject + + + + + +

+ + + + +
+
+
+
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+
+
# File 'lacci/lib/shoes/app.rb', line 196
+
+def all_drawables
+  out = []
+
+  to_add = [@document_root, @document_root.children]
+  until to_add.empty?
+    out.concat(to_add)
+    to_add = to_add.flat_map { |w| w.respond_to?(:children) ? w.children : [] }.compact
+  end
+
+  out
+end
+
+
+ +
+

+ + #backgroundObject + + + + + +

+
+

This is going to go away. See issue #496

+ + +
+
+
+ + +
+ + + + +
+
+
+
+266
+267
+268
+
+
# File 'lacci/lib/shoes/app.rb', line 266
+
+def background(...)
+  current_slot.background(...)
+end
+
+
+ +
+

+ + #borderObject + + + + + +

+
+

This is going to go away. See issue #498

+ + +
+
+
+ + +
+ + + + +
+
+
+
+271
+272
+273
+
+
# File 'lacci/lib/shoes/app.rb', line 271
+
+def border(...)
+  current_slot.border(...)
+end
+
+
+ +
+

+ + #current_draw_contextHash + + + + + +

+
+

Get the current draw context for the current slot

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Hash) + + + + — +

    a hash of Shoes styles for the current draw context

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+156
+157
+158
+
+
# File 'lacci/lib/shoes/app.rb', line 156
+
+def current_draw_context
+  current_slot&.current_draw_context
+end
+
+
+ +
+

+ + #current_slotObject + + + + + +

+ + + + +
+
+
+
+125
+126
+127
+
+
# File 'lacci/lib/shoes/app.rb', line 125
+
+def current_slot
+  @slots[-1]
+end
+
+
+ +
+

+ + #destroy(send_event: true) ⇒ Object + + + + + +

+ + + + +
+
+
+
+191
+192
+193
+194
+
+
# File 'lacci/lib/shoes/app.rb', line 191
+
+def destroy(send_event: true)
+  @do_shutdown = true
+  send_shoes_event(event_name: "destroy") if send_event
+end
+
+
+ +
+

+ + #featuresObject + + + + + +

+
+

This is defined to avoid the linkable-id check in the Shoes-style method_missing def'n

+ + +
+
+
+ + +
+ + + + +
+
+
+
+21
+22
+23
+
+
# File 'lacci/lib/shoes/app.rb', line 21
+
+def features
+  @features
+end
+
+
+ +
+

+ + #find_drawables_by(*specs) ⇒ Object + + + + + +

+
+

We can add various ways to find drawables here. +These are sort of like Shoes selectors, used for testing.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+
+
# File 'lacci/lib/shoes/app.rb', line 210
+
+def find_drawables_by(*specs)
+  drawables = all_drawables
+  specs.each do |spec|
+    if spec == Shoes::App
+      drawables = [Shoes::App.instance]
+    elsif spec.is_a?(Class)
+      drawables.select! { |w| spec === w }
+    elsif spec.is_a?(Symbol) || spec.is_a?(String)
+      s = spec.to_s
+      case s[0]
+      when "$"
+        begin
+          # I'm not finding a global_variable_get or similar...
+          global_value = eval s
+          drawables &= [global_value]
+        rescue
+          raise Shoes::Errors::InvalidAttributeValueError, "Error getting global variable: #{spec.inspect}"
+        end
+      when "@"
+        if Shoes::App.instance.instance_variables.include?(spec.to_sym)
+          drawables &= [self.instance_variable_get(spec)]
+        else
+          raise Shoes::Errors::InvalidAttributeValueError, "Can't find top-level instance variable: #{spec.inspect}!"
+        end
+      else
+        if s.start_with?("id:")
+          find_id = Integer(s[3..-1])
+          drawable = Shoes::Drawable.drawable_by_id(find_id)
+          drawables &= [drawable]
+        else
+          raise Shoes::Errors::InvalidAttributeValueError, "Don't know how to find drawables by #{spec.inspect}!"
+        end
+      end
+    else
+      raise(Shoes::Errors::InvalidAttributeValueError, "Don't know how to find drawables by #{spec.inspect}!")
+    end
+  end
+  drawables
+end
+
+
+ +
+

+ + #initObject + + + + + +

+ + + + +
+
+
+
+105
+106
+107
+108
+109
+110
+
+
# File 'lacci/lib/shoes/app.rb', line 105
+
+def init
+  send_shoes_event(event_name: "init")
+  return if @do_shutdown
+
+  ::Shoes::App.instance.with_slot(@document_root, &@app_code_body)
+end
+
+
+ +
+

+ + #line_to(x, y) ⇒ Object + + + + + +

+
+ + +
+
+
+ +

Raises:

+ + +
+ + + + +
+
+
+
+292
+293
+294
+295
+296
+297
+298
+
+
# File 'lacci/lib/shoes/app.rb', line 292
+
+def line_to(x, y)
+  raise(Shoes::Errors::InvalidAttributeValueError, "Pass only Numeric arguments to line_to!") unless x.is_a?(Numeric) && y.is_a?(Numeric)
+
+  if current_slot.is_a?(::Shoes::Shape)
+    current_slot.add_shape_command(["line_to", x, y])
+  end
+end
+
+
+ +
+

+ + #move_to(x, y) ⇒ Object + + + + + +

+
+

Shape DSL methods

+ + +
+
+
+ +

Raises:

+ + +
+ + + + +
+
+
+
+284
+285
+286
+287
+288
+289
+290
+
+
# File 'lacci/lib/shoes/app.rb', line 284
+
+def move_to(x, y)
+  raise(Shoes::Errors::InvalidAttributeValueError, "Pass only Numeric arguments to move_to!") unless x.is_a?(Numeric) && y.is_a?(Numeric)
+
+  if current_slot.is_a?(::Shoes::Shape)
+    current_slot.add_shape_command(["move_to", x, y])
+  end
+end
+
+
+ +
+

+ + #pop_slotObject + + + + + +

+ + + + +
+
+
+
+119
+120
+121
+122
+123
+
+
# File 'lacci/lib/shoes/app.rb', line 119
+
+def pop_slot
+  return if @slots.size <= 1
+
+  @slots.pop
+end
+
+
+ +
+

+ + #push_slot(slot) ⇒ Object + + + + + +

+
+

"Container" drawables like flows, stacks, masks and the document root +are considered "slots" in Shoes parlance. When a new slot is created, +we push it here in order to track what drawables are found in that slot.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+115
+116
+117
+
+
# File 'lacci/lib/shoes/app.rb', line 115
+
+def push_slot(slot)
+  @slots.push(slot)
+end
+
+
+ +
+

+ + #runObject + + + + + +

+
+

This usually doesn't return. The display service may take control +of the main thread. Local Webview even stops any background threads. +However, some display libraries don't want to shut down and don't +want to (and/or can't) take control of the event loop.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+
+
# File 'lacci/lib/shoes/app.rb', line 164
+
+def run
+  if @do_shutdown
+    $stderr.puts "Destroy has already been signaled, but we just called Shoes::App.run!"
+    return
+  end
+
+  # The display lib can send us an event to customise the event loop handling.
+  # But it must do so before the "run" event returns.
+  send_shoes_event(event_name: "run")
+
+  case @event_loop_type
+  when "wait"
+    # Display lib wants us to busy-wait instead of it.
+    until @do_shutdown
+      Shoes::DisplayService.dispatch_event("heartbeat", nil)
+    end
+  when "displaylib"
+    # If run event returned, that means we're done.
+    destroy
+  when "return"
+    # We can just return to the main event loop. But we shouldn't call destroy.
+    # Presumably some event loop *outside* our event loop is handling things.
+  else
+    raise Shoes::Errors::InvalidAttributeValueError, "Internal error! Incorrect event loop type: #{@event_loop_type.inspect}!"
+  end
+end
+
+
+ +
+

+ + #with_slot(slot_item, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+129
+130
+131
+132
+133
+134
+135
+136
+
+
# File 'lacci/lib/shoes/app.rb', line 129
+
+def with_slot(slot_item, &block)
+  return unless block_given?
+
+  push_slot(slot_item)
+  Shoes::App.instance.instance_eval(&block)
+ensure
+  pop_slot
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Arc.html b/Shoes/Arc.html new file mode 100644 index 000000000..8251ef838 --- /dev/null +++ b/Shoes/Arc.html @@ -0,0 +1,300 @@ + + + + + + + Class: Shoes::Arc + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Arc + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/arc.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs) ⇒ Arc + + + + + +

+
+

Returns a new instance of Arc.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+17
+18
+19
+20
+21
+22
+23
+
+
# File 'lacci/lib/shoes/drawables/arc.rb', line 17
+
+def initialize(*args, **kwargs)
+  @draw_context = Shoes::App.instance.current_draw_context
+
+  super
+
+  create_display_drawable
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Arrow.html b/Shoes/Arrow.html new file mode 100644 index 000000000..e63335721 --- /dev/null +++ b/Shoes/Arrow.html @@ -0,0 +1,300 @@ + + + + + + + Class: Shoes::Arrow + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Arrow + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/arrow.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs) ⇒ Arrow + + + + + +

+
+

Returns a new instance of Arrow.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+13
+14
+15
+16
+17
+18
+19
+
+
# File 'lacci/lib/shoes/drawables/arrow.rb', line 13
+
+def initialize(*args, **kwargs)
+  @draw_context = Shoes::App.instance.current_draw_context
+
+  super
+
+  create_display_drawable
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Background.html b/Shoes/Background.html new file mode 100644 index 000000000..f160c730f --- /dev/null +++ b/Shoes/Background.html @@ -0,0 +1,190 @@ + + + + + + + Module: Shoes::Background + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Shoes::Background + + + +

+
+ + + + + + + + + +
+
Included in:
+
Flow, Stack, Widget
+
+ + + +
+
Defined in:
+
lacci/lib/shoes/background.rb
+
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #background(color, options = {}) ⇒ Object + + + + + +

+
+

NOTE: this needs to be passed through in order for the styling to work

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lacci/lib/shoes/background.rb', line 10
+
+def background(color, options = {})
+  self.background_color = color
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Border.html b/Shoes/Border.html new file mode 100644 index 000000000..6a8b68f86 --- /dev/null +++ b/Shoes/Border.html @@ -0,0 +1,298 @@ + + + + + + + Class: Shoes::Border + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Border + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/border.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs) ⇒ Border + + + + + +

+
+

Returns a new instance of Border.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+18
+19
+20
+21
+22
+23
+
+
# File 'lacci/lib/shoes/drawables/border.rb', line 18
+
+def initialize(*args, **kwargs)
+  super
+  @draw_context = Shoes::App.instance.current_draw_context
+
+  create_display_drawable
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Builtins.html b/Shoes/Builtins.html new file mode 100644 index 000000000..1f51f8cd0 --- /dev/null +++ b/Shoes/Builtins.html @@ -0,0 +1,643 @@ + + + + + + + Module: Shoes::Builtins + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Shoes::Builtins + + + +

+
+ + + + + + + + + +
+
Included in:
+
Kernel
+
+ + + +
+
Defined in:
+
lacci/lib/shoes/builtins.rb
+
+ +
+ +

Overview

+
+

Shoes has a number of built-in methods that are intended to be available everywhere, +in every Shoes and non-Shoes class, for every Shoes app.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #alert(message) ⇒ Object + + + + + +

+ + + + +
+
+
+
+22
+23
+24
+
+
# File 'lacci/lib/shoes/builtins.rb', line 22
+
+def alert(message)
+  shoes_builtin("alert", message)
+end
+
+
+ +
+

+ + #ask(message_string) ⇒ Object + + + + + +

+ + + + +
+
+
+
+18
+19
+20
+
+
# File 'lacci/lib/shoes/builtins.rb', line 18
+
+def ask(message_string)
+  shoes_builtin("ask", message_string)
+end
+
+
+ +
+

+ + #ask_color(title_bar) ⇒ Object + + + + + +

+ + + + +
+
+
+
+26
+27
+28
+
+
# File 'lacci/lib/shoes/builtins.rb', line 26
+
+def ask_color(title_bar)
+  shoes_builtin("ask_color", title_bar)
+end
+
+
+ +
+

+ + #ask_open_fileObject + + + + + +

+ + + + +
+
+
+
+30
+31
+32
+
+
# File 'lacci/lib/shoes/builtins.rb', line 30
+
+def ask_open_file()
+  shoes_builtin("ask_open_file")
+end
+
+
+ +
+

+ + #ask_open_folderObject + + + + + +

+ + + + +
+
+
+
+38
+39
+40
+
+
# File 'lacci/lib/shoes/builtins.rb', line 38
+
+def ask_open_folder()
+  shoes_builtin("ask_open_folder")
+end
+
+
+ +
+

+ + #ask_save_fileObject + + + + + +

+ + + + +
+
+
+
+34
+35
+36
+
+
# File 'lacci/lib/shoes/builtins.rb', line 34
+
+def ask_save_file()
+  shoes_builtin("ask_save_file")
+end
+
+
+ +
+

+ + #ask_save_folderObject + + + + + +

+ + + + +
+
+
+
+42
+43
+44
+
+
# File 'lacci/lib/shoes/builtins.rb', line 42
+
+def ask_save_folder()
+  shoes_builtin("ask_save_folder")
+end
+
+
+ +
+

+ + #confirm(question) ⇒ Object + + + + + +

+ + + + +
+
+
+
+46
+47
+48
+
+
# File 'lacci/lib/shoes/builtins.rb', line 46
+
+def confirm(question)
+  shoes_builtin("confirm", question)
+end
+
+
+ +
+

+ + #font(font_file_or_url) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Register the given font with Shoes so that text that wants it can use it. +Also add it to the FONTS constant.

+ + +
+
+
+

Parameters:

+
    + +
  • + + font_file_or_url + + + (String) + + + + — +

    the filename or URL for the font

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+11
+12
+13
+14
+15
+16
+
+
# File 'lacci/lib/shoes/builtins.rb', line 11
+
+def font(font_file_or_url)
+  shoes_builtin("font", font_file_or_url)
+
+  font_name = File.basename(font_file_or_url, ".*")
+  Shoes::FONTS << font_name
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Button.html b/Shoes/Button.html new file mode 100644 index 000000000..029ab5a2f --- /dev/null +++ b/Shoes/Button.html @@ -0,0 +1,588 @@ + + + + + + + Class: Shoes::Button + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Button + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/button.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs) { ... } ⇒ Shoes::Button + + + + + +

+
+

Creates a new Button object.

+ + +
+
+
+ +
+

Examples:

+ + +
Shoes.app do
+  @push = button "Push me"
+  @note = para "Nothing pushed so far"
+  @push.click {
+    @note.replace(
+      "Aha! Click! ",
+      link("Go back") { @note.replace("Nothing pushed so far") }
+    )
+  }
+end
+ +
+

Parameters:

+
    + +
  • + + text + + + (String) + + + + — +

    The text displayed on the button.

    +
    + +
  • + +
  • + + width + + + (Integer) + + + + — +

    The requested width of the button in pixels.

    +
    + +
  • + +
  • + + height + + + (Integer) + + + + — +

    The requested height of the button in pixels.

    +
    + +
  • + +
  • + + top + + + (Integer) + + + + — +

    The position of the top edge of the button relative to its parent widget.

    +
    + +
  • + +
  • + + left + + + (Integer) + + + + — +

    The position of the left edge of the button relative to its parent widget.

    +
    + +
  • + +
  • + + size + + + (Integer) + + + + — +

    The font size of the button text.

    +
    + +
  • + +
  • + + color + + + (String) + + + + — +

    The background color of the button.

    +
    + +
  • + +
  • + + padding_top + + + (Integer) + + + + — +

    The padding above the button text.

    +
    + +
  • + +
  • + + padding_bottom + + + (Integer) + + + + — +

    The padding below the button text.

    +
    + +
  • + +
  • + + text_color + + + (String) + + + + — +

    The color of the button text.

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +

    A block of code to be executed when the button is clicked.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+
+
# File 'lacci/lib/shoes/drawables/button.rb', line 35
+
+def initialize(*args, **kwargs, &block)
+  # Properties passed as positional args, not keywords, don't get auto-set
+  @block = block
+
+  super
+
+  # Bind block to a handler named "click"
+  bind_self_event("click") do
+    @log.debug("Button clicked, calling handler") if @block
+    @block&.call
+  end
+
+  create_display_drawable
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #click { ... } ⇒ Object + + + + + +

+
+

Set the click handler

+ + +
+
+
+ +

Yields:

+
    + +
  • + + + + + + + +

    A block to be called when the button is clicked.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+53
+54
+55
+
+
# File 'lacci/lib/shoes/drawables/button.rb', line 53
+
+def click(&block)
+  @block = block
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Changelog.html b/Shoes/Changelog.html new file mode 100644 index 000000000..d746f6919 --- /dev/null +++ b/Shoes/Changelog.html @@ -0,0 +1,327 @@ + + + + + + + Class: Shoes::Changelog + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Changelog + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/changelog.rb
+
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + +
+

Constructor Details

+ +
+

+ + #initializeChangelog + + + + + +

+
+

include Shoes::Log

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+14
+15
+
+
# File 'lacci/lib/shoes/changelog.rb', line 10
+
+def initialize
+  #TODO : refer to  https://github.com/scarpe-team/scarpe/pull/400
+  #       and figure out how to use scarpe logger here without getting duplicate or nil error
+  # Shoes::Log.instance = Scarpe::Components::ModularLogImpl.new
+  # log_init("Changelog")
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #get_latest_release_infoObject + + + + + +

+ + + + +
+
+
+
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+
+
# File 'lacci/lib/shoes/changelog.rb', line 17
+
+def get_latest_release_info
+  root_dir = File.dirname(__FILE__, 4) # this duplicates constants.rb, but how to share?
+
+  git_dir = "#{root_dir}/.git"
+  revision = nil
+  if File.exist?(git_dir)
+    revision = `git rev-parse HEAD`.chomp
+  end
+
+  changelog_file = "#{root_dir}/CHANGELOG.md"
+  if File.exist?(changelog_file)
+    changelog_content = File.read(changelog_file)
+    release_name_pattern = /^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2}) - (\w+)$/m
+    release_matches = changelog_content.scan(release_name_pattern)
+    latest_release = release_matches.max_by { |version, _date, _name| Gem::Version.new(version) }
+
+    if latest_release
+      #puts "Found release #{latest_release[0]} in CHANGELOG.md"
+      # @log.debug("Found release #{latest_release[0]} in CHANGELOG.md") # Logger isn't initialized yet
+      version_parts = latest_release[0].split(".").map(&:to_i)
+      rel_id = ("%02d%02d%02d" % version_parts).to_i
+
+      return({
+        RELEASE_NAME: latest_release[2],
+        RELEASE_BUILD_DATE: latest_release[1],
+        RELEASE_ID: rel_id,
+        REVISION: revision,
+      })
+    end
+  end
+
+  puts "No release found in CHANGELOG.md"
+  { RELEASE_NAME: nil, RELEASE_BUILD_DATE: nil, RELEASE_ID: nil, REVISION: revision }
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Check.html b/Shoes/Check.html new file mode 100644 index 000000000..415f90af3 --- /dev/null +++ b/Shoes/Check.html @@ -0,0 +1,490 @@ + + + + + + + Class: Shoes::Check + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Check + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/check.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs, &block) ⇒ Check + + + + + +

+
+

Returns a new instance of Check.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+
+
# File 'lacci/lib/shoes/drawables/check.rb', line 10
+
+def initialize(*args, **kwargs, &block)
+  @block = block
+  super
+
+  bind_self_event("click") do
+    self.checked = !checked?
+    @block.call(self) if @block
+  end
+  create_display_drawable
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #checked(value) ⇒ Object + + + + + +

+ + + + +
+
+
+
+29
+30
+31
+
+
# File 'lacci/lib/shoes/drawables/check.rb', line 29
+
+def checked(value)
+  self.checked = value
+end
+
+
+ +
+

+ + #checked?Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+25
+26
+27
+
+
# File 'lacci/lib/shoes/drawables/check.rb', line 25
+
+def checked?
+  @checked ? true : false
+end
+
+
+ +
+

+ + #click(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+21
+22
+23
+
+
# File 'lacci/lib/shoes/drawables/check.rb', line 21
+
+def click(&block)
+  @block = block
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Colors.html b/Shoes/Colors.html new file mode 100644 index 000000000..0bb2c97c9 --- /dev/null +++ b/Shoes/Colors.html @@ -0,0 +1,396 @@ + + + + + + + Module: Shoes::Colors + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Shoes::Colors + + + +

+
+ + + + +
+
Extended by:
+
Colors
+
+ + + + + + +
+
Included in:
+
Colors, Drawable
+
+ + + +
+
Defined in:
+
lacci/lib/shoes/colors.rb
+
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #gray(darkness = 128, alpha = nil) ⇒ Object + + + + + +

+
+ + +
+ + + + +
+
+
+
+161
+162
+163
+164
+
+
# File 'lacci/lib/shoes/colors.rb', line 161
+
+def gray(darkness = 128, alpha = nil)
+  alpha ||= (darkness.is_a?(Integer) ? 255 : 1.0)
+  [darkness, darkness, darkness, alpha]
+end
+
+
+ +
+

+ + #rgb(r, g, b, a = nil) ⇒ Object + + + + + +

+
+

Shoes allows RGB values to be Floats between 0 and 1 or Integers between 0 and 255

+ + +
+
+
+ + +
+ + + + +
+
+
+
+167
+168
+169
+170
+171
+172
+173
+174
+175
+
+
# File 'lacci/lib/shoes/colors.rb', line 167
+
+def rgb(r, g, b, a = nil)
+  if r.is_a?(Float)
+    [r, g, b, a || 1.0]
+  elsif r.is_a?(Integer)
+    [r, g, b, a || 255]
+  else
+    raise("RGB values should be Float or Integer!")
+  end
+end
+
+
+ +
+

+ + #to_rgb(color) ⇒ Object + + + + + +

+ + + + +
+
+
+
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+
+
# File 'lacci/lib/shoes/colors.rb', line 177
+
+def to_rgb(color)
+  case color
+  when nil
+    nil
+  when Array
+    color # Already an RGB array
+  when Symbol
+    if COLORS[color]
+      rgb(*COLORS[color])
+    else
+      raise("Unrecognised color name: #{color}")
+    end
+  when String
+    if color[0] == "#"
+      if color.length == 4
+        r = color[1].to_i(16)
+        g = color[2].to_i(16)
+        b = color[3].to_i(16)
+        rgb(16 * r, 16 * g, 16 * b)
+      elsif color.length == 7
+        r = color[1..2].to_i(16)
+        g = color[3..4].to_i(16)
+        b = color[5..6].to_i(16)
+        rgb(r, g, b)
+      else
+        raise("Don't know how to convert #{color.inspect} to RGB! (wrong number of digits)")
+      end
+    else
+      rgb_value = COLORS[color.to_sym]
+      if rgb_value
+        rgb(*rgb_value)
+      else
+        raise("Unrecognised color name: #{color}")
+      end
+    end
+  else
+    raise("Don't know how to convert #{color.inspect} to RGB!")
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Constants.html b/Shoes/Constants.html new file mode 100644 index 000000000..df5d8d708 --- /dev/null +++ b/Shoes/Constants.html @@ -0,0 +1,344 @@ + + + + + + + Module: Shoes::Constants + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Shoes::Constants + + + +

+
+ + + + + + + + + +
+
Included in:
+
Kernel
+
+ + + +
+
Defined in:
+
lacci/lib/shoes/constants.rb
+
+ +
+ + + +

+ Constant Summary + collapse +

+ +
+ +
LIB_DIR = +
+
+

A temp dir for Shoes app files

+ + +
+
+
+ + +
+
+
find_lib_dir
+ +
DIR = +
+
+

the Shoes library dir

+ + +
+
+
+ + +
+
+
File.dirname(__FILE__, 4)
+ +
RAD2PI = +
+
+

Math constants from Shoes3

+ + +
+
+
+ + +
+
+
0.01745329251994329577
+ +
TWO_PI = + +
+
6.28318530717958647693
+ +
HALF_PI = + +
+
1.57079632679489661923
+ +
PI = + +
+
3.14159265358979323846
+ +
FONTS = +
+
+

Fonts currently loaded and available

+ + +
+
+
+ + +
+
+
[]
+ +
FEATURES = +
+
+

Standard features available in this display service - see KNOWN_FEATURES. +These may or may not require the Shoes.app requesting them per-app.

+ + +
+
+
+ + +
+
+
[]
+ +
EXTENSIONS = +
+
+

Nonstandard extensions, e.g. Scarpe extensions, supported by this display lib. +An application may have to request the extensions for them to be available so +that a casual reader can see Shoes.app(features: :scarpe) and realize why +there are nonstandard styles or drawables.

+ + +
+
+
+ + +
+
+
[]
+ +
KNOWN_FEATURES = +
+
+

These are all known features supported by this version of Lacci. +Features on this list are allowed to be in FEATURES. Anything else +goes in EXTENSIONS and is nonstandard.

+ + +
+
+
+ + +
+
+
[
+  :html, # Supports .to_html on display objects, HTML classes on drawables, etc.
+].freeze
+ +
+ + + + + + + + + +

+ Class Method Summary + collapse +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + .find_lib_dirObject + + + + + +

+ + + + +
+
+
+
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+
+
# File 'lacci/lib/shoes/constants.rb', line 6
+
+def self.find_lib_dir
+  begin
+    require "tmpdir"
+  rescue LoadError
+    return nil
+  end
+  homes = [
+    [ENV["LOCALAPPDATA"], "Shoes"],
+    [ENV["APPDATA"], "Shoes"],
+    [ENV["HOME"], ".shoes"],
+  ]
+
+  top, file = homes.detect { |home_top, _| home_top && File.exist?(home_top) }
+  return nil if top.nil?
+  File.join(top, file)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/DisplayService.html b/Shoes/DisplayService.html new file mode 100644 index 000000000..329945a24 --- /dev/null +++ b/Shoes/DisplayService.html @@ -0,0 +1,1178 @@ + + + + + + + Class: Shoes::DisplayService + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::DisplayService + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + +
+
Extended by:
+
Log
+
+ + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/display_service.rb
+
+ +
+ + + + + +

Constant Summary

+ +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + + + +

+ Class Method Summary + collapse +

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Log

+

configure_logger, log_init, logger

+
+

Constructor Details

+ +
+

+ + #initializeDisplayService + + + + + +

+
+

Returns a new instance of DisplayService.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+165
+166
+167
+
+
# File 'lacci/lib/shoes/display_service.rb', line 165
+
+def initialize
+  @display_drawable_for = {}
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + .dispatch_event(event_name, event_target, *args, **kwargs) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Send a Shoes event to all subscribers. +An event_target may be nil, to indicate there is no target.

+ + +
+
+
+

Parameters:

+
    + +
  • + + event_name + + + (String) + + + + — +

    the name of the event

    +
    + +
  • + +
  • + + event_target + + + (String) + + + + — +

    the specific target, if any

    +
    + +
  • + +
  • + + args + + + (Array) + + + + — +

    arguments to pass to the subscribing block

    +
    + +
  • + +
  • + + args + + + (Array) + + + + — +

    keyword arguments to pass to the subscribing block

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+
+
# File 'lacci/lib/shoes/display_service.rb', line 43
+
+def dispatch_event(event_name, event_target, *args, **kwargs)
+  @@display_event_handlers ||= {}
+
+  unless @log
+    log_init("DisplayService")
+  end
+
+  raise "Cannot dispatch on event_name :any!" if event_name == :any
+
+  @log.debug("Dispatch event: #{event_name.inspect} T: #{event_target.inspect} A: #{args.inspect} KW: #{kwargs.inspect}")
+
+  # When true, this makes sure all events and properties are 100% strings, no symbols.
+  if ENV["SCARPE_DEBUG"]
+    args = JSON.parse JSON.dump(args)
+    new_kw = {}
+    kwargs.each do |k, v|
+      new_kw[k] = JSON.parse JSON.dump(v)
+    end
+    kwargs = new_kw
+  end
+
+  same_name_handlers = @@display_event_handlers[event_name] || {}
+  any_name_handlers = @@display_event_handlers[:any] || {}
+
+  # Do we have any keys, in same_name_handlers or any_name_handlers, matching the target or :any?
+  # Note that "nil" is a target like any other for these purposes -- subscribing to a nil target
+  # won't get you non-nil-target events and vice-versa.
+  handlers = [
+    same_name_handlers[:any],           # Same name, any target
+    same_name_handlers[event_target],   # Same name, same target
+    any_name_handlers[:any],            # Any name, any target
+    any_name_handlers[event_target],    # Any name, same target
+  ].compact.inject([], &:+)
+  kwargs[:event_name] = event_name
+  kwargs[:event_target] = event_target if event_target
+  handlers.each { |h| h[:handler].call(*args, **kwargs) }
+  nil
+end
+
+
+ +
+

+ + .display_serviceObject + + + + + +

+
+

Get the current display service instance. This requires a display service +class having been set first. @see set_display_service_class

+ + +
+
+
+ + +
+ + + + +
+
+
+
+156
+157
+158
+159
+160
+161
+162
+
+
# File 'lacci/lib/shoes/display_service.rb', line 156
+
+def display_service
+  return @service if @service
+
+  raise "No display service was set!" unless @display_service_klass
+
+  @service = @display_service_klass.new
+end
+
+
+ +
+

+ + .full_reset!void + + + + + +

+
+

This method returns an undefined value.

Reset the display service, for instance between unit tests. +This destroys all existing subscriptions.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+134
+135
+136
+137
+
+
# File 'lacci/lib/shoes/display_service.rb', line 134
+
+def full_reset!
+  @@display_event_handlers = {}
+  @json_debug_serialize = nil
+end
+
+
+ +
+

+ + .set_display_service_class(klass) ⇒ Object + + + + + +

+
+

Set the Display Service class which will handle display service functions +for this process. This can only be set once. The display service can be +a subclass of Shoes::DisplayService, but isn't required to be.

+ +

Shoes will create an instance of this class with no arguments passed to +initialize, and use it as the display service for the lifetime of the +process.

+ + +
+
+
+

Parameters:

+
    + +
  • + + klass + + + (Class) + + + + — +

    the class for the display service

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+148
+149
+150
+151
+152
+
+
# File 'lacci/lib/shoes/display_service.rb', line 148
+
+def set_display_service_class(klass)
+  raise "Can only set a single display service class!" if @display_service_klass
+
+  @display_service_klass = klass
+end
+
+
+ +
+

+ + .subscribe_to_event(event_name, event_target, &handler) ⇒ Integer + + + + + +

+
+

Subscribe to the given event name and target. +It's permitted to subscribe to event_name :any for all event names, +and event_target :any for all targets. An event_target of nil means +"no target", and only matches events dispatched with a nil target. +The subscription will return an unsubscribe ID, which can be used +later to unsubscribe from the notification.

+ + +
+
+
+

Parameters:

+
    + +
  • + + event_name + + + (String, Symbol) + + + + — +

    the event name to subscribe to, or :any for all event names

    +
    + +
  • + +
  • + + event_target + + + (String, Symbol, NilClass) + + + + — +

    the event target to subscribe to, or :any for all targets - nil is a valid target

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Integer) + + + + — +

    an unsubscription ID which can be used later to cancel the subscription

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+
+
# File 'lacci/lib/shoes/display_service.rb', line 93
+
+def subscribe_to_event(event_name, event_target, &handler)
+  @@display_event_handlers ||= {}
+  @@display_event_unsub_id ||= 0
+  unless handler
+    raise "Must pass a block as a handler to DisplayService.subscribe_to_event!"
+  end
+
+  unless @log
+    log_init("DisplayService")
+  end
+
+  @log.debug("Subscribe to event: #{event_name.inspect} T: #{event_target.inspect}")
+
+  id = @@display_event_unsub_id
+  @@display_event_unsub_id += 1
+
+  @@display_event_handlers[event_name] ||= {}
+  @@display_event_handlers[event_name][event_target] ||= []
+  @@display_event_handlers[event_name][event_target] << { handler:, unsub_id: id }
+
+  id
+end
+
+
+ +
+

+ + .unsub_from_events(unsub_id) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Unsubscribe from any event subscriptions matching the unsub ID.

+ + +
+
+
+

Parameters:

+
    + +
  • + + unsub_id + + + (Integer) + + + + — +

    the unsub ID returned when subscribing

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+120
+121
+122
+123
+124
+125
+126
+127
+128
+
+
# File 'lacci/lib/shoes/display_service.rb', line 120
+
+def unsub_from_events(unsub_id)
+  raise "Must provide an unsubscribe ID!" if unsub_id.nil?
+
+  @@display_event_handlers.each do |_e_name, target_hash|
+    target_hash.each do |_target, h_list|
+      h_list.delete_if { |item| item[:unsub_id] == unsub_id }
+    end
+  end
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + #create_display_drawable_for(drawable_class_name, drawable_id, properties, parent_id:, is_widget:) ⇒ Object + + + + + +

+
+

These methods are an interface to DisplayService objects.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+171
+172
+173
+
+
# File 'lacci/lib/shoes/display_service.rb', line 171
+
+def create_display_drawable_for(drawable_class_name, drawable_id, properties, parent_id:, is_widget:)
+  raise "Override in DisplayService implementation!"
+end
+
+
+ +
+

+ + #destroyObject + + + + + +

+ + + + +
+
+
+
+199
+200
+201
+
+
# File 'lacci/lib/shoes/display_service.rb', line 199
+
+def destroy
+  raise "Override in DisplayService implementation!"
+end
+
+
+ +
+

+ + #query_display_drawable_for(id, nil_ok: false) ⇒ Object + + + + + +

+ + + + +
+
+
+
+189
+190
+191
+192
+193
+194
+195
+196
+197
+
+
# File 'lacci/lib/shoes/display_service.rb', line 189
+
+def query_display_drawable_for(id, nil_ok: false)
+  @display_drawable_for ||= {}
+  display_drawable = @display_drawable_for[id]
+  unless display_drawable || nil_ok
+    raise "Could not find display drawable for linkable ID #{id.inspect}!"
+  end
+
+  display_drawable
+end
+
+
+ +
+

+ + #set_drawable_pairing(id, display_drawable) ⇒ Object + + + + + +

+ + + + +
+
+
+
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+
+
# File 'lacci/lib/shoes/display_service.rb', line 175
+
+def set_drawable_pairing(id, display_drawable)
+  if id.nil?
+    raise Shoes::Errors::BadLinkableIdError, "Linkable ID may not be nil!"
+  end
+
+  @display_drawable_for ||= {}
+  if @display_drawable_for[id]
+    raise Shoes::Errors::DuplicateCreateDrawableError, "There is already a drawable for #{id.inspect}! Not setting a new one."
+  end
+
+  @display_drawable_for[id] = display_drawable
+  nil
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/DocumentRoot.html b/Shoes/DocumentRoot.html new file mode 100644 index 000000000..4648e82d5 --- /dev/null +++ b/Shoes/DocumentRoot.html @@ -0,0 +1,398 @@ + + + + + + + Class: Shoes::DocumentRoot + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::DocumentRoot + + + +

+
+ +
+
Inherits:
+
+ Flow + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/document_root.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Shoes::Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Slot

+

#children, #draw_context

+ + + +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + + + + + + + +

Methods included from Background

+

#background

+ + + + + + + + + +

Methods inherited from Slot

+

#add_child, #append, #clear, #contents, #current_draw_context, #fill, #method_missing, #nofill, #nostroke, #remove_child, #respond_to_missing?, #rotate, #stroke, #strokewidth

+ + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(**kwargs, &block) ⇒ DocumentRoot + + + + + +

+
+

Returns a new instance of DocumentRoot.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+
+
# File 'lacci/lib/shoes/drawables/document_root.rb', line 11
+
+def initialize(**kwargs, &block)
+  super
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Slot + +

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #inspectObject + + + + + +

+
+

The default inspect string can be absolutely huge in console output, and it's frequently printed.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+16
+17
+18
+
+
# File 'lacci/lib/shoes/drawables/document_root.rb', line 16
+
+def inspect
+  "<Shoes::DocumentRoot>"
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Drawable.html b/Shoes/Drawable.html new file mode 100644 index 000000000..05b8cd92b --- /dev/null +++ b/Shoes/Drawable.html @@ -0,0 +1,4630 @@ + + + + + + + Class: Shoes::Drawable + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Drawable + + + +

+
+ +
+
Inherits:
+
+ Linkable + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + +
+
Includes:
+
MarginHelper, Colors, Log
+
+ + + + + + +
+
Defined in:
+
lacci/lib/shoes.rb,
+ lacci/lib/shoes/download.rb,
lacci/lib/shoes/drawable.rb,
lacci/lib/shoes/drawables/para.rb
+
+
+ +
+ +

Overview

+
+

Shoes::Drawable

+ +

This is the display-service portable Shoes Drawable interface. Visible Shoes +drawables like buttons inherit from this. Compound drawables made of multiple +different smaller Drawables inherit from it in their various apps or libraries. +The Shoes Drawable helps build a Shoes-side drawable tree, with parents and +children. Any API that applies to all drawables (e.g. remove) should be +defined here.

+ + +
+
+
+ + +
+

Defined Under Namespace

+

+ + + + + Classes: ResponseWrapper + + +

+ + +

+ Constant Summary + collapse +

+ +
+ +
DRAW_CONTEXT_STYLES = +
+
+

These styles can be set to a current per-slot value and inherited from parent slots. +Their value is set at drawable-create time.

+ + +
+
+
+ + +
+
+
[:fill, :stroke, :strokewidth, :rotate, :transform, :translate]
+ +
+ + + + + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + +

Class Attribute Summary collapse

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #debug_id ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute debug_id.

    +
    + +
  • + + +
  • + + + #destroyed ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute destroyed.

    +
    + +
  • + + +
  • + + + #parent ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute parent.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Class Method Summary + collapse +

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs) ⇒ Drawable + + + + + +

+
+

Returns a new instance of Drawable.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+
+
# File 'lacci/lib/shoes/drawable.rb', line 261
+
+def initialize(*args, **kwargs)
+  kwargs = margin_parse(kwargs)
+  log_init("Shoes::#{self.class.name}") unless @log
+
+  # First, get the list of allowed and disallowed styles for the given features
+  # and make sure no disallowed styles were given.
+
+  app_features = Shoes::App.instance.features
+  this_app_styles = self.class.shoes_style_names.map(&:to_sym)
+  not_this_app_styles = self.class.shoes_style_names(with_features: :all).map(&:to_sym) - this_app_styles
+
+  bad_styles = kwargs.keys & not_this_app_styles
+  unless bad_styles.empty?
+    features_needed = bad_styles.map { |s| self.class.feature_for_shoes_style(s) }.uniq
+    raise Shoes::Errors::UnsupportedFeatureError, "The style(s) #{bad_styles.inspect} are only defined for applications that request specific features: #{features_needed.inspect} (you requested #{app_features.inspect})!"
+  end
+
+  # Next, check positional arguments and make sure the correct number and type
+  # were passed and match positional args with style names.
+
+  supplied_args = kwargs.keys
+
+  req_args = self.class.required_init_args
+  opt_args = self.class.optional_init_args
+  pos_args = req_args + opt_args
+  if req_args != ["any"]
+    if args.size > pos_args.size
+      raise Shoes::Errors::BadArgumentListError, "Too many arguments given for #{self.class}#initialize! #{args.inspect}"
+    end
+
+    if args.size == 0
+      # It's fine to use keyword args instead, but we should make sure they're actually there
+      needed_args = req_args.map(&:to_sym) - kwargs.keys
+      unless needed_args.empty?
+        raise Shoes::Errors::BadArgumentListError, "Keyword arguments for #{self.class}#initialize should also supply #{needed_args.inspect}! #{args.inspect}"
+      end
+    elsif args.size < req_args.size
+      raise Shoes::Errors::BadArgumentListError, "Too few arguments given for #{self.class}#initialize! #{args.inspect}"
+    end
+
+    # Set each positional argument
+    args.each.with_index do |val, idx|
+      style_name = pos_args[idx]
+      next if style_name.nil? || style_name == "" # It's possible to have non-style positional args
+
+      val = self.class.validate_as(style_name, args[idx])
+      instance_variable_set("@#{style_name}", val)
+      supplied_args << style_name.to_sym
+    end
+  end
+
+  this_drawable_styles = self.class.shoes_style_names.map(&:to_sym)
+  dc = Shoes::App.instance.current_draw_context || {}
+
+  # Styles not passed as arguments can come from the draw context
+
+  # What styles are in the draw context, are used by this drawable, and weren't
+  # given as positional or keyword arguments?
+  draw_context_styles = (DRAW_CONTEXT_STYLES & this_drawable_styles) - supplied_args
+  unless draw_context_styles.empty?
+    # When we first call this, there is no parent. We don't want to set the parent
+    # yet because that will send a notification, and *that* should wait until after
+    # we've told the display service that this drawable was created. So instead
+    # we'll query the parent object's draw context directly.
+
+    draw_context_styles.each do |style|
+      dc_val = dc[style.to_s]
+      next if dc_val.nil?
+
+      val = self.class.validate_as(style, dc[style.to_s])
+      instance_variable_set("@#{style}", val)
+      supplied_args << style
+    end
+  end
+
+  # Styles that were *not* passed should be set to defaults
+
+  default_styles = Shoes::Drawable.drawable_default_styles[self.class]
+
+  # No arg specified for a property with a default value? Set it to default.
+  (default_styles.keys - supplied_args).each do |key|
+    val = self.class.validate_as(key, default_styles[key])
+    instance_variable_set("@#{key}", val)
+  end
+
+  # If we have a keyword arg for a style, set it as specified.
+  (this_drawable_styles & kwargs.keys).each do |key|
+    val = self.class.validate_as(key, kwargs[key])
+    instance_variable_set("@#{key}", val)
+  end
+
+  # We'd like to avoid unexpected keywords. But we're not disciplined enough to
+  # raise an error by default yet. Non-style keywords passed to Drawable#initialize
+  # are deprecated at this point, but I need to hunt down the last of them
+  # and prevent them.
+  unexpected = (kwargs.keys - this_drawable_styles)
+  unless unexpected.empty?
+    STDERR.puts "Unexpected non-style keyword(s) in #{self.class} initialize: #{unexpected.inspect}"
+  end
+
+  super(linkable_id: Shoes::Drawable.allocate_drawable_id)
+  Shoes::Drawable.register_drawable_id(self.linkable_id, self)
+
+  generate_debug_id
+
+  parent = ::Shoes::App.instance.current_slot
+  if self.class.expects_parent?
+    set_parent(parent, notify: false)
+  end
+
+  unless self.class.registered_shoes_events?
+    # No Shoes events declared and we're creating an instance?
+    # Default to no class-specific events.
+    self.class.shoes_events
+  end
+
+  # Binding the motion events here isn't perfect.
+  # What about drawables like SubscriptionItem that
+  # have no motion events? With the current Lacci
+  # implementation, the answer is that those events
+  # will never be sent. Calling .hover on one will
+  # be useless, harmless, and allowed. If you want
+  # to make it disallowed, you can do something like
+  # define a SubscriptionItem#hover that raises an
+  # exception instead.
+
+  bind_self_event("hover") do
+    @hover&.call
+  end
+
+  bind_self_event("leave") do
+    @leave&.call
+  end
+
+  bind_self_event("motion") do |x, y|
+    @motion&.call(x, y)
+  end
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + +

+ +
+

+ + #method_missing(name, *args, **kwargs, &block) ⇒ Object + + + + + +

+
+

We use method_missing to auto-create Shoes style getters and setters.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+
+
# File 'lacci/lib/shoes/drawable.rb', line 590
+
+def method_missing(name, *args, **kwargs, &block)
+  name_s = name.to_s
+
+  if name_s[-1] == "="
+    prop_name = name_s[0..-2]
+    if self.class.shoes_style_name?(prop_name)
+      self.class.define_method(name) do |new_value|
+        raise(Shoes::Errors::NoSuchLinkableIdError, "Trying to set Shoes styles in a #{self.class} with no linkable ID!") unless linkable_id
+
+        new_value = self.class.validate_as(prop_name, new_value)
+        instance_variable_set("@" + prop_name, new_value)
+        send_shoes_event({ prop_name => new_value }, event_name: "prop_change", target: linkable_id)
+      end
+
+      return self.send(name, *args, **kwargs, &block)
+    end
+  end
+
+  if self.class.shoes_style_name?(name_s)
+    self.class.define_method(name) do
+      raise(Shoes::Errors::NoSuchLinkableIdError, "Trying to get Shoes styles in an object with no linkable ID! #{inspect}") unless linkable_id
+
+      instance_variable_get("@" + name_s)
+    end
+
+    return self.send(name, *args, **kwargs, &block)
+  end
+
+  super(name, *args, **kwargs, &block)
+end
+
+
+ +
+ +
+

Class Attribute Details

+ + + +
+

+ + .drawable_classesObject + + + + + +

+
+

Returns the value of attribute drawable_classes.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+21
+22
+23
+
+
# File 'lacci/lib/shoes/drawable.rb', line 21
+
+def drawable_classes
+  @drawable_classes
+end
+
+
+ + + +
+

+ + .drawable_default_stylesObject + + + + + +

+
+

Returns the value of attribute drawable_default_styles.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+22
+23
+24
+
+
# File 'lacci/lib/shoes/drawable.rb', line 22
+
+def drawable_default_styles
+  @drawable_default_styles
+end
+
+
+ + + +
+

+ + .widget_classesObject + + + + + +

+
+

Returns the value of attribute widget_classes.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+23
+24
+25
+
+
# File 'lacci/lib/shoes/drawable.rb', line 23
+
+def widget_classes
+  @widget_classes
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #debug_idObject (readonly) + + + + + +

+
+

Returns the value of attribute debug_id.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+253
+254
+255
+
+
# File 'lacci/lib/shoes/drawable.rb', line 253
+
+def debug_id
+  @debug_id
+end
+
+
+ + + +
+

+ + #destroyedObject (readonly) + + + + + +

+
+

Returns the value of attribute destroyed.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+526
+527
+528
+
+
# File 'lacci/lib/shoes/drawable.rb', line 526
+
+def destroyed
+  @destroyed
+end
+
+
+ + + +
+

+ + #parentObject (readonly) + + + + + +

+
+

Returns the value of attribute parent.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+525
+526
+527
+
+
# File 'lacci/lib/shoes/drawable.rb', line 525
+
+def parent
+  @parent
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + .allocate_drawable_idObject + + + + + +

+
+

Assign a new Shoes Drawable ID number, starting from 1. +This allows non-overlapping small integer IDs for Shoes +linkable IDs - the number part of making it clear what +widget you're talking about.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+137
+138
+139
+140
+141
+
+
# File 'lacci/lib/shoes/drawable.rb', line 137
+
+def allocate_drawable_id
+  @drawable_id_counter ||= 0
+  @drawable_id_counter += 1
+  @drawable_id_counter
+end
+
+
+ +
+

+ + .convert_to_float(value, attribute_name) ⇒ Object + + + + + +

+ + + + +
+
+
+
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+
+
# File 'lacci/lib/shoes/drawable.rb', line 642
+
+def self.convert_to_float(value, attribute_name)
+  begin
+    value = Float(value)
+    raise Shoes::Errors::InvalidAttributeValueError, "Negative number '#{value}' not allowed for attribute '#{attribute_name}'" if value < 0
+
+    value
+  rescue ArgumentError
+    error_message = "Invalid value '#{value}' provided for attribute '#{attribute_name}'. The value should be a number."
+    raise Shoes::Errors::InvalidAttributeValueError, error_message
+  end
+end
+
+
+ +
+

+ + .convert_to_integer(value, attribute_name) ⇒ Object + + + + + +

+ + + + +
+
+
+
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+
+
# File 'lacci/lib/shoes/drawable.rb', line 630
+
+def self.convert_to_integer(value, attribute_name)
+  begin
+    value = Integer(value)
+    raise Shoes::Errors::InvalidAttributeValueError, "Negative number '#{value}' not allowed for attribute '#{attribute_name}'" if value < 0
+
+    value
+  rescue ArgumentError
+    error_message = "Invalid value '#{value}' provided for attribute '#{attribute_name}'. The value should be a number."
+    raise Shoes::Errors::InvalidAttributeValueError, error_message
+  end
+end
+
+
+ +
+

+ + .drawable_by_id(id, none_ok: false) ⇒ Object + + + + + +

+ + + + +
+
+
+
+153
+154
+155
+156
+157
+158
+159
+160
+
+
# File 'lacci/lib/shoes/drawable.rb', line 153
+
+def drawable_by_id(id, none_ok: false)
+  val = @drawables_by_id[id]
+  unless val || none_ok
+    raise "No Drawable Found! #{@drawables_by_id.inspect}"
+  end
+
+  val
+end
+
+
+ +
+

+ + .drawable_class_by_name(name) ⇒ Object + + + + + +

+ + + + +
+
+
+
+45
+46
+47
+48
+
+
# File 'lacci/lib/shoes/drawable.rb', line 45
+
+def drawable_class_by_name(name)
+  name = name.to_s
+  drawable_classes.detect { |k| k.dsl_name == name }
+end
+
+
+ +
+

+ + .dsl_nameObject + + + + + +

+ + + + +
+
+
+
+40
+41
+42
+43
+
+
# File 'lacci/lib/shoes/drawable.rb', line 40
+
+def dsl_name
+  n = name.split("::").last.chomp("Drawable")
+  n.gsub(/(.)([A-Z])/, '\1_\2').downcase
+end
+
+
+ +
+

+ + .expects_parent?Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+400
+401
+402
+403
+404
+405
+
+
# File 'lacci/lib/shoes/drawable.rb', line 400
+
+def self.expects_parent?
+  return false if [::Shoes::App, ::Shoes::DocumentRoot].include?(self)
+  return false if self < ::Shoes::TextDrawable
+
+  true
+end
+
+
+ +
+

+ + .feature_for_shoes_style(style_name) ⇒ Object + + + + + +

+
+

Query what feature, if any, is required to use a specific shoes_style. +If no specific feature is needed, nil will be returned.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+
+
# File 'lacci/lib/shoes/drawable.rb', line 200
+
+def feature_for_shoes_style(style_name)
+  style_name = style_name.to_s
+  lp = linkable_properties.detect { |prop| prop[:name] == style_name }
+  return lp[:feature] if lp
+
+  # If we get to the top of the superclass tree and we didn't find it, it's not here
+  if self.class == ::Shoes::Drawable
+    raise Shoes::Errors::NoSuchStyleError, "Can't find information for style #{style_name.inspect}!"
+  end
+
+  super
+end
+
+
+ +
+

+ + .get_shoes_eventsObject + + + + + +

+
+

Return a list of Shoes events for this class.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+70
+71
+72
+73
+74
+75
+76
+
+
# File 'lacci/lib/shoes/drawable.rb', line 70
+
+def get_shoes_events
+  if @shoes_events.nil?
+    raise Shoes::Errors::UnknownEventsForClassError, "Drawable type #{self} hasn't defined its list of Shoes events!"
+  end
+
+  @shoes_events
+end
+
+
+ +
+

+ + .init_args(*args) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Require supplying these Shoes style values as positional arguments to +initialize. Initialize will get the arg list, then set the specified styles +if args are given for them. @see opt_init_args for additional non-required +init args.

+ + +
+
+
+

Parameters:

+
    + +
  • + + args + + + (Array<String,Symbol>) + + + + — +

    an array of Shoes style names

    +
    + +
  • + +
+ +

Raises:

+ + +
+ + + + +
+
+
+
+103
+104
+105
+106
+
+
# File 'lacci/lib/shoes/drawable.rb', line 103
+
+def init_args(*args)
+  raise Shoes::Errors::BadArgumentListError, "Positional init args already set for #{self}!" if @required_init_args
+  @required_init_args = args.map(&:to_s)
+end
+
+
+ +
+

+ + .is_widget_class?(name) ⇒ Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+50
+51
+52
+
+
# File 'lacci/lib/shoes/drawable.rb', line 50
+
+def is_widget_class?(name)
+  !!Shoes::Drawable.widget_classes.intersect?([name.to_s])
+end
+
+
+ +
+

+ + .opt_init_args(*args) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Allow supplying these Shoes style values as optional positional arguments to +initialize after the mandatory args. @see init_args for setting required +init args.

+ + +
+
+
+

Parameters:

+
    + +
  • + + args + + + (Array<String,Symbol>) + + + + — +

    an array of Shoes style names

    +
    + +
  • + +
+ +

Raises:

+ + +
+ + + + +
+
+
+
+114
+115
+116
+117
+
+
# File 'lacci/lib/shoes/drawable.rb', line 114
+
+def opt_init_args(*args)
+  raise Shoes::Errors::BadArgumentListError, "Positional init args already set for #{self}!" if @opt_init_args
+  @opt_init_args = args.map(&:to_s)
+end
+
+
+ +
+

+ + .optional_init_argsArray<String> + + + + + +

+
+

Return the list of style names for optional init args for this class

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array<String>) + + + + — +

    the array of style names as strings

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+129
+130
+131
+
+
# File 'lacci/lib/shoes/drawable.rb', line 129
+
+def optional_init_args
+  @opt_init_args ||= []
+end
+
+
+ +
+

+ + .register_drawable_id(id, drawable) ⇒ Object + + + + + +

+ + + + +
+
+
+
+143
+144
+145
+146
+
+
# File 'lacci/lib/shoes/drawable.rb', line 143
+
+def register_drawable_id(id, drawable)
+  @drawables_by_id ||= {}
+  @drawables_by_id[id] = drawable
+end
+
+
+ +
+

+ + .registered_shoes_events?Boolean + + + + + +

+
+

Return whether Shoes events have already been registered for this class

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    true if events have been registered, false if not

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+81
+82
+83
+
+
# File 'lacci/lib/shoes/drawable.rb', line 81
+
+def registered_shoes_events?
+  !@shoes_events.nil?
+end
+
+
+ +
+

+ + .required_init_argsArray<String> + + + + + +

+
+

Return the list of style names for required init args for this class

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array<String>) + + + + — +

    the array of style names as strings

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+122
+123
+124
+
+
# File 'lacci/lib/shoes/drawable.rb', line 122
+
+def required_init_args
+  @required_init_args ||= [] # TODO: eventually remove the ||= here
+end
+
+
+ +
+

+ + .shoes_events(*args) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Set the list of Shoes event names that are allowed for this class.

+ + +
+
+
+

Parameters:

+
    + +
  • + + args + + + (Array) + + + + — +

    an array of event names, which will be coerced to Strings

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+89
+90
+91
+92
+93
+94
+
+
# File 'lacci/lib/shoes/drawable.rb', line 89
+
+def shoes_events(*args)
+  if @shoes_events
+    raise Shoes::Errors::DoubleRegisteredShoesEventError, "Registering shoes events #{args.inspect} for class #{self} but already registered events as #{@shoes_events.inspect}!"
+  end
+  @shoes_events = args.map(&:to_s) + self.superclass.get_shoes_events
+end
+
+
+ +
+

+ + .shoes_style(name, feature: nil, &validator) ⇒ Object + + + + + +

+
+

Shoes styles in Shoes Linkables are automatically sync'd with the display side objects. +If a block is passed to shoes_style, that's the validation for the property. It should +convert a given value to a valid value for the property or throw an exception.

+ +

If feature is non-nil, it's the feature that an app must request in order to see this +property.

+ + +
+
+
+

Parameters:

+
    + +
  • + + name + + + (String, Symbol) + + + + — +

    the style name

    +
    + +
  • + +
  • + + feature + + + (Symbol, NilClass) + + + (defaults to: nil) + + + — +

    the feature that must be defined for an app to request this style, or nil

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+184
+185
+186
+187
+188
+189
+190
+191
+
+
# File 'lacci/lib/shoes/drawable.rb', line 184
+
+def shoes_style(name, feature: nil, &validator)
+  name = name.to_s
+
+  return if linkable_properties_hash[name]
+
+  linkable_properties << { name: name, validator:, feature: }
+  linkable_properties_hash[name] = true
+end
+
+
+ +
+

+ + .shoes_style_hashesObject + + + + + +

+ + + + +
+
+
+
+229
+230
+231
+232
+233
+
+
# File 'lacci/lib/shoes/drawable.rb', line 229
+
+def shoes_style_hashes
+  parent_hashes = self != Shoes::Drawable ? self.superclass.shoes_style_hashes : []
+
+  parent_hashes + linkable_properties
+end
+
+
+ +
+

+ + .shoes_style_name?(name) ⇒ Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+235
+236
+237
+238
+
+
# File 'lacci/lib/shoes/drawable.rb', line 235
+
+def shoes_style_name?(name)
+  linkable_properties_hash[name.to_s] ||
+    (self != Shoes::Drawable && superclass.shoes_style_name?(name))
+end
+
+
+ +
+

+ + .shoes_style_names(with_features: nil) ⇒ Object + + + + + +

+
+

Return a list of shoes_style names with the given features. If with_features is nil, +return them with a list of features for the current Shoes::App. For the list of +styles available with no features requested, pass nil to with_features.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+
+
# File 'lacci/lib/shoes/drawable.rb', line 216
+
+def shoes_style_names(with_features: nil)
+  # No with_features given? Use the ones requested by this Shoes::App
+  with_features ||= Shoes::App.instance.features
+  parent_prop_names = self != Shoes::Drawable ? self.superclass.shoes_style_names(with_features:) : []
+
+  if with_features == :all
+    subclass_props = linkable_properties
+  else
+    subclass_props = linkable_properties.select { |prop| !prop[:feature] || with_features.include?(prop[:feature]) }
+  end
+  parent_prop_names | subclass_props.map { |prop| prop[:name] }
+end
+
+
+ +
+

+ + .shoes_styles(*names, feature: nil, &validator) ⇒ Object + + + + + +

+
+

Add these names as Shoes styles with the given validator and feature, if any

+ + +
+
+
+ + +
+ + + + +
+
+
+
+194
+195
+196
+
+
# File 'lacci/lib/shoes/drawable.rb', line 194
+
+def shoes_styles(*names, feature: nil, &validator)
+  names.each { |n| shoes_style(n, feature:, &validator) }
+end
+
+
+ +
+

+ + .unregister_drawable_id(id) ⇒ Object + + + + + +

+ + + + +
+
+
+
+148
+149
+150
+151
+
+
# File 'lacci/lib/shoes/drawable.rb', line 148
+
+def unregister_drawable_id(id)
+  @drawables_by_id ||= {}
+  @drawables_by_id.delete(id)
+end
+
+
+ +
+

+ + .validate_as(prop_name, value) ⇒ Object + + + + + +

+
+ + +
+
+
+ +

Raises:

+ + +
+ + + + +
+
+
+
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+
+
# File 'lacci/lib/shoes/drawable.rb', line 54
+
+def validate_as(prop_name, value)
+  prop_name = prop_name.to_s
+  hashes = shoes_style_hashes
+
+  h = hashes.detect { |hash| hash[:name] == prop_name }
+  raise(Shoes::Errors::NoSuchStyleError, "Can't find property #{prop_name.inspect} in #{self} property list: #{hashes.inspect}!") unless h
+
+  return value if h[:validator].nil?
+
+  # Pass both the property name and value to the validator block
+  h[:validator].call(value,prop_name)
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + #app { ... } ⇒ Shoes::App + + + + + +

+
+

Calling stack.app or drawable.app will execute the block +with the Shoes::App as self, and with that stack or +flow as the current slot.

+ + +
+
+
+ +

Yields:

+
    + +
  • + + + + + + + +

    the block to call with the Shoes App as self

    +
    + +
  • + +
+

Returns:

+
    + +
  • + + + (Shoes::App) + + + + — +

    the Shoes app

    +
    + +
  • + +
+

Incompatibilities with Shoes:

+
    + +
  • + + + + + +

    In Shoes Classic this is the only way +to change self, while Scarpe will also change self +with the other Slot Manipulation methods: #clear,

    + +

    append, #prepend, #before and #after.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+418
+419
+420
+421
+
+
# File 'lacci/lib/shoes/drawable.rb', line 418
+
+def app(&block)
+  Shoes::App.instance.with_slot(self, &block) if block_given?
+  Shoes::App.instance
+end
+
+
+ +
+
+
+

Return a banner-sized para. This can use all the normal +Para styles and arguments. See Para#initialize for +details.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Shoes::Para) + + + + — +

    the new para drawable

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+157
+158
+159
+
+
# File 'lacci/lib/shoes/drawables/para.rb', line 157
+
+def banner(*args, **kwargs)
+  para(*args, **{ size: :banner }.merge(kwargs))
+end
+
+
+ +
+

+ + #caption(*args, **kwargs) ⇒ Shoes::Para + + + + + +

+
+

Return a caption-sized para. This can use all the normal +Para styles and arguments. See Para#initialize for +details.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Shoes::Para) + + + + — +

    the new para drawable

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+193
+194
+195
+
+
# File 'lacci/lib/shoes/drawables/para.rb', line 193
+
+def caption(*args, **kwargs)
+  para(*args, **{ size: :caption }.merge(kwargs))
+end
+
+
+ +
+

+ + #destroyObject + + + + Also known as: + remove + + + + +

+
+

Removes the element from the Shoes::Drawable tree and removes all event subscriptions

+ + +
+
+
+ + +
+ + + + +
+
+
+
+542
+543
+544
+545
+546
+547
+548
+549
+
+
# File 'lacci/lib/shoes/drawable.rb', line 542
+
+def destroy
+  @parent&.remove_child(self)
+  @parent = nil
+  @destroyed = true
+  unsub_all_shoes_events
+  send_shoes_event(event_name: "destroy", target: linkable_id)
+  Shoes::Drawable.unregister_drawable_id(linkable_id)
+end
+
+
+ +
+

+ + #download(url, method: "GET", save: nil, styles: {}, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+
+
# File 'lacci/lib/shoes/download.rb', line 21
+
+def download(url, method: "GET", save: nil, styles: {}, &block)
+  require "net/http"
+  require "openssl"
+  require "nokogiri"
+
+  @block = block
+
+  Thread.new do
+    logger = Shoes::Log.logger("Shoes::App#download")
+    begin
+      uri = URI(url)
+      response = perform_request(uri, method, styles)
+
+      if response.is_a?(Net::HTTPRedirection)
+        new_location = response["location"]
+        new_uri = URI(new_location)
+        response = perform_request(new_uri, method, styles)
+      end
+
+      wrapped_response = ResponseWrapper.new(response) # Wrap the response
+      handle_response(wrapped_response, save, styles)
+    rescue Net::HTTPError, Net::OpenTimeout, Net::ReadTimeout => e
+      handle_error(e, logger)
+    rescue StandardError => e
+      handle_error(e.message, logger) # Pass the error message as a string
+    end
+  end
+end
+
+
+ +
+

+ + #event(event_name, *args, **kwargs) ⇒ Object + + + + + +

+ + + + +
+
+
+
+468
+469
+470
+471
+472
+
+
# File 'lacci/lib/shoes/drawable.rb', line 468
+
+def event(event_name, *args, **kwargs)
+  validate_event_name(event_name)
+
+  send_shoes_event(*args, **kwargs, event_name:, target: linkable_id)
+end
+
+
+ +
+

+ + #hideObject + + + + + +

+
+

Hide the drawable.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+553
+554
+555
+
+
# File 'lacci/lib/shoes/drawable.rb', line 553
+
+def hide
+  self.hidden = true
+end
+
+
+ +
+

+ + #hover { ... } ⇒ Object + + + + + +

+
+

Set the hover handler. Not every drawable may do something useful with this.

+ + +
+
+
+ +

Yields:

+
    + +
  • + + + + + + + +

    A block to be called when the cursor moves to be over the drawable.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+570
+571
+572
+
+
# File 'lacci/lib/shoes/drawable.rb', line 570
+
+def hover(&block)
+  @hover = block
+end
+
+
+ +
+

+ + #inscription(*args, **kwargs) ⇒ Shoes::Para + + + + + +

+
+

Return an inscription-sized para. This can use all the normal +Para styles and arguments. See Para#initialize for +details.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Shoes::Para) + + + + — +

    the new para drawable

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+202
+203
+204
+
+
# File 'lacci/lib/shoes/drawables/para.rb', line 202
+
+def inscription(*args, **kwargs)
+  para(*args, **{ size: :inscription }.merge(kwargs))
+end
+
+
+ +
+

+ + #inspectObject + + + + + +

+ + + + +
+
+
+
+437
+438
+439
+440
+441
+
+
# File 'lacci/lib/shoes/drawable.rb', line 437
+
+def inspect
+  "#<#{debug_id} " +
+    " @parent=#{@parent ? @parent.debug_id : "(none)"} " +
+    "@children=#{@children ? @children.map(&:debug_id) : "(none)"} properties=#{shoes_style_values.inspect}>"
+end
+
+
+ +
+

+ + #leave { ... } ⇒ Object + + + + + +

+
+

Set the leave handler. Not every drawable may do something useful with this.

+ + +
+
+
+ +

Yields:

+
    + +
  • + + + + + + + +

    A block to be called when the cursor moves to be off of the drawable.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+577
+578
+579
+
+
# File 'lacci/lib/shoes/drawable.rb', line 577
+
+def leave(&block)
+  @leave = block
+end
+
+
+ +
+

+ + #motion { ... } ⇒ Object + + + + + +

+
+

Set the motion handler, called with x and y coordinates as params. +Not every drawable may do something useful with this.

+ + +
+
+
+ +

Yields:

+
    + +
  • + + + + + + + +

    A block to be called when the cursor moves around over the drawable.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+585
+586
+587
+
+
# File 'lacci/lib/shoes/drawable.rb', line 585
+
+def motion(&block)
+  @motion = block
+end
+
+
+ +
+

+ + #respond_to_missing?(name, include_private = false) ⇒ Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+621
+622
+623
+624
+625
+626
+627
+628
+
+
# File 'lacci/lib/shoes/drawable.rb', line 621
+
+def respond_to_missing?(name, include_private = false)
+  name_s = name.to_s
+  return true if self.class.shoes_style_name?(name_s)
+  return true if self.class.shoes_style_name?(name_s[0..-2]) && name_s[-1] == "="
+  return true if Drawable.drawable_class_by_name(name_s)
+
+  super
+end
+
+
+ +
+

+ + #set_parent(new_parent, notify: true) ⇒ Object + + + + + +

+
+

Set the Drawable's parent drawable. Notify the display service +that the parent has changed unless instructed not to. +We don't notify when first creating the Drawable. The create +event that is first sent will include the parent.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+532
+533
+534
+535
+536
+537
+538
+539
+
+
# File 'lacci/lib/shoes/drawable.rb', line 532
+
+def set_parent(new_parent, notify: true)
+  @parent&.remove_child(self)
+  new_parent&.add_child(self)
+  @parent = new_parent
+  return unless notify
+
+  send_shoes_event(new_parent&.linkable_id, event_name: "parent", target: linkable_id)
+end
+
+
+ +
+

+ + #shoes_style_valuesObject + + + + + +

+ + + + +
+
+
+
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+
+
# File 'lacci/lib/shoes/drawable.rb', line 474
+
+def shoes_style_values
+  all_property_names = self.class.shoes_style_names
+
+  properties = {}
+  all_property_names.each do |prop|
+    properties[prop] = instance_variable_get("@" + prop)
+  end
+  properties["shoes_linkable_id"] = self.linkable_id
+  properties
+end
+
+
+ +
+

+ + #showObject + + + + + +

+
+

Show the drawable.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+558
+559
+560
+
+
# File 'lacci/lib/shoes/drawable.rb', line 558
+
+def show
+  self.hidden = false
+end
+
+
+ +
+

+ + #style(*args, **kwargs) ⇒ Object + + + + + +

+ + + + +
+
+
+
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+
+
# File 'lacci/lib/shoes/drawable.rb', line 485
+
+def style(*args, **kwargs)
+  if args.empty? && kwargs.empty?
+    # Just called as .style()
+    shoes_style_values
+  elsif args.empty?
+    # This is called to set one or more Shoes styles
+    prop_names = self.class.shoes_style_names
+    unknown_styles = kwargs.keys.select { |k| !prop_names.include?(k.to_s) }
+    unless unknown_styles.empty?
+      raise Shoes::Errors::NoSuchStyleError, "Unknown styles for drawable type #{self.class.name}: #{unknown_styles.join(", ")}"
+    end
+
+    kwargs.each do |name, val|
+      instance_variable_set("@#{name}", val)
+    end
+  elsif args.length == 1 && args[0] < Shoes::Drawable
+    # Shoes supports calling .style with a Shoes class, e.g. .style(Shoes::Button, displace_left: 5)
+    kwargs.each do |name, val|
+      Shoes::Drawable.drawable_default_styles[args[0]][name.to_sym] = val
+    end
+  else
+    raise Shoes::Errors::InvalidAttributeValueError, "Unexpected arguments to style! args: #{args.inspect}, keyword args: #{kwargs.inspect}"
+  end
+end
+
+
+ +
+

+ + #subtitle(*args, **kwargs) ⇒ Shoes::Para + + + + + +

+
+

Return a subtitle-sized para. This can use all the normal +Para styles and arguments. See Para#initialize for +details.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Shoes::Para) + + + + — +

    the new para drawable

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+175
+176
+177
+
+
# File 'lacci/lib/shoes/drawables/para.rb', line 175
+
+def subtitle(*args, **kwargs)
+  para(*args, **{ size: :subtitle }.merge(kwargs))
+end
+
+
+ +
+

+ + #tagline(*args, **kwargs) ⇒ Shoes::Para + + + + + +

+
+

Return a tagline-sized para. This can use all the normal +Para styles and arguments. See Para#initialize for +details.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Shoes::Para) + + + + — +

    the new para drawable

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+184
+185
+186
+
+
# File 'lacci/lib/shoes/drawables/para.rb', line 184
+
+def tagline(*args, **kwargs)
+  para(*args, **{ size: :tagline }.merge(kwargs))
+end
+
+
+ +
+

+ + #title(*args, **kwargs) ⇒ Shoes::Para + + + + + +

+
+

Return a title-sized para. This can use all the normal +Para styles and arguments. See Para#initialize for +details.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Shoes::Para) + + + + — +

    the new para drawable

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+166
+167
+168
+
+
# File 'lacci/lib/shoes/drawables/para.rb', line 166
+
+def title(*args, **kwargs)
+  para(*args, **{ size: :title }.merge(kwargs))
+end
+
+
+ +
+

+ + #toggleObject + + + + + +

+
+

Hide the drawable if it is currently shown. Show it if it is currently hidden.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+563
+564
+565
+
+
# File 'lacci/lib/shoes/drawable.rb', line 563
+
+def toggle
+  self.hidden = !self.hidden
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Drawable/ResponseWrapper.html b/Shoes/Drawable/ResponseWrapper.html new file mode 100644 index 000000000..346040caf --- /dev/null +++ b/Shoes/Drawable/ResponseWrapper.html @@ -0,0 +1,391 @@ + + + + + + + Class: Shoes::Drawable::ResponseWrapper + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Drawable::ResponseWrapper + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/download.rb
+
+ +
+ + + + + +

Instance Attribute Summary collapse

+
    + +
  • + + + #response ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute response.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + collapse +

+ + + + +
+

Constructor Details

+ +
+

+ + #initialize(response) ⇒ ResponseWrapper + + + + + +

+
+

Returns a new instance of ResponseWrapper.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lacci/lib/shoes/download.rb', line 8
+
+def initialize(response)
+  @response = response
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #responseObject (readonly) + + + + + +

+
+

Returns the value of attribute response.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+6
+7
+8
+
+
# File 'lacci/lib/shoes/download.rb', line 6
+
+def response
+  @response
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #bodyObject + + + + + +

+ + + + +
+
+
+
+16
+17
+18
+
+
# File 'lacci/lib/shoes/download.rb', line 16
+
+def body
+  @response.body
+end
+
+
+ +
+

+ + #headersObject + + + + + +

+ + + + +
+
+
+
+12
+13
+14
+
+
# File 'lacci/lib/shoes/download.rb', line 12
+
+def headers
+  @response.each_header.to_h
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/EditBox.html b/Shoes/EditBox.html new file mode 100644 index 000000000..09655a169 --- /dev/null +++ b/Shoes/EditBox.html @@ -0,0 +1,418 @@ + + + + + + + Class: Shoes::EditBox + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::EditBox + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/edit_box.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs, &block) ⇒ EditBox + + + + + +

+
+

Returns a new instance of EditBox.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+
+
# File 'lacci/lib/shoes/drawables/edit_box.rb', line 10
+
+def initialize(*args, **kwargs, &block)
+  @callback = block
+  super
+
+  bind_self_event("change") do |new_text|
+    self.text = new_text
+    @callback&.call(self)
+  end
+
+  create_display_drawable
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #append(new_text) ⇒ Object + + + + + +

+ + + + +
+
+
+
+26
+27
+28
+
+
# File 'lacci/lib/shoes/drawables/edit_box.rb', line 26
+
+def append(new_text)
+  self.text = (self.text || "") + new_text
+end
+
+
+ +
+

+ + #change(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+22
+23
+24
+
+
# File 'lacci/lib/shoes/drawables/edit_box.rb', line 22
+
+def change(&block)
+  @callback = block
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/EditLine.html b/Shoes/EditLine.html new file mode 100644 index 000000000..97d4462bd --- /dev/null +++ b/Shoes/EditLine.html @@ -0,0 +1,366 @@ + + + + + + + Class: Shoes::EditLine + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::EditLine + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/edit_line.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs, &block) ⇒ EditLine + + + + + +

+
+

Returns a new instance of EditLine.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+
+
# File 'lacci/lib/shoes/drawables/edit_line.rb', line 10
+
+def initialize(*args, **kwargs, &block)
+  @block = block
+  super
+
+  bind_self_event("change") do |new_text|
+    self.text = new_text
+    @block&.call(new_text)
+  end
+
+  create_display_drawable
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #change(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+22
+23
+24
+
+
# File 'lacci/lib/shoes/drawables/edit_line.rb', line 22
+
+def change(&block)
+  @block = block
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Error.html b/Shoes/Error.html new file mode 100644 index 000000000..340b6de5f --- /dev/null +++ b/Shoes/Error.html @@ -0,0 +1,140 @@ + + + + + + + Exception: Shoes::Error + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ + \ No newline at end of file diff --git a/Shoes/Errors.html b/Shoes/Errors.html new file mode 100644 index 000000000..d95722907 --- /dev/null +++ b/Shoes/Errors.html @@ -0,0 +1,115 @@ + + + + + + + Module: Shoes::Errors + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ + \ No newline at end of file diff --git a/Shoes/Errors/BadArgumentListError.html b/Shoes/Errors/BadArgumentListError.html new file mode 100644 index 000000000..675849670 --- /dev/null +++ b/Shoes/Errors/BadArgumentListError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Shoes::Errors::BadArgumentListError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Shoes::Errors::BadArgumentListError + + + +

+
+ +
+
Inherits:
+
+ Shoes::Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Errors/BadFilenameError.html b/Shoes/Errors/BadFilenameError.html new file mode 100644 index 000000000..216d76214 --- /dev/null +++ b/Shoes/Errors/BadFilenameError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Shoes::Errors::BadFilenameError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Shoes::Errors::BadFilenameError + + + +

+
+ +
+
Inherits:
+
+ Shoes::Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Errors/BadLinkableIdError.html b/Shoes/Errors/BadLinkableIdError.html new file mode 100644 index 000000000..89d03dea3 --- /dev/null +++ b/Shoes/Errors/BadLinkableIdError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Shoes::Errors::BadLinkableIdError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Shoes::Errors::BadLinkableIdError + + + +

+
+ +
+
Inherits:
+
+ Shoes::Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Errors/DoubleRegisteredShoesEventError.html b/Shoes/Errors/DoubleRegisteredShoesEventError.html new file mode 100644 index 000000000..aaf2c9078 --- /dev/null +++ b/Shoes/Errors/DoubleRegisteredShoesEventError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Shoes::Errors::DoubleRegisteredShoesEventError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Shoes::Errors::DoubleRegisteredShoesEventError + + + +

+
+ +
+
Inherits:
+
+ Shoes::Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Errors/DuplicateCreateDrawableError.html b/Shoes/Errors/DuplicateCreateDrawableError.html new file mode 100644 index 000000000..584ee6b56 --- /dev/null +++ b/Shoes/Errors/DuplicateCreateDrawableError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Shoes::Errors::DuplicateCreateDrawableError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Shoes::Errors::DuplicateCreateDrawableError + + + +

+
+ +
+
Inherits:
+
+ Shoes::Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Errors/InvalidAttributeValueError.html b/Shoes/Errors/InvalidAttributeValueError.html new file mode 100644 index 000000000..0c511847e --- /dev/null +++ b/Shoes/Errors/InvalidAttributeValueError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Shoes::Errors::InvalidAttributeValueError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Shoes::Errors::InvalidAttributeValueError + + + +

+
+ +
+
Inherits:
+
+ Shoes::Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Errors/MultipleDrawablesFoundError.html b/Shoes/Errors/MultipleDrawablesFoundError.html new file mode 100644 index 000000000..3c3bf172e --- /dev/null +++ b/Shoes/Errors/MultipleDrawablesFoundError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Shoes::Errors::MultipleDrawablesFoundError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Shoes::Errors::MultipleDrawablesFoundError + + + +

+
+ +
+
Inherits:
+
+ Shoes::Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Errors/MultipleShoesSpecRunsError.html b/Shoes/Errors/MultipleShoesSpecRunsError.html new file mode 100644 index 000000000..2202d07f4 --- /dev/null +++ b/Shoes/Errors/MultipleShoesSpecRunsError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Shoes::Errors::MultipleShoesSpecRunsError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Shoes::Errors::MultipleShoesSpecRunsError + + + +

+
+ +
+
Inherits:
+
+ Shoes::Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Errors/NoDrawablesFoundError.html b/Shoes/Errors/NoDrawablesFoundError.html new file mode 100644 index 000000000..e9e562246 --- /dev/null +++ b/Shoes/Errors/NoDrawablesFoundError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Shoes::Errors::NoDrawablesFoundError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Shoes::Errors::NoDrawablesFoundError + + + +

+
+ +
+
Inherits:
+
+ Shoes::Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Errors/NoSuchLinkableIdError.html b/Shoes/Errors/NoSuchLinkableIdError.html new file mode 100644 index 000000000..baab9a3fb --- /dev/null +++ b/Shoes/Errors/NoSuchLinkableIdError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Shoes::Errors::NoSuchLinkableIdError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Shoes::Errors::NoSuchLinkableIdError + + + +

+
+ +
+
Inherits:
+
+ Shoes::Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Errors/NoSuchListItemError.html b/Shoes/Errors/NoSuchListItemError.html new file mode 100644 index 000000000..70a3a4a7c --- /dev/null +++ b/Shoes/Errors/NoSuchListItemError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Shoes::Errors::NoSuchListItemError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Shoes::Errors::NoSuchListItemError + + + +

+
+ +
+
Inherits:
+
+ Shoes::Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Errors/NoSuchStyleError.html b/Shoes/Errors/NoSuchStyleError.html new file mode 100644 index 000000000..51f45859d --- /dev/null +++ b/Shoes/Errors/NoSuchStyleError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Shoes::Errors::NoSuchStyleError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Shoes::Errors::NoSuchStyleError + + + +

+
+ +
+
Inherits:
+
+ Shoes::Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Errors/SingletonError.html b/Shoes/Errors/SingletonError.html new file mode 100644 index 000000000..994c7d906 --- /dev/null +++ b/Shoes/Errors/SingletonError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Shoes::Errors::SingletonError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Shoes::Errors::SingletonError + + + +

+
+ +
+
Inherits:
+
+ Shoes::Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Errors/TooManyInstancesError.html b/Shoes/Errors/TooManyInstancesError.html new file mode 100644 index 000000000..61071f616 --- /dev/null +++ b/Shoes/Errors/TooManyInstancesError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Shoes::Errors::TooManyInstancesError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Shoes::Errors::TooManyInstancesError + + + +

+
+ +
+
Inherits:
+
+ Shoes::Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Errors/UnknownEventsForClassError.html b/Shoes/Errors/UnknownEventsForClassError.html new file mode 100644 index 000000000..516a01548 --- /dev/null +++ b/Shoes/Errors/UnknownEventsForClassError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Shoes::Errors::UnknownEventsForClassError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Shoes::Errors::UnknownEventsForClassError + + + +

+
+ +
+
Inherits:
+
+ Shoes::Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Errors/UnregisteredShoesEventError.html b/Shoes/Errors/UnregisteredShoesEventError.html new file mode 100644 index 000000000..1b1216a86 --- /dev/null +++ b/Shoes/Errors/UnregisteredShoesEventError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Shoes::Errors::UnregisteredShoesEventError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Shoes::Errors::UnregisteredShoesEventError + + + +

+
+ +
+
Inherits:
+
+ Shoes::Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Errors/UnsupportedFeatureError.html b/Shoes/Errors/UnsupportedFeatureError.html new file mode 100644 index 000000000..dbe3ae86b --- /dev/null +++ b/Shoes/Errors/UnsupportedFeatureError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Shoes::Errors::UnsupportedFeatureError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Shoes::Errors::UnsupportedFeatureError + + + +

+
+ +
+
Inherits:
+
+ Shoes::Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/errors.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Flow.html b/Shoes/Flow.html new file mode 100644 index 000000000..884f6b216 --- /dev/null +++ b/Shoes/Flow.html @@ -0,0 +1,340 @@ + + + + + + + Class: Shoes::Flow + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Flow + + + +

+
+ +
+
Inherits:
+
+ Slot + + + show all + +
+
+ + + + + + +
+
Includes:
+
Background
+
+ + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/flow.rb
+
+ +
+ +
+

Direct Known Subclasses

+

DocumentRoot

+
+ + + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Slot

+

#children, #draw_context

+ + + +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Background

+

#background

+ + + + + + + + + +

Methods inherited from Slot

+

#add_child, #append, #clear, #contents, #current_draw_context, #fill, #method_missing, #nofill, #nostroke, #remove_child, #respond_to_missing?, #rotate, #stroke, #strokewidth

+ + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs, &block) ⇒ Flow + + + + + +

+
+

Returns a new instance of Flow.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+14
+15
+16
+17
+18
+
+
# File 'lacci/lib/shoes/drawables/flow.rb', line 11
+
+def initialize(*args, **kwargs, &block)
+  super
+
+  # Create the display-side drawable *before* instance_eval, which will add child drawables with their display drawables
+  create_display_drawable
+
+  Shoes::App.instance.with_slot(self, &block) if block_given?
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Slot + +

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Image.html b/Shoes/Image.html new file mode 100644 index 000000000..334f2d618 --- /dev/null +++ b/Shoes/Image.html @@ -0,0 +1,418 @@ + + + + + + + Class: Shoes::Image + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Image + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/image.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs) ⇒ Image + + + + + +

+
+

Returns a new instance of Image.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+9
+10
+11
+12
+13
+14
+15
+16
+
+
# File 'lacci/lib/shoes/drawables/image.rb', line 9
+
+def initialize(*args, **kwargs)
+  super
+
+  # Get the image dimensions
+  # @width, @height = size
+
+  create_display_drawable
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #replace(url) ⇒ Object + + + + + +

+ + + + +
+
+
+
+18
+19
+20
+
+
# File 'lacci/lib/shoes/drawables/image.rb', line 18
+
+def replace(url)
+  self.url = url
+end
+
+
+ +
+

+ + #sizeObject + + + + + +

+ + + + +
+
+
+
+22
+23
+24
+25
+26
+27
+
+
# File 'lacci/lib/shoes/drawables/image.rb', line 22
+
+def size
+  require "fastimage"
+  width, height = FastImage.size(@url)
+
+  [width, height]
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Line.html b/Shoes/Line.html new file mode 100644 index 000000000..916ca32af --- /dev/null +++ b/Shoes/Line.html @@ -0,0 +1,300 @@ + + + + + + + Class: Shoes::Line + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Line + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/line.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs) ⇒ Line + + + + + +

+
+

Returns a new instance of Line.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+9
+10
+11
+12
+13
+14
+15
+
+
# File 'lacci/lib/shoes/drawables/line.rb', line 9
+
+def initialize(*args, **kwargs)
+  @draw_context = Shoes::App.instance.current_draw_context
+
+  super
+
+  create_display_drawable
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Link.html b/Shoes/Link.html new file mode 100644 index 000000000..98aeb85b9 --- /dev/null +++ b/Shoes/Link.html @@ -0,0 +1,331 @@ + + + + + + + Class: Shoes::Link + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Link + + + +

+
+ +
+
Inherits:
+
+ TextDrawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/link.rb
+
+ +
+ +
+

Direct Known Subclasses

+

LinkHover

+
+ + + +

Constant Summary

+ +

Constants inherited + from TextDrawable

+

TextDrawable::STRIKETHROUGH_VALUES, TextDrawable::UNDERLINE_VALUES

+ + + +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from TextDrawable

+

#replace, #text, #text=, #text_children_to_items, #to_s

+ + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs, &block) ⇒ Link + + + + + +

+
+

Empty by the time it reaches Drawable#initialize

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+
+
# File 'lacci/lib/shoes/drawables/link.rb', line 11
+
+def initialize(*args, **kwargs, &block)
+  @block = block
+  # We can't send a block to the display drawable, but we can send a boolean
+  @has_block = !block.nil?
+
+  super
+
+  bind_self_event("click") do
+    @block&.call
+  end
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/LinkHover.html b/Shoes/LinkHover.html new file mode 100644 index 000000000..a3dad1fed --- /dev/null +++ b/Shoes/LinkHover.html @@ -0,0 +1,330 @@ + + + + + + + Class: Shoes::LinkHover + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::LinkHover + + + +

+
+ +
+
Inherits:
+
+ Link + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/link.rb
+
+ +
+ +

Overview

+
+

In Shoes, the LinkHover pseudo-class is used to set default styles for links when +hovered over. The functionality isn't present in Lacci yet.

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants inherited + from TextDrawable

+

TextDrawable::STRIKETHROUGH_VALUES, TextDrawable::UNDERLINE_VALUES

+ + + +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + + + + + + + +

Methods inherited from TextDrawable

+

#replace, #text, #text=, #text_children_to_items, #to_s

+ + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initializeLinkHover + + + + + +

+
+

Returns a new instance of LinkHover.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+27
+28
+29
+
+
# File 'lacci/lib/shoes/drawables/link.rb', line 27
+
+def initialize
+  raise "This class should never be instantiated directly! Use link, not link_hover!"
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Linkable.html b/Shoes/Linkable.html new file mode 100644 index 000000000..13148d487 --- /dev/null +++ b/Shoes/Linkable.html @@ -0,0 +1,583 @@ + + + + + + + Class: Shoes::Linkable + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Linkable + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/display_service.rb
+
+ +
+ +

Overview

+
+

This is for objects that can be referred to via events, using their +IDs. There are also convenience functions for binding and sending +events.

+ +

Linkable objects may be event targets. Technically anything, linkable +or not, can be an event subscriber, but linkables get easy convenience +functions for subscription.

+ + +
+
+
+ + +
+ + + + +

Instance Attribute Summary collapse

+
    + +
  • + + + #linkable_id ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute linkable_id.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + collapse +

+ + + + +
+

Constructor Details

+ +
+

+ + #initialize(linkable_id: object_id) ⇒ Linkable + + + + + +

+
+

Returns a new instance of Linkable.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+214
+215
+216
+217
+
+
# File 'lacci/lib/shoes/display_service.rb', line 214
+
+def initialize(linkable_id: object_id)
+  @linkable_id = linkable_id
+  @subscriptions = {}
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #linkable_idObject (readonly) + + + + + +

+
+

Returns the value of attribute linkable_id.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+212
+213
+214
+
+
# File 'lacci/lib/shoes/display_service.rb', line 212
+
+def linkable_id
+  @linkable_id
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #bind_shoes_event(event_name:, target: nil, &handler) ⇒ Object + + + + + +

+ + + + +
+
+
+
+227
+228
+229
+230
+231
+
+
# File 'lacci/lib/shoes/display_service.rb', line 227
+
+def bind_shoes_event(event_name:, target: nil, &handler)
+  sub = DisplayService.subscribe_to_event(event_name, target, &handler)
+  @subscriptions[sub] = true
+  sub
+end
+
+
+ +
+

+ + #send_self_event(*args, event_name:, **kwargs) ⇒ Object + + + + + +

+ + + + +
+
+
+
+219
+220
+221
+
+
# File 'lacci/lib/shoes/display_service.rb', line 219
+
+def send_self_event(*args, event_name:, **kwargs)
+  DisplayService.dispatch_event(event_name, self.linkable_id, *args, **kwargs)
+end
+
+
+ +
+

+ + #send_shoes_event(*args, event_name:, target: nil, **kwargs) ⇒ Object + + + + + +

+ + + + +
+
+
+
+223
+224
+225
+
+
# File 'lacci/lib/shoes/display_service.rb', line 223
+
+def send_shoes_event(*args, event_name:, target: nil, **kwargs)
+  DisplayService.dispatch_event(event_name, target, *args, **kwargs)
+end
+
+
+ +
+

+ + #unsub_all_shoes_eventsObject + + + + + +

+ + + + +
+
+
+
+241
+242
+243
+244
+
+
# File 'lacci/lib/shoes/display_service.rb', line 241
+
+def unsub_all_shoes_events
+  @subscriptions.keys.each { |k| DisplayService.unsub_from_events(k) }
+  @subscriptions.clear
+end
+
+
+ +
+

+ + #unsub_shoes_event(unsub_id) ⇒ Object + + + + + +

+ + + + +
+
+
+
+233
+234
+235
+236
+237
+238
+239
+
+
# File 'lacci/lib/shoes/display_service.rb', line 233
+
+def unsub_shoes_event(unsub_id)
+  unless @subscriptions[unsub_id]
+    $stderr.puts "Unsubscribing from event that isn't in subscriptions! #{unsub_id.inspect}"
+  end
+  DisplayService.unsub_from_events(unsub_id)
+  @subscriptions.delete unsub_id
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/ListBox.html b/Shoes/ListBox.html new file mode 100644 index 000000000..d1d7d7a17 --- /dev/null +++ b/Shoes/ListBox.html @@ -0,0 +1,591 @@ + + + + + + + Class: Shoes::ListBox + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::ListBox + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/list_box.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(**kwargs, &block) ⇒ ListBox + + + + + +

+
+

Returns a new instance of ListBox.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+
+
# File 'lacci/lib/shoes/drawables/list_box.rb', line 15
+
+def initialize(**kwargs, &block)
+  # These aren't being set as styles -- remove them from kwargs before calling super
+  # TODO: set [] as default value for items?
+  @items = kwargs.delete(:items) || []
+  @chosen = kwargs.delete(:choose) || @items&.first
+
+  super(**kwargs, &block)
+
+  bind_self_event("change") do |new_item|
+    self.chosen = new_item
+    @callback&.call(self)
+  end
+
+  create_display_drawable
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #change { ... } ⇒ Shoes::ListBox + + + + + +

+
+

Register a block to be called when the selection changes.

+ + +
+
+
+ +

Yields:

+
    + +
  • + + + + + + + +

    the block to be called when selection changes

    +
    + +
  • + +
+

Returns:

+ + +
+ + + + +
+
+
+
+54
+55
+56
+57
+
+
# File 'lacci/lib/shoes/drawables/list_box.rb', line 54
+
+def change(&block)
+  @callback = block
+  self # Allow chaining calls
+end
+
+
+ +
+

+ + #choose(item) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Select an item. item should be a text entry from items.

+ + +
+
+
+

Parameters:

+
    + +
  • + + item + + + (String) + + + + — +

    the item to choose

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+35
+36
+37
+38
+39
+40
+41
+
+
# File 'lacci/lib/shoes/drawables/list_box.rb', line 35
+
+def choose(item)
+  unless self.items.include?(item)
+    raise Shoes::Errors::NoSuchListItemError, "List items (#{self.items.inspect}) do not contain item #{item.inspect}!"
+  end
+
+  @chosen = item
+end
+
+
+ +
+

+ + #textString|NilClass + + + + + +

+
+

The currently chosen text item or nil.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String|NilClass) + + + + — +

    the current text item or nil.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+46
+47
+48
+
+
# File 'lacci/lib/shoes/drawables/list_box.rb', line 46
+
+def text
+  @chosen
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Log.html b/Shoes/Log.html new file mode 100644 index 000000000..d8b4e1b6d --- /dev/null +++ b/Shoes/Log.html @@ -0,0 +1,497 @@ + + + + + + + Module: Shoes::Log + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Shoes::Log + + + +

+ + +

Overview

+
+

Include this module to get a @log instance variable to log as your +configured component.

+ + +
+
+
+ + +
+ +

+ Constant Summary + collapse +

+ +
+ +
DEFAULT_COMPONENT = +
+
+

These constants will wind up included in a lot of places. Should they move?

+ + +
+
+
+ + +
+
+
"default"
+ +
DEFAULT_LOG_CONFIG = + +
+
{
+  "default" => "info",
+}
+ +
DEFAULT_DEBUG_LOG_CONFIG = + +
+
{
+  "default" => "debug",
+}
+ +
+ + + + + +

Class Attribute Summary collapse

+
    + +
  • + + + .current_log_config ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute current_log_config.

    +
    + +
  • + + +
  • + + + .instance ⇒ Object + + + + + + + + + + + + + + + + +

    Returns the value of attribute instance.

    +
    + +
  • + + +
+ + + + + +

+ Class Method Summary + collapse +

+ + + +

+ Instance Method Summary + collapse +

+ + + + + +
+

Class Attribute Details

+ + + +
+

+ + .current_log_configObject (readonly) + + + + + +

+
+

Returns the value of attribute current_log_config.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+28
+29
+30
+
+
# File 'lacci/lib/shoes/log.rb', line 28
+
+def current_log_config
+  @current_log_config
+end
+
+
+ + + +
+

+ + .instanceObject + + + + + +

+
+

Returns the value of attribute instance.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+27
+28
+29
+
+
# File 'lacci/lib/shoes/log.rb', line 27
+
+def instance
+  @instance
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + .configure_logger(log_config) ⇒ Object + + + + + +

+ + + + +
+
+
+
+40
+41
+42
+
+
# File 'lacci/lib/shoes/log.rb', line 40
+
+def configure_logger(log_config)
+  @instance.configure_logger(log_config)
+end
+
+
+ +
+

+ + .logger(component = self) ⇒ Object + + + + + +

+ + + + +
+
+
+
+36
+37
+38
+
+
# File 'lacci/lib/shoes/log.rb', line 36
+
+def logger(component = self)
+  @instance.logger_for_component(component)
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + #log_init(component = self) ⇒ Object + + + + + +

+ + + + +
+
+
+
+45
+46
+47
+
+
# File 'lacci/lib/shoes/log.rb', line 45
+
+def log_init(component = self)
+  @log = Shoes::Log.instance.logger_for_component(component)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/LoggedWrapper.html b/Shoes/LoggedWrapper.html new file mode 100644 index 000000000..cf783ca30 --- /dev/null +++ b/Shoes/LoggedWrapper.html @@ -0,0 +1,377 @@ + + + + + + + Class: Shoes::LoggedWrapper + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::LoggedWrapper + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + +
+
Includes:
+
Log
+
+ + + + + + +
+
Defined in:
+
lacci/lib/shoes/log.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

+ + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+
+

Constructor Details

+ +
+

+ + #initialize(instance, component = instance) ⇒ LoggedWrapper + + + + + +

+
+

Returns a new instance of LoggedWrapper.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+52
+53
+54
+55
+56
+
+
# File 'lacci/lib/shoes/log.rb', line 52
+
+def initialize(instance, component = instance)
+  log_init(component)
+
+  @instance = instance
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + +

+ +
+

+ + #method_missing(method) ⇒ Object + + + + + +

+ + + + +
+
+
+
+58
+59
+60
+61
+62
+63
+64
+65
+
+
# File 'lacci/lib/shoes/log.rb', line 58
+
+def method_missing(method, ...)
+  self.singleton_class.define_method(method) do |*args, **kwargs, &block|
+    ret = @instance.send(method, *args, **kwargs, &block)
+    @log.info("Method: #{method} Args: #{args.inspect} KWargs: #{kwargs.inspect} Block: #{block ? "y" : "n"} Return: #{ret.inspect}")
+    ret
+  end
+  send(method, ...)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #respond_to_missing?(method_name, include_private = false) ⇒ Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+67
+68
+69
+
+
# File 'lacci/lib/shoes/log.rb', line 67
+
+def respond_to_missing?(method_name, include_private = false)
+  @instance.respond_to_missing?(method_name, include_private)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Oval.html b/Shoes/Oval.html new file mode 100644 index 000000000..3bb85a319 --- /dev/null +++ b/Shoes/Oval.html @@ -0,0 +1,348 @@ + + + + + + + Class: Shoes::Oval + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Oval + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/oval.rb
+
+ +
+ +

Overview

+
+ + +
+ + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **options) ⇒ Oval + + + + + +

+
+

Returns a new instance of Oval.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+
+
# File 'lacci/lib/shoes/drawables/oval.rb', line 20
+
+def initialize(*args, **options)
+  @draw_context = Shoes::App.instance.current_draw_context
+
+  super # Parse any positional or keyword args
+
+  unless @left && @top && (@width || @height || @radius)
+    raise Shoes::Errors::InvalidAttributeValueError, "Oval requires left, top and one of (width, height, radius) to be specified!"
+  end
+
+  # Calzini expects "radius" to mean the x-axis-aligned radius, not y-axis-aligned.
+  # For an axis-aligned oval the two may be different.
+
+  # If we have no width, but a radius, default the width to be the radius * 2
+  @width ||= @radius * 2 if @radius
+
+  # We now know we have width or height, but maybe not both.
+
+  # Default to a circle - set height from width or vice-versa
+  @width ||= @height
+  @height ||= @width
+
+  # If we don't have radius yet, set it from width
+  @radius ||= @width / 2
+
+  create_display_drawable
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Para.html b/Shoes/Para.html new file mode 100644 index 000000000..e338c24e4 --- /dev/null +++ b/Shoes/Para.html @@ -0,0 +1,786 @@ + + + + + + + Class: Shoes::Para + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Para + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + +
+
Includes:
+
FontHelper
+
+ + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/para.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from FontHelper

+

#contains_number?, #parse_font

+ + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs) ⇒ Para + + + + + +

+
+

Initializes a new instance of the Para drawable. There are different +methods to instantiate slightly different styles of Para, such as +tagline, caption and subtitle. These will always be different +sizes, but may be generally styled differently for some display services.

+ + +
+
+
+ +
+

Examples:

+ + +
Shoes.app do
+  p = para "Hello, This is at the top!", stroke: red, size: :title, font: "Arial"
+
+  banner("Welcome to Shoes!")
+  title("Shoes Examples")
+  subtitle("Explore the Features")
+  tagline("Step into a World of Shoes")
+  caption("A GUI Framework for Ruby")
+  inscription("Designed for Easy Development")
+
+  p.replace "On top we'll switch to ", strong("bold"), "!"
+end
+ +
+

Parameters:

+
    + +
  • + + args + + + + + + + — +

    The text content of the paragraph.

    +
    + +
  • + +
  • + + kwargs + + + (Hash) + + + + — +

    the various Shoes styles for this paragraph.

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+
+
# File 'lacci/lib/shoes/drawables/para.rb', line 43
+
+def initialize(*args, **kwargs)
+
+  if kwargs[:font]
+    arr= parse_font(kwargs[:font])
+    
+    if arr[0] != nil
+
+      kwargs[:emphasis] = arr[0]
+
+    end
+
+    if arr[1] != nil
+
+      kwargs[:font_variant] = arr[1]
+
+    end
+
+    if arr[2] != nil
+
+      kwargs[:font_weight] = arr[2]
+
+    end
+
+    if arr[3] != nil
+
+      kwargs[:size] = arr[3]
+
+    end
+
+    if arr[4] != ""
+
+      kwargs[:family] = arr[4]
+
+    end
+
+  end
+ 
+  # Don't pass text_children args to Drawable#initialize
+  super(*[], **kwargs)
+    
+  # Text_children alternates strings and TextDrawables, so we can't just pass
+  # it as a Shoes style. It won't serialize.
+  update_text_children(args)
+
+  create_display_drawable
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #replace(*children) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Sets the paragraph text to a new value, which can +include TextDrawables like em(), strong(), etc.

+ + +
+
+
+

Parameters:

+
    + +
  • + + children + + + (Array) + + + + — +

    the arguments can be Strings and/or TextDrawables

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+105
+106
+107
+
+
# File 'lacci/lib/shoes/drawables/para.rb', line 105
+
+def replace(*children)
+  update_text_children(children)
+end
+
+
+ +
+

+ + #textString + + + + + +

+
+

Return the text, but not the styling, of the para's +contents. For example, if the contents had strong +and emphasized text, the bold and emphasized would +be removed but the text would be returned.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +

    the text from this para

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+124
+125
+126
+
+
# File 'lacci/lib/shoes/drawables/para.rb', line 124
+
+def text
+  @text_children.map(&:to_s).join
+end
+
+
+ +
+

+ + #text=(*children) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Set the paragraph text to a single String. +To use bold, italics, etc. use #replace instead.

+ + +
+
+
+

Parameters:

+
    + +
  • + + child + + + (String) + + + + — +

    the new text to use for this Para

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+114
+115
+116
+
+
# File 'lacci/lib/shoes/drawables/para.rb', line 114
+
+def text=(*children)
+  update_text_children(children)
+end
+
+
+ +
+

+ + #to_sString + + + + + +

+
+

Return the text but not styling from the para. This +is the same as #text.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +

    the text from this para

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+132
+133
+134
+
+
# File 'lacci/lib/shoes/drawables/para.rb', line 132
+
+def to_s
+  self.text
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Progress.html b/Shoes/Progress.html new file mode 100644 index 000000000..29a2d470f --- /dev/null +++ b/Shoes/Progress.html @@ -0,0 +1,296 @@ + + + + + + + Class: Shoes::Progress + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Progress + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/progress.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(**kwargs) ⇒ Progress + + + + + +

+
+

Returns a new instance of Progress.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+9
+10
+11
+12
+13
+
+
# File 'lacci/lib/shoes/drawables/progress.rb', line 9
+
+def initialize(**kwargs)
+  super
+
+  create_display_drawable
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Radio.html b/Shoes/Radio.html new file mode 100644 index 000000000..5f869ae92 --- /dev/null +++ b/Shoes/Radio.html @@ -0,0 +1,500 @@ + + + + + + + Class: Shoes::Radio + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Radio + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/radio.rb
+
+ +
+ +

Overview

+
+

A Radio button drawable. Only a single radio button may be checked in each +group. If no group is specified, or the group is nil, default to all +radio buttons in the same slot being treated as being in the same group.

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs, &block) ⇒ Radio + + + + + +

+
+

Returns a new instance of Radio.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+13
+14
+15
+16
+17
+18
+19
+20
+
+
# File 'lacci/lib/shoes/drawables/radio.rb', line 13
+
+def initialize(*args, **kwargs, &block)
+  @block = block
+
+  super
+
+  bind_self_event("click") { click }
+  create_display_drawable
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #checked(value) ⇒ Object + + + + + +

+ + + + +
+
+
+
+31
+32
+33
+
+
# File 'lacci/lib/shoes/drawables/radio.rb', line 31
+
+def checked(value)
+  self.checked = value
+end
+
+
+ +
+

+ + #checked?Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+27
+28
+29
+
+
# File 'lacci/lib/shoes/drawables/radio.rb', line 27
+
+def checked?
+  @checked ? true : false
+end
+
+
+ +
+

+ + #click(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+22
+23
+24
+25
+
+
# File 'lacci/lib/shoes/drawables/radio.rb', line 22
+
+def click(&block)
+  @block = block
+  self.checked = !checked?
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Rect.html b/Shoes/Rect.html new file mode 100644 index 000000000..ca1e9c042 --- /dev/null +++ b/Shoes/Rect.html @@ -0,0 +1,300 @@ + + + + + + + Class: Shoes::Rect + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Rect + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/rect.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs) ⇒ Rect + + + + + +

+
+

Returns a new instance of Rect.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+14
+15
+16
+
+
# File 'lacci/lib/shoes/drawables/rect.rb', line 10
+
+def initialize(*args, **kwargs)
+  @draw_context = Shoes::App.instance.current_draw_context
+
+  super
+
+  create_display_drawable
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Shape.html b/Shoes/Shape.html new file mode 100644 index 000000000..4badb6189 --- /dev/null +++ b/Shoes/Shape.html @@ -0,0 +1,427 @@ + + + + + + + Class: Shoes::Shape + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Shape + + + +

+
+ +
+
Inherits:
+
+ Slot + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/shape.rb
+
+ +
+ +

Overview

+
+

A Shape acts as a sort of union type for drawn shapes. In Shoes you can use it to merge multiple +ovals, arcs, stars, etc. into a single drawn shape.

+ +

In Shoes3, a Shape isn't really a Slot. It's a kind of DSL with drawing commands that happen +to have the same name as the Art drawables like star, arc, etc. Here we're treating it as +a slot containing those drawables, which is wrong but not too wrong.

+ + +
+
+
+ +

Incompatibilities with Shoes:

+
    + +
  • + + + + + +

    A Shoes3 Shape is not a slot; Scarpe does not do union shapes

    +
    + +
  • + +
+ +
+ + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Slot

+

#children, #draw_context

+ + + +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Slot

+

#add_child, #append, #clear, #contents, #current_draw_context, #fill, #method_missing, #nofill, #nostroke, #remove_child, #respond_to_missing?, #rotate, #stroke, #strokewidth

+ + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(**kwargs, &block) ⇒ Shape + + + + + +

+
+

Returns a new instance of Shape.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+17
+18
+19
+20
+21
+22
+23
+24
+25
+
+
# File 'lacci/lib/shoes/drawables/shape.rb', line 17
+
+def initialize(**kwargs, &block)
+  @shape_commands = []
+  @draw_context = Shoes::App.instance.current_draw_context
+
+  super
+  create_display_drawable
+
+  Shoes::App.instance.with_slot(self, &block) if block_given?
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Slot + +

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #add_shape_command(cmd) ⇒ Object + + + + + +

+
+

The cmd should be an array of the form:

+ +
[cmd_name, *args]
+
+ +

such as ["move_to", 50, 50]. Note that these must +be JSON-serializable.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+33
+34
+35
+
+
# File 'lacci/lib/shoes/drawables/shape.rb', line 33
+
+def add_shape_command(cmd)
+  @shape_commands << cmd
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Slot.html b/Shoes/Slot.html new file mode 100644 index 000000000..61991da03 --- /dev/null +++ b/Shoes/Slot.html @@ -0,0 +1,1634 @@ + + + + + + + Class: Shoes::Slot + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Slot + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes.rb,
+ lacci/lib/shoes/drawables/slot.rb
+
+
+ +
+ +
+

Direct Known Subclasses

+

Flow, Shape, Stack, Widget

+
+ + + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #children ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
    + +
  • + + +
  • + + + #draw_context ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    This only shows this specific slot's settings, not its parent's.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initializeSlot + + + + + +

+
+

Returns a new instance of Slot.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+
+
# File 'lacci/lib/shoes/drawables/slot.rb', line 14
+
+def initialize(...)
+  # The draw context tracks current settings like fill and stroke,
+  # plus potentially other current state that changes from drawable
+  # to drawable and slot to slot.
+  @draw_context = {
+    "fill" => nil,
+    "stroke" => nil,
+    "strokewidth" => nil,
+    "rotate" => nil,
+    # "transform" => nil, # "corner",
+    # "translate" => nil, # [0, 0],
+  }
+
+  super
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + +

+ +
+

+ + #method_missing(name, *args, **kwargs, &block) ⇒ Object + + + + + +

+
+

We use method_missing for drawable-creating methods like "button". +The parent's method_missing will auto-create Shoes style getters and setters. +This is similar to the method_missing in Shoes::App, but differs in where +the new drawable will appear.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+
+
# File 'lacci/lib/shoes/drawables/slot.rb', line 55
+
+def method_missing(name, *args, **kwargs, &block)
+  klass = ::Shoes::Drawable.drawable_class_by_name(name)
+  return super unless klass
+
+  ::Shoes::Slot.define_method(name) do |*args, **kwargs, &block|
+    instance = nil
+
+    # Look up the Shoes drawable and create it. But first set
+    # this slot as the current one so that draw context
+    # is handled properly.
+    Shoes::App.instance.with_slot(self) do
+      instance = klass.new(*args, **kwargs, &block)
+    end
+
+    instance
+  end
+
+  send(name, *args, **kwargs, &block)
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #childrenObject (readonly) + + + + + +

+
+ + +
+
+
+ +

Incompatibilities with Shoes:

+
    + +
  • + + + + + +

    Shoes uses #content, not #children, for this. Scarpe does both.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lacci/lib/shoes/drawables/slot.rb', line 5
+
+def children
+  @children
+end
+
+
+ + + +
+

+ + #draw_contextObject (readonly) + + + + + +

+
+

This only shows this specific slot's settings, not its parent's. +Use current_draw_context to allow inheritance.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+
+
# File 'lacci/lib/shoes/drawables/slot.rb', line 11
+
+def draw_context
+  @draw_context
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #add_child(child) ⇒ Object + + + + + +

+
+

Do not call directly, use set_parent

+ + +
+
+
+ + +
+ + + + +
+
+
+
+40
+41
+42
+43
+
+
# File 'lacci/lib/shoes/drawables/slot.rb', line 40
+
+def add_child(child)
+  @children ||= []
+  @children << child
+end
+
+
+ +
+

+ + #append { ... } ⇒ void + + + + + +

+
+

This method returns an undefined value.

Call the block to append new children to a Slot.

+ +

Should only be called on a Slot, since only Slots can have children.

+ + +
+
+
+ +

Yields:

+
    + +
  • + + + + + + + +

    the block to call to replace children; will be called on the Shoes::App, appending to the called Slot as the current slot

    +
    + +
  • + +
+

Raises:

+ +

Incompatibilities with Shoes:

+
    + +
  • + + + + + +

    Shoes Classic calls the append block with current self, while Scarpe uses the Shoes::App as self

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+172
+173
+174
+175
+176
+177
+
+
# File 'lacci/lib/shoes/drawables/slot.rb', line 172
+
+def append(&block)
+  raise(Shoes::Errors::InvalidAttributeValueError, "append requires a block!") unless block_given?
+  raise(Shoes::Errors::InvalidAttributeValueError, "Don't append to something that isn't a slot!") unless self.is_a?(Shoes::Slot)
+
+  Shoes::App.instance.with_slot(self, &block)
+end
+
+
+ +
+

+ + #clear { ... } ⇒ void + + + + + +

+
+

This method returns an undefined value.

Remove all children from this drawable. If a block +is given, call the block to replace the children with +new contents from that block.

+ +

Should only be called on Slots, which can +have children.

+ + +
+
+
+ +

Yields:

+
    + +
  • + + + + + + + +

    The block to call to replace the contents of the drawable (optional)

    +
    + +
  • + +
+

Incompatibilities with Shoes:

+
    + +
  • + + + + + +

    Shoes Classic calls the clear block with current self, while Scarpe uses the Shoes::App as self

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+157
+158
+159
+160
+161
+162
+
+
# File 'lacci/lib/shoes/drawables/slot.rb', line 157
+
+def clear(&block)
+  @children ||= []
+  @children.dup.each(&:destroy)
+  append(&block) if block_given?
+  nil
+end
+
+
+ +
+

+ + #contentsObject + + + + + +

+
+

Get a list of child drawables

+ + +
+
+
+ + +
+ + + + +
+
+
+
+46
+47
+48
+49
+
+
# File 'lacci/lib/shoes/drawables/slot.rb', line 46
+
+def contents
+  @children ||= []
+  @children.dup
+end
+
+
+ +
+

+ + #current_draw_contextHash + + + + + +

+
+

Get the current draw context styles, based on this slot and its parent slots.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Hash) + + + + — +

    a hash of Shoes styles for the context

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+137
+138
+139
+140
+141
+142
+
+
# File 'lacci/lib/shoes/drawables/slot.rb', line 137
+
+def current_draw_context
+  s = @parent ? @parent.current_draw_context : {}
+  @draw_context.each { |k, v| s[k] = v unless v.nil? }
+
+  s
+end
+
+
+ +
+

+ + #fill(color) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Set the default fill color in this slot and child slots. +Pass nil for "no setting", so that it can inherit defaults.

+ + +
+
+
+

Parameters:

+
    + +
  • + + color + + + (Nil, Color) + + + + — +

    a Shoes color for the fill color or nil to use parent setting

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+88
+89
+90
+
+
# File 'lacci/lib/shoes/drawables/slot.rb', line 88
+
+def fill(color)
+  @draw_context["fill"] = color
+end
+
+
+ +
+

+ + #nofillvoid + + + + + +

+
+

This method returns an undefined value.

Set the default fill in this slot and child slots to transparent.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+95
+96
+97
+
+
# File 'lacci/lib/shoes/drawables/slot.rb', line 95
+
+def nofill
+  @draw_context["fill"] = rgb(0, 0, 0, 0)
+end
+
+
+ +
+

+ + #nostrokevoid + + + + + +

+
+

This method returns an undefined value.

Set the default stroke in this slot and child slots +to transparent.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+121
+122
+123
+
+
# File 'lacci/lib/shoes/drawables/slot.rb', line 121
+
+def nostroke
+  @draw_context["stroke"] = rgb(0, 0, 0, 0)
+end
+
+
+ +
+

+ + #remove_child(child) ⇒ Object + + + + + +

+
+

Do not call directly, use set_parent

+ + +
+
+
+ + +
+ + + + +
+
+
+
+31
+32
+33
+34
+35
+36
+37
+
+
# File 'lacci/lib/shoes/drawables/slot.rb', line 31
+
+def remove_child(child)
+  @children ||= []
+  unless @children.include?(child)
+    @log.warn("remove_child: no such child(#{child.inspect}) for parent(#{parent.inspect})!")
+  end
+  @children.delete(child)
+end
+
+
+ +
+

+ + #respond_to_missing?(name, include_private = false) ⇒ Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+75
+76
+77
+78
+79
+
+
# File 'lacci/lib/shoes/drawables/slot.rb', line 75
+
+def respond_to_missing?(name, include_private = false)
+  return true if ::Shoes::Drawable.drawable_class_by_name(name.to_s)
+
+  false
+end
+
+
+ +
+

+ + #rotate(angle) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Set the current rotation in this slot and any child slots. +Pass nil to reset the angle to default.

+ + +
+
+
+

Parameters:

+
    + +
  • + + angle + + + (Numeric, Nil) + + + + — +

    the new default rotation for shapes or nil to use parent setting

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+130
+131
+132
+
+
# File 'lacci/lib/shoes/drawables/slot.rb', line 130
+
+def rotate(angle)
+  @draw_context["rotate"] = angle
+end
+
+
+ +
+

+ + #stroke(color) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Set the default stroke color in this slot and child slots. +Pass nil for "no setting" so it can inherit defaults.

+ + +
+
+
+

Parameters:

+
    + +
  • + + color + + + (Nil, Color) + + + + — +

    a Shoes color for the stroke color or nil to use parent setting

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+104
+105
+106
+
+
# File 'lacci/lib/shoes/drawables/slot.rb', line 104
+
+def stroke(color)
+  @draw_context["stroke"] = color
+end
+
+
+ +
+

+ + #strokewidth(width) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Set the default strokewidth in this slot and child slots. +Pass nil for "no setting".

+ + +
+
+
+

Parameters:

+
    + +
  • + + width + + + (Numeric, Nil) + + + + — +

    the new width, or nil to use parent setting

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+113
+114
+115
+
+
# File 'lacci/lib/shoes/drawables/slot.rb', line 113
+
+def strokewidth(width)
+  @draw_context["strokewidth"] = width
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Spec.html b/Shoes/Spec.html new file mode 100644 index 000000000..52d2678bf --- /dev/null +++ b/Shoes/Spec.html @@ -0,0 +1,247 @@ + + + + + + + Module: Shoes::Spec + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Shoes::Spec + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes-spec.rb
+
+ +
+ +

Overview

+
+

A Scarpe-compatible display service can set Shoes::Spec.instance to +a ShoesSpec testing class, and use it to run Shoes-Spec code. +A Shoes application should never do this. It's intended to be used +by display services.

+ + +
+
+
+ + +
+ + + + + + + +

+ Class Method Summary + collapse +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + .instanceObject + + + + + +

+ + + + +
+
+
+
+9
+10
+11
+
+
# File 'lacci/lib/shoes-spec.rb', line 9
+
+def self.instance
+  @instance
+end
+
+
+ +
+

+ + .instance=(spec_inst) ⇒ Object + + + + + +

+ + + + +
+
+
+
+13
+14
+15
+16
+17
+18
+19
+
+
# File 'lacci/lib/shoes-spec.rb', line 13
+
+def self.instance=(spec_inst)
+  if @instance && @instance != spec_inst
+    raise "Lacci can only use a single ShoesSpec implementation at one time!"
+  end
+
+  @instance = spec_inst
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/SpecInstance.html b/Shoes/SpecInstance.html new file mode 100644 index 000000000..099ad4e33 --- /dev/null +++ b/Shoes/SpecInstance.html @@ -0,0 +1,286 @@ + + + + + + + Class: Shoes::SpecInstance + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::SpecInstance + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes-spec.rb
+
+ +
+ +

Overview

+
+

ShoesSpec testing objects can optionally inherit from this object, +which shows the ShoesSpec testing API.

+ + +
+
+
+ + +

See Also:

+
    + +
  • {Shoes{Shoes::Spec{Shoes::Spec.instance=}
  • + +
+ +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #run_shoes_spec_test_code(code, class_name: nil, test_name: nil) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Once a Shoes app has been created, this method can be called to +execute Shoes-Spec testing code for that application. Shoes-Spec +uses Minitest for most of its APIs, and Minitest generally reports +results with a class name and test name. If those aren't passed +explicitly, the SpecInstance can choose reasonable defaults.

+ +

The test code should be set up to run automatically from the +display service's existing hooks. For instance, the code might +run in response to the first heartbeat, if the display service +uses heartbeats.

+ +

The test code will export assertion data in its native format. +Multiple display services choose to use the Scarpe-Component +for Minitest data export, which is straightforward to import +into the Shoes-Spec test harness.

+ + +
+
+
+

Parameters:

+
    + +
  • + + code + + + (String) + + + + — +

    the ShoesSpec code to execute

    +
    + +
  • + +
  • + + class_name + + + (String|NilClass) + + + (defaults to: nil) + + + — +

    the Minitest class name for reporting or nil

    +
    + +
  • + +
  • + + test_name + + + (String|NilClass) + + + (defaults to: nil) + + + — +

    the Minitest test name for reporting or nil

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+47
+48
+49
+
+
# File 'lacci/lib/shoes-spec.rb', line 47
+
+def run_shoes_spec_test_code(code, class_name: nil, test_name: nil)
+  raise "Child class should override this!"
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/SpecProxy.html b/Shoes/SpecProxy.html new file mode 100644 index 000000000..80c712f77 --- /dev/null +++ b/Shoes/SpecProxy.html @@ -0,0 +1,416 @@ + + + + + + + Class: Shoes::SpecProxy + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::SpecProxy + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes-spec.rb
+
+ +
+ +

Overview

+
+

ShoesSpec instances support finder methods like button() that return +a proxy to the corresponding drawable. Those proxies should support +standard Shoes::Drawable methods, including the ones appropriate to +the same drawable object. They should also support certain other +testing-specific methods like "trigger_click" that are used to +simulate display-side events during testing.

+ +

Keep in mind that a proxy will often be in a different process from +the Shoes app. So the proxy can't portably return the object or +display object, though it could possibly return another proxy for such +a thing.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #trigger_change(value) ⇒ Object + + + + + +

+
+

Trigger a change in value for a drawable like a list_box +with multiple values.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+89
+90
+91
+
+
# File 'lacci/lib/shoes-spec.rb', line 89
+
+def trigger_change(value)
+  raise "Child class should override this!"
+end
+
+
+ +
+

+ + #trigger_clickObject + + + + + +

+
+

Trigger a click on a button or button-like drawable. Not every +drawable will support this operation.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+69
+70
+71
+
+
# File 'lacci/lib/shoes-spec.rb', line 69
+
+def trigger_click()
+  raise "Child class should override this!"
+end
+
+
+ +
+

+ + #trigger_hoverObject + + + + + +

+
+

Trigger a hover over a hoverable drawable. Not every +drawable will support this operation. A drawable that supports +hover should support leave and vice-versa.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+76
+77
+78
+
+
# File 'lacci/lib/shoes-spec.rb', line 76
+
+def trigger_hover()
+  raise "Child class should override this!"
+end
+
+
+ +
+

+ + #trigger_leaveObject + + + + + +

+
+

Trigger ending hover over a hoverable drawable. Not every +drawable will support this operation. A drawable that supports +hover should support leave and vice-versa.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+83
+84
+85
+
+
# File 'lacci/lib/shoes-spec.rb', line 83
+
+def trigger_leave()
+  raise "Child class should override this!"
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Stack.html b/Shoes/Stack.html new file mode 100644 index 000000000..23027a1aa --- /dev/null +++ b/Shoes/Stack.html @@ -0,0 +1,338 @@ + + + + + + + Class: Shoes::Stack + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Stack + + + +

+
+ +
+
Inherits:
+
+ Slot + + + show all + +
+
+ + + + + + +
+
Includes:
+
Background
+
+ + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/stack.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Slot

+

#children, #draw_context

+ + + +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Background

+

#background

+ + + + + + + + + +

Methods inherited from Slot

+

#add_child, #append, #clear, #contents, #current_draw_context, #fill, #method_missing, #nofill, #nostroke, #remove_child, #respond_to_missing?, #rotate, #stroke, #strokewidth

+ + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs, &block) ⇒ Stack + + + + + +

+
+

Returns a new instance of Stack.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+14
+15
+16
+17
+18
+19
+
+
# File 'lacci/lib/shoes/drawables/stack.rb', line 11
+
+def initialize(*args, **kwargs, &block)
+  super
+
+  create_display_drawable
+
+  # Create the display-side drawable *before* running the block.
+  # Then child drawables have a parent to add themselves to.
+  Shoes::App.instance.with_slot(self, &block) if block_given?
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Slot + +

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Star.html b/Shoes/Star.html new file mode 100644 index 000000000..532ab1086 --- /dev/null +++ b/Shoes/Star.html @@ -0,0 +1,300 @@ + + + + + + + Class: Shoes::Star + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Star + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/star.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs) ⇒ Star + + + + + +

+
+

Returns a new instance of Star.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+19
+20
+21
+22
+23
+24
+25
+
+
# File 'lacci/lib/shoes/drawables/star.rb', line 19
+
+def initialize(*args, **kwargs)
+  super
+
+  @draw_context = Shoes::App.instance.current_draw_context
+
+  create_display_drawable
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/SubscriptionItem.html b/Shoes/SubscriptionItem.html new file mode 100644 index 000000000..4881be462 --- /dev/null +++ b/Shoes/SubscriptionItem.html @@ -0,0 +1,505 @@ + + + + + + + Class: Shoes::SubscriptionItem + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::SubscriptionItem + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/subscription_item.rb
+
+ +
+ +

Overview

+
+

Certain Shoes calls like motion and keydown are basically an +event subscription, with no other visible presence. However, +they have a place in the drawable tree and can be deleted.

+ +

Depending on the display library they may not have any +direct visual (or similar) presence there either.

+ +

Inheriting from Drawable gives these a parent slot and a +linkable_id automatically.

+ +

Events not yet implemented: start, finish events for slots - +start is first draw, finish is drawable destroyed

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(args: [], shoes_api_name:, &block) ⇒ SubscriptionItem + + + + + +

+
+

Returns a new instance of SubscriptionItem.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+
+
# File 'lacci/lib/shoes/drawables/subscription_item.rb', line 19
+
+def initialize(args: [], shoes_api_name:, &block)
+  super
+
+  @callback = block
+
+  case shoes_api_name
+  when "animate"
+    @unsub_id = bind_self_event("animate") do |frame|
+      @callback.call(frame)
+    end
+  when "every"
+    @unsub_id = bind_self_event("every") do |count|
+      @callback.call(count)
+    end
+  when "timer"
+    @unsub_id = bind_self_event("timer") do
+      @callback.call
+    end
+  when "hover"
+    # Hover passes the Shoes drawable as the block param
+    @unsub_id = bind_self_event("hover") do
+      @callback&.call(self)
+    end
+  when "leave"
+    # Leave passes the Shoes drawable as the block param
+    @unsub_id = bind_self_event("leave") do
+      @callback&.call(self)
+    end
+  when "motion"
+    # Shoes sends back x, y, mods as the args.
+    # Shoes3 uses the strings "control" "shift" and
+    # "control_shift" as the mods arg.
+    @unsub_id = bind_self_event("motion") do |x, y, ctrl_key, shift_key, **_kwargs|
+      mods = [ctrl_key ? "control" : nil, shift_key ? "shift" : nil].compact.join("_")
+      @callback&.call(x, y, mods)
+    end
+  when "click"
+    # Click has block params button, left, top
+    # button is the button number, left and top are coords
+    @unsub_id = bind_self_event("click") do |button, x, y, **_kwargs|
+      @callback&.call(button, x, y)
+    end
+  when "release"
+    # Click has block params button, left, top
+    # button is the button number, left and top are coords
+    @unsub_id = bind_self_event("release") do |button, x, y, **_kwargs|
+      @callback&.call(button, x, y)
+    end
+  when "keypress"
+    # Keypress passes the key string or symbol to the handler
+    # Do anything special for serialisation here?
+    @unsub_id = bind_self_event("keypress") do |key|
+      @callback&.call(key)
+    end
+  else
+    raise "Unknown Shoes event #{shoes_api_name.inspect} passed to SubscriptionItem!"
+  end
+
+  @unsub_id = bind_self_event(shoes_api_name) do |*args|
+    @callback&.call(*args)
+  end
+
+  # This won't create a visible display drawable, but will turn into
+  # an invisible drawable and a stream of events.
+  create_display_drawable
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #destroyObject + + + + + +

+ + + + +
+
+
+
+86
+87
+88
+89
+90
+91
+92
+
+
# File 'lacci/lib/shoes/drawables/subscription_item.rb', line 86
+
+def destroy
+  # TODO: we need a better way to do this automatically. See https://github.com/scarpe-team/scarpe/issues/291
+  unsub_shoes_event(@unsub_id) if @unsub_id
+  @unsub_id = nil
+
+  super
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/TextDrawable.html b/Shoes/TextDrawable.html new file mode 100644 index 000000000..5cd75c908 --- /dev/null +++ b/Shoes/TextDrawable.html @@ -0,0 +1,738 @@ + + + + + + + Class: Shoes::TextDrawable + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::TextDrawable + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/text_drawable.rb
+
+ +
+ +

Overview

+
+

TextDrawable is the parent class of various classes of +text that can go inside a para. This includes normal +text, but also links, italic text, bold text, etc.

+ +

In Shoes3 this corresponds to cText, and it would +have methods app, contents, children, parent, +style, to_s, text, text= and replace.

+ +

Much of what this does and how is similar to Para. +It's a very similar API.

+ + +
+
+
+ + +
+

Direct Known Subclasses

+

Link

+
+ + +

+ Constant Summary + collapse +

+ +
+ +
STRIKETHROUGH_VALUES = + +
+
[nil, "none", "single"]
+ +
UNDERLINE_VALUES = + +
+
[nil, "none", "single", "double", "low", "error"]
+ +
+ + + + + + +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs) ⇒ TextDrawable + + + + + +

+
+

Returns a new instance of TextDrawable.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+
+
# File 'lacci/lib/shoes/drawables/text_drawable.rb', line 35
+
+def initialize(*args, **kwargs)
+  # Don't pass text_children args to Drawable#initialize
+  super(*[], **kwargs)
+
+  # Text_children alternates strings and TextDrawables, so we can't just pass
+  # it as a Shoes style. It won't serialize.
+  update_text_children(args)
+
+  create_display_drawable
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #replace(*children) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Sets the paragraph text to a new value, which can +include Shoes::TextDrawables like em(), strong(), etc.

+ + +
+
+
+

Parameters:

+
    + +
  • + + children + + + (Array) + + + + — +

    the arguments can be Strings and/or TextDrawables

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+55
+56
+57
+
+
# File 'lacci/lib/shoes/drawables/text_drawable.rb', line 55
+
+def replace(*children)
+  update_text_children(children)
+end
+
+
+ +
+

+ + #textString + + + + + +

+
+

Return the text, but not the styling, of the para's +contents. For example, if the contents had strong +and emphasized text, the bold and emphasized would +be removed but the text would be returned.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +

    the text from this para

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+74
+75
+76
+
+
# File 'lacci/lib/shoes/drawables/text_drawable.rb', line 74
+
+def text
+  @text_children.map(&:to_s).join
+end
+
+
+ +
+

+ + #text=(*children) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Set the paragraph text to a single String. +To use bold, italics, etc. use Para#replace instead.

+ + +
+
+
+

Parameters:

+
    + +
  • + + child + + + (String) + + + + — +

    the new text to use for this Para

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+64
+65
+66
+
+
# File 'lacci/lib/shoes/drawables/text_drawable.rb', line 64
+
+def text=(*children)
+  update_text_children(children)
+end
+
+
+ +
+

+ + #text_children_to_items(text_children) ⇒ Object + + + + + +

+ + + + +
+
+
+
+46
+47
+48
+
+
# File 'lacci/lib/shoes/drawables/text_drawable.rb', line 46
+
+def text_children_to_items(text_children)
+  text_children.map { |arg| arg.is_a?(TextDrawable) ? arg.linkable_id : arg.to_s }
+end
+
+
+ +
+

+ + #to_sString + + + + + +

+
+

Return the text but not styling from the para. This +is the same as #text.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +

    the text from this para

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+82
+83
+84
+
+
# File 'lacci/lib/shoes/drawables/text_drawable.rb', line 82
+
+def to_s
+  self.text
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Video.html b/Shoes/Video.html new file mode 100644 index 000000000..e055abd8c --- /dev/null +++ b/Shoes/Video.html @@ -0,0 +1,296 @@ + + + + + + + Class: Shoes::Video + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Video + + + +

+
+ +
+
Inherits:
+
+ Drawable + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/video.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs) ⇒ Video + + + + + +

+
+

Returns a new instance of Video.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+9
+10
+11
+12
+13
+
+
# File 'lacci/lib/shoes/drawables/video.rb', line 9
+
+def initialize(*args, **kwargs)
+  super
+
+  create_display_drawable
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Drawable + +

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Widget.html b/Shoes/Widget.html new file mode 100644 index 000000000..6a3dea1d2 --- /dev/null +++ b/Shoes/Widget.html @@ -0,0 +1,267 @@ + + + + + + + Class: Shoes::Widget + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Widget + + + +

+
+ +
+
Inherits:
+
+ Slot + + + show all + +
+
+ + + + + + +
+
Includes:
+
Background
+
+ + + + + + +
+
Defined in:
+
lacci/lib/shoes/drawables/widget.rb,
+ lacci/lib/shoes.rb
+
+
+ +
+ +

Overview

+
+

TODO: when this is subclassed, grab :initialize out +of the subclass, put it into :initialize_widget, and +replace with an initialize that creates the display +widget propertly, sets the linkable_id, etc.

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants inherited + from Drawable

+

Drawable::DRAW_CONTEXT_STYLES

+ + + +

Constants included + from Log

+

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Slot

+

#children, #draw_context

+ + + +

Attributes inherited from Drawable

+

#debug_id, #destroyed, #parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + + + + + + + +

Method Summary

+ +

Methods included from Background

+

#background

+ + + + + + + + + +

Methods inherited from Slot

+

#add_child, #append, #clear, #contents, #current_draw_context, #fill, #initialize, #method_missing, #nofill, #nostroke, #remove_child, #respond_to_missing?, #rotate, #stroke, #strokewidth

+ + + + + + + + + +

Methods inherited from Drawable

+

allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #initialize, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as

+ + + + + + + + + +

Methods included from MarginHelper

+

#margin_parse

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #initialize, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event

+
+

Constructor Details

+ +

This class inherits a constructor from Shoes::Slot

+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class Shoes::Slot + +

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/_index.html b/_index.html new file mode 100644 index 000000000..0aad0d3d3 --- /dev/null +++ b/_index.html @@ -0,0 +1,1530 @@ + + + + + + + Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Documentation by YARD 0.9.28

+
+

Alphabetic Index

+ +

File Listing

+ + +
+

Namespace Listing A-Z

+ + + + + + + + +
+ + +
    +
  • A
  • +
      + +
    • + App + + (Scarpe::Webview) + +
    • + +
    • + App + + (Shoes) + +
    • + +
    • + App + + (Niente) + +
    • + +
    • + AppShutdownError + + (Scarpe) + +
    • + +
    • + Arc + + (Scarpe::Webview) + +
    • + +
    • + Arc + + (Shoes) + +
    • + +
    • + Arrow + + (Scarpe::Webview) + +
    • + +
    • + Arrow + + (Shoes) + +
    • + +
    • + AssetServer + + (Scarpe::Components) + +
    • + +
    +
+ + + + + + + + + + + + + + + + + +
    +
  • H
  • +
      + +
    • + HTML + + (Scarpe::Components) + +
    • + +
    • + HTMLAssertions + + (Scarpe::Test) + +
    • + +
    • + Helpers + + (Scarpe::Test) + +
    • + +
    +
+ + +
+ + + + + + + + +
    +
  • K
  • + +
+ + +
    +
  • L
  • + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
    +
  • V
  • +
      + +
    • + Video + + (Scarpe::Webview) + +
    • + +
    • + Video + + (Shoes) + +
    • + +
    +
+ + + + +
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/class_list.html b/class_list.html new file mode 100644 index 000000000..919868012 --- /dev/null +++ b/class_list.html @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + Class List + + + +
+
+

Class List

+ + + +
+ + +
+ + diff --git a/css/common.css b/css/common.css new file mode 100644 index 000000000..cf25c4523 --- /dev/null +++ b/css/common.css @@ -0,0 +1 @@ +/* Override this file with custom rules */ \ No newline at end of file diff --git a/css/full_list.css b/css/full_list.css new file mode 100644 index 000000000..fa3598242 --- /dev/null +++ b/css/full_list.css @@ -0,0 +1,58 @@ +body { + margin: 0; + font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif; + font-size: 13px; + height: 101%; + overflow-x: hidden; + background: #fafafa; +} + +h1 { padding: 12px 10px; padding-bottom: 0; margin: 0; font-size: 1.4em; } +.clear { clear: both; } +.fixed_header { position: fixed; background: #fff; width: 100%; padding-bottom: 10px; margin-top: 0; top: 0; z-index: 9999; height: 70px; } +#search { position: absolute; right: 5px; top: 9px; padding-left: 24px; } +#content.insearch #search, #content.insearch #noresults { background: url(data:image/gif;base64,R0lGODlhEAAQAPYAAP///wAAAPr6+pKSkoiIiO7u7sjIyNjY2J6engAAAI6OjsbGxjIyMlJSUuzs7KamppSUlPLy8oKCghwcHLKysqSkpJqamvT09Pj4+KioqM7OzkRERAwMDGBgYN7e3ujo6Ly8vCoqKjY2NkZGRtTU1MTExDw8PE5OTj4+PkhISNDQ0MrKylpaWrS0tOrq6nBwcKysrLi4uLq6ul5eXlxcXGJiYoaGhuDg4H5+fvz8/KKiohgYGCwsLFZWVgQEBFBQUMzMzDg4OFhYWBoaGvDw8NbW1pycnOLi4ubm5kBAQKqqqiQkJCAgIK6urnJyckpKSjQ0NGpqatLS0sDAwCYmJnx8fEJCQlRUVAoKCggICLCwsOTk5ExMTPb29ra2tmZmZmhoaNzc3KCgoBISEiIiIgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCAAAACwAAAAAEAAQAAAHaIAAgoMgIiYlg4kACxIaACEJCSiKggYMCRselwkpghGJBJEcFgsjJyoAGBmfggcNEx0flBiKDhQFlIoCCA+5lAORFb4AJIihCRbDxQAFChAXw9HSqb60iREZ1omqrIPdJCTe0SWI09GBACH5BAkIAAAALAAAAAAQABAAAAdrgACCgwc0NTeDiYozCQkvOTo9GTmDKy8aFy+NOBA7CTswgywJDTIuEjYFIY0JNYMtKTEFiRU8Pjwygy4ws4owPyCKwsMAJSTEgiQlgsbIAMrO0dKDGMTViREZ14kYGRGK38nHguHEJcvTyIEAIfkECQgAAAAsAAAAABAAEAAAB2iAAIKDAggPg4iJAAMJCRUAJRIqiRGCBI0WQEEJJkWDERkYAAUKEBc4Po1GiKKJHkJDNEeKig4URLS0ICImJZAkuQAhjSi/wQyNKcGDCyMnk8u5rYrTgqDVghgZlYjcACTA1sslvtHRgQAh+QQJCAAAACwAAAAAEAAQAAAHZ4AAgoOEhYaCJSWHgxGDJCQARAtOUoQRGRiFD0kJUYWZhUhKT1OLhR8wBaaFBzQ1NwAlkIszCQkvsbOHL7Y4q4IuEjaqq0ZQD5+GEEsJTDCMmIUhtgk1lo6QFUwJVDKLiYJNUd6/hoEAIfkECQgAAAAsAAAAABAAEAAAB2iAAIKDhIWGgiUlh4MRgyQkjIURGRiGGBmNhJWHm4uen4ICCA+IkIsDCQkVACWmhwSpFqAABQoQF6ALTkWFnYMrVlhWvIKTlSAiJiVVPqlGhJkhqShHV1lCW4cMqSkAR1ofiwsjJyqGgQAh+QQJCAAAACwAAAAAEAAQAAAHZ4AAgoOEhYaCJSWHgxGDJCSMhREZGIYYGY2ElYebi56fhyWQniSKAKKfpaCLFlAPhl0gXYNGEwkhGYREUywag1wJwSkHNDU3D0kJYIMZQwk8MjPBLx9eXwuETVEyAC/BOKsuEjYFhoEAIfkECQgAAAAsAAAAABAAEAAAB2eAAIKDhIWGgiUlh4MRgyQkjIURGRiGGBmNhJWHm4ueICImip6CIQkJKJ4kigynKaqKCyMnKqSEK05StgAGQRxPYZaENqccFgIID4KXmQBhXFkzDgOnFYLNgltaSAAEpxa7BQoQF4aBACH5BAkIAAAALAAAAAAQABAAAAdogACCg4SFggJiPUqCJSWGgkZjCUwZACQkgxGEXAmdT4UYGZqCGWQ+IjKGGIUwPzGPhAc0NTewhDOdL7Ykji+dOLuOLhI2BbaFETICx4MlQitdqoUsCQ2vhKGjglNfU0SWmILaj43M5oEAOwAAAAAAAAAAAA==) no-repeat center left; } +#full_list { padding: 0; list-style: none; margin-left: 0; margin-top: 80px; font-size: 1.1em; } +#full_list ul { padding: 0; } +#full_list li { padding: 0; margin: 0; list-style: none; } +#full_list li .item { padding: 5px 5px 5px 12px; } +#noresults { padding: 7px 12px; background: #fff; } +#content.insearch #noresults { margin-left: 7px; } +li.collapsed ul { display: none; } +li a.toggle { cursor: default; position: relative; left: -5px; top: 4px; text-indent: -999px; width: 10px; height: 9px; margin-left: -10px; display: block; float: left; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAK8AAACvABQqw0mAAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTM5jWRgMAAAAVdEVYdENyZWF0aW9uIFRpbWUAMy8xNC8wOeNZPpQAAAE2SURBVDiNrZTBccIwEEXfelIAHUA6CZ24BGaWO+FuzZAK4k6gg5QAdGAq+Bxs2Yqx7BzyL7Llp/VfzZeQhCTc/ezuGzKKnKSzpCxXJM8fwNXda3df5RZETlIt6YUzSQDs93sl8w3wBZxCCE10GM1OcWbWjB2mWgEH4Mfdyxm3PSepBHibgQE2wLe7r4HjEidpnXMYdQPKEMJcsZ4zs2POYQOcaPfwMVOo58zsAdMt18BuoVDPxUJRacELbXv3hUIX2vYmOUvi8C8ydz/ThjXrqKqqLbDIAdsCKBd+Wo7GWa7o9qzOQHVVVXeAbs+yHHCH4aTsaCOQqunmUy1yBUAXkdMIfMlgF5EXLo2OpV/c/Up7jG4hhHcYLgWzAZXUc2b2ixsfvc/RmNNfOXD3Q/oeL9axJE1yT9IOoUu6MGUkAAAAAElFTkSuQmCC) no-repeat bottom left; } +li.collapsed a.toggle { opacity: 0.5; cursor: default; background-position: top left; } +li { color: #888; cursor: pointer; } +li.deprecated { text-decoration: line-through; font-style: italic; } +li.odd { background: #f0f0f0; } +li.even { background: #fafafa; } +.item:hover { background: #ddd; } +li small:before { content: "("; } +li small:after { content: ")"; } +li small.search_info { display: none; } +a, a:visited { text-decoration: none; color: #05a; } +li.clicked > .item { background: #05a; color: #ccc; } +li.clicked > .item a, li.clicked > .item a:visited { color: #eee; } +li.clicked > .item a.toggle { opacity: 0.5; background-position: bottom right; } +li.collapsed.clicked a.toggle { background-position: top right; } +#search input { border: 1px solid #bbb; border-radius: 3px; } +#full_list_nav { margin-left: 10px; font-size: 0.9em; display: block; color: #aaa; } +#full_list_nav a, #nav a:visited { color: #358; } +#full_list_nav a:hover { background: transparent; color: #5af; } +#full_list_nav span:after { content: ' | '; } +#full_list_nav span:last-child:after { content: ''; } + +#content h1 { margin-top: 0; } +li { white-space: nowrap; cursor: normal; } +li small { display: block; font-size: 0.8em; } +li small:before { content: ""; } +li small:after { content: ""; } +li small.search_info { display: none; } +#search { width: 170px; position: static; margin: 3px; margin-left: 10px; font-size: 0.9em; color: #888; padding-left: 0; padding-right: 24px; } +#content.insearch #search { background-position: center right; } +#search input { width: 110px; } + +#full_list.insearch ul { display: block; } +#full_list.insearch .item { display: none; } +#full_list.insearch .found { display: block; padding-left: 11px !important; } +#full_list.insearch li a.toggle { display: none; } +#full_list.insearch li small.search_info { display: block; } diff --git a/css/style.css b/css/style.css new file mode 100644 index 000000000..eb0dbc86f --- /dev/null +++ b/css/style.css @@ -0,0 +1,497 @@ +html { + width: 100%; + height: 100%; +} +body { + font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif; + font-size: 13px; + width: 100%; + margin: 0; + padding: 0; + display: flex; + display: -webkit-flex; + display: -ms-flexbox; +} + +#nav { + position: relative; + width: 100%; + height: 100%; + border: 0; + border-right: 1px dotted #eee; + overflow: auto; +} +.nav_wrap { + margin: 0; + padding: 0; + width: 20%; + height: 100%; + position: relative; + display: flex; + display: -webkit-flex; + display: -ms-flexbox; + flex-shrink: 0; + -webkit-flex-shrink: 0; + -ms-flex: 1 0; +} +#resizer { + position: absolute; + right: -5px; + top: 0; + width: 10px; + height: 100%; + cursor: col-resize; + z-index: 9999; +} +#main { + flex: 5 1; + -webkit-flex: 5 1; + -ms-flex: 5 1; + outline: none; + position: relative; + background: #fff; + padding: 1.2em; + padding-top: 0.2em; + box-sizing: border-box; +} + +@media (max-width: 920px) { + .nav_wrap { width: 100%; top: 0; right: 0; overflow: visible; position: absolute; } + #resizer { display: none; } + #nav { + z-index: 9999; + background: #fff; + display: none; + position: absolute; + top: 40px; + right: 12px; + width: 500px; + max-width: 80%; + height: 80%; + overflow-y: scroll; + border: 1px solid #999; + border-collapse: collapse; + box-shadow: -7px 5px 25px #aaa; + border-radius: 2px; + } +} + +@media (min-width: 920px) { + body { height: 100%; overflow: hidden; } + #main { height: 100%; overflow: auto; } + #search { display: none; } +} + +#main img { max-width: 100%; } +h1 { font-size: 25px; margin: 1em 0 0.5em; padding-top: 4px; border-top: 1px dotted #d5d5d5; } +h1.noborder { border-top: 0px; margin-top: 0; padding-top: 4px; } +h1.title { margin-bottom: 10px; } +h1.alphaindex { margin-top: 0; font-size: 22px; } +h2 { + padding: 0; + padding-bottom: 3px; + border-bottom: 1px #aaa solid; + font-size: 1.4em; + margin: 1.8em 0 0.5em; + position: relative; +} +h2 small { font-weight: normal; font-size: 0.7em; display: inline; position: absolute; right: 0; } +h2 small a { + display: block; + height: 20px; + border: 1px solid #aaa; + border-bottom: 0; + border-top-left-radius: 5px; + background: #f8f8f8; + position: relative; + padding: 2px 7px; +} +.clear { clear: both; } +.inline { display: inline; } +.inline p:first-child { display: inline; } +.docstring, .tags, #filecontents { font-size: 15px; line-height: 1.5145em; } +.docstring p > code, .docstring p > tt, .tags p > code, .tags p > tt { + color: #c7254e; background: #f9f2f4; padding: 2px 4px; font-size: 1em; + border-radius: 4px; +} +.docstring h1, .docstring h2, .docstring h3, .docstring h4 { padding: 0; border: 0; border-bottom: 1px dotted #bbb; } +.docstring h1 { font-size: 1.2em; } +.docstring h2 { font-size: 1.1em; } +.docstring h3, .docstring h4 { font-size: 1em; border-bottom: 0; padding-top: 10px; } +.summary_desc .object_link a, .docstring .object_link a { + font-family: monospace; font-size: 1.05em; + color: #05a; background: #EDF4FA; padding: 2px 4px; font-size: 1em; + border-radius: 4px; +} +.rdoc-term { padding-right: 25px; font-weight: bold; } +.rdoc-list p { margin: 0; padding: 0; margin-bottom: 4px; } +.summary_desc pre.code .object_link a, .docstring pre.code .object_link a { + padding: 0px; background: inherit; color: inherit; border-radius: inherit; +} + +/* style for */ +#filecontents table, .docstring table { border-collapse: collapse; } +#filecontents table th, #filecontents table td, +.docstring table th, .docstring table td { border: 1px solid #ccc; padding: 8px; padding-right: 17px; } +#filecontents table tr:nth-child(odd), +.docstring table tr:nth-child(odd) { background: #eee; } +#filecontents table tr:nth-child(even), +.docstring table tr:nth-child(even) { background: #fff; } +#filecontents table th, .docstring table th { background: #fff; } + +/* style for
a",d=q.getElementsByTagName("*"),e=q.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=q.getElementsByTagName("input")[0],b={leadingWhitespace:q.firstChild.nodeType===3,tbody:!q.getElementsByTagName("tbody").length,htmlSerialize:!!q.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:q.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete q.test}catch(s){b.deleteExpando=!1}!q.addEventListener&&q.attachEvent&&q.fireEvent&&(q.attachEvent("onclick",function(){b.noCloneEvent=!1}),q.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),q.appendChild(i),k=c.createDocumentFragment(),k.appendChild(q.lastChild),b.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,k.removeChild(i),k.appendChild(q),q.innerHTML="",a.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",q.style.width="2px",q.appendChild(j),b.reliableMarginRight=(parseInt((a.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0);if(q.attachEvent)for(o in{submit:1,change:1,focusin:1})n="on"+o,p=n in q,p||(q.setAttribute(n,"return;"),p=typeof q[n]=="function"),b[o+"Bubbles"]=p;k.removeChild(q),k=g=h=j=q=i=null,f(function(){var a,d,e,g,h,i,j,k,m,n,o,r=c.getElementsByTagName("body")[0];!r||(j=1,k="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",m="visibility:hidden;border:0;",n="style='"+k+"border:5px solid #000;padding:0;'",o="
"+""+"
",a=c.createElement("div"),a.style.cssText=m+"width:0;height:0;position:static;top:0;margin-top:"+j+"px",r.insertBefore(a,r.firstChild),q=c.createElement("div"),a.appendChild(q),q.innerHTML="
t
",l=q.getElementsByTagName("td"),p=l[0].offsetHeight===0,l[0].style.display="",l[1].style.display="none",b.reliableHiddenOffsets=p&&l[0].offsetHeight===0,q.innerHTML="",q.style.width=q.style.paddingLeft="1px",f.boxModel=b.boxModel=q.offsetWidth===2,typeof q.style.zoom!="undefined"&&(q.style.display="inline",q.style.zoom=1,b.inlineBlockNeedsLayout=q.offsetWidth===2,q.style.display="",q.innerHTML="
",b.shrinkWrapBlocks=q.offsetWidth!==2),q.style.cssText=k+m,q.innerHTML=o,d=q.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,i={doesNotAddBorder:e.offsetTop!==5,doesAddBorderForTableAndCells:h.offsetTop===5},e.style.position="fixed",e.style.top="20px",i.fixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",i.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,i.doesNotIncludeMarginInBodyOffset=r.offsetTop!==j,r.removeChild(a),q=a=null,f.extend(b,i))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.nodeName.toLowerCase()]||f.valHooks[g.type];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;h=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/\bhover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")}; +f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&i.push({elem:this,matches:d.slice(e)});for(j=0;j0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function() +{for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||!bc.test("<"+a.nodeName)?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=bg[l]||bg._default,n=m[0],o=b.createElement("div");b===c?bh.appendChild(o):U(b).appendChild(o),o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return br.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bq,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bq.test(g)?g.replace(bq,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bz(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bA=function(a,b){var c,d,e;b=b.replace(bs,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b)));return c}),c.documentElement.currentStyle&&(bB=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f===null&&g&&(e=g[b])&&(f=e),!bt.test(f)&&bu.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f||0,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),bz=bA||bB,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bD=/%20/g,bE=/\[\]$/,bF=/\r?\n/g,bG=/#.*$/,bH=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bI=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bJ=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bK=/^(?:GET|HEAD)$/,bL=/^\/\//,bM=/\?/,bN=/)<[^<]*)*<\/script>/gi,bO=/^(?:select|textarea)/i,bP=/\s+/,bQ=/([?&])_=[^&]*/,bR=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bS=f.fn.load,bT={},bU={},bV,bW,bX=["*/"]+["*"];try{bV=e.href}catch(bY){bV=c.createElement("a"),bV.href="",bV=bV.href}bW=bR.exec(bV.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bS)return bS.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bN,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bO.test(this.nodeName)||bI.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bF,"\r\n")}}):{name:b.name,value:c.replace(bF,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b_(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b_(a,b);return a},ajaxSettings:{url:bV,isLocal:bJ.test(bW[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bX},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bZ(bT),ajaxTransport:bZ(bU),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?cb(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cc(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bH.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bG,"").replace(bL,bW[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bP),d.crossDomain==null&&(r=bR.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bW[1]&&r[2]==bW[2]&&(r[3]||(r[1]==="http:"?80:443))==(bW[3]||(bW[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),b$(bT,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bK.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bM.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bQ,"$1_="+x);d.url=y+(y===d.url?(bM.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bX+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=b$(bU,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)ca(g,a[g],c,e);return d.join("&").replace(bD,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cd=f.now(),ce=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cd++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ce.test(b.url)||e&&ce.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ce,l),b.url===j&&(e&&(k=k.replace(ce,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cf=a.ActiveXObject?function(){for(var a in ch)ch[a](0,1)}:!1,cg=0,ch;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ci()||cj()}:ci,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cf&&delete ch[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cg,cf&&(ch||(ch={},f(a).unload(cf)),ch[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var ck={},cl,cm,cn=/^(?:toggle|show|hide)$/,co=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cp,cq=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cr;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cu("show",3),a,b,c);for(var g=0,h=this.length;g=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cy(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cy(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,d,"padding")):this[d]():null},f.fn["outer"+c]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,d,a?"margin":"border")):this[d]():null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNumeric(j)?j:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window); \ No newline at end of file diff --git a/method_list.html b/method_list.html new file mode 100644 index 000000000..99a77aa28 --- /dev/null +++ b/method_list.html @@ -0,0 +1,4839 @@ + + + + + + + + + + + + + + + + + + Method List + + + +
+
+

Method List

+ + + +
+ + +
+ + diff --git a/top-level-namespace.html b/top-level-namespace.html new file mode 100644 index 000000000..dc3608868 --- /dev/null +++ b/top-level-namespace.html @@ -0,0 +1,159 @@ + + + + + + + Top Level Namespace + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Top Level Namespace + + + +

+
+ + + + + + + + + + + +
+ +

Defined Under Namespace

+

+ + + Modules: FontHelper, Kernel, Lacci, MarginHelper, Minitest, Niente, Scarpe + + + + Classes: Range, Shoes + + +

+ + +

+ Constant Summary + collapse +

+ +
+ +
SCARPE_DIR = +
+
+

Wherever this file is installed, locate Scarpe relative to it. This could be an installed gem or a dev repo.

+ + +
+
+
+ + +
+
+
File.join(__dir__, "../..")
+ +
SERVICE = + +
+
Scarpe::Webview::ContainedService.new(s, s)
+ +
ALREADY_SET_UP_LOGGED_TEST_FAILURES = +
+
+

We want test failures set up once total, not per Minitest::Test. So an instance var +doesn't do it.

+ + +
+
+
+ + +
+
+
{ setup: false }
+ +
+ + + + + + + + + + +
+ + + +
+ + \ No newline at end of file