glimmer 2.0.1 → 2.1.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: 6a2d51ad333d0d08344d21c90f6bec78ec0cd09b61cd2d86b5d79ecf8374b7f6
4
- data.tar.gz: c85f1d8f57ec0556ca3042d49050714908c763dbea9e911f10cde85dc5405b75
3
+ metadata.gz: 912a0642f9a9a7a0811c8ba1fc41cd0cc1c0d0782bb358309bf2d2f70d5a187e
4
+ data.tar.gz: 3d35f07751808800467b9e267aab343a04e0609d71ca15048273b725c1525ce4
5
5
  SHA512:
6
- metadata.gz: 26211cca1888df8245ea8c1c76b74effac9370038e42474cbf1e7fb4b905c54a0f5b972dfdb4413293898fb75fea155779bfd49e15f118e7560cba5ffb13b3da
7
- data.tar.gz: d56fe91c1eaac6730ef3b706a3e4adf467251cdc48f1ead6f2ea9070e85145ac3e2b774813d2222dd86dbfac0a416dfab54232f0e840cf0e1a28dc2acf7cc2fc
6
+ metadata.gz: 0e185959434641f56cc0ce6b031a2444348cdb076681ec026d2fb78851602f069e79eed56f55b0abe50281bf6595555642aeff92cb721f236b49bc5dbf8101b2
7
+ data.tar.gz: a2be36ee355356c73217bed677f09eb4e1e54b5f7c473cf8fa2a5de8e17d8cd423164af7c9f5f10285dc365dcc4475216e75965c6f804c9b4fdc77e533224229
data/README.md CHANGED
@@ -156,7 +156,8 @@ end
156
156
  ```
157
157
 
158
158
  An extra convenience expression module is included called `BindExpression`. It builds a `Glimmer::DataBinding::ModelBinding` object for [data-binding](#data-binding) purposes.
159
- You may learn more about it by looking at how [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) uses it.
159
+ Another convenience expression module is `ObserveExpression`, which enables a one-way `observe` operation.
160
+ You may learn more about both by looking at how [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) uses them.
160
161
 
161
162
  DSL expressions go into the `glimmer/dsl/{dsl_name}` namespace directory.
162
163
 
@@ -207,7 +208,7 @@ end
207
208
  ### Setup
208
209
 
209
210
  Follow these steps to author a [Glimmer](https://rubygems.org/gems/glimmer) DSL:
210
- - Add `gem 'glimmer', '~> 2.0.1'` to `Gemfile` and run `bundle` or run `gem install glimmer -v2.0.1` and add `require 'glimmer'`
211
+ - Add `gem 'glimmer', '~> 2.1.0'` to `Gemfile` and run `bundle` or run `gem install glimmer -v2.1.0` and add `require 'glimmer'`
211
212
  - 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)
212
213
  - Create `glimmer/dsl/[dsl_name]/[expresion_name]_expresion.rb` for every [expresion_name] expression needed, whether dynamic or static
213
214
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.1
1
+ 2.1.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 2.0.1 ruby lib
5
+ # stub: glimmer 2.1.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer".freeze
9
- s.version = "2.0.1"
9
+ s.version = "2.1.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-07-24"
14
+ s.date = "2021-08-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 = [
@@ -39,6 +39,7 @@ Gem::Specification.new do |s|
39
39
  "lib/glimmer/dsl/engine.rb",
40
40
  "lib/glimmer/dsl/expression.rb",
41
41
  "lib/glimmer/dsl/expression_handler.rb",
42
+ "lib/glimmer/dsl/observe_expression.rb",
42
43
  "lib/glimmer/dsl/parent_expression.rb",
43
44
  "lib/glimmer/dsl/static_expression.rb",
44
45
  "lib/glimmer/dsl/top_level_expression.rb",
@@ -0,0 +1,48 @@
1
+ # Copyright (c) 2007-2021 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer/data_binding/observer'
23
+ require 'glimmer/data_binding/model_binding'
24
+
25
+ module Glimmer
26
+ module DSL
27
+ module ObserveExpression
28
+ REGEX_NESTED_OR_INDEXED_PROPERTY = /([^\[]+)(\[[^\]]+\])?/
29
+
30
+ def can_interpret?(parent, keyword, *args, &block)
31
+ keyword == 'observe' and
32
+ block_given? and
33
+ (args.size == 2) and
34
+ textual?(args[1])
35
+ end
36
+
37
+ def interpret(parent, keyword, *args, &block)
38
+ observer = DataBinding::Observer.proc(&block)
39
+ if args[1].to_s.match(REGEX_NESTED_OR_INDEXED_PROPERTY)
40
+ observer_registration = observer.observe(DataBinding::ModelBinding.new(args[0], args[1]))
41
+ else
42
+ observer_registration = observer.observe(args[0], args[1])
43
+ end
44
+ observer_registration
45
+ end
46
+ end
47
+ end
48
+ 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.0.1
4
+ version: 2.1.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-07-24 00:00:00.000000000 Z
11
+ date: 2021-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: array_include_methods
@@ -241,6 +241,7 @@ files:
241
241
  - lib/glimmer/dsl/engine.rb
242
242
  - lib/glimmer/dsl/expression.rb
243
243
  - lib/glimmer/dsl/expression_handler.rb
244
+ - lib/glimmer/dsl/observe_expression.rb
244
245
  - lib/glimmer/dsl/parent_expression.rb
245
246
  - lib/glimmer/dsl/static_expression.rb
246
247
  - lib/glimmer/dsl/top_level_expression.rb