glimmer 0.7.7 → 0.7.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76d86f5e3e322edba85aee815e28a0bb19b6ed56694ff44b1311a759b249b189
4
- data.tar.gz: ad84ddf98c7a9da150f1dd4897e7a7df0e7d8cf06d317a1a748929c1446895ce
3
+ metadata.gz: 7a3d10cd74668598ac83511994d117f3b99f7332d798d671ddc412dcac3c92fa
4
+ data.tar.gz: 1daf7b7330d0e73790ec98c5ef3afdf3f991f0f447f5b72ce47bc70901bb8baa
5
5
  SHA512:
6
- metadata.gz: dbbd46186a07700fed156566a5a0de4fb5ad90720ae2e24eb0662bc1ef3a64850f29d4f91fa577f388136511e3ec20689a97e1686e25f34112fabf35c05c2981
7
- data.tar.gz: f484803847e17525090f815ea117d429f10abc87f12a5c38343c9d6e2f56ff6bf055b153f5fa3f250ae60adde2b5ff4cba7b209b0b1693bc98d0f619cc1d15db
6
+ metadata.gz: 81136d0e73a2e26f01bc16b8986f8569910a63509730766d6cb70a533e1fbe38fdce3bfc7e0488d5bbe2a76e10413a46b0765811960698f70a343d45ab3c78a2
7
+ data.tar.gz: e20bab1be17773690ac997385921e47520e324afe3b4efcf0f0b6ae4dcf00cd6bcaea9b36c048c9c1eec54023af4c853e8c9aaa55138b40fa58f4262cbd09872
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Glimmer 0.7.7 Beta (Desktop Development Library for Ruby)
1
+ # Glimmer 0.7.8 Beta (Desktop Development Library for Ruby)
2
2
  [![Gem Version](https://badge.fury.io/rb/glimmer.svg)](http://badge.fury.io/rb/glimmer)
3
3
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer)
4
4
  [![Test Coverage](https://api.codeclimate.com/v1/badges/38fbc278022862794414/test_coverage)](https://codeclimate.com/github/AndyObtiva/glimmer/test_coverage)
@@ -75,7 +75,7 @@ NOTE: Glimmer is in beta mode. Please help make better by adopting for small or
75
75
 
76
76
  ## Table of Contents
77
77
 
78
- - [Glimmer 0.7.7 Beta (Desktop Development Library for Ruby)](#glimmer-075-beta-desktop-development-library-for-ruby)
78
+ - [Glimmer 0.7.8 Beta (Desktop Development Library for Ruby)](#glimmer-078-beta-desktop-development-library-for-ruby)
79
79
  - [Examples](#examples)
80
80
  - [Hello, World!](#hello-world)
81
81
  - [Tic Tac Toe](#tic-tac-toe)
@@ -105,6 +105,7 @@ NOTE: Glimmer is in beta mode. Please help make better by adopting for small or
105
105
  - [Samples](#samples)
106
106
  - [Hello Samples](#hello-samples)
107
107
  - [Elaborate Samples](#elaborate-samples)
108
+ - [External Samples](#external-samples)
108
109
  - [In Production](#in-production)
109
110
  - [SWT Reference](#swt-reference)
110
111
  - [SWT Packages](#swt-packages)
@@ -112,7 +113,8 @@ NOTE: Glimmer is in beta mode. Please help make better by adopting for small or
112
113
  - [Raw JRuby Command](#raw-jruby-command)
113
114
  - [Mac Support](#mac-support)
114
115
  - [Packaging & Distribution](#packaging--distribution)
115
- - [Defaults](#defaults)
116
+ - [Packaging Defaults](#packaging-defaults)
117
+ - [Packaging Configuration](#packaging-configuration)
116
118
  - [javapackager Extra Arguments](#javapackager-extra-arguments)
117
119
  - [Mac Application Distribution](#mac-application-distribution)
118
120
  - [Self Signed Certificate](#self-signed-certificate)
@@ -152,8 +154,9 @@ https://www.eclipse.org/swt/faq.php
152
154
  ## Pre-requisites
153
155
 
154
156
  - SWT 4.15 (comes included in Glimmer gem)
155
- - JRuby 9.2.11.1 (supporting Ruby 2.5.x syntax) (find at https://www.jruby.org/download)
156
- - Java SE Runtime Environment 7 or higher (find at https://www.oracle.com/java/technologies/javase-downloads.html)
157
+ - JRuby 9.2.11.1 (supporting Ruby 2.5.x syntax) (find at [https://www.jruby.org/download](https://www.jruby.org/download))
158
+ - Java SE Runtime Environment 7 or higher (find at [https://www.oracle.com/java/technologies/javase-downloads.html](https://www.oracle.com/java/technologies/javase-downloads.html))
159
+ - (Optional) RVM is needed for [Scaffolding](#scaffolding) only (find at [https://rvm.io/](https://rvm.io/))
157
160
 
158
161
  On **Mac** and **Linux**, an easy way to obtain JRuby is through [RVM](http://rvm.io) by running:
159
162
 
@@ -171,7 +174,7 @@ Please follow these instructions to make the `glimmer` command available on your
171
174
 
172
175
  Run this command to install directly:
173
176
  ```
174
- jgem install glimmer -v 0.7.7
177
+ jgem install glimmer -v 0.7.8
175
178
  ```
176
179
 
177
180
  `jgem` is JRuby's version of `gem` command.
@@ -182,7 +185,7 @@ Otherwise, you may also run `jruby -S gem install ...`
182
185
 
183
186
  Add the following to `Gemfile`:
184
187
  ```
185
- gem 'glimmer', '~> 0.7.7'
188
+ gem 'glimmer', '~> 0.7.8'
186
189
  ```
187
190
 
188
191
  And, then run:
@@ -219,7 +222,7 @@ bin/glimmer samples/hello/hello_world.rb
219
222
  Below are the full usage instructions that come up when running `glimmer` without args.
220
223
 
221
224
  ```
222
- Usage: glimmer [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
225
+ Usage: glimmer [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
223
226
 
224
227
  Runs Glimmer applications/tasks.
225
228
 
@@ -234,7 +237,7 @@ glimmer package:jar # Generate JAR
234
237
  glimmer package:native # Generate Native files (DMG/PKG/APP on the Mac)
235
238
  glimmer scaffold[app_name] # Scaffold a Glimmer application directory structure to begin building a new app
236
239
  glimmer scaffold:custom_shell[custom_shell_name,namespace] # Scaffold a Glimmer::UI::CustomShell subclass (represents a full window view) under app/views (namespace is optional)
237
- glimmer scaffold:custom_shell_gem[custom_widget_name,namespace] # Scaffold a Glimmer::UI::CustomShell subclass (represents a full window view) under its own Ruby gem project (namespace is required)
240
+ glimmer scaffold:custom_shell_gem[custom_shell_name,namespace] # Scaffold a Glimmer::UI::CustomShell subclass (represents a full window view) under its own Ruby gem + app project (namespace is required)
238
241
  glimmer scaffold:custom_widget[custom_widget_name,namespace] # Scaffold a Glimmer::UI::CustomWidget subclass (represents a part of a view) under app/views (namespace is optional)
239
242
  glimmer scaffold:custom_widget_gem[custom_widget_name,namespace] # Scaffold a Glimmer::UI::CustomWidget subclass (represents a part of a view) under its own Ruby gem project (namespace is required)
240
243
 
@@ -244,8 +247,9 @@ automatically preloading the glimmer Ruby gem and SWT jar dependency.
244
247
  Optionally, extra Glimmer options, JRuby options and environment variables may be passed in.
245
248
 
246
249
  Glimmer options:
247
- - "--debug" : Displays extra debugging information and passes "--debug" to JRuby
248
- - "--log-level=VALUE" : Sets Glimmer's Ruby logger level ("ERROR" / "WARN" / "INFO" / "DEBUG"; default is "WARN")
250
+ - "--quiet" : Does not announce file path of Glimmer application being launched nor enable logging
251
+ - "--debug" : Displays extra debugging information, passes "--debug" to JRuby, and enables debug logging
252
+ - "--log-level=VALUE" : Sets Glimmer's Ruby logger level ("ERROR" / "WARN" / "INFO" / "DEBUG"; default is none)
249
253
 
250
254
  Example: glimmer samples/hello_world.rb
251
255
 
@@ -277,7 +281,7 @@ getting you to a running and delivered state of an advanced "Hello, World!" Glim
277
281
  This should greatly facilitate building a new Glimmer app by helping you be productive and focus on app details while
278
282
  letting Glimmer scaffolding take care of initial app file structure concerns, such as adding:
279
283
  - Main application class that includes Glimmer
280
- - Main application view that houses main window content
284
+ - Main application view that houses main window content, about dialog, and preferences dialog
281
285
  - View and Model directories
282
286
  - Rakefile including Glimmer tasks
283
287
  - Version
@@ -285,7 +289,7 @@ letting Glimmer scaffolding take care of initial app file structure concerns, su
285
289
  - Icon
286
290
  - Bin file for starting application
287
291
 
288
- NOTE: Scaffolding currently supports Mac packaging only at the moment.
292
+ NOTE: Scaffolding requires RVM and currently supports Mac packaging only at the moment.
289
293
 
290
294
  #### App
291
295
 
@@ -344,8 +348,10 @@ glimmer scaffold:custom_widget[custom_widget_name]
344
348
  #### Custom Shell Gem
345
349
 
346
350
  Custom shell gems are self-contained Glimmer apps as well as reusable custom shells.
347
- As such, they are packaged as both a native executable (e.g. Mac DMG/PKG/APP) and a Ruby gem.
348
- Of course, you can build a Ruby gem and disregard its native executable packaging if you do not need it.
351
+ They have everything scaffolded Glimmer apps come with in addition to gem content like a Jeweler Rakefile that can build gemspec and release gems.
352
+ Unlike scaffolded Glimmer apps, custom shell gem content lives under the `lib` directory (not `app`).
353
+ They can be packaged as both a native executable (e.g. Mac DMG/PKG/APP) and a Ruby gem.
354
+ Of course, you can just build a Ruby gem and disregard native executable packaging if you do not need it.
349
355
 
350
356
  To scaffold a Glimmer custom shell gem (full window view distributed as a Ruby gem), run the following command:
351
357
 
@@ -359,7 +365,10 @@ The Ruby gem name will follow the convention "glimmer-cs-customwidgetname-namesp
359
365
 
360
366
  Only official Glimmer gems created by the Glimmer project committers will have no namespace (e.g. [glimmer-cs-gladiator](https://rubygems.org/gems/glimmer-cs-gladiator) Ruby gem)
361
367
 
362
- Example: [https://github.com/AndyObtiva/glimmer-cs-gladiator](https://github.com/AndyObtiva/glimmer-cs-gladiator)
368
+ Examples:
369
+
370
+ - [glimmer-cs-gladiator](https://github.com/AndyObtiva/glimmer-cs-gladiator): Gladiator (Glimmer Editor)
371
+ - [glimmer-cs-calculator](https://github.com/AndyObtiva/glimmer-cs-calculator): Glimmer Calculator
363
372
 
364
373
  #### Custom Widget Gem
365
374
 
@@ -619,6 +628,12 @@ Shell widget proxy has extra methods specific to SWT Shell:
619
628
  - `#pack`: Packs contained widgets using SWT's `Shell#pack` method
620
629
  - `#pack_same_size`: Packs contained widgets without changing shell's size when widget sizes change
621
630
 
631
+ #### Dialog
632
+
633
+ Dialog is a variation on Shell. It is basically a shell that is modal (blocks what's behind it) and belongs to another shell. It only has a close button.
634
+
635
+ Glimmer facilitates building dialogs by using the `dialog` keyword, which automatically adds the SWT::DIALOG_TRIM and SWT::APPLICATION_MODAL [widget styles](#widget-styles) needed for a dialog.
636
+
622
637
  #### Menus
623
638
 
624
639
  Glimmer DSL provides support for SWT Menu and MenuItem widgets.
@@ -1535,17 +1550,17 @@ Notice how `Red::Composite` became `red__composite` with double-underscore, whic
1535
1550
 
1536
1551
  Keep in mind that namespaces are not needed to be specified if the Custom Widget class has a unique name, not clashing with a basic SWT widget or another custom widget name.
1537
1552
 
1538
- Custom Widgets have the following attributes (attribute readers) available to call from inside the `#body` method:
1553
+ Custom Widgets have the following attributes available to call from inside the `#body` method:
1539
1554
  - `#parent`: Glimmer object parenting custom widget
1540
1555
  - `#swt_style`: SWT style integer. Can be useful if you want to allow consumers to customize a widget inside the custom widget body
1541
- - `#options`: a hash of options passed in parentheses when declaring a custom widget (useful for passing in model data) (e.g. `calendar(events: events)`). Custom widget class can declare option names (array) with `.options` method as shown below, which generates attribute readers for every option (not to be confused with `#options` instance method for retrieving options hash containing names & values)
1556
+ - `#options`: a hash of options passed in parentheses when declaring a custom widget (useful for passing in model data) (e.g. `calendar(events: events)`). Custom widget class can declare option names (array) with `::options` class method as shown below, which generates attribute accessors for every option (not to be confused with `#options` instance method for retrieving options hash containing names & values)
1542
1557
  - `#content`: nested block underneath custom widget. It will be automatically called at the end of processing the custom widget body. Alternatively, the custom widget body may call `content.call` at the place where the content is needed to show up as shown in the following example.
1543
1558
  - `#body_root`: top-most (root) widget returned from `#body` method.
1544
1559
  - `#swt_widget`: actual SWT widget for `body_root`
1545
1560
 
1546
1561
  Additionally, custom widgets can call the following class methods:
1547
- - `.options`: declares a list of options by taking an option name array (symbols/strings). This generates option attribute readers (e.g. `options :orientation, :bg_color` generates `#orientation` and `#bg_color` attribute readers)
1548
- - `.option`: declares a single option taking option name and default value as arguments (also generates an attribute reader just like `.options`)
1562
+ - `.options`: declares a list of options by taking an option name array (symbols/strings). This generates option attribute accessors (e.g. `options :orientation, :bg_color` generates `#orientation`, `#orientation=(v)`, `#bg_color`, and `#bg_color=(v)` attribute accessors)
1563
+ - `.option`: declares a single option taking option name and default value as arguments (also generates attribute accessors just like `.options`)
1549
1564
 
1550
1565
  #### Content/Options Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1551
1566
 
@@ -1977,11 +1992,21 @@ glimmer samples/hello/hello_computed.rb # demonstrates computed data-binding
1977
1992
  For more elaborate samples, check the following:
1978
1993
 
1979
1994
  ```
1980
- glimmer samples/elaborate/login.rb # demonstrates general data-binding
1995
+ glimmer samples/elaborate/login.rb # demonstrates basic data-binding
1981
1996
  glimmer samples/elaborate/contact_manager.rb # demonstrates table data-binding
1982
1997
  glimmer samples/elaborate/tic_tac_toe.rb # demonstrates a full MVC application
1983
1998
  ```
1984
1999
 
2000
+ ### External Samples
2001
+
2002
+ #### [Glimmer Calculator](https://github.com/AndyObtiva/glimmer-cs-calculator)
2003
+
2004
+ ![Glimmer Calculator](https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-calculator/v1.0.0/glimmer-cs-calculator-screenshot.png)
2005
+
2006
+ [Glimmer Calculator](https://github.com/AndyObtiva/glimmer-cs-calculator) is a basic calculator sample project demonstrating data-binding and TDD (test-driven-development) with Glimmer following the MVP pattern (Model-View-Presenter).
2007
+
2008
+ #### [Gladiator](https://github.com/AndyObtiva/glimmer-cs-gladiator)
2009
+
1985
2010
  ![Gladiator](https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/v0.1.5/images/glimmer-gladiator.png)
1986
2011
 
1987
2012
  [Gladiator](https://github.com/AndyObtiva/glimmer-cs-gladiator) (short for Glimmer Editor) is a Glimmer sample project under on-going development.
@@ -2111,33 +2136,20 @@ Glimmer apps may be packaged and distributed on the Mac, Windows, and Linux via
2111
2136
  - Warbler (https://github.com/jruby/warbler): Enables bundling a Glimmer app into a JAR file
2112
2137
  - javapackager (https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javapackager.html): Enables packaging a JAR file as a DMG file on Mac, EXE on Windows, and multiple Linux supported formats on Linux.
2113
2138
 
2114
- Glimmer simplifies the process for Mac packaging by providing a rake task.
2115
-
2116
- To use:
2117
- - Create `Rakefile` in your app root directory
2118
- - Add the following line to it: `require 'glimmer/rake_task'`
2119
- - Create a Ruby script under bin (e.g. `bin/math_bowling`) to require the application file that uses Glimmer (e.g. `'../app/my_application.rb'`):
2120
- ```ruby
2121
- require_relative '../app/my_application.rb'
2122
- ```
2123
- - Include Icon (Optional): If you'd like to include an icon for your app (.icns format on the Mac), place it under `package/macosx` matching the humanized application local directory name (e.g. 'Math Bowling.icns' [containing space] for MathBowling or math_bowling). You may generate your Mac icon easily using tools like Image2Icon (http://www.img2icnsapp.com/) or manually using the Mac terminal command `iconutil` (iconutil guide: https://applehelpwriter.com/tag/iconutil/)
2124
- - Include Version (Optional): Create a `VERSION` file in your application and fill it your app version on one line (e.g. `1.1.0`)
2125
- - Include License (Optional): Create a `LICENSE.txt` file in your application and fill it up with your license (e.g. MIT). It will show up to people when installing your app. Note that, you may optionally also specify license type, but you'd have to do so manually via `-BlicenseType=MIT` shown in an [example below](#javapackager-extra-arguments).
2126
- - Extra args (Optional): You may optionally add the following to `Rakefile` to configure extra arguments for javapackager: `Glimmer::Packager.javapackager_extra_args = "..."` (Useful to avoid re-entering extra arguments on every run of rake task.). Read about them in [their section below](#javapackager-extra-arguments).
2139
+ Glimmer simplifies the process of Mac packaging via the `glimmer package` command. It works out of the box for any application generated by [Glimmer Scaffolding](https://github.com/AndyObtiva/glimmer/blob/master/README.md#scaffolding):
2127
2140
 
2128
- Now, you can run the following rake command to package your app into a Mac DMG file (using both Warbler and javapackager):
2129
2141
  ```
2130
- rake glimmer:package
2142
+ glimmer package
2131
2143
  ```
2132
2144
 
2133
- This will generate a JAR file under `./dist` directory, which is then used to generate a DMG file (and pkg/app) under `./packages/bundles`.
2145
+ This will automatically generate a JAR file under `./dist` directory using Warbler, which is then used to automatically generate a DMG file (and pkg/app) under `./packages/bundles` using `javapackager`.
2134
2146
  JAR file name will match your application local directory name (e.g. `MathBowling.jar` for `~/code/MathBowling`)
2135
2147
  DMG file name will match the humanized local directory name + dash + application version (e.g. `Math Bowling-1.0.dmg` for `~/code/MathBowling` with version 1.0 or unspecified)
2136
2148
 
2137
- THe rake task will automatically set "mac.CFBundleIdentifier" to ="org.#{project_name}.application.#{project_name}".
2149
+ The `glimmer package` command will automatically set "mac.CFBundleIdentifier" to ="org.#{project_name}.application.#{project_name}".
2138
2150
  You may override by configuring as an extra argument for javapackger (e.g. Glimmer::Package.javapackager_extra_args = " -Bmac.CFBundleIdentifier=org.andymaleh.application.MathBowling")
2139
2151
 
2140
- ### Defaults
2152
+ ### Packaging Defaults
2141
2153
 
2142
2154
  Glimmer employs smart defaults in packaging.
2143
2155
 
@@ -2145,13 +2157,24 @@ The package application name (shows up in top menu bar on the Mac) will be a hum
2145
2157
 
2146
2158
  Also, the package will only include these directories: app, config, db, lib, script, bin, docs, fonts, images, sounds, videos
2147
2159
 
2148
- After running once, you will find a `config/warble.rb` file. It has the JAR packaging configuration. You may adjust included directories in it if needed, and then rerun `rake glimmer:package` and it will pick up your custom configuration. Alternatively, if you'd like to customize the included directories to begin with, don't run `rake glimmer:package` right away. Run this command first:
2160
+ After running once, you will find a `config/warble.rb` file. It has the JAR packaging configuration. You may adjust included directories in it if needed, and then rerun `glimmer package` and it will pick up your custom configuration. Alternatively, if you'd like to customize the included directories to begin with, don't run `glimmer package` right away. Run this command first:
2149
2161
 
2150
2162
  ```
2151
- rake glimmer:package:config
2163
+ glimmer package:config
2152
2164
  ```
2153
2165
 
2154
- This will generate `config/warble.rb`, which you may configure and then run `rake glimmer:package` afterwards.
2166
+ This will generate `config/warble.rb`, which you may configure and then run `glimmer package` afterwards.
2167
+
2168
+ ### Packaging Configuration
2169
+
2170
+ - Ensure you have a Ruby script under `bin` directory that launches the application, preferably matching your project directory name (e.g. `bin/math_bowling`) :
2171
+ ```ruby
2172
+ require_relative '../app/my_application.rb'
2173
+ ```
2174
+ - Include Icon (Optional): If you'd like to include an icon for your app (.icns format on the Mac), place it under `package/macosx` matching the humanized application local directory name (e.g. 'Math Bowling.icns' [containing space] for MathBowling or math_bowling). You may generate your Mac icon easily using tools like Image2Icon (http://www.img2icnsapp.com/) or manually using the Mac terminal command `iconutil` (iconutil guide: https://applehelpwriter.com/tag/iconutil/)
2175
+ - Include Version (Optional): Create a `VERSION` file in your application and fill it your app version on one line (e.g. `1.1.0`)
2176
+ - Include License (Optional): Create a `LICENSE.txt` file in your application and fill it up with your license (e.g. MIT). It will show up to people when installing your app. Note that, you may optionally also specify license type, but you'd have to do so manually via `-BlicenseType=MIT` shown in an [example below](#javapackager-extra-arguments).
2177
+ - Extra args (Optional): You may optionally add the following to `Rakefile` to configure extra arguments for javapackager: `Glimmer::Packager.javapackager_extra_args = "..."` (Useful to avoid re-entering extra arguments on every run of rake task.). Read about them in [their section below](#javapackager-extra-arguments).
2155
2178
 
2156
2179
  ### javapackager Extra Arguments
2157
2180
 
@@ -2179,7 +2202,7 @@ https://developer.apple.com/library/archive/releasenotes/General/SubmittingToMac
2179
2202
  Example (env var):
2180
2203
 
2181
2204
  ```
2182
- JAVAPACKAGER_EXTRA_ARGS='-Bmac.CFBundleName="Math Bowling Game"' rake glimmer:package
2205
+ JAVAPACKAGER_EXTRA_ARGS='-Bmac.CFBundleName="Math Bowling Game"' glimmer package
2183
2206
  ```
2184
2207
 
2185
2208
  That overrides the default application display name.
@@ -2224,7 +2247,7 @@ Example:
2224
2247
  Glimmer::Package.javapackager_extra_args = '-Bmac.signing-key-developer-id-app="Andy Maleh"'
2225
2248
  ```
2226
2249
 
2227
- Now, when you run `rake glimmer:package`, it builds a self-signed DMG file. When you make available online, and users download, upon launching application, they are presented with your certificate, which they have to sign if they trust you in order to use the application.
2250
+ Now, when you run `glimmer package`, it builds a self-signed DMG file. When you make available online, and users download, upon launching application, they are presented with your certificate, which they have to sign if they trust you in order to use the application.
2228
2251
 
2229
2252
  ### Gotchas
2230
2253
 
@@ -2241,7 +2264,7 @@ Glimmer::Package.javapackager_extra_args = '-srcfiles "ACME.txt" -BlicenseFile="
2241
2264
 
2242
2265
  2. Mounted DMG Residue
2243
2266
 
2244
- If you run `rake glimmer:package` multiple times, sometimes it leaves a mounted DMG project in your finder. Unmount before you run the command again or it might fail with an error saying: "Error: Bundler "DMG Installer" (dmg) failed to produce a bundle."
2267
+ If you run `glimmer package` multiple times, sometimes it leaves a mounted DMG project in your finder. Unmount before you run the command again or it might fail with an error saying: "Error: Bundler "DMG Installer" (dmg) failed to produce a bundle."
2245
2268
 
2246
2269
  By the way, keep in mind that during normal operation, it does also indicate a false-negative while completing successfully similar to the following (please ignore):
2247
2270
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.7
1
+ 0.7.8
@@ -0,0 +1,26 @@
1
+ require 'glimmer/dsl/static_expression'
2
+ require 'glimmer/dsl/parent_expression'
3
+ require 'glimmer/dsl/top_level_expression'
4
+ require 'glimmer/swt/shell_proxy'
5
+
6
+ module Glimmer
7
+ module DSL
8
+ module SWT
9
+ class DialogExpression < StaticExpression
10
+ include TopLevelExpression
11
+ include ParentExpression
12
+
13
+ def can_interpret?(parent, keyword, *args, &block)
14
+ keyword == 'dialog' and
15
+ (parent.nil? or parent.is_a?(Glimmer::SWT::ShellProxy))
16
+ end
17
+
18
+ def interpret(parent, keyword, *args, &block)
19
+ args = [parent] + args unless parent.nil?
20
+ args += [:dialog_trim, :application_modal]
21
+ Glimmer::SWT::ShellProxy.send(:new, *args)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -8,7 +8,7 @@ module Glimmer
8
8
  OPERATING_SYSTEMS_SUPPORTED = ["mac", "windows", "linux"]
9
9
 
10
10
  TEXT_USAGE_PREFIX = <<~MULTI_LINE_STRING
11
- Usage: glimmer [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
11
+ Usage: glimmer [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
12
12
 
13
13
  Runs Glimmer applications/tasks.
14
14
 
@@ -27,8 +27,9 @@ module Glimmer
27
27
  Optionally, extra Glimmer options, JRuby options and environment variables may be passed in.
28
28
 
29
29
  Glimmer options:
30
- - "--debug" : Displays extra debugging information and passes "--debug" to JRuby
31
- - "--log-level=VALUE" : Sets Glimmer's Ruby logger level ("ERROR" / "WARN" / "INFO" / "DEBUG"; default is "WARN")
30
+ - "--quiet" : Does not announce file path of Glimmer application being launched nor enable logging
31
+ - "--debug" : Displays extra debugging information, passes "--debug" to JRuby, and enables debug logging
32
+ - "--log-level=VALUE" : Sets Glimmer's Ruby logger level ("ERROR" / "WARN" / "INFO" / "DEBUG"; default is none)
32
33
 
33
34
  Example: glimmer samples/hello_world.rb
34
35
 
@@ -37,7 +38,7 @@ module Glimmer
37
38
 
38
39
  GLIMMER_LIB_LOCAL = File.expand_path(File.join(__FILE__, '..', '..', 'glimmer.rb'))
39
40
  GLIMMER_LIB_GEM = 'glimmer'
40
- GLIMMER_OPTIONS = %w[--log-level]
41
+ GLIMMER_OPTIONS = %w[--log-level --quiet]
41
42
  GLIMMER_OPTION_ENV_VAR_MAPPING = {
42
43
  '--log-level' => 'GLIMMER_LOGGER_LEVEL'
43
44
  }
@@ -77,8 +78,8 @@ module Glimmer
77
78
  end
78
79
 
79
80
  def glimmer_option_env_vars(glimmer_options)
80
- glimmer_options.reduce({}) do |hash, pair|
81
- hash.merge(GLIMMER_OPTION_ENV_VAR_MAPPING[pair.first] => pair.last)
81
+ GLIMMER_OPTION_ENV_VAR_MAPPING.reduce({}) do |hash, pair|
82
+ glimmer_options[pair.first] ? hash.merge(GLIMMER_OPTION_ENV_VAR_MAPPING[pair.first] => glimmer_options[pair.first]) : hash
82
83
  end
83
84
  end
84
85
 
@@ -108,7 +109,7 @@ module Glimmer
108
109
  Rake::Task[rake_task].invoke(*rake_task_args)
109
110
  else
110
111
  @@mutex.synchronize do
111
- puts "Launching Glimmer Application: #{application}" unless application.to_s.match(/(irb)|(gladiator)/)
112
+ puts "Launching Glimmer Application: #{application}" if jruby_options_string.to_s.include?('--debug') || glimmer_options['--quiet'].to_s.downcase != 'true'
112
113
  end
113
114
  command = "#{env_vars_string} jruby #{jruby_options_string}#{jruby_os_specific_options} #{devmode_require}-r #{the_glimmer_lib} -S #{application}"
114
115
  puts command if jruby_options_string.to_s.include?('--debug')
@@ -123,6 +124,8 @@ module Glimmer
123
124
  attr_reader :jruby_options
124
125
 
125
126
  def initialize(raw_options)
127
+ raw_options << '--quiet' if !caller.join("\n").include?('/bin/glimmer:') && !raw_options.join.include?('--quiet=')
128
+ raw_options << '--log-level=DEBUG' if raw_options.join.include?('--debug') && !raw_options.join.include?('--log-level=')
126
129
  @application_paths = extract_application_paths(raw_options)
127
130
  @env_vars = extract_env_vars(raw_options)
128
131
  @glimmer_options = extract_glimmer_options(raw_options)
@@ -140,7 +143,7 @@ module Glimmer
140
143
  private
141
144
 
142
145
  def launch_application
143
- load File.expand_path('./Rakefile') if File.exist?(File.expand_path('./Rakefile'))
146
+ load File.expand_path('./Rakefile') if File.exist?(File.expand_path('./Rakefile')) && caller.join("\n").include?('/bin/glimmer:')
144
147
  threads = @application_paths.map do |application_path|
145
148
  Thread.new do
146
149
  self.class.launch(
@@ -188,8 +191,8 @@ module Glimmer
188
191
  end.each do |glimmer_option|
189
192
  options.delete(glimmer_option)
190
193
  end.reduce({}) do |hash, glimmer_option_string|
191
- match = glimmer_option_string.match(/^([^=]+)=?(.*)$/)
192
- hash.merge(match[1] => match[2])
194
+ match = glimmer_option_string.match(/^([^=]+)=?(.+)?$/)
195
+ hash.merge(match[1] => (match[2] || 'true'))
193
196
  end
194
197
  end
195
198
  end
@@ -76,9 +76,9 @@ namespace :glimmer do
76
76
  Scaffold.custom_widget(args[:custom_widget_name], args[:namespace])
77
77
  end
78
78
 
79
- desc 'Scaffold a Glimmer::UI::CustomShell subclass (represents a full window view) under its own Ruby gem project (namespace is required)'
80
- task :custom_shell_gem, [:custom_widget_name, :namespace] do |t, args|
81
- Scaffold.custom_shell_gem(args[:custom_widget_name], args[:namespace])
79
+ desc 'Scaffold a Glimmer::UI::CustomShell subclass (represents a full window view) under its own Ruby gem + app project (namespace is required)'
80
+ task :custom_shell_gem, [:custom_shell_name, :namespace] do |t, args|
81
+ Scaffold.custom_shell_gem(args[:custom_shell_name], args[:namespace])
82
82
  end
83
83
 
84
84
  desc 'Scaffold a Glimmer::UI::CustomWidget subclass (represents a part of a view) under its own Ruby gem project (namespace is required)'
@@ -107,7 +107,7 @@ class Scaffold
107
107
  RAKEFILE = <<~MULTI_LINE_STRING
108
108
  require 'glimmer/rake_task'
109
109
 
110
- ## Uncomment the following section if you would like to customize javapackager
110
+ ## Use the following configuration if you would like to customize javapackager
111
111
  ## arguments for `glimmer package` command.
112
112
  #
113
113
  # Glimmer::Package.javapackager_extra_args =
@@ -146,7 +146,7 @@ class Scaffold
146
146
  write "app/#{file_name(app_name)}.rb", app_main_file(app_name)
147
147
  mkdir 'app/models'
148
148
  mkdir 'app/views'
149
- custom_shell('AppView', current_dir_name)
149
+ custom_shell('AppView', current_dir_name, :app)
150
150
  if OS.mac?
151
151
  mkdir_p 'package/macosx'
152
152
  icon_file = "package/macosx/#{human_name(app_name)}.icns"
@@ -161,12 +161,12 @@ class Scaffold
161
161
  # TODO generate rspec test suite
162
162
  end
163
163
 
164
- def custom_shell(custom_shell_name, namespace)
164
+ def custom_shell(custom_shell_name, namespace, shell_type = nil)
165
165
  namespace ||= current_dir_name
166
166
  root_dir = File.exists?('app') ? 'app' : 'lib'
167
167
  parent_dir = "#{root_dir}/views/#{file_name(namespace)}"
168
168
  mkdir_p parent_dir unless File.exists?(parent_dir)
169
- write "#{parent_dir}/#{file_name(custom_shell_name)}.rb", custom_shell_file(custom_shell_name, namespace)
169
+ write "#{parent_dir}/#{file_name(custom_shell_name)}.rb", custom_shell_file(custom_shell_name, namespace, shell_type)
170
170
  end
171
171
 
172
172
  def custom_widget(custom_widget_name, namespace)
@@ -179,7 +179,7 @@ class Scaffold
179
179
 
180
180
  def custom_shell_gem(custom_shell_name, namespace)
181
181
  gem_name = "glimmer-cs-#{compact_name(custom_shell_name)}"
182
- gem_summary = "Glimmer Custom Widget - #{human_name(custom_shell_name)}"
182
+ gem_summary = "#{human_name(custom_shell_name)} - Glimmer Custom Shell"
183
183
  if namespace
184
184
  gem_name += "-#{compact_name(namespace)}"
185
185
  gem_summary += " (#{human_name(namespace)})"
@@ -196,9 +196,10 @@ class Scaffold
196
196
  write 'Rakefile', gem_rakefile(custom_shell_name, namespace)
197
197
  append "lib/#{gem_name}.rb", gem_main_file(custom_shell_name, namespace)
198
198
  mkdir 'lib/views'
199
- custom_shell(custom_shell_name, namespace)
199
+ custom_shell(custom_shell_name, namespace, :gem)
200
200
  mkdir 'bin'
201
- write "bin/#{file_name(custom_shell_name)}", gem_bin_file(gem_name, custom_shell_name, namespace)
201
+ write "bin/#{gem_name}", gem_bin_file(gem_name, custom_shell_name, namespace)
202
+ write "bin/#{file_name(custom_shell_name)}", gem_bin_command_file(gem_name)
202
203
  FileUtils.chmod 0755, "bin/#{file_name(custom_shell_name)}"
203
204
  if OS.mac?
204
205
  mkdir_p 'package/macosx'
@@ -217,7 +218,7 @@ class Scaffold
217
218
 
218
219
  def custom_widget_gem(custom_widget_name, namespace)
219
220
  gem_name = "glimmer-cw-#{compact_name(custom_widget_name)}"
220
- gem_summary = "Glimmer Custom Widget - #{human_name(custom_widget_name)}"
221
+ gem_summary = "#{human_name(custom_widget_name)} - Glimmer Custom Widget"
221
222
  if namespace
222
223
  gem_name += "-#{compact_name(namespace)}"
223
224
  gem_summary += " (#{human_name(namespace)})"
@@ -291,7 +292,8 @@ class Scaffold
291
292
  include Glimmer
292
293
 
293
294
  APP_ROOT = File.expand_path('../..', __FILE__)
294
- VERSION = File.read(File.expand_path('VERSION', APP_ROOT))
295
+ VERSION = File.read(File.join(APP_ROOT, 'VERSION'))
296
+ LICENSE = File.read(File.join(APP_ROOT, 'LICENSE.txt'))
295
297
 
296
298
  def open
297
299
  app_view.open
@@ -335,13 +337,30 @@ class Scaffold
335
337
  MULTI_LINE_STRING
336
338
  end
337
339
 
340
+ def gem_bin_command_file(gem_name)
341
+ <<~MULTI_LINE_STRING
342
+ #!/usr/bin/env ruby
343
+
344
+ require 'glimmer/launcher'
345
+
346
+ runner = File.expand_path("../#{gem_name}", __FILE__)
347
+ launcher = Glimmer::Launcher.new([runner] + ARGV)
348
+ launcher.launch
349
+ MULTI_LINE_STRING
350
+ end
351
+
338
352
  def gem_rakefile(custom_shell_name = nil, namespace = nil)
339
353
  rakefile_content = File.read('Rakefile')
340
354
  lines = rakefile_content.split("\n")
341
355
  require_rake_line_index = lines.index(lines.detect {|l| l.include?("require 'rake'") })
342
356
  lines.insert(require_rake_line_index, "require 'glimmer/launcher'")
343
357
  gem_files_line_index = lines.index(lines.detect {|l| l.include?('# dependencies defined in Gemfile') })
344
- lines.insert(gem_files_line_index, " gem.files = Dir['lib/**/*.rb']")
358
+ if custom_shell_name
359
+ lines.insert(gem_files_line_index, " gem.files = Dir['VERSION', 'LICENSE.txt', 'lib/**/*.rb', 'bin/**/*']")
360
+ lines.insert(gem_files_line_index+1, " gem.executables = ['#{file_name(custom_shell_name)}']")
361
+ else
362
+ lines.insert(gem_files_line_index, " gem.files = Dir['lib/**/*.rb']")
363
+ end
345
364
  spec_pattern_line_index = lines.index(lines.detect {|l| l.include?('spec.pattern =') })
346
365
  lines.insert(spec_pattern_line_index+1, " spec.ruby_opts = [Glimmer::Launcher.jruby_swt_options]")
347
366
  lines << "\nrequire 'glimmer/rake_task'\n"
@@ -382,52 +401,143 @@ class Scaffold
382
401
  lines.join("\n")
383
402
  end
384
403
 
385
- def custom_shell_file(custom_shell_name, namespace)
404
+ def custom_shell_file(custom_shell_name, namespace, shell_type)
386
405
  namespace_type = class_name(namespace) == class_name(current_dir_name) ? 'class' : 'module'
387
406
 
388
- <<~MULTI_LINE_STRING
389
- #{namespace_type} #{class_name(namespace)}
390
- class #{class_name(custom_shell_name)}
391
- include Glimmer::UI::CustomShell
392
-
393
- ## Add options like the following to configure CustomShell by outside consumers
394
- #
395
- # options :title, :background_color
396
- # option :width, 320
397
- # option :height, 240
398
-
399
- ## Uncomment before_body block to pre-initialize variables to use in body
400
- #
401
- #
402
- # before_body {
403
- #
404
- # }
405
-
406
- ## Uncomment after_body block to setup observers for widgets in body
407
- #
408
- # after_body {
409
- #
410
- # }
407
+ custom_shell_file_content = <<-MULTI_LINE_STRING
408
+ #{namespace_type} #{class_name(namespace)}
409
+ class #{class_name(custom_shell_name)}
410
+ include Glimmer::UI::CustomShell
411
+
412
+ MULTI_LINE_STRING
413
+
414
+ if shell_type == :gem
415
+ custom_shell_file_content += <<-MULTI_LINE_STRING
416
+ GEM_ROOT = File.expand_path('../../../..', __FILE__)
417
+ VERSION = File.read(File.join(GEM_ROOT, 'VERSION'))
418
+ LICENSE = File.read(File.join(GEM_ROOT, 'LICENSE.txt'))
411
419
 
412
- ## Add widget content inside custom shell body
413
- ## Top-most widget must be a shell or another custom shell
414
- #
415
- body {
416
- shell {
417
- # Replace example content below with custom shell content
418
- minimum_size 320, 240
419
- text "#{human_name(namespace)} - #{human_name(custom_shell_name)}"
420
- grid_layout
421
- label {
422
- text "Hello, World!"
423
- font height: 40
424
- layout_data :center, :center, true, true
425
- }
420
+ MULTI_LINE_STRING
421
+ end
422
+
423
+ custom_shell_file_content += <<-MULTI_LINE_STRING
424
+ ## Add options like the following to configure CustomShell by outside consumers
425
+ #
426
+ # options :title, :background_color
427
+ # option :width, 320
428
+ # option :height, 240
429
+ option :greeting, 'Hello, World!'
430
+
431
+ ## Use before_body block to pre-initialize variables to use in body
432
+ #
433
+ #
434
+ MULTI_LINE_STRING
435
+
436
+ if %i[gem app].include?(shell_type)
437
+ custom_shell_file_content += <<-MULTI_LINE_STRING
438
+ before_body {
439
+ Display.setAppName('#{shell_type == :gem ? human_name(custom_shell_name) : human_name(namespace)}')
440
+ Display.setAppVersion(VERSION)
441
+ }
442
+ MULTI_LINE_STRING
443
+ else
444
+ custom_shell_file_content += <<-MULTI_LINE_STRING
445
+ # before_body {
446
+ #
447
+ # }
448
+ MULTI_LINE_STRING
449
+ end
450
+
451
+ custom_shell_file_content += <<-MULTI_LINE_STRING
452
+
453
+ ## Use after_body block to setup observers for widgets in body
454
+ #
455
+ # after_body {
456
+ #
457
+ # }
458
+
459
+ ## Add widget content inside custom shell body
460
+ ## Top-most widget must be a shell or another custom shell
461
+ #
462
+ body {
463
+ shell {
464
+ # Replace example content below with custom shell content
465
+ minimum_size 320, 240
466
+ text "#{human_name(namespace)} - #{human_name(custom_shell_name)}"
467
+ grid_layout
468
+ MULTI_LINE_STRING
469
+
470
+ if %i[gem app].include?(shell_type)
471
+ custom_shell_file_content += <<-MULTI_LINE_STRING
472
+ on_about {
473
+ display_about_dialog
474
+ }
475
+ on_preferences {
476
+ display_preferences_dialog
477
+ }
478
+ MULTI_LINE_STRING
479
+ end
480
+
481
+ custom_shell_file_content += <<-MULTI_LINE_STRING
482
+ label(:center) {
483
+ text bind(self, :greeting)
484
+ font height: 40
485
+ layout_data :fill, :center, true, true
486
+ }
487
+ }
488
+ }
489
+ MULTI_LINE_STRING
490
+
491
+ if %i[gem app].include?(shell_type)
492
+ custom_shell_file_content += <<-MULTI_LINE_STRING
493
+
494
+ def display_about_dialog
495
+ message_box = MessageBox.new(swt_widget)
496
+ message_box.setText("About")
497
+ message = "#{human_name(namespace)} - #{human_name(custom_shell_name)} \#{VERSION}\n\n"
498
+ message += LICENSE
499
+ message_box.setMessage(message)
500
+ message_box.open
501
+ end
502
+
503
+ def display_preferences_dialog
504
+ dialog(swt_widget) {
505
+ text 'Preferences'
506
+ grid_layout {
507
+ margin_height 5
508
+ margin_width 5
509
+ }
510
+ group {
511
+ row_layout {
512
+ type :vertical
513
+ spacing 10
514
+ }
515
+ text 'Greeting'
516
+ font style: :bold
517
+ [
518
+ 'Hello, World!',
519
+ 'Howdy, Partner!'
520
+ ].each do |greeting_text|
521
+ button(:radio) {
522
+ text greeting_text
523
+ selection bind(self, :greeting) { |g| g == greeting_text }
524
+ layout_data {
525
+ width 160
526
+ }
527
+ on_widget_selected { |event|
528
+ self.greeting = event.widget.getText
426
529
  }
427
530
  }
428
-
429
531
  end
430
- end
532
+ }
533
+ }.open
534
+ end
535
+ MULTI_LINE_STRING
536
+ end
537
+
538
+ custom_shell_file_content += <<-MULTI_LINE_STRING
539
+ end
540
+ end
431
541
  MULTI_LINE_STRING
432
542
  end
433
543
 
@@ -444,14 +554,14 @@ class Scaffold
444
554
  # options :custom_text, :background_color
445
555
  # option :foreground_color, :red
446
556
 
447
- ## Uncomment before_body block to pre-initialize variables to use in body
557
+ ## Use before_body block to pre-initialize variables to use in body
448
558
  #
449
559
  #
450
560
  # before_body {
451
561
  #
452
562
  # }
453
563
 
454
- ## Uncomment after_body block to setup observers for widgets in body
564
+ ## Use after_body block to setup observers for widgets in body
455
565
  #
456
566
  # after_body {
457
567
  #
@@ -83,7 +83,7 @@ module Glimmer
83
83
  else
84
84
  new_options = new_options.reduce({}) {|new_options_hash, new_option| new_options_hash.merge(new_option => nil)}
85
85
  @options = options.merge(new_options)
86
- def_option_attr_readers(new_options)
86
+ def_option_attr_accessors(new_options)
87
87
  end
88
88
  end
89
89
 
@@ -91,15 +91,18 @@ module Glimmer
91
91
  new_option = new_option.to_s.to_sym
92
92
  new_options = {new_option => new_option_default}
93
93
  @options = options.merge(new_options)
94
- def_option_attr_readers(new_options)
94
+ def_option_attr_accessors(new_options)
95
95
  end
96
96
 
97
- def def_option_attr_readers(new_options)
97
+ def def_option_attr_accessors(new_options)
98
98
  new_options.each do |option, default|
99
99
  class_eval <<-end_eval, __FILE__, __LINE__
100
100
  def #{option}
101
101
  options[:#{option}]
102
102
  end
103
+ def #{option}=(option_value)
104
+ self.options[:#{option}] = option_value
105
+ end
103
106
  end_eval
104
107
  end
105
108
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.7
4
+ version: 0.7.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-28 00:00:00.000000000 Z
11
+ date: 2020-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -216,6 +216,7 @@ files:
216
216
  - lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb
217
217
  - lib/glimmer/dsl/swt/custom_widget_expression.rb
218
218
  - lib/glimmer/dsl/swt/data_binding_expression.rb
219
+ - lib/glimmer/dsl/swt/dialog_expression.rb
219
220
  - lib/glimmer/dsl/swt/display_expression.rb
220
221
  - lib/glimmer/dsl/swt/dsl.rb
221
222
  - lib/glimmer/dsl/swt/exec_expression.rb