glimmer 1.3.1 → 2.0.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: 351035b802dcf014c087c908f8481dbbf13d8479fdd1766b47e25be2177ffc98
4
- data.tar.gz: 7960514819570b96106dcde2c71889feb0bd706dbe5803e3e62bf02c28f4c1f1
3
+ metadata.gz: 8772f56eb8991b7a79057afe8640670356862b2347a47b0e685caebb62568835
4
+ data.tar.gz: b53c4203d47bf66c8b3b9246d3ff96ecf82922452c6370df1637d2358b9d5dba
5
5
  SHA512:
6
- metadata.gz: f127846dc71e67d3667cd738a96f11d667718d93f28494e31414a29a6e93b323f04af33bcc022bb8a4cc96e413622209589f1f2ab2ba5efc10bf5bce6baf33f7
7
- data.tar.gz: 6a300696cb179c0d01173fd4a652d6ef78219ad944ff2af9ef7fbfec19e9a853365631f92bae5c7b2353946a2c2e498d178f14f96ee357f61a02b872b1e17537
6
+ metadata.gz: ab4149e944396d0e236b87e632996ba1b4e585291c503061686ddd2da7d49fb46f921761bf6863f8c75923501dd2ca3af3cff7eb18f4a4f42dbafaa397bbc08a
7
+ data.tar.gz: f8eadc4773b6b459d43f21ad9f041b5387766d4faf29111d81f364ca98bfb8fdcafdd4267f25c5c476af540de841d882a79a10261d84264346905c3d38073929
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.0.0
7
+
8
+ - Extract Glimmer::DSL::BindExpression from Glimmer DSL for SWT
9
+ - Make concurrent-ruby an optional dependency (automatically using its data-structure classes if present)
10
+
6
11
  ### 1.3.1
7
12
 
8
13
  - 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.
@@ -157,6 +157,9 @@ module Glimmer
157
157
  end
158
158
  ```
159
159
 
160
+ An extra convenience expression module is included called `BindExpression`. It builds a `Glimmer::DataBinding::ModelBinding` object for [data-binding](#data-binding) purposes.
161
+ You may learn more about it by looking at how [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) uses it.
162
+
160
163
  DSL expressions go into the `glimmer/dsl/{dsl_name}` namespace directory.
161
164
 
162
165
  Also, every DSL requires a `glimmer/dsl/{dsl_name}/dsl.rb` file, which configures the DSL into Glimmer via a call to:
@@ -206,7 +209,7 @@ end
206
209
  ### Setup
207
210
 
208
211
  Follow these steps to author a [Glimmer](https://rubygems.org/gems/glimmer) DSL:
209
- - Add `gem 'glimmer', '~> 1.3.1'` to `Gemfile` and run `bundle` or run `gem install glimmer -v1.3.1` and add `require 'glimmer'`
212
+ - Add `gem 'glimmer', '~> 2.0.0'` to `Gemfile` and run `bundle` or run `gem install glimmer -v2.0.0` and add `require 'glimmer'`
210
213
  - 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
214
  - Create `glimmer/dsl/[dsl_name]/[expresion_name]_expresion.rb` for every [expresion_name] expression needed, whether dynamic or static
212
215
 
@@ -938,6 +941,7 @@ These are the main classes concerning data-binding:
938
941
  - `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
942
  - `ObservableArray`: Mixin module for any observable array collection that automatically handles notifying observers upon performing array mutation operations (e.g. `push` or `delete`)
940
943
  - `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
944
+ - `Shine`: enables highly intuitive and visually expressive syntax to perform bidirectional (two-way) data-binding with `<=>` and unidirectional (one-way) data-binding with `<=`
941
945
 
942
946
  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
947
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.1
1
+ 2.0.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.3.1 ruby lib
5
+ # stub: glimmer 2.0.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer".freeze
9
- s.version = "1.3.1"
9
+ s.version = "2.0.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-23"
14
+ s.date = "2021-07-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,6 +34,8 @@ 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,11 +44,12 @@ Gem::Specification.new do |s|
42
44
  "lib/glimmer/dsl/top_level_expression.rb",
43
45
  "lib/glimmer/error.rb",
44
46
  "lib/glimmer/ext/module.rb",
45
- "lib/glimmer/invalid_keyword_error.rb"
47
+ "lib/glimmer/invalid_keyword_error.rb",
48
+ "lib/glimmer/shim/concurrent.rb"
46
49
  ]
47
50
  s.homepage = "http://github.com/AndyObtiva/glimmer".freeze
48
51
  s.licenses = ["MIT".freeze]
49
- s.rubygems_version = "3.2.3".freeze
52
+ s.rubygems_version = "3.2.22".freeze
50
53
  s.summary = "Glimmer - DSL Engine for Ruby GUI and More".freeze
51
54
 
52
55
  if s.respond_to? :specification_version then
@@ -56,10 +59,9 @@ Gem::Specification.new do |s|
56
59
  if s.respond_to? :add_runtime_dependency then
57
60
  s.add_runtime_dependency(%q<array_include_methods>.freeze, [">= 1.0.4", "< 2.0.0"])
58
61
  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
62
  s.add_development_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
61
63
  s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
62
- s.add_development_dependency(%q<puts_debuggerer>.freeze, ["~> 0.10.0"])
64
+ s.add_development_dependency(%q<puts_debuggerer>.freeze, ["~> 0.13"])
63
65
  s.add_development_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
64
66
  s.add_development_dependency(%q<jeweler>.freeze, [">= 2.0.0", "< 3.0.0"])
65
67
  s.add_development_dependency(%q<rdoc>.freeze, [">= 6.2.1", "< 7.0.0"])
@@ -70,10 +72,9 @@ Gem::Specification.new do |s|
70
72
  else
71
73
  s.add_dependency(%q<array_include_methods>.freeze, [">= 1.0.4", "< 2.0.0"])
72
74
  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
75
  s.add_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
75
76
  s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
76
- s.add_dependency(%q<puts_debuggerer>.freeze, ["~> 0.10.0"])
77
+ s.add_dependency(%q<puts_debuggerer>.freeze, ["~> 0.13"])
77
78
  s.add_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
78
79
  s.add_dependency(%q<jeweler>.freeze, [">= 2.0.0", "< 3.0.0"])
79
80
  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
 
@@ -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
- args = Concurrent::Array.new(args[0...proc_object.parameters.size])
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
 
@@ -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
@@ -1,11 +1,13 @@
1
- class Module
2
- alias append_features_without_glimmer append_features
3
- def append_features(mod)
4
- if self == Glimmer && mod == Object
5
- Glimmer::Config.logger.debug { 'Appending Glimmer to Singleton Class of main object (not appending to Object everywhere to avoid method pollution)' }
6
- TOPLEVEL_BINDING.receiver.singleton_class.include(self)
7
- else
8
- append_features_without_glimmer(mod)
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
@@ -0,0 +1,10 @@
1
+ require 'set'
2
+
3
+ # Accommadate libraries that do not need or support concurrent-ruby (e.g. Glimmer DSL for Opal)
4
+ if !Object.constants.include?(:Concurrent)
5
+ module Concurrent
6
+ Array = ::Array
7
+ Hash = ::Hash
8
+ Set = ::Set
9
+ end
10
+ 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.3.1
4
+ version: 2.0.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-23 00:00:00.000000000 Z
11
+ date: 2021-07-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.10.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.10.0
94
+ version: '0.13'
115
95
  - !ruby/object:Gem::Dependency
116
96
  name: rake
117
97
  requirement: !ruby/object:Gem::Requirement
@@ -256,6 +236,8 @@ 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
@@ -265,6 +247,7 @@ files:
265
247
  - lib/glimmer/error.rb
266
248
  - lib/glimmer/ext/module.rb
267
249
  - lib/glimmer/invalid_keyword_error.rb
250
+ - lib/glimmer/shim/concurrent.rb
268
251
  homepage: http://github.com/AndyObtiva/glimmer
269
252
  licenses:
270
253
  - MIT
@@ -284,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
284
267
  - !ruby/object:Gem::Version
285
268
  version: '0'
286
269
  requirements: []
287
- rubygems_version: 3.2.3
270
+ rubygems_version: 3.2.22
288
271
  signing_key:
289
272
  specification_version: 4
290
273
  summary: Glimmer - DSL Engine for Ruby GUI and More