glimmer 1.3.1 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +7 -4
- data/VERSION +1 -1
- data/glimmer.gemspec +10 -8
- data/lib/glimmer.rb +1 -9
- data/lib/glimmer/data_binding/model_binding.rb +7 -2
- data/lib/glimmer/data_binding/observable_array.rb +9 -0
- data/lib/glimmer/data_binding/shine.rb +56 -0
- data/lib/glimmer/dsl/bind_expression.rb +54 -0
- data/lib/glimmer/dsl/observe_expression.rb +48 -0
- data/lib/glimmer/ext/module.rb +10 -8
- data/lib/glimmer/shim/concurrent.rb +10 -0
- metadata +8 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fe1b04f0f5ff0f52c71e4490690fd3b0fab149deb79f34f3a659b40f01bd9c1
|
4
|
+
data.tar.gz: 39ebc17ee659e5e29b19c28fa03916812ead713c9db8bf36922dc5c1f611a798
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9f80e0781a58abffaa3672f7c5f239b0f67dfb42f3544cac71a3b2b9efac8b469753a6115983ef396f0a685c5012459bf8c8ba194b96fe50df0a4f801fa4020
|
7
|
+
data.tar.gz: 7fbe75d4c821b59073c815503978b0a7452b38db6a8f5b4b0768578f9104714bcd814b232671e9e09e88c45f7e7161f7c7c226b5662315f382f2574862b91ae6
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,23 @@
|
|
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.1.1
|
7
|
+
|
8
|
+
- Support double/triple/arbitrary dimension indexed arrays in ModelBinding property (e.g. `'grid[1][0]'` )
|
9
|
+
|
10
|
+
### 2.1.0
|
11
|
+
|
12
|
+
- Extracted ObserveExpression from Glimmer DSL for SWT
|
13
|
+
|
14
|
+
### 2.0.1
|
15
|
+
|
16
|
+
- ObservableArray notify observers on shift
|
17
|
+
|
18
|
+
### 2.0.0
|
19
|
+
|
20
|
+
- Extract Glimmer::DSL::BindExpression from Glimmer DSL for SWT
|
21
|
+
- Make concurrent-ruby an optional dependency (automatically using its data-structure classes if present)
|
22
|
+
|
6
23
|
### 1.3.1
|
7
24
|
|
8
25
|
- Use `Concurrent::Array` instead of `Array` in `Glimmer::DataBinding::ModelBinding`
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) an
|
|
16
16
|
|
17
17
|
[**Glimmer**](https://rubygems.org/gems/glimmer) is a DSL (Domain-Specific Language) Framework that consists of two things:
|
18
18
|
- [DSL Engine](#dsl-engine): enables building internal DSLs embedded in Ruby (e.g. for GUI, XML, or CSS).
|
19
|
-
- [Data-Binding Library](#data-binding-library): enables synchronizing GUI with Model Attributes bidirectionally
|
19
|
+
- [Data-Binding Library](#data-binding-library): enables synchronizing GUI with Model Attributes bidirectionally **(now with Shine syntax support in v2)**.
|
20
20
|
|
21
21
|
[**Glimmer**](https://rubygems.org/gems/glimmer) is ***the cream of the crop*** when it comes to building DSLs in Ruby:
|
22
22
|
- Supports building the tersest most concise domain specific language syntax in Ruby.
|
@@ -36,8 +36,6 @@ Start by checking out Glimmer's original GUI DSL, which got extracted into its o
|
|
36
36
|
- [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS
|
37
37
|
- [glimmer-dsl-tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (MRI Ruby Desktop Development GUI Library)
|
38
38
|
|
39
|
-
[Glimmer and/or Glimmer DSLs receive two updates per month](https://rubygems.org/gems/glimmer-dsl-swt/versions). You can trust [Glimmer](https://rubygems.org/gems/glimmer) with your Ruby development needs.
|
40
|
-
|
41
39
|
## Table of Contents
|
42
40
|
|
43
41
|
- [Glimmer](#-glimmer---dsl-framework-for-ruby-gui-and-more)
|
@@ -157,6 +155,10 @@ module Glimmer
|
|
157
155
|
end
|
158
156
|
```
|
159
157
|
|
158
|
+
An extra convenience expression module is included called `BindExpression`. It builds a `Glimmer::DataBinding::ModelBinding` object for [data-binding](#data-binding) purposes.
|
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.
|
161
|
+
|
160
162
|
DSL expressions go into the `glimmer/dsl/{dsl_name}` namespace directory.
|
161
163
|
|
162
164
|
Also, every DSL requires a `glimmer/dsl/{dsl_name}/dsl.rb` file, which configures the DSL into Glimmer via a call to:
|
@@ -206,7 +208,7 @@ end
|
|
206
208
|
### Setup
|
207
209
|
|
208
210
|
Follow these steps to author a [Glimmer](https://rubygems.org/gems/glimmer) DSL:
|
209
|
-
- Add `gem 'glimmer', '~> 1.
|
211
|
+
- Add `gem 'glimmer', '~> 2.1.0'` to `Gemfile` and run `bundle` or run `gem install glimmer -v2.1.0` and add `require 'glimmer'`
|
210
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)
|
211
213
|
- Create `glimmer/dsl/[dsl_name]/[expresion_name]_expresion.rb` for every [expresion_name] expression needed, whether dynamic or static
|
212
214
|
|
@@ -938,6 +940,7 @@ These are the main classes concerning data-binding:
|
|
938
940
|
- `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.
|
939
941
|
- `ObservableArray`: Mixin module for any observable array collection that automatically handles notifying observers upon performing array mutation operations (e.g. `push` or `delete`)
|
940
942
|
- `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
|
943
|
+
- `Shine`: enables highly intuitive and visually expressive syntax to perform bidirectional (two-way) data-binding with `<=>` and unidirectional (one-way) data-binding with `<=`
|
941
944
|
|
942
945
|
You may learn more from [Data-Binding](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#data-binding) and [Observer](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#observer) usage in [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt)
|
943
946
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
2.1.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 1.
|
5
|
+
# stub: glimmer 2.1.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "glimmer".freeze
|
9
|
-
s.version = "1.
|
9
|
+
s.version = "2.1.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-
|
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 = [
|
@@ -34,15 +34,19 @@ Gem::Specification.new do |s|
|
|
34
34
|
"lib/glimmer/data_binding/observable_array.rb",
|
35
35
|
"lib/glimmer/data_binding/observable_model.rb",
|
36
36
|
"lib/glimmer/data_binding/observer.rb",
|
37
|
+
"lib/glimmer/data_binding/shine.rb",
|
38
|
+
"lib/glimmer/dsl/bind_expression.rb",
|
37
39
|
"lib/glimmer/dsl/engine.rb",
|
38
40
|
"lib/glimmer/dsl/expression.rb",
|
39
41
|
"lib/glimmer/dsl/expression_handler.rb",
|
42
|
+
"lib/glimmer/dsl/observe_expression.rb",
|
40
43
|
"lib/glimmer/dsl/parent_expression.rb",
|
41
44
|
"lib/glimmer/dsl/static_expression.rb",
|
42
45
|
"lib/glimmer/dsl/top_level_expression.rb",
|
43
46
|
"lib/glimmer/error.rb",
|
44
47
|
"lib/glimmer/ext/module.rb",
|
45
|
-
"lib/glimmer/invalid_keyword_error.rb"
|
48
|
+
"lib/glimmer/invalid_keyword_error.rb",
|
49
|
+
"lib/glimmer/shim/concurrent.rb"
|
46
50
|
]
|
47
51
|
s.homepage = "http://github.com/AndyObtiva/glimmer".freeze
|
48
52
|
s.licenses = ["MIT".freeze]
|
@@ -56,10 +60,9 @@ Gem::Specification.new do |s|
|
|
56
60
|
if s.respond_to? :add_runtime_dependency then
|
57
61
|
s.add_runtime_dependency(%q<array_include_methods>.freeze, [">= 1.0.4", "< 2.0.0"])
|
58
62
|
s.add_runtime_dependency(%q<facets>.freeze, [">= 3.1.0", "< 4.0.0"])
|
59
|
-
s.add_runtime_dependency(%q<concurrent-ruby>.freeze, [">= 1.1.7", "< 2.0.0"])
|
60
63
|
s.add_development_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
|
61
64
|
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
62
|
-
s.add_development_dependency(%q<puts_debuggerer>.freeze, ["~> 0.
|
65
|
+
s.add_development_dependency(%q<puts_debuggerer>.freeze, ["~> 0.13"])
|
63
66
|
s.add_development_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
|
64
67
|
s.add_development_dependency(%q<jeweler>.freeze, [">= 2.0.0", "< 3.0.0"])
|
65
68
|
s.add_development_dependency(%q<rdoc>.freeze, [">= 6.2.1", "< 7.0.0"])
|
@@ -70,10 +73,9 @@ Gem::Specification.new do |s|
|
|
70
73
|
else
|
71
74
|
s.add_dependency(%q<array_include_methods>.freeze, [">= 1.0.4", "< 2.0.0"])
|
72
75
|
s.add_dependency(%q<facets>.freeze, [">= 3.1.0", "< 4.0.0"])
|
73
|
-
s.add_dependency(%q<concurrent-ruby>.freeze, [">= 1.1.7", "< 2.0.0"])
|
74
76
|
s.add_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
|
75
77
|
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
76
|
-
s.add_dependency(%q<puts_debuggerer>.freeze, ["~> 0.
|
78
|
+
s.add_dependency(%q<puts_debuggerer>.freeze, ["~> 0.13"])
|
77
79
|
s.add_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
|
78
80
|
s.add_dependency(%q<jeweler>.freeze, [">= 2.0.0", "< 3.0.0"])
|
79
81
|
s.add_dependency(%q<rdoc>.freeze, [">= 6.2.1", "< 7.0.0"])
|
data/lib/glimmer.rb
CHANGED
@@ -22,18 +22,10 @@
|
|
22
22
|
require 'logger'
|
23
23
|
require 'set'
|
24
24
|
require 'array_include_methods'
|
25
|
-
if RUBY_ENGINE == 'opal'
|
26
|
-
module Concurrent
|
27
|
-
Array = ::Array
|
28
|
-
Hash = ::Hash
|
29
|
-
Set = ::Set
|
30
|
-
end
|
31
|
-
else
|
32
|
-
require 'concurrent-ruby'
|
33
|
-
end
|
34
25
|
|
35
26
|
$LOAD_PATH.unshift(File.expand_path('..', __FILE__))
|
36
27
|
|
28
|
+
require 'glimmer/shim/concurrent'
|
37
29
|
require 'glimmer/config'
|
38
30
|
require 'glimmer/ext/module'
|
39
31
|
|
@@ -75,7 +75,7 @@ module Glimmer
|
|
75
75
|
# If there are any indexed property names, this returns indexes as properties.
|
76
76
|
# e.g. property name expression "addresses[1].state" gives ['addresses', '[1]', 'state']
|
77
77
|
def nested_property_names
|
78
|
-
@nested_property_names ||= Concurrent::Array.new(property_name_expression.split(
|
78
|
+
@nested_property_names ||= Concurrent::Array.new(property_name_expression.split(/\[|\./).map {|pne| pne.end_with?(']') ? "[#{pne}" : pne })
|
79
79
|
end
|
80
80
|
|
81
81
|
# Final nested property name
|
@@ -242,7 +242,12 @@ module Glimmer
|
|
242
242
|
|
243
243
|
def invoke_proc_with_exact_parameters(proc_object, *args)
|
244
244
|
return if proc_object.nil?
|
245
|
-
|
245
|
+
if RUBY_ENGINE == 'opal'
|
246
|
+
# opal doesn't support proc_object.parameters.size properly it seems
|
247
|
+
args = Concurrent::Array.new(args[0...1])
|
248
|
+
else
|
249
|
+
args = Concurrent::Array.new(args[0...proc_object.parameters.size])
|
250
|
+
end
|
246
251
|
proc_object.call(*args)
|
247
252
|
end
|
248
253
|
|
@@ -130,6 +130,15 @@ module Glimmer
|
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
|
+
def shift
|
134
|
+
shifted_element = first
|
135
|
+
unregister_dependent_observers(shifted_element)
|
136
|
+
remove_element_observers(shifted_element)
|
137
|
+
super.tap do
|
138
|
+
notify_observers
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
133
142
|
def delete(element)
|
134
143
|
unregister_dependent_observers(element)
|
135
144
|
remove_element_observers(element)
|
@@ -0,0 +1,56 @@
|
|
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
|
+
module Glimmer
|
23
|
+
module DataBinding
|
24
|
+
class Shine
|
25
|
+
include Glimmer
|
26
|
+
|
27
|
+
def initialize(parent, parent_attribute)
|
28
|
+
@parent = parent
|
29
|
+
@parent_attribute = parent_attribute
|
30
|
+
end
|
31
|
+
|
32
|
+
def <=>(other)
|
33
|
+
if other.is_a?(Array)
|
34
|
+
args_clone = other.clone
|
35
|
+
@parent.content {
|
36
|
+
send(@parent_attribute, bind(*args_clone))
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def <=(other)
|
42
|
+
if other.is_a?(Array)
|
43
|
+
args_clone = other.clone
|
44
|
+
if args_clone.last.is_a?(Hash)
|
45
|
+
args_clone.last[:read_only] = true
|
46
|
+
else
|
47
|
+
args_clone << {read_only: true}
|
48
|
+
end
|
49
|
+
@parent.content {
|
50
|
+
send(@parent_attribute, bind(*args_clone))
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,54 @@
|
|
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/dsl/static_expression'
|
23
|
+
require 'glimmer/data_binding/model_binding'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module DSL
|
27
|
+
# Responsible for setting up the return value of the bind keyword (command symbol)
|
28
|
+
# as a ModelBinding. It is to be used as the argument of another data-binding expression.
|
29
|
+
module BindExpression
|
30
|
+
def can_interpret?(parent, keyword, *args, &block)
|
31
|
+
(
|
32
|
+
keyword == 'bind' and
|
33
|
+
(
|
34
|
+
(
|
35
|
+
(args.size == 2) and
|
36
|
+
textual?(args[1])
|
37
|
+
) ||
|
38
|
+
(
|
39
|
+
(args.size == 3) and
|
40
|
+
textual?(args[1]) and
|
41
|
+
(args[2].is_a?(Hash))
|
42
|
+
)
|
43
|
+
)
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
def interpret(parent, keyword, *args, &block)
|
48
|
+
binding_options = args[2] || {}
|
49
|
+
binding_options[:on_read] = binding_options.delete(:on_read) || binding_options.delete('on_read') || block
|
50
|
+
DataBinding::ModelBinding.new(args[0], args[1].to_s, binding_options)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -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
|
data/lib/glimmer/ext/module.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
unless RUBY_ENGINE == 'opal'
|
2
|
+
class Module
|
3
|
+
alias append_features_without_glimmer append_features
|
4
|
+
def append_features(mod)
|
5
|
+
if self == Glimmer && mod == Object
|
6
|
+
Glimmer::Config.logger.debug { 'Appending Glimmer to Singleton Class of main object (not appending to Object everywhere to avoid method pollution)' }
|
7
|
+
TOPLEVEL_BINDING.receiver.singleton_class.include(self)
|
8
|
+
else
|
9
|
+
append_features_without_glimmer(mod)
|
10
|
+
end
|
9
11
|
end
|
10
12
|
end
|
11
13
|
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.
|
4
|
+
version: 2.1.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-
|
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
|
@@ -50,26 +50,6 @@ 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
|
73
53
|
- !ruby/object:Gem::Dependency
|
74
54
|
name: rspec-mocks
|
75
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,14 +84,14 @@ dependencies:
|
|
104
84
|
requirements:
|
105
85
|
- - "~>"
|
106
86
|
- !ruby/object:Gem::Version
|
107
|
-
version: 0.
|
87
|
+
version: '0.13'
|
108
88
|
type: :development
|
109
89
|
prerelease: false
|
110
90
|
version_requirements: !ruby/object:Gem::Requirement
|
111
91
|
requirements:
|
112
92
|
- - "~>"
|
113
93
|
- !ruby/object:Gem::Version
|
114
|
-
version: 0.
|
94
|
+
version: '0.13'
|
115
95
|
- !ruby/object:Gem::Dependency
|
116
96
|
name: rake
|
117
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -256,15 +236,19 @@ files:
|
|
256
236
|
- lib/glimmer/data_binding/observable_array.rb
|
257
237
|
- lib/glimmer/data_binding/observable_model.rb
|
258
238
|
- lib/glimmer/data_binding/observer.rb
|
239
|
+
- lib/glimmer/data_binding/shine.rb
|
240
|
+
- lib/glimmer/dsl/bind_expression.rb
|
259
241
|
- lib/glimmer/dsl/engine.rb
|
260
242
|
- lib/glimmer/dsl/expression.rb
|
261
243
|
- lib/glimmer/dsl/expression_handler.rb
|
244
|
+
- lib/glimmer/dsl/observe_expression.rb
|
262
245
|
- lib/glimmer/dsl/parent_expression.rb
|
263
246
|
- lib/glimmer/dsl/static_expression.rb
|
264
247
|
- lib/glimmer/dsl/top_level_expression.rb
|
265
248
|
- lib/glimmer/error.rb
|
266
249
|
- lib/glimmer/ext/module.rb
|
267
250
|
- lib/glimmer/invalid_keyword_error.rb
|
251
|
+
- lib/glimmer/shim/concurrent.rb
|
268
252
|
homepage: http://github.com/AndyObtiva/glimmer
|
269
253
|
licenses:
|
270
254
|
- MIT
|