Skip to content

Latest commit

 

History

History
36 lines (19 loc) · 2.92 KB

Technical Overview.md

File metadata and controls

36 lines (19 loc) · 2.92 KB

Technical Overview

This third version of the Ruby Console+ makes use of the observer pattern, asynchronous communication and promises.

Simplified class diagram

The console plugin can create one or more console instances. The Console class provides basic functionality and is extended with Feature classes. A console instance opens an HtmlDialog which contains the user interface consisting of the console (input), the console output and an editor for files.

Bridge

The Bridge class had originally been created because SketchUp's WebDialog used to have severe limitations for communicating between the Ruby interpreter and JavaScript (unicode, message length, serialization, message loss). The move to HtmlDialog solved most issues, so now it is mostly used for convenience for its a powerful API.

Communication is completely asynchronous and based on promises. A promise is a proxy object for the result of an operation (that may be asynchronous). Subsequent operations can be scheduled immediately on the promise and will be executed as soon as the result is available.

Features System

To handle the growing amount of features, they are implemented like extensions, with the core console having only basic functionality. A feature can include both Ruby code and JavaScript code.

Features are searched in the features folder and loaded into Ruby as soon as the plugin is loaded. The JavaScript part of features is loaded whenever a console dialog is opened. A feature's class is initialized with a shared struct which gives access to several components of the plugin on which you can listen for events and act on them (observer pattern).

JavaScript Modules

Like the ace editor, the console now uses AMD modules. Requirejs loads a module definition after all dependent modules have been loaded asynchronously. If a function needs a module, it can require its dependencies in an array and then access them as parameters of a callback function:

requirejs(['module_name'], function callback (module) {});

The main module configures paths where to look up modules and then loads the user interface controller in app.

User Interface

The user interface uses Bootstrap for CSS and some widgets. The user interface consists of modules console (with output) and editor, which each are wrappers around an instance of ace.

Ace Editor

The ace editor is an IDE based on web technologies. To update to a new version, download from the prepackaged versions. For the old Internet-Explorer-based webdialogs in older SketchUp versions, I had to heavily patch ace to circumvent errors caused by limited web standard support. This is not necessary anymore since this version does at the moment not aim for backward compatibility. Remaining patches can be found in the patches directory.