glimmer 0.9.5 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +34 -26
- data/VERSION +1 -1
- data/lib/glimmer.rb +3 -3
- data/lib/glimmer/config.rb +10 -7
- data/lib/glimmer/data_binding/observable_model.rb +1 -1
- data/lib/glimmer/dsl/engine.rb +3 -3
- data/lib/glimmer/dsl/expression_handler.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c67def84181cab028446e3087c2c22d091bb0b17d02aa91e3948a8d7b176113
|
4
|
+
data.tar.gz: a2613dc9b58d1ef2d048b93f695e2aef799b06c46ec85999a78ecb48a6c5d469
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbab9c4d0212aa47f46dd73394c05a47ebb95d1b18afb1b76b7400c72ae188f849776f411e3808b3fbd75537d3c7ca416fe3bcf90c08aba17e3058a8bccbc228
|
7
|
+
data.tar.gz: f913e477fa27d42e46614470e3e9e3c18fafd08e2a8fb6eb65c579b6a5894884e61da5203fc0df1d41fd4860f5dc4b435c123c6b5822a4056f6c01bfb4854ff2
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ Glimmer DSL gems:
|
|
17
17
|
- [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (Desktop GUI)
|
18
18
|
- [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Web GUI Adapter for Desktop Apps)
|
19
19
|
- [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
|
20
|
-
- [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS
|
20
|
+
- [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS
|
21
21
|
|
22
22
|
## Examples
|
23
23
|
|
@@ -251,7 +251,7 @@ Otherwise, Option 2 ([Bundler](#option-2-bundler)) is recommended for building G
|
|
251
251
|
|
252
252
|
Run this command to install directly:
|
253
253
|
```
|
254
|
-
jgem install glimmer-dsl-swt -v 0.
|
254
|
+
jgem install glimmer-dsl-swt -v 0.4.1
|
255
255
|
```
|
256
256
|
|
257
257
|
`jgem` is JRuby's version of `gem` command.
|
@@ -269,7 +269,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
|
|
269
269
|
|
270
270
|
Add the following to `Gemfile`:
|
271
271
|
```
|
272
|
-
gem 'glimmer-dsl-swt', '~> 0.
|
272
|
+
gem 'glimmer-dsl-swt', '~> 0.4.1'
|
273
273
|
```
|
274
274
|
|
275
275
|
And, then run:
|
@@ -484,7 +484,10 @@ The Ruby gem name will follow the convention "glimmer-cw-customwidgetname-namesp
|
|
484
484
|
|
485
485
|
Only official Glimmer gems created by the Glimmer project committers will have no namespace (e.g. [glimmer-cw-video](https://rubygems.org/gems/glimmer-cw-video) Ruby gem)
|
486
486
|
|
487
|
-
|
487
|
+
Examples:
|
488
|
+
|
489
|
+
- [glimmer-cw-video](https://github.com/AndyObtiva/glimmer-cw-video): Video Widget
|
490
|
+
- [glimmer-cw-cdatetime-nebula](https://github.com/AndyObtiva/glimmer-cw-cdatetime-nebula): Nebula CDateTime Widget
|
488
491
|
|
489
492
|
### Gem Listing
|
490
493
|
|
@@ -569,7 +572,7 @@ Output:
|
|
569
572
|
|
570
573
|
Css glimmer-dsl-css 0.1.0 AndyMaleh Glimmer DSL for CSS
|
571
574
|
Opal glimmer-dsl-opal 0.0.9 AndyMaleh Glimmer DSL for Opal
|
572
|
-
Swt glimmer-dsl-swt 0.
|
575
|
+
Swt glimmer-dsl-swt 0.4.1 AndyMaleh Glimmer DSL for SWT
|
573
576
|
Xml glimmer-dsl-xml 0.1.0 AndyMaleh Glimmer DSL for XML
|
574
577
|
|
575
578
|
```
|
@@ -761,7 +764,7 @@ automatically uses the display created earlier without having to explicitly hook
|
|
761
764
|
```ruby
|
762
765
|
@display = display {
|
763
766
|
cursor_location 300, 300
|
764
|
-
|
767
|
+
on_swt_keydown {
|
765
768
|
# ...
|
766
769
|
}
|
767
770
|
# ...
|
@@ -1721,10 +1724,10 @@ Glimmer comes with `Observer` module, which is used internally for data-binding,
|
|
1721
1724
|
|
1722
1725
|
Glimmer supports observing widgets with two main types of events:
|
1723
1726
|
1. `on_{swt-listener-method-name}`: where {swt-listener-method-name} is replaced with the lowercase underscored event method name on an SWT listener class (e.g. `on_verify_text` for `org.eclipse.swt.events.VerifyListener#verifyText`).
|
1724
|
-
2. `
|
1727
|
+
2. `on_swt_{swt-event-constant}`: where {swt-event-constant} is replaced with an [`org.eclipse.swt.SWT`](https://help.eclipse.org/2020-06/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/SWT.html) event constant (e.g. `on_swt_show` for `SWT.Show` to observe when widget becomes visible)
|
1725
1728
|
|
1726
1729
|
Additionally, there are two more types of events:
|
1727
|
-
- SWT `display` supports global listeners called filters that run on any widget. They are hooked via `
|
1730
|
+
- SWT `display` supports global listeners called filters that run on any widget. They are hooked via `on_swt_{swt-event-constant}`
|
1728
1731
|
- SWT `display` supports Mac application menu item observers (`on_about` and `on_preferences`), which you can read about under [Miscellaneous](#miscellaneous).
|
1729
1732
|
|
1730
1733
|
Number 1 is more commonly used in SWT applications, so make it your starting point. Number 2 covers events not found in number 1, so look into it if you don't find an SWT listener you need in number 1.
|
@@ -1769,21 +1772,21 @@ Note that every Tic Tac Toe grid cell has its `text` and `enabled` properties da
|
|
1769
1772
|
|
1770
1773
|
Next however, each of these Tic Tac Toe grid cells, which are clickable buttons, have an `on_widget_selected` observer, which once triggered, marks the cell on the `TicTacToe::Board` to make a move.
|
1771
1774
|
|
1772
|
-
**Regarding number 2**, you can figure out all available events by looking at the `org.eclipse.swt.SWT` API:
|
1775
|
+
**Regarding number 2**, you can figure out all available events by looking at the [`org.eclipse.swt.SWT`](https://help.eclipse.org/2020-06/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/SWT.html) API:
|
1773
1776
|
|
1774
1777
|
https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/SWT.html
|
1775
1778
|
|
1776
1779
|
Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
1777
1780
|
|
1778
|
-
`SWT.Show` - hooks a listener for showing a widget (using `
|
1779
|
-
`SWT.Hide` - hooks a listener for hiding a widget (using `
|
1781
|
+
`SWT.Show` - hooks a listener for showing a widget (using `on_swt_show` in Glimmer)
|
1782
|
+
`SWT.Hide` - hooks a listener for hiding a widget (using `on_swt_hide` in Glimmer)
|
1780
1783
|
|
1781
1784
|
```ruby
|
1782
1785
|
shell {
|
1783
1786
|
@button1 = button {
|
1784
1787
|
text "Show 2nd Button"
|
1785
1788
|
visible true
|
1786
|
-
|
1789
|
+
on_swt_show {
|
1787
1790
|
@button2.swt_widget.setVisible(false)
|
1788
1791
|
}
|
1789
1792
|
on_widget_selected {
|
@@ -1793,7 +1796,7 @@ shell {
|
|
1793
1796
|
@button2 = button {
|
1794
1797
|
text "Show 1st Button"
|
1795
1798
|
visible false
|
1796
|
-
|
1799
|
+
on_swt_show {
|
1797
1800
|
@button1.swt_widget.setVisible(false)
|
1798
1801
|
}
|
1799
1802
|
on_widget_selected {
|
@@ -1803,7 +1806,7 @@ shell {
|
|
1803
1806
|
}.open
|
1804
1807
|
```
|
1805
1808
|
|
1806
|
-
**Gotcha:** SWT.Resize event needs to be hooked using **`
|
1809
|
+
**Gotcha:** SWT.Resize event needs to be hooked using **`on_swt_Resize`** because [`org.eclipse.swt.SWT`](https://help.eclipse.org/2020-06/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/SWT.html) has 2 constants for resize: `RESIZE` and `Resize`, so it cannot infer the right one automatically from the underscored version `on_swt_resize`
|
1807
1810
|
|
1808
1811
|
##### Alternative Syntax
|
1809
1812
|
|
@@ -2097,7 +2100,7 @@ shell { |app_shell|
|
|
2097
2100
|
@current_step_number = 1
|
2098
2101
|
@wizard_steps = 5.times.map { |n|
|
2099
2102
|
wizard_step(number: n+1, step_count: 5) {
|
2100
|
-
|
2103
|
+
on_swt_hide {
|
2101
2104
|
if @current_step_number < 5
|
2102
2105
|
@current_step_number += 1
|
2103
2106
|
app_shell.hide
|
@@ -2397,7 +2400,7 @@ Also, you may invoke `Display.setAppVersion('1.0.0')` if needed for OS app versi
|
|
2397
2400
|
|
2398
2401
|
#### Video Widget
|
2399
2402
|
|
2400
|
-

|
2403
|
+
[](https://github.com/AndyObtiva/glimmer-cw-video)
|
2401
2404
|
|
2402
2405
|
Glimmer supports a [video custom widget](https://github.com/AndyObtiva/glimmer-cw-video) not in SWT.
|
2403
2406
|
|
@@ -2449,17 +2452,16 @@ Glimmer configuration may be done via the `Glimmer::Config` module.
|
|
2449
2452
|
|
2450
2453
|
### logger
|
2451
2454
|
|
2452
|
-
Glimmer supports logging via a Ruby Logger
|
2453
|
-
It is
|
2454
|
-
|
2455
|
-
|
2456
|
-
|
2455
|
+
Glimmer supports logging via a standard `STDOUT` Ruby `Logger` configured in the `Glimmer::Config.logger` config option.
|
2456
|
+
It is set to level Logger::ERROR by default.
|
2457
|
+
Log level may be adjusted via `Glimmer::Config.logger.level` just like any other Ruby Logger.
|
2458
|
+
It may be replaced with a custom logger via `Glimmer::Config.logger = custom_logger`
|
2459
|
+
All logging is done lazily via blocks (e.g. `logger.debug {message}`) to avoid affecting app performance with logging when below the configured logging level threshold.
|
2457
2460
|
|
2458
2461
|
Example:
|
2459
2462
|
|
2460
2463
|
```ruby
|
2461
|
-
Glimmer::Config.
|
2462
|
-
Glimmer::Config.logger.level = Logger::DEBUG
|
2464
|
+
Glimmer::Config.logger.level = :debug
|
2463
2465
|
```
|
2464
2466
|
This results in more verbose debug loggging to `STDOUT`, which is very helpful in troubleshooting Glimmer DSL syntax when needed.
|
2465
2467
|
|
@@ -3067,13 +3069,15 @@ Glimmer DSL Engine specific tasks are at:
|
|
3067
3069
|
|
3068
3070
|
## Change Log
|
3069
3071
|
|
3072
|
+
[glimmer-dsl-swt/CHANGELOG.md](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/CHANGELOG.md)
|
3073
|
+
|
3070
3074
|
[CHANGELOG.md](CHANGELOG.md)
|
3071
3075
|
|
3072
3076
|
## Contributing
|
3073
3077
|
|
3074
3078
|
**Contributors Wanted!**
|
3075
3079
|
|
3076
|
-
If you would like to contribute to Glimmer, please study up on Glimmer and [SWT](#swt-reference), run all Glimmer [samples](#samples), and build a small sample app to add to [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) Hello or Elaborate samples via a Pull Request. Once done, contact me on [Chat](#chat).
|
3080
|
+
If you would like to contribute to Glimmer, please study up on Glimmer and [SWT](#swt-reference), run all Glimmer [samples](#samples), and build a small sample app (perhaps from [this TODO list](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/TODO.md#samples)) to add to [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) Hello or Elaborate samples via a Pull Request. Once done, contact me on [Chat](#chat).
|
3077
3081
|
|
3078
3082
|
You may apply for contributing to any of these Glimmer DSL gems whether you prefer to focus on the desktop or web:
|
3079
3083
|
- [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (Desktop GUI)
|
@@ -3096,7 +3100,11 @@ If your company would like to invest fulltime in further development of the Glim
|
|
3096
3100
|
|
3097
3101
|
## License
|
3098
3102
|
|
3099
|
-
|
3100
|
-
|
3103
|
+
[MIT](https://opensource.org/licenses/MIT)
|
3104
|
+
|
3105
|
+
Copyright (c) 2007-2020 - Andy Maleh.
|
3106
|
+
See [LICENSE.txt](LICENSE.txt) for further details.
|
3107
|
+
|
3108
|
+
--
|
3101
3109
|
|
3102
3110
|
Glimmer logo was made by <a href="https://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon"> www.flaticon.com</a>
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.10.0
|
data/lib/glimmer.rb
CHANGED
@@ -52,16 +52,16 @@ module Glimmer
|
|
52
52
|
if method_symbol.to_s.match(REGEX_METHODS_EXCLUDED)
|
53
53
|
raise ExcludedKeywordError, "Glimmer excluded keyword: #{method_symbol}"
|
54
54
|
end
|
55
|
-
Glimmer::Config.logger
|
55
|
+
Glimmer::Config.logger.debug {"Interpreting keyword: #{method_symbol}"}
|
56
56
|
Glimmer::DSL::Engine.interpret(method_symbol, *args, &block)
|
57
57
|
rescue ExcludedKeywordError => e
|
58
58
|
# TODO add a feature to show excluded keywords optionally for debugging purposes
|
59
59
|
super(method_symbol, *args, &block)
|
60
60
|
rescue InvalidKeywordError => e
|
61
61
|
if !method_symbol.to_s.match(REGEX_METHODS_EXCLUDED)
|
62
|
-
Glimmer::Config.logger
|
62
|
+
Glimmer::Config.logger.error {e.message}
|
63
63
|
end
|
64
|
-
Glimmer::Config.logger
|
64
|
+
Glimmer::Config.logger.debug {"#{e.message}\n#{e.backtrace.join("\n")}"}
|
65
65
|
super(method_symbol, *args, &block)
|
66
66
|
end
|
67
67
|
end
|
data/lib/glimmer/config.rb
CHANGED
@@ -11,20 +11,23 @@ module Glimmer
|
|
11
11
|
|
12
12
|
# Returns Glimmer logger (standard Ruby logger)
|
13
13
|
def logger
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
reset_logger! unless defined? @@logger
|
15
|
+
@@logger
|
16
|
+
end
|
17
|
+
|
18
|
+
def logger=(custom_logger)
|
19
|
+
@@logger = custom_logger
|
18
20
|
end
|
19
21
|
|
20
|
-
def
|
21
|
-
|
22
|
+
def reset_logger!
|
23
|
+
self.logger = Logger.new(STDOUT).tap do |logger|
|
24
|
+
logger.level = Logger::ERROR
|
25
|
+
end
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
26
30
|
|
27
31
|
if ENV['GLIMMER_LOGGER_LEVEL']
|
28
|
-
Glimmer::Config.enable_logging
|
29
32
|
Glimmer::Config.logger.level = ENV['GLIMMER_LOGGER_LEVEL'].downcase
|
30
33
|
end
|
@@ -70,7 +70,7 @@ module Glimmer
|
|
70
70
|
end
|
71
71
|
rescue => e
|
72
72
|
#ignore writing if no property writer exists
|
73
|
-
Glimmer::Config.logger
|
73
|
+
Glimmer::Config.logger.debug {"No need to observe property writer: #{property_writer_name}\n#{e.message}\n#{e.backtrace.join("\n")}"}
|
74
74
|
end
|
75
75
|
|
76
76
|
def unregister_dependent_observers(property_name, old_value)
|
data/lib/glimmer/dsl/engine.rb
CHANGED
@@ -96,7 +96,7 @@ module Glimmer
|
|
96
96
|
dynamic_expression_chains_of_responsibility[dsl] = expression_names.reverse.map do |expression_name|
|
97
97
|
expression_class(dsl_namespace, expression_name).new
|
98
98
|
end.reduce(nil) do |last_expresion_handler, expression|
|
99
|
-
Glimmer::Config.logger
|
99
|
+
Glimmer::Config.logger.debug {"Adding dynamic expression: #{expression.class.name}"}
|
100
100
|
expression_handler = ExpressionHandler.new(expression)
|
101
101
|
expression_handler.next = last_expresion_handler if last_expresion_handler
|
102
102
|
expression_handler
|
@@ -104,7 +104,7 @@ module Glimmer
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def add_static_expression(static_expression)
|
107
|
-
Glimmer::Config.logger
|
107
|
+
Glimmer::Config.logger.debug {"Adding static expression: #{static_expression.class.name}"}
|
108
108
|
keyword = static_expression.class.keyword
|
109
109
|
static_expression_dsl = static_expression.class.dsl
|
110
110
|
static_expressions[keyword] ||= {}
|
@@ -132,7 +132,7 @@ module Glimmer
|
|
132
132
|
if !static_expression.can_interpret?(Glimmer::DSL::Engine.parent, keyword, *args, &block)
|
133
133
|
raise Error, "Invalid use of Glimmer keyword #{keyword} with args #{args} under parent #{Glimmer::DSL::Engine.parent}"
|
134
134
|
else
|
135
|
-
Glimmer::Config.logger
|
135
|
+
Glimmer::Config.logger.debug {"#{static_expression.class.name} will handle expression keyword #{keyword}"}
|
136
136
|
static_expression.interpret(Glimmer::DSL::Engine.parent, keyword, *args, &block).tap do |ui_object|
|
137
137
|
Glimmer::DSL::Engine.add_content(ui_object, static_expression, &block) unless block.nil?
|
138
138
|
Glimmer::DSL::Engine.dsl_stack.pop
|
@@ -23,9 +23,9 @@ module Glimmer
|
|
23
23
|
# Otherwise, it forwards to the next handler configured via `#next=` method
|
24
24
|
# If there is no handler next, then it raises an error
|
25
25
|
def handle(parent, keyword, *args, &block)
|
26
|
-
Glimmer::Config.logger
|
26
|
+
Glimmer::Config.logger.debug {"Attempting to handle #{keyword} with #{@expression.class.name.split(":").last}"}
|
27
27
|
if @expression.can_interpret?(parent, keyword, *args, &block)
|
28
|
-
Glimmer::Config.logger
|
28
|
+
Glimmer::Config.logger.debug {"#{@expression.class.name} will handle expression keyword #{keyword}"}
|
29
29
|
return @expression
|
30
30
|
elsif @next_expression_handler
|
31
31
|
return @next_expression_handler.handle(parent, keyword, *args, &block)
|
@@ -34,7 +34,7 @@ module Glimmer
|
|
34
34
|
message = "Glimmer keyword #{keyword} with args #{args} cannot be handled"
|
35
35
|
message += " inside parent #{parent}" if parent
|
36
36
|
message += "! Check the validity of the code."
|
37
|
-
# Glimmer::Config.logger
|
37
|
+
# Glimmer::Config.logger.error {message}
|
38
38
|
raise InvalidKeywordError, message
|
39
39
|
end
|
40
40
|
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.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|