glimmer 2.2.0 → 2.2.1

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: d61c8e3da07109cf0edf0df46e0937a862b3e80007a12da8050c2415481cbb6e
4
- data.tar.gz: c618e4c0b024a9da219fbe78c263a442981d3d0a40f8a13bb7639edf50310e09
3
+ metadata.gz: 35f985810a976094fb1e6e50371f6f48c71730ae8cfd4fad862734d8e319d71e
4
+ data.tar.gz: 78826cb87a5fcc16e609b3dd3065bea51a28a765c6d2b80341ee1cce1a57a23a
5
5
  SHA512:
6
- metadata.gz: c1b3b5d7aa04427f0e1188e0cd7e3855d517c0adfb6c561160c465f043685c48a651df8fde9eb05e31b84578a1986182422e49bb329fd35b9f0cd623fac4bc77
7
- data.tar.gz: 5b4177d4ae038eefd1c210e8054f92ebe716b1a7edb2b40e94466ee2ba35aaafced1320128e75603f156ed3a7cdc56db200fd4369916dc0862f44fbd7ac12760
6
+ metadata.gz: 6e3d5f3fd5b2fddb43b32fb8f8c47ce059cf424161453da590de1aba03b002a538ddd2107cfc099703878a5520a7bdaf45cc560cfd1e87ed564894fb324c94e8
7
+ data.tar.gz: d53be152046beb31ceef2ae20aad7aa2bd8d93e0c75c53ec7a0def995c8457461f26fd1294047413cc9961f8064ea5b939b5ea430d4e2b81e4e3e40ca0a30f6c
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
+ ### 2.2.1
7
+
8
+ - Have `ObservableHash` call `notify_observers(key)` upon performing all mutation operations (as expected): `delete`, `delete_if`, `filter!`, `select!`, `keep_if`, `reject!`, `merge!`, `replace`, `shift`, `transform_keys!`, `transform_values!`
9
+ - Fix issue with `Glimmer::DataBinding::Observer.proc {|new_value| ...}.observe(array)` resulting in new_value coming across as `nil when the array is updated
10
+
6
11
  ### 2.2.0
7
12
 
8
13
  - New `Glimmer::DataBinding::ObservableHash` support for observing `hash[key]=value` mutations
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.2.0'` to `Gemfile` and run `bundle` or run `gem install glimmer -v2.2.0` and add `require 'glimmer'`
213
+ - Add `gem 'glimmer', '~> 2.2.1'` to `Gemfile` and run `bundle` or run `gem install glimmer -v2.2.1` 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
 
@@ -1226,7 +1226,7 @@ These are the main classes concerning data-binding:
1226
1226
  - `Glimmer::DataBinding::Observable`: General super-module for all observables. Main methods concerned are: `add_observer` and `remove_observer`
1227
1227
  - `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.
1228
1228
  - `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`)
1229
- - `Glimmer::DataBinding::ObservableHash`: Mixin module for any observable hash that automatically handles notifying observers upon performing array mutation operation (e.g. `hash[key]=value`)
1229
+ - `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!`)
1230
1230
  - `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
1231
1231
  - `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 `<=`
1232
1232
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.0
1
+ 2.2.1
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.2.0 ruby lib
5
+ # stub: glimmer 2.2.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer".freeze
9
- s.version = "2.2.0"
9
+ s.version = "2.2.1"
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-09-28"
14
+ s.date = "2021-10-03"
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. 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 = [
@@ -51,7 +51,7 @@ Gem::Specification.new do |s|
51
51
  ]
52
52
  s.homepage = "http://github.com/AndyObtiva/glimmer".freeze
53
53
  s.licenses = ["MIT".freeze]
54
- s.rubygems_version = "3.2.22".freeze
54
+ s.rubygems_version = "3.2.28".freeze
55
55
  s.summary = "Glimmer - DSL Engine for Ruby GUI and More".freeze
56
56
 
57
57
  if s.respond_to? :specification_version then
@@ -99,7 +99,7 @@ module Glimmer
99
99
  end
100
100
 
101
101
  def notify_observers
102
- property_observer_list.to_a.each(&:call)
102
+ property_observer_list.to_a.each { |o| o.call(self) }
103
103
  end
104
104
 
105
105
  def <<(element)
@@ -115,7 +115,7 @@ module Glimmer
115
115
 
116
116
  def notify_observers(key)
117
117
  all_key_observer_list.to_a.each { |observer| observer.call(self[key], key) }
118
- (key_observer_list(key).to_a - all_key_observer_list.to_a).each { |observer| observer.call(self[key]) }
118
+ (key_observer_list(key).to_a - all_key_observer_list.to_a).each { |observer| observer.call(self[key], key) }
119
119
  end
120
120
 
121
121
  def add_key_writer_observer(key = nil)
@@ -176,6 +176,181 @@ module Glimmer
176
176
  @hash_object_observers[key] = ObservableModel::Notifier.new(self, key) unless @hash_object_observers.has_key?(key)
177
177
  @hash_object_observers[key]
178
178
  end
179
+
180
+ def delete(key, &block)
181
+ old_value = self[key]
182
+ unless old_value.nil?
183
+ unregister_dependent_observers(key, old_value)
184
+ unregister_dependent_observers(nil, old_value)
185
+ end
186
+ super(key, &block).tap do
187
+ notify_observers(key) unless old_value.nil?
188
+ end
189
+ end
190
+
191
+ def delete_if(&block)
192
+ if block_given?
193
+ old_hash = self.dup
194
+ super(&block).tap do |new_hash|
195
+ deleted_keys = old_hash.keys - new_hash.keys
196
+ deleted_keys.each do |deleted_key|
197
+ deleted_value = old_hash[deleted_key]
198
+ unless deleted_value.nil?
199
+ unregister_dependent_observers(deleted_key, deleted_value)
200
+ unregister_dependent_observers(nil, deleted_value)
201
+ notify_observers(deleted_key)
202
+ end
203
+ end
204
+ end
205
+ else
206
+ super
207
+ end
208
+ end
209
+
210
+ def select!(&block)
211
+ if block_given?
212
+ old_hash = self.dup
213
+ super(&block).tap do |new_hash|
214
+ deleted_keys = old_hash.keys - new_hash.keys
215
+ deleted_keys.each do |deleted_key|
216
+ deleted_value = old_hash[deleted_key]
217
+ unless deleted_value.nil?
218
+ unregister_dependent_observers(deleted_key, deleted_value)
219
+ unregister_dependent_observers(nil, deleted_value)
220
+ notify_observers(deleted_key)
221
+ end
222
+ end
223
+ end
224
+ else
225
+ super
226
+ end
227
+ end
228
+
229
+ def keep_if(&block)
230
+ if block_given?
231
+ old_hash = self.dup
232
+ super(&block).tap do |new_hash|
233
+ deleted_keys = old_hash.keys - new_hash.keys
234
+ deleted_keys.each do |deleted_key|
235
+ deleted_value = old_hash[deleted_key]
236
+ unless deleted_value.nil?
237
+ unregister_dependent_observers(deleted_key, deleted_value)
238
+ unregister_dependent_observers(nil, deleted_value)
239
+ notify_observers(deleted_key)
240
+ end
241
+ end
242
+ end
243
+ else
244
+ super
245
+ end
246
+ end
247
+
248
+ def reject!(&block)
249
+ if block_given?
250
+ old_hash = self.dup
251
+ super(&block).tap do |new_hash|
252
+ deleted_keys = old_hash.keys - new_hash.keys
253
+ deleted_keys.each do |deleted_key|
254
+ deleted_value = old_hash[deleted_key]
255
+ unless deleted_value.nil?
256
+ unregister_dependent_observers(deleted_key, deleted_value)
257
+ unregister_dependent_observers(nil, deleted_value)
258
+ notify_observers(deleted_key)
259
+ end
260
+ end
261
+ end
262
+ else
263
+ super
264
+ end
265
+ end
266
+
267
+ def shift
268
+ old_hash = self.dup
269
+ super.tap do
270
+ new_hash = self
271
+ deleted_keys = old_hash.keys - new_hash.keys
272
+ deleted_keys.each do |deleted_key|
273
+ deleted_value = old_hash[deleted_key]
274
+ unless deleted_value.nil?
275
+ unregister_dependent_observers(deleted_key, deleted_value)
276
+ unregister_dependent_observers(nil, deleted_value)
277
+ notify_observers(deleted_key)
278
+ end
279
+ end
280
+ end
281
+ end
282
+
283
+ def merge!(*other_hashes, &block)
284
+ if other_hashes.empty?
285
+ super
286
+ else
287
+ old_hash = self.dup
288
+ super(*other_hashes, &block).tap do |new_hash|
289
+ changed_keys = other_hashes.map(&:keys).reduce(:+)
290
+ changed_keys.each do |changed_key|
291
+ old_value = old_hash[changed_key]
292
+ if new_hash[changed_key] != old_value
293
+ unregister_dependent_observers(changed_key, old_value)
294
+ unregister_dependent_observers(nil, old_value)
295
+ notify_observers(changed_key)
296
+ end
297
+ end
298
+ end
299
+ end
300
+ end
301
+
302
+ def replace(other_hash)
303
+ old_hash = self.dup
304
+ super(other_hash).tap do |new_hash|
305
+ changed_keys = old_hash.keys + new_hash.keys
306
+ changed_keys.each do |changed_key|
307
+ old_value = old_hash[changed_key]
308
+ if new_hash[changed_key] != old_value
309
+ unregister_dependent_observers(changed_key, old_value)
310
+ unregister_dependent_observers(nil, old_value)
311
+ notify_observers(changed_key)
312
+ end
313
+ end
314
+ end
315
+ end
316
+
317
+ def transform_keys!(hash2 = nil, &block)
318
+ if hash2.nil? && block.nil?
319
+ super
320
+ else
321
+ old_hash = self.dup
322
+ result = hash2.nil? ? super(&block) : super(hash2, &block)
323
+ result.tap do |new_hash|
324
+ changed_keys = old_hash.keys + new_hash.keys
325
+ changed_keys.each do |changed_key|
326
+ old_value = old_hash[changed_key]
327
+ if new_hash[changed_key] != old_value
328
+ unregister_dependent_observers(changed_key, old_value)
329
+ unregister_dependent_observers(nil, old_value)
330
+ notify_observers(changed_key)
331
+ end
332
+ end
333
+ end
334
+ end
335
+ end
336
+
337
+ def transform_values!(&block)
338
+ if block_given?
339
+ old_hash = self.dup
340
+ super(&block).tap do |new_hash|
341
+ new_hash.keys.each do |changed_key|
342
+ old_value = old_hash[changed_key]
343
+ if new_hash[changed_key] != old_value
344
+ unregister_dependent_observers(changed_key, old_value)
345
+ unregister_dependent_observers(nil, old_value)
346
+ notify_observers(changed_key)
347
+ end
348
+ end
349
+ end
350
+ else
351
+ super
352
+ end
353
+ end
179
354
  end
180
355
  end
181
356
  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.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-28 00:00:00.000000000 Z
11
+ date: 2021-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: array_include_methods
@@ -263,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
263
263
  - !ruby/object:Gem::Version
264
264
  version: '0'
265
265
  requirements: []
266
- rubygems_version: 3.2.22
266
+ rubygems_version: 3.2.28
267
267
  signing_key:
268
268
  specification_version: 4
269
269
  summary: Glimmer - DSL Engine for Ruby GUI and More