glimmer 2.6.0 → 2.7.0

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: d0270d930a2379147403b0ed98ad22d38fc737a4bd45cac8a079b873db3b26b0
4
- data.tar.gz: 002ea9f8c526d059ec0401397c0a2feb624f2333222b40e628a814275568ae7a
3
+ metadata.gz: 2ffd3369029bb8e3b291c4885ff034ec303595578341e947e21071d86bb90ad0
4
+ data.tar.gz: ba20e80562daf4dd96512e1c4dd4ff0dc3fb015a7039712c80805d2b211b95db
5
5
  SHA512:
6
- metadata.gz: 8034dbe6953955e23c2a355f211337fb9593e8722251ed35152af4b587422c675e675dd93e0d6b8ef9a04145f5a2ebbf364ed83f8a17296f7f4c4a83c711eb3c
7
- data.tar.gz: 6f43bac5604f4759bbdcea11a0b1a84b68c24e7e087862f00f4bb7145ecfe0085ae1cbabe379c96a6f19c22465faa62c13bcfaeedc1f8390129e177d5318c0f5
6
+ metadata.gz: a5f25a4abf5eaa792ee955145cfb94449831d7b2da3479152d1d4bd2872eec053b3e9c730e3c94713a0a552a00215239bb6a907a191c3e29aea2e5ed2a307c7c
7
+ data.tar.gz: 5356bc6024b81b3524793fe7feb2b1d858a830af308ee002da5445cd172c04839a104a0e28cdff8c095045268a05b363cdea60fbdc052647aeab5c16f40979cf
data/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  Related Change Logs:
4
4
  - [glimmer-dsl-swt/CHANGELOG.md](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/CHANGELOG.md)
5
5
 
6
+ ### 2.7.0
7
+
8
+ - Support Hash keyed properties via `ModelBinding` (e.g. property as `some_hash_attribute[:some_key]`, `some_hash_attribute['some_key']`, `some_hash_attribute["some_key"]`)
9
+
6
10
  ### 2.6.0
7
11
 
8
12
  - If a static expression cannot handle keyword, it is tried with available dynamic expressions instead of erroring out.
data/README.md CHANGED
@@ -1,12 +1,11 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 style="position: relative; top: 20px;" />](https://rubygems.org/gems/glimmer) Glimmer - DSL Framework for Ruby GUI and More
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 style="position: relative; top: 20px;" />](https://rubygems.org/gems/glimmer) Glimmer 2.7.0
2
+ ## DSL Framework for Ruby GUI and More
2
3
  [![Gem Version](https://badge.fury.io/rb/glimmer.svg)](http://badge.fury.io/rb/glimmer)
3
4
  [![rspec](https://github.com/AndyObtiva/glimmer/workflows/rspec/badge.svg)](https://github.com/AndyObtiva/glimmer/actions?query=workflow%3Arspec)
4
5
  [![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer?branch=master)
5
6
  [![Maintainability](https://api.codeclimate.com/v1/badges/38fbc278022862794414/maintainability)](https://codeclimate.com/github/AndyObtiva/glimmer/maintainability)
6
7
  [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
7
8
 
8
- **[Contributors Wanted! (Submit a Glimmer App Sample to Get Started)](#contributing)**
9
-
10
9
  **(The Original Glimmer Library Handling the World’s Ruby GUI Needs Since 2007. Beware of Imitators!)**
11
10
 
12
11
  [**Glimmer**](https://rubygems.org/gems/glimmer) started out as a [GUI Library](https://github.com/AndyObtiva/glimmer-dsl-swt) and grew into a full-fledged [DSL Framework](#dsl-engine) with support for multiple GUI DSLs. Glimmer's namesake is referring to the Glimmer of Ruby in Graphical User Interfaces (contrary to [popular myth](http://blog.headius.com/2007/11/tab-sweep.html) perpetrated by [Charles Nutter](http://blog.headius.com/2007/11/tab-sweep.html), Glimmer has nothing to do with the ill-fated Whitney Houston movie, which does not in fact share the same name)
@@ -29,14 +28,19 @@ Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) an
29
28
 
30
29
  Start by checking out [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt), Glimmer's original GUI DSL (for [JRuby](https://www.jruby.org/)), which got extracted into its own gem; and [Glimmer DSL for LibUI](https://github.com/AndyObtiva/glimmer-dsl-libui), Glimmer's CRuby GUI DSL, which has no prerequisites beyond installing the Ruby gem.
31
30
 
32
- [**Glimmer**](https://rubygems.org/gems/glimmer) supports the following DSLs:
33
- - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
34
- - [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)
35
- - [glimmer-dsl-libui](https://github.com/AndyObtiva/glimmer-dsl-libui): Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development GUI Library)
36
- - [glimmer-dsl-tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (MRI Ruby Desktop Development GUI Library)
37
- - [glimmer-dsl-gtk](https://github.com/AndyObtiva/glimmer-dsl-gtk): Glimmer DSL for GTK (Ruby-GNOME Desktop Development GUI Library)
38
- - [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
39
- - [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS
31
+ **[Glimmer](https://rubygems.org/gems/glimmer) DSL Comparison Table:**
32
+ DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
33
+ ----|-----------|---------|------------------|------|------|--------
34
+ [Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)](https://github.com/AndyObtiva/glimmer-dsl-swt) | Mac / Windows / Linux | Yes | Yes (Canvas Shape DSL) | Very Mature / Scaffolding / Native Executable Packaging / Custom Widgets | Slow JRuby Startup Time / Heavy Memory Footprint | Java / JRuby
35
+ [Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)](https://github.com/AndyObtiva/glimmer-dsl-opal) | All Web Browsers | No | Yes (Canvas Shape DSL) | Simpler than All JavaScript Technologies / Auto-Webify Desktop Apps | Setup Process / Incomplete Alpha | Rails
36
+ [Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-libui) | Mac / Windows / Linux | Yes | Yes (Area API) | Very Simple Setup / Fast Startup Time / Light Memory Footprint | LibUI is an Incomplete Mid-Alpha Only | None Other Than MRI Ruby
37
+ [Glimmer DSL for Tk (MRI Ruby Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-tk) | Mac / Windows / Linux | Some Native-Themed Widgets (Not Truly Native) | Yes (Canvas) | Fast Startup Time / Light Memory Footprint | Complicated setup / Widgets Do Not Look Truly Native, Espcially on Linux | ActiveTcl / MRI Ruby
38
+ [Glimmer DSL for GTK (Ruby-GNOME Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-gtk) | Mac / Windows / Linux | Only on Linux | Yes (Cairo) | Complete Access to GNOME Features on Linux | Not Native on Mac and Windows | None Other Than MRI Ruby on Linux / Brew Packages on Mac / MSYS & MING Toolchains on Windows / MRI Ruby
39
+ [Glimmer DSL for FX (FOX Toolkit Ruby Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-fx) | Mac (requires XQuartz) / Windows / Linux | No | Yes (Canvas) | No Prerequisites on Windows | Widgets Do Not Look Native / Mac Usage Obtrusively Starts XQuartz | None Other Than MRI Ruby on Windows / XQuarts on Mac / MRI Ruby
40
+ [Glimmer DSL for JFX (JRuby JavaFX Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-jfx) | Mac / Windows / Linux | No | Yes (javafx.scene.shape and javafx.scene.canvas) | Rich in Custom Widgets | Slow JRuby Startup Time / Heavy Memory Footprint / Widgets Do Not Look Native | Java / JRuby / JavaFX SDK
41
+ [Glimmer DSL for Swing (JRuby Swing Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-swing) | Mac / Windows / Linux | No | Yes (Java2D) | Very Mature | Slow JRuby Startup Time / Heavy Memory Footprint / Widgets Do Not Look Native | Java / JRuby
42
+ [Glimmer DSL for XML (& HTML)](https://github.com/AndyObtiva/glimmer-dsl-xml) | All Web Browsers | No | Yes (SVG) | Programmable / Lighter-weight Than Actual XML | XML Elements Are Sometimes Not Well-Named (Many Types of Input) | None
43
+ [Glimmer DSL for CSS](https://github.com/AndyObtiva/glimmer-dsl-css) | All Web Browsers | No | Yes | Programmable | CSS Is Over-Engineered / Too Many Features To Learn | None
40
44
 
41
45
  ## Table of Contents
42
46
 
@@ -52,6 +56,10 @@ Start by checking out [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimme
52
56
  - [Glimmer DSL for Tk (MRI Ruby Desktop Development GUI Library)](#glimmer-dsl-for-tk-mri-ruby-desktop-development-gui-library)
53
57
  - [Glimmer DSL for XML (& HTML)](#glimmer-dsl-for-xml--html)
54
58
  - [Glimmer DSL for CSS](#glimmer-dsl-for-css)
59
+ - [Glimmer DSL for GTK (Ruby-GNOME Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-gtk)
60
+ - [Glimmer DSL for FX (FOX Toolkit Ruby Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-fx)
61
+ - [Glimmer DSL for JFX (JRuby JavaFX Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-jfx)
62
+ - [Glimmer DSL for Swing (JRuby Swing Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-swing)
55
63
  - [Data-Binding Library](#data-binding-library)
56
64
  - [Glimmer Process](#glimmer-process)
57
65
  - [Resources](#resources)
@@ -72,7 +80,8 @@ Glimmer is fundamentally a DSL Engine that can support any number of DSLs like t
72
80
  Glimmer DSL syntax consists mainly of:
73
81
  - **keywords** (e.g. `table` for a table widget)
74
82
  - **style/args** (e.g. :multi as in `table(:multi)` for a multi-line selection table widget)
75
- - **content (nested attributes/keywords)** (e.g. `{ table_column { text 'Name'} }` as in `table(:multi) { table_column { text 'Name'} }` for a multi-line selection table widget with a table column having header text property `'Name'` as content)
83
+ - **content (nested properties/keywords/listeners)** (e.g. `{ table_column { text 'Name'} }` as in `table(:multi) { table_column { text 'Name'} }` for a multi-line selection table widget with a table column having header text property `'Name'` as content)
84
+ - **methods** (e.g. `shell.show` opens a window)
76
85
 
77
86
  Here is a Hello, World! example from [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt):
78
87
 
@@ -232,7 +241,7 @@ end
232
241
  ### Setup
233
242
 
234
243
  Follow these steps to author a [Glimmer](https://rubygems.org/gems/glimmer) DSL:
235
- - Add `gem 'glimmer', '~> 2.6.0'` to `Gemfile` and run `bundle` or run `gem install glimmer -v2.6.0` and add `require 'glimmer'`
244
+ - Add `gem 'glimmer', '~> 2.7.0'` to `Gemfile` and run `bundle` or run `gem install glimmer -v2.7.0` and add `require 'glimmer'`
236
245
  - Create `glimmer/dsl/[dsl_name]/dsl.rb`, which requires and adds all dynamic expressions for the [dsl_name] Glimmer DSL module as per the code shown in the previous section (or [Official DSLs](#official-dsls) as examples)
237
246
  - Create `glimmer/dsl/[dsl_name]/[expresion_name]_expresion.rb` for every [expresion_name] expression needed, whether dynamic or static
238
247
 
@@ -1231,7 +1240,7 @@ Glimmer::DataBinding::Observer.proc do |new_value, changed_key|
1231
1240
  end.observe(hash)
1232
1241
  ```
1233
1242
 
1234
- If you would like to observe nested model attribute changes and/or indexed array changes (specifying a nested array index/indices), you can use the more advanced `Glimmer::DataBinding::ModelBinding` class instead.
1243
+ If you would like to observe nested model attribute changes, you can use the more advanced `Glimmer::DataBinding::ModelBinding` class instead.
1235
1244
 
1236
1245
  Example of observing nested model attributes:
1237
1246
 
@@ -1241,7 +1250,7 @@ ModelBinding.new(model, "address1.street").add_observer do |new_address1_street_
1241
1250
  end
1242
1251
  ```
1243
1252
 
1244
- Example of observing indexed array changes (combined with a nested model attribute):
1253
+ Example of observing indexed array changes (specifying an array index) (combined with a nested model attribute):
1245
1254
 
1246
1255
  ```ruby
1247
1256
  ModelBinding.new(model, "employees[5].name").add_observer do |new_employee_6_name|
@@ -1257,10 +1266,19 @@ ModelBinding.new(model, "grid[5][7]").add_observer do |new_grid_cell_value|
1257
1266
  end
1258
1267
  ```
1259
1268
 
1269
+ Example of observing keyed hash changes (specifying a hash key as `Symbol` or single/double-quoted `String`) (combined with a nested model attribute):
1270
+
1271
+ ```ruby
1272
+ ModelBinding.new(model, "employees[:manager].name").add_observer do |new_employee_6_name|
1273
+ # Do some work with new manager employee's name
1274
+ end
1275
+ ```
1276
+
1260
1277
  Data-bound `ModelBinding` attribute can be:
1261
1278
  - **Direct:** `Symbol` representing attribute reader/writer (e.g. `[person, :name`])
1262
1279
  - **Nested:** `String` representing nested attribute path (e.g. `[company, 'address.street']`). That results in "nested data-binding"
1263
1280
  - **Indexed:** `String` containing array attribute index (e.g. `[customer, 'addresses[0].street']`). That results in "indexed data-binding"
1281
+ - **Keyed:** `String` containing hash attribute key (e.g. `[customer, 'addresses[:main].street']`). That results in "keyed data-binding"
1264
1282
 
1265
1283
  Data-binding options include:
1266
1284
  - `before_read {|value| ...}`: performs an operation before reading data from Model to update View.
@@ -1315,6 +1333,7 @@ Learn more by reading the [GPG](PROCESS.md) (Glimmer Process Guidelines)
1315
1333
 
1316
1334
  ## Resources
1317
1335
 
1336
+ * [Glimmer DSL for SWT Video Tutorials](https://andymaleh.blogspot.com/search/label/Tutorial+SWT)
1318
1337
  * [Code Master Blog](http://andymaleh.blogspot.com/search/label/Glimmer)
1319
1338
  * [JRuby Cookbook by Justin Edelson & Henry Liu](http://shop.oreilly.com/product/9780596519650.do)
1320
1339
  * [MountainWest RubyConf 2011 Video](https://confreaks.tv/videos/mwrc2011-whatever-happened-to-desktop-development-in-ruby)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.6.0
1
+ 2.7.0
data/glimmer.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: glimmer 2.6.0 ruby lib
5
+ # stub: glimmer 2.7.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer".freeze
9
- s.version = "2.6.0"
9
+ s.version = "2.7.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["AndyMaleh".freeze]
14
- s.date = "2022-01-22"
14
+ s.date = "2022-02-20"
15
15
  s.description = "Glimmer is a Ruby DSL Framework for Ruby GUI and More, consisting of a DSL Engine and an Observable / Observer / Data-Binding Library (including Observable Model, Observable Array, and Observable Hash). Used in Glimmer DSL for SWT (JRuby Desktop Development GUI Framework), Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps), Glimmer DSL for Tk (Ruby Desktop Development GUI Library), Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development GUI Library), Glimmer DSL for GTK (Ruby-GNOME Desktop Development GUI Library), Glimmer DSL for XML (& HTML), and Glimmer DSL for CSS.".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
17
  s.extra_rdoc_files = [
@@ -27,6 +27,11 @@ module Glimmer
27
27
  class ModelBinding
28
28
  include Observable
29
29
  include Observer
30
+
31
+ ARRAY_INDEXED_PROPERTY_ARGUMENT_REGEX = /\d+/
32
+ HASH_SYMBOL_INDEXED_PROPERTY_ARGUMENT_REGEX = /:[^:]+/
33
+ HASH_SINGLE_QUOTE_INDEXED_PROPERTY_ARGUMENT_REGEX = /'[^']+'/
34
+ HASH_DOUBLE_QUOTE_INDEXED_PROPERTY_ARGUMENT_REGEX = /"[^"]+"/
30
35
 
31
36
  attr_reader :binding_options, :property_name_expression
32
37
 
@@ -206,7 +211,7 @@ module Glimmer
206
211
  def call(value, *extra_args)
207
212
  return if model.nil?
208
213
  converted_value = value
209
- invoke_property_writer(model, model.is_a?(Hash) ? property_name : "#{property_name}=", converted_value) unless converted_value == evaluate_property || property_name.nil?
214
+ invoke_property_writer(model, model.is_a?(Hash) && !property_indexed?(property_name) ? property_name : "#{property_name}=", converted_value) unless converted_value == evaluate_property || property_name.nil?
210
215
  end
211
216
 
212
217
  def evaluate_property
@@ -260,7 +265,7 @@ module Glimmer
260
265
  if property_indexed?(property_expression)
261
266
  property_method = '[]'
262
267
  property_argument = property_expression[1...-1]
263
- property_argument = property_argument.to_i if property_argument.match(/\d+/)
268
+ property_argument = indexed_property_argument(property_argument)
264
269
  object.send(property_method, property_argument)
265
270
  else
266
271
  if property_expression.nil?
@@ -281,7 +286,7 @@ module Glimmer
281
286
  if property_indexed?(property_expression)
282
287
  property_method = '[]='
283
288
  property_argument = property_expression[1...-2]
284
- property_argument = property_argument.to_i if property_argument.match(/\d+/)
289
+ property_argument = indexed_property_argument(property_argument)
285
290
  object.send(property_method, property_argument, converted_value)
286
291
  else
287
292
  if object.is_a?(Hash)
@@ -292,6 +297,20 @@ module Glimmer
292
297
  end
293
298
  apply_processor(@binding_options[:after_write], converted_value)
294
299
  end
300
+
301
+ def indexed_property_argument(property_argument)
302
+ if property_argument.match(ARRAY_INDEXED_PROPERTY_ARGUMENT_REGEX)
303
+ property_argument.to_i
304
+ elsif property_argument.match(HASH_SYMBOL_INDEXED_PROPERTY_ARGUMENT_REGEX)
305
+ property_argument.sub(':', '').to_sym
306
+ elsif property_argument.match(HASH_SINGLE_QUOTE_INDEXED_PROPERTY_ARGUMENT_REGEX)
307
+ property_argument.gsub("'", '')
308
+ elsif property_argument.match(HASH_DOUBLE_QUOTE_INDEXED_PROPERTY_ARGUMENT_REGEX)
309
+ property_argument.gsub('"', '')
310
+ else
311
+ property_argument
312
+ end
313
+ end
295
314
  end
296
315
  end
297
316
  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: 2.6.0
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-22 00:00:00.000000000 Z
11
+ date: 2022-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: array_include_methods