glimmer 1.0.11 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +125 -138
- data/VERSION +1 -1
- data/glimmer.gemspec +35 -20
- data/lib/glimmer/data_binding/model_binding.rb +33 -20
- metadata +17 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c181d967c5d8c834867570a112937498dd4d45c9585f357a683368de979967c1
|
4
|
+
data.tar.gz: 50a1ed33fd43a34e500de9ce2954d02ffc511204108c8d80b99eb31b885c8f1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a1d46f0e7f051000acbcf5756dd3c15a892583557388a181d47186e74a39f4eeb27c3c05b94780cae47c67f8b5a3e4c8a237cd5ce94c551cbb0eec8a6494af3
|
7
|
+
data.tar.gz: 54ce9ae27a6f5f4b320783ec1e107cde725435da3e3bb3199bb6ff44a89f647de81339654be98d06a903aed3feb4caf096bbc80d9c9e9df8ef194e3c9789b8a4
|
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.1.0
|
7
|
+
|
8
|
+
- ModelBinding hooks for before_read, after_read, before_write, after_write
|
9
|
+
|
6
10
|
## 1.0.11
|
7
11
|
|
8
12
|
- Alias unregister as deregister everywhere
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 style="position: relative; top: 20px;" />](https://rubygems.org/gems/glimmer) Glimmer 1.0
|
1
|
+
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 style="position: relative; top: 20px;" />](https://rubygems.org/gems/glimmer) Glimmer 1.1.0 - DSL Framework for GUI and More
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/glimmer.svg)](http://badge.fury.io/rb/glimmer)
|
3
3
|
[![rspec](https://github.com/AndyObtiva/glimmer/workflows/rspec/badge.svg)](https://github.com/AndyObtiva/glimmer/actions?query=workflow%3Arspec)
|
4
4
|
[![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer?branch=master)
|
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
**(The Original Glimmer Library Since 2007. Beware of Imitators!)**
|
11
11
|
|
12
|
-
[**Glimmer**](https://rubygems.org/gems/glimmer) started out as a [GUI Library](https://github.com/AndyObtiva/glimmer-dsl-swt) and grew into a full-fledged [DSL Framework](#dsl-engine) with support for multiple GUI DSLs. Glimmer's namesake is referring to the Glimmer of Ruby in Graphical User Interfaces (contrary to popular myth perpetrated by [Charles Nutter](http://blog.headius.com/2007/11/tab-sweep.html), Glimmer has nothing to do with the ill-fated Whitney Houston movie, which does not in fact share the same name)
|
12
|
+
[**Glimmer**](https://rubygems.org/gems/glimmer) started out as a [GUI Library](https://github.com/AndyObtiva/glimmer-dsl-swt) and grew into a full-fledged [DSL Framework](#dsl-engine) with support for multiple GUI DSLs. Glimmer's namesake is referring to the Glimmer of Ruby in Graphical User Interfaces (contrary to [popular myth](http://blog.headius.com/2007/11/tab-sweep.html) perpetrated by [Charles Nutter](http://blog.headius.com/2007/11/tab-sweep.html), Glimmer has nothing to do with the ill-fated Whitney Houston movie, which does not in fact share the same name)
|
13
13
|
|
14
14
|
[<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
|
15
15
|
Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) and [Chalmers/Gothenburg University Software Engineering Master's Lecture Material](http://www.cse.chalmers.se/~bergert/slides/guest_lecture_DSLs.pdf)
|
@@ -38,7 +38,7 @@ Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) an
|
|
38
38
|
|
39
39
|
## Table of Contents
|
40
40
|
|
41
|
-
- [Glimmer 1.0
|
41
|
+
- [Glimmer 1.1.0](#-glimmer-110---dsl-framework-for-gui-and-more)
|
42
42
|
- [Official DSLs](#official-dsls)
|
43
43
|
- [Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)](#glimmer-dsl-for-swt-jruby-desktop-development-gui-framework)
|
44
44
|
- [Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)](#glimmer-dsl-for-opal-pure-ruby-web-gui-and-auto-webifier-of-desktop-apps)
|
@@ -76,6 +76,8 @@ To get started, visit the [Glimmer DSL for SWT project page](https://github.com/
|
|
76
76
|
|
77
77
|
##### Hello, World!
|
78
78
|
|
79
|
+
![Hello World](images/glimmer-hello-world.png)
|
80
|
+
|
79
81
|
Glimmer GUI code (from [samples/hello/hello_world.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_world.rb)):
|
80
82
|
```ruby
|
81
83
|
include Glimmer
|
@@ -88,162 +90,141 @@ shell {
|
|
88
90
|
}.open
|
89
91
|
```
|
90
92
|
|
91
|
-
Glimmer
|
93
|
+
##### Glimmer Tetris
|
92
94
|
|
93
|
-
![
|
95
|
+
![Tetris](https://raw.githubusercontent.com/AndyObtiva/glimmer-dsl-swt/v4.18.3.1/images/glimmer-tetris.png)
|
94
96
|
|
95
|
-
|
96
|
-
|
97
|
-
Glimmer GUI code (from [samples/elaborate/tic_tac_toe.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/elaborate/tic_tac_toe.rb)):
|
97
|
+
Glimmer GUI code (from [samples/elaborate/tetris.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/v4.18.3.1/samples/elaborate/tetris.rb)):
|
98
98
|
|
99
99
|
```ruby
|
100
100
|
# ...
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
101
|
+
shell(:no_resize) {
|
102
|
+
grid_layout {
|
103
|
+
num_columns 2
|
104
|
+
make_columns_equal_width false
|
105
|
+
margin_width 0
|
106
|
+
margin_height 0
|
107
|
+
horizontal_spacing 0
|
108
|
+
}
|
109
|
+
|
110
|
+
text 'Glimmer Tetris'
|
111
|
+
minimum_size 475, 500
|
112
|
+
background :gray
|
113
|
+
|
114
|
+
tetris_menu_bar(game: game)
|
115
|
+
|
116
|
+
playfield(game_playfield: game.playfield, playfield_width: playfield_width, playfield_height: playfield_height, block_size: BLOCK_SIZE)
|
117
|
+
|
118
|
+
score_lane(game: game, block_size: BLOCK_SIZE) {
|
119
|
+
layout_data(:fill, :fill, true, true)
|
120
|
+
}
|
121
|
+
|
122
|
+
on_widget_disposed {
|
123
|
+
deregister_observers
|
119
124
|
}
|
120
125
|
}
|
121
126
|
# ...
|
122
127
|
```
|
123
128
|
|
124
|
-
|
125
|
-
|
126
|
-
![Tic Tac Toe](images/glimmer-tic-tac-toe-in-progress.png)
|
129
|
+
##### Hello, Table!
|
127
130
|
|
128
|
-
|
131
|
+
![Hello Table](https://raw.githubusercontent.com/AndyObtiva/glimmer-dsl-swt/master/images/glimmer-hello-table.png)
|
129
132
|
|
130
|
-
Glimmer GUI code (from [samples/
|
133
|
+
Glimmer GUI code (from [samples/hello/hello_table.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_table.rb)):
|
131
134
|
|
132
135
|
```ruby
|
133
136
|
# ...
|
134
137
|
shell {
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
138
|
+
grid_layout
|
139
|
+
|
140
|
+
text 'Hello, Table!'
|
141
|
+
|
142
|
+
label {
|
143
|
+
layout_data :center, :center, true, false
|
144
|
+
|
145
|
+
text 'Baseball Playoff Schedule'
|
146
|
+
font height: 30, style: :bold
|
147
|
+
}
|
148
|
+
|
149
|
+
combo(:read_only) {
|
150
|
+
layout_data :center, :center, true, false
|
151
|
+
selection bind(BaseballGame, :playoff_type)
|
152
|
+
font height: 16
|
153
|
+
}
|
154
|
+
|
155
|
+
table(:editable) { |table_proxy|
|
156
|
+
layout_data :fill, :fill, true, true
|
157
|
+
|
158
|
+
table_column {
|
159
|
+
text 'Game Date'
|
160
|
+
width 150
|
161
|
+
sort_property :date # ensure sorting by real date value (not `game_date` string specified in items below)
|
162
|
+
editor :date_drop_down, property: :date_time
|
163
|
+
}
|
164
|
+
table_column {
|
165
|
+
text 'Game Time'
|
166
|
+
width 150
|
167
|
+
sort_property :time # ensure sorting by real time value (not `game_time` string specified in items below)
|
168
|
+
editor :time, property: :date_time
|
169
|
+
}
|
170
|
+
table_column {
|
171
|
+
text 'Ballpark'
|
172
|
+
width 180
|
173
|
+
editor :none
|
174
|
+
}
|
175
|
+
table_column {
|
176
|
+
text 'Home Team'
|
177
|
+
width 150
|
178
|
+
editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
|
179
|
+
}
|
180
|
+
table_column {
|
181
|
+
text 'Away Team'
|
182
|
+
width 150
|
183
|
+
editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
|
184
|
+
}
|
185
|
+
table_column {
|
186
|
+
text 'Promotion'
|
187
|
+
width 150
|
188
|
+
# default text editor is used here
|
189
|
+
}
|
190
|
+
|
191
|
+
# Data-bind table items (rows) to a model collection property, specifying column properties ordering per nested model
|
192
|
+
items bind(BaseballGame, :schedule), column_properties(:game_date, :game_time, :ballpark, :home_team, :away_team, :promotion)
|
193
|
+
|
194
|
+
# Data-bind table selection
|
195
|
+
selection bind(BaseballGame, :selected_game)
|
196
|
+
|
197
|
+
# Default initial sort property
|
198
|
+
sort_property :date
|
199
|
+
|
200
|
+
# Sort by these additional properties after handling sort by the column the user clicked
|
201
|
+
additional_sort_properties :date, :time, :home_team, :away_team, :ballpark, :promotion
|
202
|
+
|
203
|
+
menu {
|
204
|
+
menu_item {
|
205
|
+
text 'Book'
|
201
206
|
|
202
|
-
|
203
|
-
|
204
|
-
on_widget_selected { @contact_manager_presenter.list }
|
205
|
-
on_key_pressed {|key_event|
|
206
|
-
@contact_manager_presenter.list if key_event.keyCode == swt(:cr)
|
207
|
-
}
|
207
|
+
on_widget_selected {
|
208
|
+
book_selected_game
|
208
209
|
}
|
209
210
|
}
|
210
211
|
}
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
text "First Name"
|
222
|
-
width 80
|
223
|
-
}
|
224
|
-
table_column {
|
225
|
-
text "Last Name"
|
226
|
-
width 80
|
227
|
-
}
|
228
|
-
table_column {
|
229
|
-
text "Email"
|
230
|
-
width 200
|
231
|
-
}
|
232
|
-
items bind(@contact_manager_presenter, :results),
|
233
|
-
column_properties(:first_name, :last_name, :email)
|
234
|
-
on_mouse_up { |event|
|
235
|
-
table_proxy.edit_table_item(event.table_item, event.column_index)
|
236
|
-
}
|
212
|
+
}
|
213
|
+
|
214
|
+
button {
|
215
|
+
text 'Book Selected Game'
|
216
|
+
layout_data :center, :center, true, false
|
217
|
+
font height: 16
|
218
|
+
enabled bind(BaseballGame, :selected_game)
|
219
|
+
|
220
|
+
on_widget_selected {
|
221
|
+
book_selected_game
|
237
222
|
}
|
238
223
|
}
|
239
224
|
}.open
|
240
225
|
# ...
|
241
226
|
```
|
242
227
|
|
243
|
-
Glimmer App:
|
244
|
-
|
245
|
-
![Contact Manager](images/glimmer-contact-manager.png)
|
246
|
-
|
247
228
|
#### Production Desktop Apps Built with Glimmer DSL for SWT
|
248
229
|
|
249
230
|
[<img alt="Are We There Yet Logo" src="https://raw.githubusercontent.com/AndyObtiva/are-we-there-yet/master/are-we-there-yet-logo.svg" width="40" />Are We There Yet?](https://github.com/AndyObtiva/are-we-there-yet) - Small Project Tracking App
|
@@ -254,6 +235,10 @@ Glimmer App:
|
|
254
235
|
|
255
236
|
[![Math Bowling App Screenshot](https://raw.githubusercontent.com/AndyObtiva/MathBowling/master/Math-Bowling-Screenshot.png)](https://github.com/AndyObtiva/MathBowling)
|
256
237
|
|
238
|
+
[<img alt="Garderie Rainbow Daily Agenda Logo" src="https://raw.githubusercontent.com/AndyObtiva/garderie_rainbow_daily_agenda/master/images/garderie_rainbow_daily_agenda_logo.png" width="40" />Garderie Rainbow Daily Agenda](https://github.com/AndyObtiva/garderie_rainbow_daily_agenda) - A child nursery daily agenda reporting desktop app
|
239
|
+
|
240
|
+
[![Garderie Rainbow Daily Agenda App Screenshot](https://raw.githubusercontent.com/AndyObtiva/garderie_rainbow_daily_agenda/master/images/garderie_rainbow_daily_agenda_screenshot.png)](https://github.com/AndyObtiva/garderie_rainbow_daily_agenda)
|
241
|
+
|
257
242
|
### Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)
|
258
243
|
|
259
244
|
[Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal) is an experimental proof-of-concept web GUI adapter for [Glimmer](https://github.com/AndyObtiva/glimmer) desktop apps (i.e. apps built with [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt)). It webifies them via [Rails](https://rubyonrails.org/), allowing Ruby desktop apps to run on the web via [Opal Ruby](https://opalrb.com/) without changing a line of code. Apps may then be custom-styled for the web with standard CSS.
|
@@ -418,9 +403,9 @@ shell {
|
|
418
403
|
caret nil
|
419
404
|
}
|
420
405
|
command_button('AC')
|
421
|
-
operation_button('
|
422
|
-
operation_button('
|
423
|
-
operation_button('
|
406
|
+
operation_button('÷')
|
407
|
+
operation_button('�')
|
408
|
+
operation_button('−')
|
424
409
|
(7..9).each { |number|
|
425
410
|
number_button(number)
|
426
411
|
}
|
@@ -852,9 +837,11 @@ Example: `Glimmer::DSL::Engine.enabled_dsls = [:xml, :css]`
|
|
852
837
|
|
853
838
|
## Data-Binding Library
|
854
839
|
|
855
|
-
Data-Binding enables
|
840
|
+
Data-Binding enables mapping GUI properties (like text and color) to Model attributes (like name and age).
|
841
|
+
|
842
|
+
Glimmer enhances observed models automatically (including array operations like `<<` and `reject!`) on first observation. As such, you get automatic observable support, including nested and computed observations. No need to change your model code to data-bind it to the view or add repetitive boilerplate modules. View data-binding is truly decoupled from model logic by being able to observe any model attribute (Ruby attribute reader/writer combo or Ruby attribute reader alone for read-only data-binding when needed)
|
856
843
|
|
857
|
-
|
844
|
+
This relies mainly on the Observer Design Pattern and the MVP (Model-View-Presenter) Architectural Pattern (a variation on MVC)
|
858
845
|
|
859
846
|
These are the main classes concerning data-binding:
|
860
847
|
- `Observer`: Provides general observer support including unique registration and deregistration for cleanup and prevention of memory leaks. Main methods concerned are: `call`, `register` (alias: `observe`), and `unregister` (alias: `unobserve` or `deregister`)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/glimmer.gemspec
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in
|
3
|
+
# Instead, edit Jeweler::Tasks in rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: glimmer 1.0
|
5
|
+
# stub: glimmer 1.1.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "glimmer".freeze
|
9
|
-
s.version = "1.0
|
9
|
+
s.version = "1.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-
|
14
|
+
s.date = "2021-02-08"
|
15
15
|
s.description = "Glimmer is a Ruby DSL Framework 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 = [
|
18
|
+
"CHANGELOG.md",
|
18
19
|
"LICENSE.txt",
|
19
20
|
"README.md"
|
20
21
|
]
|
@@ -45,27 +46,41 @@ Gem::Specification.new do |s|
|
|
45
46
|
]
|
46
47
|
s.homepage = "http://github.com/AndyObtiva/glimmer".freeze
|
47
48
|
s.licenses = ["MIT".freeze]
|
48
|
-
s.rubygems_version = "3.
|
49
|
+
s.rubygems_version = "3.0.6".freeze
|
49
50
|
s.summary = "Glimmer Ruby DSL Engine".freeze
|
50
51
|
|
51
52
|
if s.respond_to? :specification_version then
|
52
53
|
s.specification_version = 4
|
53
|
-
end
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
55
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
56
|
+
s.add_runtime_dependency(%q<array_include_methods>.freeze, [">= 1.0.4", "< 2.0.0"])
|
57
|
+
s.add_runtime_dependency(%q<facets>.freeze, [">= 3.1.0", "< 4.0.0"])
|
58
|
+
s.add_runtime_dependency(%q<concurrent-ruby>.freeze, [">= 1.1.7", "< 2.0.0"])
|
59
|
+
s.add_development_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
|
60
|
+
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
61
|
+
s.add_development_dependency(%q<puts_debuggerer>.freeze, ["~> 0.10.0"])
|
62
|
+
s.add_development_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
|
63
|
+
s.add_development_dependency(%q<jeweler>.freeze, [">= 2.0.0", "< 3.0.0"])
|
64
|
+
s.add_development_dependency(%q<rdoc>.freeze, [">= 6.2.1", "< 7.0.0"])
|
65
|
+
s.add_development_dependency(%q<coveralls>.freeze, [">= 0"])
|
66
|
+
s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.16.1"])
|
67
|
+
s.add_development_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
|
68
|
+
s.add_development_dependency(%q<rake-tui>.freeze, [">= 0"])
|
69
|
+
else
|
70
|
+
s.add_dependency(%q<array_include_methods>.freeze, [">= 1.0.4", "< 2.0.0"])
|
71
|
+
s.add_dependency(%q<facets>.freeze, [">= 3.1.0", "< 4.0.0"])
|
72
|
+
s.add_dependency(%q<concurrent-ruby>.freeze, [">= 1.1.7", "< 2.0.0"])
|
73
|
+
s.add_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
|
74
|
+
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
75
|
+
s.add_dependency(%q<puts_debuggerer>.freeze, ["~> 0.10.0"])
|
76
|
+
s.add_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
|
77
|
+
s.add_dependency(%q<jeweler>.freeze, [">= 2.0.0", "< 3.0.0"])
|
78
|
+
s.add_dependency(%q<rdoc>.freeze, [">= 6.2.1", "< 7.0.0"])
|
79
|
+
s.add_dependency(%q<coveralls>.freeze, [">= 0"])
|
80
|
+
s.add_dependency(%q<simplecov>.freeze, ["~> 0.16.1"])
|
81
|
+
s.add_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
|
82
|
+
s.add_dependency(%q<rake-tui>.freeze, [">= 0"])
|
83
|
+
end
|
69
84
|
else
|
70
85
|
s.add_dependency(%q<array_include_methods>.freeze, [">= 1.0.4", "< 2.0.0"])
|
71
86
|
s.add_dependency(%q<facets>.freeze, [">= 3.1.0", "< 4.0.0"])
|
@@ -72,21 +72,6 @@ module Glimmer
|
|
72
72
|
nested_property? ? nested_property_name : property_name_expression
|
73
73
|
end
|
74
74
|
|
75
|
-
def convert_on_read(value)
|
76
|
-
apply_converter(@binding_options[:on_read], value)
|
77
|
-
end
|
78
|
-
|
79
|
-
def convert_on_write(value)
|
80
|
-
apply_converter(@binding_options[:on_write], value)
|
81
|
-
end
|
82
|
-
|
83
|
-
def apply_converter(converter, value)
|
84
|
-
return value if converter.nil?
|
85
|
-
return value.send(converter) if (converter.is_a?(String) || converter.is_a?(Symbol)) && value.respond_to?(converter)
|
86
|
-
return converter.call(value) if converter.respond_to?(:call, value)
|
87
|
-
raise Glimmer::Error, "Unsupported bind converter: #{converter.inspect}"
|
88
|
-
end
|
89
|
-
|
90
75
|
# All nested property names
|
91
76
|
# e.g. property name expression "address.state" gives ['address', 'state']
|
92
77
|
# If there are any indexed property names, this returns indexes as properties.
|
@@ -215,9 +200,12 @@ module Glimmer
|
|
215
200
|
def evaluate_property
|
216
201
|
value = nil
|
217
202
|
value = invoke_property_reader(model, property_name) unless model.nil?
|
218
|
-
|
203
|
+
apply_processor(@binding_options[:before_read], value)
|
204
|
+
converted_value = convert_on_read(value)
|
205
|
+
apply_processor(@binding_options[:after_read], converted_value)
|
206
|
+
converted_value
|
219
207
|
end
|
220
|
-
|
208
|
+
|
221
209
|
def evaluate_options_property
|
222
210
|
model.send(options_property_name) unless model.nil?
|
223
211
|
end
|
@@ -230,6 +218,29 @@ module Glimmer
|
|
230
218
|
property_expression.to_s.start_with?('[')
|
231
219
|
end
|
232
220
|
|
221
|
+
private
|
222
|
+
|
223
|
+
def convert_on_read(value)
|
224
|
+
apply_processor(@binding_options[:on_read], value)
|
225
|
+
end
|
226
|
+
|
227
|
+
def convert_on_write(value)
|
228
|
+
apply_processor(@binding_options[:on_write], value)
|
229
|
+
end
|
230
|
+
|
231
|
+
def apply_processor(processor, value)
|
232
|
+
return value if processor.nil?
|
233
|
+
return value.send(processor) if (processor.is_a?(String) || processor.is_a?(Symbol)) && value.respond_to?(processor)
|
234
|
+
return invoke_proc_with_exact_parameters(processor, value) if processor.respond_to?(:call)
|
235
|
+
raise Glimmer::Error, "Unsupported bind processor: #{processor.inspect}"
|
236
|
+
end
|
237
|
+
|
238
|
+
def invoke_proc_with_exact_parameters(proc_object, *args)
|
239
|
+
return if proc_object.nil?
|
240
|
+
args = args[0...proc_object.parameters.size]
|
241
|
+
proc_object.call(*args)
|
242
|
+
end
|
243
|
+
|
233
244
|
def invoke_property_reader(object, property_expression)
|
234
245
|
if property_indexed?(property_expression)
|
235
246
|
property_method = '[]'
|
@@ -243,14 +254,16 @@ module Glimmer
|
|
243
254
|
|
244
255
|
def invoke_property_writer(object, property_expression, value)
|
245
256
|
raise "Cannot invoke `#{property_expression}` because ModelBinding#binding_options[:read_only]=true" if @binding_options[:read_only]
|
246
|
-
|
257
|
+
apply_processor(@binding_options[:before_write], value)
|
258
|
+
converted_value = convert_on_write(value)
|
259
|
+
apply_processor(@binding_options[:after_write], converted_value)
|
247
260
|
if property_indexed?(property_expression)
|
248
261
|
property_method = '[]='
|
249
262
|
property_argument = property_expression[1...-2]
|
250
263
|
property_argument = property_argument.to_i if property_argument.match(/\d+/)
|
251
|
-
object.send(property_method, property_argument,
|
264
|
+
object.send(property_method, property_argument, converted_value)
|
252
265
|
else
|
253
|
-
object.send(property_expression,
|
266
|
+
object.send(property_expression, converted_value)
|
254
267
|
end
|
255
268
|
end
|
256
269
|
end
|
metadata
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.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-
|
11
|
+
date: 2021-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: array_include_methods
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
@@ -20,6 +19,7 @@ dependencies:
|
|
20
19
|
- - "<"
|
21
20
|
- !ruby/object:Gem::Version
|
22
21
|
version: 2.0.0
|
22
|
+
name: array_include_methods
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -31,7 +31,6 @@ dependencies:
|
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 2.0.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name: facets
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
36
35
|
requirements:
|
37
36
|
- - ">="
|
@@ -40,6 +39,7 @@ dependencies:
|
|
40
39
|
- - "<"
|
41
40
|
- !ruby/object:Gem::Version
|
42
41
|
version: 4.0.0
|
42
|
+
name: facets
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -51,7 +51,6 @@ dependencies:
|
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 4.0.0
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
|
-
name: concurrent-ruby
|
55
54
|
requirement: !ruby/object:Gem::Requirement
|
56
55
|
requirements:
|
57
56
|
- - ">="
|
@@ -60,6 +59,7 @@ dependencies:
|
|
60
59
|
- - "<"
|
61
60
|
- !ruby/object:Gem::Version
|
62
61
|
version: 2.0.0
|
62
|
+
name: concurrent-ruby
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -71,12 +71,12 @@ dependencies:
|
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: 2.0.0
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
|
-
name: rspec-mocks
|
75
74
|
requirement: !ruby/object:Gem::Requirement
|
76
75
|
requirements:
|
77
76
|
- - "~>"
|
78
77
|
- !ruby/object:Gem::Version
|
79
78
|
version: 3.5.0
|
79
|
+
name: rspec-mocks
|
80
80
|
type: :development
|
81
81
|
prerelease: false
|
82
82
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -85,12 +85,12 @@ dependencies:
|
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: 3.5.0
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
|
-
name: rspec
|
89
88
|
requirement: !ruby/object:Gem::Requirement
|
90
89
|
requirements:
|
91
90
|
- - "~>"
|
92
91
|
- !ruby/object:Gem::Version
|
93
92
|
version: 3.5.0
|
93
|
+
name: rspec
|
94
94
|
type: :development
|
95
95
|
prerelease: false
|
96
96
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -99,12 +99,12 @@ dependencies:
|
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: 3.5.0
|
101
101
|
- !ruby/object:Gem::Dependency
|
102
|
-
name: puts_debuggerer
|
103
102
|
requirement: !ruby/object:Gem::Requirement
|
104
103
|
requirements:
|
105
104
|
- - "~>"
|
106
105
|
- !ruby/object:Gem::Version
|
107
106
|
version: 0.10.0
|
107
|
+
name: puts_debuggerer
|
108
108
|
type: :development
|
109
109
|
prerelease: false
|
110
110
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -113,7 +113,6 @@ dependencies:
|
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: 0.10.0
|
115
115
|
- !ruby/object:Gem::Dependency
|
116
|
-
name: rake
|
117
116
|
requirement: !ruby/object:Gem::Requirement
|
118
117
|
requirements:
|
119
118
|
- - ">="
|
@@ -122,6 +121,7 @@ dependencies:
|
|
122
121
|
- - "<"
|
123
122
|
- !ruby/object:Gem::Version
|
124
123
|
version: 14.0.0
|
124
|
+
name: rake
|
125
125
|
type: :development
|
126
126
|
prerelease: false
|
127
127
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -133,7 +133,6 @@ dependencies:
|
|
133
133
|
- !ruby/object:Gem::Version
|
134
134
|
version: 14.0.0
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
|
-
name: jeweler
|
137
136
|
requirement: !ruby/object:Gem::Requirement
|
138
137
|
requirements:
|
139
138
|
- - ">="
|
@@ -142,6 +141,7 @@ dependencies:
|
|
142
141
|
- - "<"
|
143
142
|
- !ruby/object:Gem::Version
|
144
143
|
version: 3.0.0
|
144
|
+
name: jeweler
|
145
145
|
type: :development
|
146
146
|
prerelease: false
|
147
147
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -153,7 +153,6 @@ dependencies:
|
|
153
153
|
- !ruby/object:Gem::Version
|
154
154
|
version: 3.0.0
|
155
155
|
- !ruby/object:Gem::Dependency
|
156
|
-
name: rdoc
|
157
156
|
requirement: !ruby/object:Gem::Requirement
|
158
157
|
requirements:
|
159
158
|
- - ">="
|
@@ -162,6 +161,7 @@ dependencies:
|
|
162
161
|
- - "<"
|
163
162
|
- !ruby/object:Gem::Version
|
164
163
|
version: 7.0.0
|
164
|
+
name: rdoc
|
165
165
|
type: :development
|
166
166
|
prerelease: false
|
167
167
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -173,12 +173,12 @@ dependencies:
|
|
173
173
|
- !ruby/object:Gem::Version
|
174
174
|
version: 7.0.0
|
175
175
|
- !ruby/object:Gem::Dependency
|
176
|
-
name: coveralls
|
177
176
|
requirement: !ruby/object:Gem::Requirement
|
178
177
|
requirements:
|
179
178
|
- - ">="
|
180
179
|
- !ruby/object:Gem::Version
|
181
180
|
version: '0'
|
181
|
+
name: coveralls
|
182
182
|
type: :development
|
183
183
|
prerelease: false
|
184
184
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -187,12 +187,12 @@ dependencies:
|
|
187
187
|
- !ruby/object:Gem::Version
|
188
188
|
version: '0'
|
189
189
|
- !ruby/object:Gem::Dependency
|
190
|
-
name: simplecov
|
191
190
|
requirement: !ruby/object:Gem::Requirement
|
192
191
|
requirements:
|
193
192
|
- - "~>"
|
194
193
|
- !ruby/object:Gem::Version
|
195
194
|
version: 0.16.1
|
195
|
+
name: simplecov
|
196
196
|
type: :development
|
197
197
|
prerelease: false
|
198
198
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -201,12 +201,12 @@ dependencies:
|
|
201
201
|
- !ruby/object:Gem::Version
|
202
202
|
version: 0.16.1
|
203
203
|
- !ruby/object:Gem::Dependency
|
204
|
-
name: simplecov-lcov
|
205
204
|
requirement: !ruby/object:Gem::Requirement
|
206
205
|
requirements:
|
207
206
|
- - "~>"
|
208
207
|
- !ruby/object:Gem::Version
|
209
208
|
version: 0.7.0
|
209
|
+
name: simplecov-lcov
|
210
210
|
type: :development
|
211
211
|
prerelease: false
|
212
212
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -215,12 +215,12 @@ dependencies:
|
|
215
215
|
- !ruby/object:Gem::Version
|
216
216
|
version: 0.7.0
|
217
217
|
- !ruby/object:Gem::Dependency
|
218
|
-
name: rake-tui
|
219
218
|
requirement: !ruby/object:Gem::Requirement
|
220
219
|
requirements:
|
221
220
|
- - ">="
|
222
221
|
- !ruby/object:Gem::Version
|
223
222
|
version: '0'
|
223
|
+
name: rake-tui
|
224
224
|
type: :development
|
225
225
|
prerelease: false
|
226
226
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -237,6 +237,7 @@ email: andy.am@gmail.com
|
|
237
237
|
executables: []
|
238
238
|
extensions: []
|
239
239
|
extra_rdoc_files:
|
240
|
+
- CHANGELOG.md
|
240
241
|
- LICENSE.txt
|
241
242
|
- README.md
|
242
243
|
files:
|
@@ -282,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
282
283
|
- !ruby/object:Gem::Version
|
283
284
|
version: '0'
|
284
285
|
requirements: []
|
285
|
-
rubygems_version: 3.
|
286
|
+
rubygems_version: 3.0.6
|
286
287
|
signing_key:
|
287
288
|
specification_version: 4
|
288
289
|
summary: Glimmer Ruby DSL Engine
|