glimmer 2.2.2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -2
- data/VERSION +1 -1
- data/glimmer.gemspec +4 -4
- data/lib/glimmer/data_binding/observable_array.rb +41 -0
- data/lib/glimmer/data_binding/observable_model.rb +2 -2
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04a3036ea66bf774c6c27cf8b248e5658df35ccc3a69998159e43a013d3489e0
|
4
|
+
data.tar.gz: 4241bfc406e54c13bbc4357918bf2bfed5a353f63f5200eea6ed60e0f7c84281
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff74a70f8137ce7967d36e47a191ebdf8efbd67e15724449dd9c5b3a9db04d526a3ab00f4ba484d89af71430ed0543217ac7a0722427b47d735baf3ca4adc524
|
7
|
+
data.tar.gz: f854ebfc523130f308b289fcf575d782776057f4f2d212332d38eeb719444e0d8d7790d0f7e2824059a9bccea1f22be532e1bd55619ba2e66dd585930d4574f5
|
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.3.0
|
7
|
+
|
8
|
+
- Have observing `ObservableArray` automatically notice if any values are nested arrays and observe them for micro-changes (recursively all the way down)
|
9
|
+
|
6
10
|
### 2.2.2
|
7
11
|
|
8
12
|
- Support auto-notifying on `ObservableArray#replace` observed changes
|
data/README.md
CHANGED
@@ -210,7 +210,7 @@ end
|
|
210
210
|
### Setup
|
211
211
|
|
212
212
|
Follow these steps to author a [Glimmer](https://rubygems.org/gems/glimmer) DSL:
|
213
|
-
- Add `gem 'glimmer', '~> 2.
|
213
|
+
- Add `gem 'glimmer', '~> 2.3.0'` to `Gemfile` and run `bundle` or run `gem install glimmer -v2.3.0` and add `require 'glimmer'`
|
214
214
|
- 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)
|
215
215
|
- Create `glimmer/dsl/[dsl_name]/[expresion_name]_expresion.rb` for every [expresion_name] expression needed, whether dynamic or static
|
216
216
|
|
@@ -1163,7 +1163,7 @@ These are the main classes concerning data-binding:
|
|
1163
1163
|
- `Glimmer::DataBinding::Observer`: Provides general observer support including unique registration and deregistration for cleanup and prevention of memory leaks. Main methods concerned are: `call`, `register` (alias: `observe`), and `unregister` (alias: `unobserve` or `deregister`)
|
1164
1164
|
- `Glimmer::DataBinding::Observable`: General super-module for all observables. Main methods concerned are: `add_observer` and `remove_observer`
|
1165
1165
|
- `Glimmer::DataBinding::ObservableModel`: Mixin module for any observable model with observable attributes. In addition to `Observable` methods, it has a `notify_observers` method to be called when changes occur. It automatically enhances all attribute setters (ending with `=`) to notify observers on changes. Also, it automatically handles observing array attributes using `ObservableArray` appropriately so they would notify observers upon array mutation changes.
|
1166
|
-
- `Glimmer::DataBinding::ObservableArray`: Mixin module for any observable array collection that automatically handles notifying observers upon performing array mutation operations (e.g. `push`, `select!`, or `delete`)
|
1166
|
+
- `Glimmer::DataBinding::ObservableArray`: Mixin module for any observable array collection that automatically handles notifying observers upon performing array mutation operations (e.g. `push`, `select!`, or `delete`) recursively (meaning if an array contained arrays and they changed, observers are notified)
|
1167
1167
|
- `Glimmer::DataBinding::ObservableHash`: Mixin module for any observable hash that automatically handles notifying observers upon performing hash mutation operations (e.g. `hash[key]=value`, `select!`, `merge!`)
|
1168
1168
|
- `Glimmer::DataBinding::ModelBinding`: a higher-level abstraction that relies on all the other observer/observable classes to support basic data-binding, nested data-binding, and computed data-binding
|
1169
1169
|
- `Glimmer::DataBinding::Shine`: enables highly intuitive and visually expressive syntax to perform bidirectional (two-way) data-binding with `<=>` and unidirectional (one-way) data-binding with `<=`
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.0
|
data/glimmer.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
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.
|
5
|
+
# stub: glimmer 2.3.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "glimmer".freeze
|
9
|
-
s.version = "2.
|
9
|
+
s.version = "2.3.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 = "2021-10-
|
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
|
14
|
+
s.date = "2021-10-07"
|
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 Tk (Ruby Desktop Development GUI Library), Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development GUI Library), Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps), 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 = [
|
18
18
|
"CHANGELOG.md",
|
@@ -21,6 +21,7 @@
|
|
21
21
|
|
22
22
|
require 'set'
|
23
23
|
require 'glimmer/data_binding/observable'
|
24
|
+
require 'glimmer/data_binding/observer'
|
24
25
|
require 'array_include_methods'
|
25
26
|
|
26
27
|
using ArrayIncludeMethods
|
@@ -29,6 +30,20 @@ module Glimmer
|
|
29
30
|
module DataBinding
|
30
31
|
module ObservableArray
|
31
32
|
include Observable
|
33
|
+
|
34
|
+
class Notifier
|
35
|
+
include Observer
|
36
|
+
|
37
|
+
attr_reader :observable_array
|
38
|
+
|
39
|
+
def initialize(observable_array)
|
40
|
+
@observable_array = observable_array
|
41
|
+
end
|
42
|
+
|
43
|
+
def call(new_value=nil, *extra_args)
|
44
|
+
@observable_array.notify_observers
|
45
|
+
end
|
46
|
+
end
|
32
47
|
|
33
48
|
def add_observer(observer, *element_properties)
|
34
49
|
element_properties = element_properties.flatten.compact.uniq
|
@@ -49,6 +64,23 @@ module Glimmer
|
|
49
64
|
element_properties_for(observer).each do |property|
|
50
65
|
observer.observe(element, property)
|
51
66
|
end
|
67
|
+
ensure_array_object_observer(element) if element.is_a?(Array)
|
68
|
+
end
|
69
|
+
|
70
|
+
def ensure_array_object_observer(object)
|
71
|
+
return unless object&.is_a?(Array)
|
72
|
+
array_object_observer = array_object_observer_for(object)
|
73
|
+
array_observer_registration = array_object_observer.observe(object)
|
74
|
+
property_observer_list.each do |observer|
|
75
|
+
my_registration = observer.registration_for(self)
|
76
|
+
observer.add_dependent(my_registration => array_observer_registration)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def array_object_observer_for(object)
|
81
|
+
@array_object_observers ||= Concurrent::Hash.new
|
82
|
+
@array_object_observers[object] = Notifier.new(self) unless @array_object_observers.has_key?(object)
|
83
|
+
@array_object_observers[object]
|
52
84
|
end
|
53
85
|
|
54
86
|
def remove_observer(observer, *element_properties)
|
@@ -76,6 +108,15 @@ module Glimmer
|
|
76
108
|
element_properties_for(observer).each do |property|
|
77
109
|
observer.unobserve(element, property)
|
78
110
|
end
|
111
|
+
if element.is_a?(ObservableArray)
|
112
|
+
array_object_observer_for(element).unobserve(element)
|
113
|
+
element.property_observer_list.select {|o| o.observable_array == self}.each do |o|
|
114
|
+
o.registrations.each do |registration|
|
115
|
+
registration.deregister
|
116
|
+
end
|
117
|
+
@array_object_observers.reject! {|k, v| v == o}
|
118
|
+
end
|
119
|
+
end
|
79
120
|
end
|
80
121
|
|
81
122
|
def has_observer?(observer)
|
@@ -143,7 +143,7 @@ module Glimmer
|
|
143
143
|
|
144
144
|
def array_object_observer_for(property_name)
|
145
145
|
@array_object_observers ||= Concurrent::Hash.new
|
146
|
-
@array_object_observers[property_name] =
|
146
|
+
@array_object_observers[property_name] = Notifier.new(self, property_name) unless @array_object_observers.has_key?(property_name)
|
147
147
|
@array_object_observers[property_name]
|
148
148
|
end
|
149
149
|
|
@@ -160,7 +160,7 @@ module Glimmer
|
|
160
160
|
|
161
161
|
def hash_object_observer_for(property_name)
|
162
162
|
@hash_object_observers ||= Concurrent::Hash.new
|
163
|
-
@hash_object_observers[property_name] =
|
163
|
+
@hash_object_observers[property_name] = Notifier.new(self, property_name) unless @hash_object_observers.has_key?(property_name)
|
164
164
|
@hash_object_observers[property_name]
|
165
165
|
end
|
166
166
|
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.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: array_include_methods
|
@@ -203,11 +203,12 @@ dependencies:
|
|
203
203
|
- !ruby/object:Gem::Version
|
204
204
|
version: '0'
|
205
205
|
description: Glimmer is a Ruby DSL Framework for Ruby GUI and More, consisting of
|
206
|
-
a DSL Engine and an Observable / Observer / Data-Binding Library (including
|
207
|
-
|
208
|
-
Development GUI Framework),
|
209
|
-
Library),
|
210
|
-
|
206
|
+
a DSL Engine and an Observable / Observer / Data-Binding Library (including Observable
|
207
|
+
Model, Observable Array, and Observable Hash). Used in Glimmer DSL for SWT (JRuby
|
208
|
+
Desktop Development GUI Framework), Glimmer DSL for Tk (Ruby Desktop Development
|
209
|
+
GUI Library), Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development
|
210
|
+
GUI Library), Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop
|
211
|
+
Apps), Glimmer DSL for XML (& HTML), and Glimmer DSL for CSS.
|
211
212
|
email: andy.am@gmail.com
|
212
213
|
executables: []
|
213
214
|
extensions: []
|