glimmer 1.0.7 → 1.0.8
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/CHANGELOG.md +5 -0
- data/README.md +120 -120
- data/VERSION +1 -1
- data/glimmer.gemspec +5 -4
- data/lib/glimmer.rb +1 -0
- data/lib/glimmer/data_binding/model_binding.rb +4 -4
- data/lib/glimmer/data_binding/observable_array.rb +5 -5
- data/lib/glimmer/data_binding/observable_model.rb +2 -2
- data/lib/glimmer/data_binding/observer.rb +2 -2
- data/lib/glimmer/dsl/engine.rb +10 -10
- metadata +22 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f3b9d6aa82ade846c56a4c1128d51fdcb7fcffbd5aa4e0c3a30272556538a07
|
4
|
+
data.tar.gz: bdbc807624d438309c9b6f5581056412d68008b14b60b28016cdd486b1d05270
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af20767a864c17dcb33decb04c24439f34a103dd1205e0adb79983227dcef684dfd7af6c1a6ccde7b9541befb7ddc027aa74d25dc0f07cc4c857cb2079b0f835
|
7
|
+
data.tar.gz: 9a1e882342a1a08912e365d2e7950e195b50a83b7a554a4df2de447151c324c1b91ecc93d56e10aaaf248b2dace385e184439ac50717bf81e8d39c4ef08e8d76
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,11 @@
|
|
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
|
+
## 1.0.8
|
7
|
+
|
8
|
+
- Concurrent Array/Hash/Set data structures to better support parallel multi-threading
|
9
|
+
- Fix issue with a certain nil static_expression case not handled properly in Glimmer::DSL::Engine
|
10
|
+
|
6
11
|
## 1.0.7
|
7
12
|
|
8
13
|
- Refactor generated `__original_{method_name}` methods in `ObservableModel` to have double-underscore after the word "original" as `__original__{method_name}` to improve clarity that the method is generated via meta-programming of a pre-existing method
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
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 1.0.
|
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 1.0.8 - DSL Framework
|
2
2
|
[](http://badge.fury.io/rb/glimmer)
|
3
3
|
[](https://github.com/AndyObtiva/glimmer/actions?query=workflow%3Arspec)
|
4
4
|
[](https://coveralls.io/github/AndyObtiva/glimmer?branch=master)
|
@@ -38,13 +38,13 @@ Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) an
|
|
38
38
|
|
39
39
|
## Table of Contents
|
40
40
|
|
41
|
-
- [Glimmer 1.0.
|
41
|
+
- [Glimmer 1.0.8](#-glimmer-108---dsl-framework)
|
42
42
|
- [Official DSLs](#official-dsls)
|
43
43
|
- [Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)](#glimmer-dsl-for-swt-jruby-desktop-development-gui-framework)
|
44
|
-
- [Glimmer DSL for Tk (Ruby Desktop Development GUI Library)](#glimmer-dsl-for-tk-ruby-desktop-development-gui-library)
|
45
44
|
- [Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)](#glimmer-dsl-for-opal-pure-ruby-web-gui-and-auto-webifier-of-desktop-apps)
|
46
45
|
- [Glimmer DSL for XML (& HTML)](#glimmer-dsl-for-xml--html)
|
47
46
|
- [Glimmer DSL for CSS](#glimmer-dsl-for-css)
|
47
|
+
- [Glimmer DSL for Tk (Ruby Desktop Development GUI Library)](#glimmer-dsl-for-tk-ruby-desktop-development-gui-library)
|
48
48
|
- [DSL Engine](#dsl-engine)
|
49
49
|
- [Multi-DSL Support](#multi-dsl-support)
|
50
50
|
- [Data-Binding Library](#data-binding-library)
|
@@ -254,123 +254,6 @@ Glimmer App:
|
|
254
254
|
|
255
255
|
[](https://github.com/AndyObtiva/MathBowling)
|
256
256
|
|
257
|
-
### Glimmer DSL for Tk (Ruby Desktop Development GUI Library)
|
258
|
-
|
259
|
-
[Tcl/Tk](https://www.tcl.tk/) has evolved into a practical desktop GUI toolkit due to gaining truely native looking widgets on Mac, Windows, and Linux in [Tk version 8.5](https://www.tcl.tk/software/tcltk/8.5.html#:~:text=Highlights%20of%20Tk%208.5&text=Font%20rendering%3A%20Now%20uses%20anti,and%20window%20layout%2C%20and%20more.).
|
260
|
-
|
261
|
-
Additionally, [Ruby](https://www.ruby-lang.org/en/) 3.0 Ractor (formerly known as [Guilds](https://olivierlacan.com/posts/concurrency-in-ruby-3-with-guilds/)) supports truly parallel multi-threading, making both [MRI](https://github.com/ruby/ruby) and [Tk](https://www.tcl.tk/) finally viable for support in [Glimmer](https://github.com/AndyObtiva/glimmer) (Ruby Desktop Development GUI Library) as an alternative to [JRuby on SWT](https://github.com/AndyObtiva/glimmer-dsl-swt).
|
262
|
-
|
263
|
-
The trade-off is that while [SWT](https://www.eclipse.org/swt/) provides a plethora of high quality reusable widgets for the Enterprise (such as [Nebula](https://www.eclipse.org/nebula/)), [Tk](https://www.tcl.tk/) enables very fast app startup time via [MRI Ruby](https://www.ruby-lang.org/en/).
|
264
|
-
|
265
|
-
[Glimmer DSL for Tk](https://github.com/AndyObtiva/glimmer-dsl-tk) aims to provide a DSL similar to the [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) to enable more productive desktop development in Ruby with:
|
266
|
-
- Declarative DSL syntax that visually maps to the GUI widget hierarchy
|
267
|
-
- Convention over configuration via smart defaults and automation of low-level details
|
268
|
-
- Requiring the least amount of syntax possible to build GUI
|
269
|
-
- Bidirectional Data-Binding to declaratively wire and automatically synchronize GUI with Business Models
|
270
|
-
- Custom Widget support
|
271
|
-
- Scaffolding for new custom widgets, apps, and gems
|
272
|
-
- Native-Executable packaging on Mac, Windows, and Linux
|
273
|
-
|
274
|
-
To get started, visit the [Glimmer DSL for Tk project page](https://github.com/AndyObtiva/glimmer-dsl-tk#pre-requisites) for instructions on installing the [glimmer-dsl-tk gem](https://rubygems.org/gems/glimmer-dsl-tk).
|
275
|
-
|
276
|
-
#### Glimmer DSL for Tk Samples
|
277
|
-
|
278
|
-
##### Hello, World!
|
279
|
-
|
280
|
-
Glimmer code (from [samples/hello/hello_world.rb](https://github.com/AndyObtiva/glimmer-dsl-tk/blob/master/samples/hello/hello_world.rb)):
|
281
|
-
|
282
|
-
```ruby
|
283
|
-
include Glimmer
|
284
|
-
|
285
|
-
root {
|
286
|
-
label {
|
287
|
-
text 'Hello, World!'
|
288
|
-
}
|
289
|
-
}.open
|
290
|
-
```
|
291
|
-
|
292
|
-
Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
|
293
|
-
|
294
|
-
```
|
295
|
-
ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_world.rb'"
|
296
|
-
```
|
297
|
-
|
298
|
-
Glimmer app:
|
299
|
-
|
300
|
-

|
301
|
-
|
302
|
-
##### Hello, Tab!
|
303
|
-
|
304
|
-
Glimmer code (from [samples/hello/hello_tab.rb](https://github.com/AndyObtiva/glimmer-dsl-tk/blob/master/samples/hello/hello_tab.rb)):
|
305
|
-
|
306
|
-
```ruby
|
307
|
-
include Glimmer
|
308
|
-
|
309
|
-
root {
|
310
|
-
title 'Hello, Tab!'
|
311
|
-
|
312
|
-
notebook {
|
313
|
-
frame(text: 'English') {
|
314
|
-
label {
|
315
|
-
text 'Hello, World!'
|
316
|
-
}
|
317
|
-
}
|
318
|
-
|
319
|
-
frame(text: 'French') {
|
320
|
-
label {
|
321
|
-
text 'Bonjour, Univers!'
|
322
|
-
}
|
323
|
-
}
|
324
|
-
}
|
325
|
-
}.open
|
326
|
-
```
|
327
|
-
|
328
|
-
Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
|
329
|
-
|
330
|
-
```
|
331
|
-
ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_tab.rb'"
|
332
|
-
```
|
333
|
-
|
334
|
-
Glimmer app:
|
335
|
-
|
336
|
-

|
337
|
-

|
338
|
-
|
339
|
-
##### Hello, Combo!
|
340
|
-
|
341
|
-
Glimmer code (from [samples/hello/hello_combo.rb](https://github.com/AndyObtiva/glimmer-dsl-tk/blob/master/samples/hello/hello_combo.rb)):
|
342
|
-
|
343
|
-
```ruby
|
344
|
-
# ... more code precedes
|
345
|
-
root {
|
346
|
-
title 'Hello, Combo!'
|
347
|
-
|
348
|
-
combobox { |proxy|
|
349
|
-
state 'readonly'
|
350
|
-
text bind(person, :country)
|
351
|
-
}
|
352
|
-
|
353
|
-
button { |proxy|
|
354
|
-
text "Reset Selection"
|
355
|
-
command {
|
356
|
-
person.reset_country
|
357
|
-
}
|
358
|
-
}
|
359
|
-
}.open
|
360
|
-
# ... more code follows
|
361
|
-
```
|
362
|
-
|
363
|
-
Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
|
364
|
-
|
365
|
-
```
|
366
|
-
ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_combo.rb'"
|
367
|
-
```
|
368
|
-
|
369
|
-
Glimmer app:
|
370
|
-
|
371
|
-

|
372
|
-

|
373
|
-
|
374
257
|
### Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)
|
375
258
|
|
376
259
|
[Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal) is an experimental proof-of-concept web GUI adapter for [Glimmer](https://github.com/AndyObtiva/glimmer) desktop apps (i.e. apps built with [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt)). It webifies them via [Rails](https://rubyonrails.org/), allowing Ruby desktop apps to run on the web via [Opal Ruby](https://opalrb.com/) without changing a line of code. Apps may then be custom-styled for the web with standard CSS.
|
@@ -657,6 +540,123 @@ Output:
|
|
657
540
|
body{font-size:1.1em;background:white}body > h1{background-color:red;font-size:2em}
|
658
541
|
```
|
659
542
|
|
543
|
+
### Glimmer DSL for Tk (Ruby Desktop Development GUI Library)
|
544
|
+
|
545
|
+
[Tcl/Tk](https://www.tcl.tk/) has evolved into a practical desktop GUI toolkit due to gaining truely native looking widgets on Mac, Windows, and Linux in [Tk version 8.5](https://www.tcl.tk/software/tcltk/8.5.html#:~:text=Highlights%20of%20Tk%208.5&text=Font%20rendering%3A%20Now%20uses%20anti,and%20window%20layout%2C%20and%20more.).
|
546
|
+
|
547
|
+
Additionally, [Ruby](https://www.ruby-lang.org/en/) 3.0 Ractor (formerly known as [Guilds](https://olivierlacan.com/posts/concurrency-in-ruby-3-with-guilds/)) supports truly parallel multi-threading, making both [MRI](https://github.com/ruby/ruby) and [Tk](https://www.tcl.tk/) finally viable for support in [Glimmer](https://github.com/AndyObtiva/glimmer) (Ruby Desktop Development GUI Library) as an alternative to [JRuby on SWT](https://github.com/AndyObtiva/glimmer-dsl-swt).
|
548
|
+
|
549
|
+
The trade-off is that while [SWT](https://www.eclipse.org/swt/) provides a plethora of high quality reusable widgets for the Enterprise (such as [Nebula](https://www.eclipse.org/nebula/)), [Tk](https://www.tcl.tk/) enables very fast app startup time via [MRI Ruby](https://www.ruby-lang.org/en/).
|
550
|
+
|
551
|
+
[Glimmer DSL for Tk](https://github.com/AndyObtiva/glimmer-dsl-tk) aims to provide a DSL similar to the [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) to enable more productive desktop development in Ruby with:
|
552
|
+
- Declarative DSL syntax that visually maps to the GUI widget hierarchy
|
553
|
+
- Convention over configuration via smart defaults and automation of low-level details
|
554
|
+
- Requiring the least amount of syntax possible to build GUI
|
555
|
+
- Bidirectional Data-Binding to declaratively wire and automatically synchronize GUI with Business Models
|
556
|
+
- Custom Widget support
|
557
|
+
- Scaffolding for new custom widgets, apps, and gems
|
558
|
+
- Native-Executable packaging on Mac, Windows, and Linux
|
559
|
+
|
560
|
+
To get started, visit the [Glimmer DSL for Tk project page](https://github.com/AndyObtiva/glimmer-dsl-tk#pre-requisites) for instructions on installing the [glimmer-dsl-tk gem](https://rubygems.org/gems/glimmer-dsl-tk).
|
561
|
+
|
562
|
+
#### Glimmer DSL for Tk Samples
|
563
|
+
|
564
|
+
##### Hello, World!
|
565
|
+
|
566
|
+
Glimmer code (from [samples/hello/hello_world.rb](https://github.com/AndyObtiva/glimmer-dsl-tk/blob/master/samples/hello/hello_world.rb)):
|
567
|
+
|
568
|
+
```ruby
|
569
|
+
include Glimmer
|
570
|
+
|
571
|
+
root {
|
572
|
+
label {
|
573
|
+
text 'Hello, World!'
|
574
|
+
}
|
575
|
+
}.open
|
576
|
+
```
|
577
|
+
|
578
|
+
Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
|
579
|
+
|
580
|
+
```
|
581
|
+
ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_world.rb'"
|
582
|
+
```
|
583
|
+
|
584
|
+
Glimmer app:
|
585
|
+
|
586
|
+

|
587
|
+
|
588
|
+
##### Hello, Tab!
|
589
|
+
|
590
|
+
Glimmer code (from [samples/hello/hello_tab.rb](https://github.com/AndyObtiva/glimmer-dsl-tk/blob/master/samples/hello/hello_tab.rb)):
|
591
|
+
|
592
|
+
```ruby
|
593
|
+
include Glimmer
|
594
|
+
|
595
|
+
root {
|
596
|
+
title 'Hello, Tab!'
|
597
|
+
|
598
|
+
notebook {
|
599
|
+
frame(text: 'English') {
|
600
|
+
label {
|
601
|
+
text 'Hello, World!'
|
602
|
+
}
|
603
|
+
}
|
604
|
+
|
605
|
+
frame(text: 'French') {
|
606
|
+
label {
|
607
|
+
text 'Bonjour, Univers!'
|
608
|
+
}
|
609
|
+
}
|
610
|
+
}
|
611
|
+
}.open
|
612
|
+
```
|
613
|
+
|
614
|
+
Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
|
615
|
+
|
616
|
+
```
|
617
|
+
ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_tab.rb'"
|
618
|
+
```
|
619
|
+
|
620
|
+
Glimmer app:
|
621
|
+
|
622
|
+

|
623
|
+

|
624
|
+
|
625
|
+
##### Hello, Combo!
|
626
|
+
|
627
|
+
Glimmer code (from [samples/hello/hello_combo.rb](https://github.com/AndyObtiva/glimmer-dsl-tk/blob/master/samples/hello/hello_combo.rb)):
|
628
|
+
|
629
|
+
```ruby
|
630
|
+
# ... more code precedes
|
631
|
+
root {
|
632
|
+
title 'Hello, Combo!'
|
633
|
+
|
634
|
+
combobox { |proxy|
|
635
|
+
state 'readonly'
|
636
|
+
text bind(person, :country)
|
637
|
+
}
|
638
|
+
|
639
|
+
button { |proxy|
|
640
|
+
text "Reset Selection"
|
641
|
+
command {
|
642
|
+
person.reset_country
|
643
|
+
}
|
644
|
+
}
|
645
|
+
}.open
|
646
|
+
# ... more code follows
|
647
|
+
```
|
648
|
+
|
649
|
+
Run (with the [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed):
|
650
|
+
|
651
|
+
```
|
652
|
+
ruby -r glimmer-dsl-tk -e "require '../samples/hello/hello_combo.rb'"
|
653
|
+
```
|
654
|
+
|
655
|
+
Glimmer app:
|
656
|
+
|
657
|
+

|
658
|
+

|
659
|
+
|
660
660
|
## DSL Engine
|
661
661
|
|
662
662
|
Glimmer is fundamentally a DSL Engine that can support any number of DSLs like the official Glimmer DSLs (gems starting with the `glimmer-dsl-` prefix like `glimmer-dsl-swt`) or any DSLs for that matter.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.8
|
data/glimmer.gemspec
CHANGED
@@ -2,20 +2,19 @@
|
|
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 1.0.
|
5
|
+
# stub: glimmer 1.0.8 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "glimmer".freeze
|
9
|
-
s.version = "1.0.
|
9
|
+
s.version = "1.0.8"
|
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 = "2021-01-
|
14
|
+
s.date = "2021-01-19"
|
15
15
|
s.description = "Glimmer is a Ruby DSL Framework consisting of a DSL Engine and an Observable/Observer/Data-Binding Library. Used in the Glimmer DSL for SWT (JRuby Desktop Development GUI Framework), the Glimmer DSL for Tk (Ruby Desktop Development GUI Library), the Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps), the Glimmer DSL for XML (& HTML), and the Glimmer DSL for CSS.".freeze
|
16
16
|
s.email = "andy.am@gmail.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
18
|
-
"CHANGELOG.md",
|
19
18
|
"LICENSE.txt",
|
20
19
|
"README.md"
|
21
20
|
]
|
@@ -55,6 +54,7 @@ Gem::Specification.new do |s|
|
|
55
54
|
if s.respond_to? :add_runtime_dependency then
|
56
55
|
s.add_runtime_dependency(%q<array_include_methods>.freeze, [">= 1.0.4", "< 2.0.0"])
|
57
56
|
s.add_runtime_dependency(%q<facets>.freeze, [">= 3.1.0", "< 4.0.0"])
|
57
|
+
s.add_runtime_dependency(%q<concurrent-ruby>.freeze, [">= 1.1.7", "< 2.0.0"])
|
58
58
|
s.add_development_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
|
59
59
|
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
60
60
|
s.add_development_dependency(%q<puts_debuggerer>.freeze, ["~> 0.10.0"])
|
@@ -68,6 +68,7 @@ Gem::Specification.new do |s|
|
|
68
68
|
else
|
69
69
|
s.add_dependency(%q<array_include_methods>.freeze, [">= 1.0.4", "< 2.0.0"])
|
70
70
|
s.add_dependency(%q<facets>.freeze, [">= 3.1.0", "< 4.0.0"])
|
71
|
+
s.add_dependency(%q<concurrent-ruby>.freeze, [">= 1.1.7", "< 2.0.0"])
|
71
72
|
s.add_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
|
72
73
|
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
73
74
|
s.add_dependency(%q<puts_debuggerer>.freeze, ["~> 0.10.0"])
|
data/lib/glimmer.rb
CHANGED
@@ -33,7 +33,7 @@ module Glimmer
|
|
33
33
|
def initialize(base_model, property_name_expression, binding_options = nil)
|
34
34
|
@base_model = base_model
|
35
35
|
@property_name_expression = property_name_expression
|
36
|
-
@binding_options = binding_options ||
|
36
|
+
@binding_options = binding_options || Concurrent::Hash.new
|
37
37
|
if computed?
|
38
38
|
@computed_model_bindings = computed_by.map do |computed_by_property_expression|
|
39
39
|
self.class.new(base_model, computed_by_property_expression)
|
@@ -120,9 +120,9 @@ module Glimmer
|
|
120
120
|
end
|
121
121
|
|
122
122
|
def nested_property_observers_for(observer)
|
123
|
-
@nested_property_observers_collection ||=
|
123
|
+
@nested_property_observers_collection ||= Concurrent::Hash.new
|
124
124
|
unless @nested_property_observers_collection.has_key?(observer)
|
125
|
-
@nested_property_observers_collection[observer] = nested_property_names.reduce(
|
125
|
+
@nested_property_observers_collection[observer] = nested_property_names.reduce(Concurrent::Hash.new) do |output, property_name|
|
126
126
|
output.merge(
|
127
127
|
property_name => Observer.proc do |new_value|
|
128
128
|
# Ensure reattaching observers when a higher level nested property is updated (e.g. person.address changes reattaches person.address.street observer)
|
@@ -164,7 +164,7 @@ module Glimmer
|
|
164
164
|
end
|
165
165
|
|
166
166
|
def computed_observer_for(observer)
|
167
|
-
@computed_observer_collection ||=
|
167
|
+
@computed_observer_collection ||= Concurrent::Hash.new
|
168
168
|
unless @computed_observer_collection.has_key?(observer)
|
169
169
|
@computed_observer_collection[observer] = Observer.proc do |new_value|
|
170
170
|
observer.call(evaluate_property)
|
@@ -34,7 +34,7 @@ module Glimmer
|
|
34
34
|
element_properties = element_properties.flatten.compact.uniq
|
35
35
|
return observer if has_observer?(observer) && has_observer_element_properties?(observer, element_properties)
|
36
36
|
property_observer_list << observer
|
37
|
-
observer_element_properties[observer] = element_properties_for(observer) + Set.new(element_properties)
|
37
|
+
observer_element_properties[observer] = element_properties_for(observer) + Concurrent::Set.new(element_properties)
|
38
38
|
each { |element| add_element_observer(element, observer) }
|
39
39
|
observer
|
40
40
|
end
|
@@ -55,7 +55,7 @@ module Glimmer
|
|
55
55
|
element_properties = element_properties.flatten.compact.uniq
|
56
56
|
if !element_properties.empty?
|
57
57
|
old_element_properties = element_properties_for(observer)
|
58
|
-
observer_element_properties[observer] = element_properties_for(observer) - Set.new(element_properties)
|
58
|
+
observer_element_properties[observer] = element_properties_for(observer) - Concurrent::Set.new(element_properties)
|
59
59
|
each { |element| element_properties.each { |property| observer.unobserve(element, property) } }
|
60
60
|
end
|
61
61
|
if element_properties_for(observer).empty?
|
@@ -87,15 +87,15 @@ module Glimmer
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def property_observer_list
|
90
|
-
@property_observer_list ||= Set.new
|
90
|
+
@property_observer_list ||= Concurrent::Set.new
|
91
91
|
end
|
92
92
|
|
93
93
|
def observer_element_properties
|
94
|
-
@observer_element_properties ||=
|
94
|
+
@observer_element_properties ||= Concurrent::Hash.new
|
95
95
|
end
|
96
96
|
|
97
97
|
def element_properties_for(observer)
|
98
|
-
observer_element_properties[observer] ||= Set.new
|
98
|
+
observer_element_properties[observer] ||= Concurrent::Set.new
|
99
99
|
end
|
100
100
|
|
101
101
|
def notify_observers
|
@@ -92,7 +92,7 @@ module Glimmer
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def property_observer_list(property_name)
|
95
|
-
property_observer_hash[property_name.to_sym] = Set.new unless property_observer_hash[property_name.to_sym]
|
95
|
+
property_observer_hash[property_name.to_sym] = Concurrent::Set.new unless property_observer_hash[property_name.to_sym]
|
96
96
|
property_observer_hash[property_name.to_sym]
|
97
97
|
end
|
98
98
|
|
@@ -137,7 +137,7 @@ module Glimmer
|
|
137
137
|
end
|
138
138
|
|
139
139
|
def array_object_observer_for(property_name)
|
140
|
-
@array_object_observers ||=
|
140
|
+
@array_object_observers ||= Concurrent::Hash.new
|
141
141
|
@array_object_observers[property_name] = ObservableModel::Notifier.new(self, property_name) unless @array_object_observers.has_key?(property_name)
|
142
142
|
@array_object_observers[property_name]
|
143
143
|
end
|
@@ -61,7 +61,7 @@ module Glimmer
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def registrations
|
64
|
-
@registrations ||= Set.new
|
64
|
+
@registrations ||= Concurrent::Set.new
|
65
65
|
end
|
66
66
|
|
67
67
|
def registration_for(observable, property = nil)
|
@@ -75,7 +75,7 @@ module Glimmer
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def dependents_for(registration)
|
78
|
-
dependents[registration] ||= Set.new
|
78
|
+
dependents[registration] ||= Concurrent::Set.new
|
79
79
|
end
|
80
80
|
|
81
81
|
# registers observer in an observable on a property (optional)
|
data/lib/glimmer/dsl/engine.rb
CHANGED
@@ -28,7 +28,7 @@ module Glimmer
|
|
28
28
|
module DSL
|
29
29
|
# Glimmer DSL Engine
|
30
30
|
#
|
31
|
-
# Follows Interpreter
|
31
|
+
# Follows Interpreter, Chain of Responsibility, and Singleton Design Patterns
|
32
32
|
#
|
33
33
|
# When DSL engine interprets an expression, it attempts to handle
|
34
34
|
# with ordered expression array specified via `.expressions=` method.
|
@@ -55,8 +55,8 @@ module Glimmer
|
|
55
55
|
raise Glimmer::Error, "Unsupported keyword: #{keyword}" unless static_expression_dsl || retrieved_static_expression
|
56
56
|
Glimmer::DSL::Engine.dsl_stack.push(static_expression_dsl || Glimmer::DSL::Engine.dsl)
|
57
57
|
static_expression = Glimmer::DSL::Engine.static_expressions[keyword][Glimmer::DSL::Engine.dsl]
|
58
|
-
if !static_expression.can_interpret?(Glimmer::DSL::Engine.parent, keyword, *args, &block)
|
59
|
-
raise Error, "Invalid use of Glimmer keyword #{keyword} with args #{args} under parent #{Glimmer::DSL::Engine.parent}"
|
58
|
+
if static_expression.nil? || !static_expression.can_interpret?(Glimmer::DSL::Engine.parent, keyword, *args, &block)
|
59
|
+
raise Error, "Invalid use of Glimmer keyword #{keyword} with args #{args} under parent #{Glimmer::DSL::Engine.parent.inspect}"
|
60
60
|
else
|
61
61
|
Glimmer::Config.logger.info {"#{static_expression.class.name} will handle expression keyword #{keyword}"}
|
62
62
|
Glimmer::DSL::Engine.interpret_expression(static_expression, keyword, *args, &block)
|
@@ -86,7 +86,7 @@ module Glimmer
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def disabled_dsls
|
89
|
-
@disabled_dsls ||=
|
89
|
+
@disabled_dsls ||= Concurrent::Array.new
|
90
90
|
end
|
91
91
|
|
92
92
|
def enabled_dsls=(dsl_names)
|
@@ -109,12 +109,12 @@ module Glimmer
|
|
109
109
|
|
110
110
|
# Dynamic expression chains of responsibility indexed by dsl
|
111
111
|
def dynamic_expression_chains_of_responsibility
|
112
|
-
@dynamic_expression_chains_of_responsibility ||=
|
112
|
+
@dynamic_expression_chains_of_responsibility ||= Concurrent::Hash.new
|
113
113
|
end
|
114
114
|
|
115
115
|
# Static expressions indexed by keyword and dsl
|
116
116
|
def static_expressions
|
117
|
-
@static_expressions ||=
|
117
|
+
@static_expressions ||= Concurrent::Hash.new
|
118
118
|
end
|
119
119
|
|
120
120
|
# Sets dynamic expression chains of responsibility. Useful for internal testing
|
@@ -147,7 +147,7 @@ module Glimmer
|
|
147
147
|
Glimmer::Config.logger.info {"Adding static expression: #{static_expression.class.name}"}
|
148
148
|
keyword = static_expression.class.keyword
|
149
149
|
static_expression_dsl = static_expression.class.dsl
|
150
|
-
static_expressions[keyword] ||=
|
150
|
+
static_expressions[keyword] ||= Concurrent::Hash.new
|
151
151
|
static_expressions[keyword][static_expression_dsl] = static_expression
|
152
152
|
Glimmer.send(:define_method, keyword, &STATIC_EXPRESSION_METHOD_FACTORY.call(keyword))
|
153
153
|
end
|
@@ -203,16 +203,16 @@ module Glimmer
|
|
203
203
|
def_delegator :parent_stack, :last, :parent
|
204
204
|
|
205
205
|
def parent_stack
|
206
|
-
parent_stacks[dsl] ||=
|
206
|
+
parent_stacks[dsl] ||= Concurrent::Array.new
|
207
207
|
end
|
208
208
|
|
209
209
|
def parent_stacks
|
210
|
-
@parent_stacks ||=
|
210
|
+
@parent_stacks ||= Concurrent::Hash.new
|
211
211
|
end
|
212
212
|
|
213
213
|
# Enables multiple DSLs to play well with each other when mixing together
|
214
214
|
def dsl_stack
|
215
|
-
@dsl_stack ||=
|
215
|
+
@dsl_stack ||= Concurrent::Array.new
|
216
216
|
end
|
217
217
|
end
|
218
218
|
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: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: array_include_methods
|
@@ -50,6 +50,26 @@ dependencies:
|
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 4.0.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: concurrent-ruby
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 1.1.7
|
60
|
+
- - "<"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.0.0
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.1.7
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 2.0.0
|
53
73
|
- !ruby/object:Gem::Dependency
|
54
74
|
name: rspec-mocks
|
55
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -217,7 +237,6 @@ email: andy.am@gmail.com
|
|
217
237
|
executables: []
|
218
238
|
extensions: []
|
219
239
|
extra_rdoc_files:
|
220
|
-
- CHANGELOG.md
|
221
240
|
- LICENSE.txt
|
222
241
|
- README.md
|
223
242
|
files:
|