glimmer 1.2.0 → 1.3.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: 91c30ea530add452134bdbe1b691612d1cbc1df62e9d96d934aba1b8208ac1bf
4
- data.tar.gz: 2e54d62f536bd132379c195032e62b82e5f6f973f3aa95df002464c99ed39ce1
3
+ metadata.gz: bc60f9fe9c141b35fe836c661860faf448bccccad9f4bfe14c885301e393e75d
4
+ data.tar.gz: 994743aae8636eea4f89fbad60850942854f2d7388bf7f13ce465e4cbe1a809e
5
5
  SHA512:
6
- metadata.gz: 2793b625f74e8fcbd17e1463aa87f4f5cdd7e63d9219f55d9a749f18ce56acef87a86147d227d4246251accc48d7bd451eef170d0e0c34fa4be1a1fa251a6bdb
7
- data.tar.gz: 596cfae4c4545bb7d2bfcb8a6ef4c3be243f70f1dd129e27b16b718ed7b234ab9e5d685075cd6720c8459960c5966f4bd93f494a46d9a0adf7fba5902542d818
6
+ metadata.gz: 777b7ce413bec3f1cf75accdedcb905e393a9b94e2be4572c590f6e3108d2cee7923f83c02e0753ba2f2bb21427b77116da37d8af1a86e477da5821be9d4e5d5
7
+ data.tar.gz: baa2ed05d9cd5759b08a8555ceba26f2672be40f28d868c975e5286a5daf484a7128709093332e7f3f69dc99a5a43cde8550ebe472891cee65c20882751defa0
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
+ ### 1.3.0
7
+
8
+ - Support the `Expression#around` hook, which executes code around both `interpret` and `add_content`
9
+
6
10
  ## 1.2.0
7
11
 
8
12
  - Alter `Engine`/`Expression`/`ParentExpression` API to pass `keyword` and `args` to `#add_content` method. This enables consumers to vary behavior based on `keyword` and `args`, not just `parent` and presence of `block`.
data/README.md CHANGED
@@ -102,6 +102,9 @@ Every `Expression` sublcass must specify two methods at least:
102
102
 
103
103
  For example, some parent widgets use their block for other reasons or process their children at very specific times, so they may override that method and disable it, or otherwise call `super` and do additional work.
104
104
 
105
+ Otherwise, all expressions support the `around` hook method:
106
+ - `around(parent, keyword, args, block, &interpret_and_add_content)`: a hook for executing code around both `interpret` and `add_content`. Clients may invoke `interpret_and_add_content.call` or `yield` when ready for interpretation. `parent`, `keyword`, `args`, and `block` are supplied in case they are needed in the `around` logic.
107
+
105
108
  Example of a dynamic expression:
106
109
 
107
110
  ```ruby
@@ -201,7 +204,7 @@ end
201
204
  ### Setup
202
205
 
203
206
  Follow these steps to author a [Glimmer](https://rubygems.org/gems/glimmer) DSL:
204
- - Add `gem 'glimmer', '~> 1.2.0'` to `Gemfile` and run `bundle` or run `gem install glimmer -v1.2.0` and add `require 'glimmer'`
207
+ - Add `gem 'glimmer', '~> 1.3.0'` to `Gemfile` and run `bundle` or run `gem install glimmer -v1.3.0` and add `require 'glimmer'`
205
208
  - 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)
206
209
  - Create `glimmer/dsl/[dsl_name]/[expresion_name]_expresion.rb` for every [expresion_name] expression needed, whether dynamic or static
207
210
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.3.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 1.2.0 ruby lib
5
+ # stub: glimmer 1.3.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer".freeze
9
- s.version = "1.2.0"
9
+ s.version = "1.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-03-03"
14
+ s.date = "2021-03-08"
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 = [
@@ -176,10 +176,14 @@ module Glimmer
176
176
  end
177
177
 
178
178
  def interpret_expression(expression, keyword, *args, &block)
179
- expression.interpret(parent, keyword, *args, &block).tap do |ui_object|
180
- add_content(ui_object, expression, keyword, *args, &block)
181
- dsl_stack.pop
179
+ new_parent = nil
180
+ expression.around(parent, keyword, args, block) do
181
+ new_parent = expression.interpret(parent, keyword, *args, &block).tap do |new_parent|
182
+ add_content(new_parent, expression, keyword, *args, &block)
183
+ dsl_stack.pop
184
+ end
182
185
  end
186
+ new_parent
183
187
  end
184
188
 
185
189
  # Adds content block to parent UI object
@@ -187,12 +191,12 @@ module Glimmer
187
191
  # This allows evaluating parent UI object properties and children
188
192
  #
189
193
  # For example, a shell widget would get properties set and children added
190
- def add_content(parent, expression, keyword, *args, &block)
194
+ def add_content(new_parent, expression, keyword, *args, &block)
191
195
  if block_given? && expression.is_a?(ParentExpression)
192
196
  dsl_stack.push(expression.class.dsl)
193
- parent_stack.push(parent)
197
+ parent_stack.push(new_parent)
194
198
  begin
195
- expression.add_content(parent, keyword, *args, &block)
199
+ expression.add_content(new_parent, keyword, *args, &block)
196
200
  ensure
197
201
  parent_stack.pop
198
202
  dsl_stack.pop
@@ -47,13 +47,23 @@ module Glimmer
47
47
  raise Error, "#interpret must be implemented by an Expression subclass"
48
48
  end
49
49
 
50
- # Adds block content to specified parent UI object (Optional)
50
+ # Adds block content to newly interpreted parent object (Optional)
51
51
  #
52
52
  # Only expressions that receive a content block should implement
53
- def add_content(parent, keyword, *args, &block)
53
+ def add_content(new_parent, keyword, *args, &block)
54
54
  # No Op by default
55
55
  end
56
-
56
+
57
+ # Executes code around the `interpret_and_add_content` block,
58
+ # which invokes `interpret` and `add_content` when called without args
59
+ # (parent, keyword, args, block are supplied automatically).
60
+ # Clients may invoke yield as an alternative to calling `interpret_and_add_content` directly.
61
+ # This method takes parent, keyword, args, block in case they are needed
62
+ # in its around logic.
63
+ def around(parent, keyword, args, block, &interpret_and_add_content)
64
+ interpret_and_add_content.call
65
+ end
66
+
57
67
  # Checks if object is a Symbol or a String
58
68
  def textual?(object)
59
69
  object.is_a?(Symbol) or object.is_a?(String)
@@ -25,8 +25,11 @@ module Glimmer
25
25
  module DSL
26
26
  # Mixin that represents expressions that always have a content block
27
27
  module ParentExpression
28
- def add_content(parent, keyword, *args, &block)
29
- block.call(parent)
28
+ # Default implementation that simply invokes block content with newly interpreted parent object as an argument
29
+ #
30
+ # Only expressions that receive a content block should implement
31
+ def add_content(new_parent, keyword, *args, &block)
32
+ block.call(new_parent)
30
33
  end
31
34
  end
32
35
  end
@@ -50,7 +50,8 @@ module Glimmer
50
50
  end
51
51
  end
52
52
 
53
- # Subclasses may optionally implement
53
+ # Subclasses may optionally implement, but by default it only ensures that
54
+ # the keyword matches lower case static expression class name minus `Expression`
54
55
  def can_interpret?(parent, keyword, *args, &block)
55
56
  true
56
57
  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.2.0
4
+ version: 1.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-03-03 00:00:00.000000000 Z
11
+ date: 2021-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: array_include_methods