glimmer-dsl-opal 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +95 -20
- data/VERSION +1 -1
- data/lib/glimmer-dsl-opal.rb +10 -8
- data/lib/glimmer/data_binding/element_binding.rb +35 -0
- data/lib/glimmer/data_binding/observable_element.rb +14 -0
- data/lib/glimmer/dsl/opal/bind_expression.rb +37 -0
- data/lib/glimmer/dsl/opal/button_expression.rb +17 -0
- data/lib/glimmer/dsl/opal/combo_expression.rb +17 -0
- data/lib/glimmer/dsl/opal/combo_selection_data_binding_expression.rb +40 -0
- data/lib/glimmer/dsl/opal/composite_expression.rb +17 -0
- data/lib/glimmer/dsl/opal/data_binding_expression.rb +34 -0
- data/lib/glimmer/dsl/opal/dsl.rb +9 -0
- data/lib/glimmer/dsl/opal/label_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/property_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/shell_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/widget_listener_expression.rb +18 -0
- data/lib/glimmer/opal/div_proxy.rb +14 -0
- data/lib/glimmer/opal/{shell.rb → document_proxy.rb} +19 -5
- data/lib/glimmer/opal/element_proxy.rb +52 -0
- data/lib/glimmer/opal/event_listener_proxy.rb +18 -0
- data/lib/glimmer/opal/input_proxy.rb +30 -0
- data/lib/glimmer/opal/label_proxy.rb +24 -0
- data/lib/glimmer/opal/select_proxy.rb +58 -0
- data/lib/samples/elaborate/contact_manager.rb +95 -0
- data/lib/samples/elaborate/contact_manager/contact.rb +11 -0
- data/lib/samples/elaborate/contact_manager/contact_manager_presenter.rb +36 -0
- data/lib/samples/elaborate/contact_manager/contact_repository.rb +244 -0
- data/lib/samples/elaborate/launch +6 -0
- data/lib/samples/elaborate/login.rb +88 -0
- data/lib/samples/elaborate/tic_tac_toe.rb +53 -0
- data/lib/samples/elaborate/tic_tac_toe/board.rb +124 -0
- data/lib/samples/elaborate/tic_tac_toe/cell.rb +27 -0
- data/lib/samples/hello/hello_browser.rb +8 -0
- data/lib/samples/hello/hello_combo.rb +34 -0
- data/lib/samples/hello/hello_computed.rb +69 -0
- data/lib/samples/hello/hello_computed/contact.rb +21 -0
- data/lib/samples/hello/hello_list_multi_selection.rb +44 -0
- data/lib/samples/hello/hello_list_single_selection.rb +34 -0
- data/lib/samples/hello/hello_tab.rb +24 -0
- data/lib/samples/hello/hello_world.rb +8 -0
- data/lib/samples/hello/launch +10 -0
- data/lib/samples/launch +4 -0
- metadata +39 -6
- data/lib/glimmer/opal/label.rb +0 -31
@@ -0,0 +1,27 @@
|
|
1
|
+
class TicTacToe
|
2
|
+
class Cell
|
3
|
+
EMPTY = ""
|
4
|
+
attr_accessor :sign, :empty
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
reset
|
8
|
+
end
|
9
|
+
|
10
|
+
def mark(sign)
|
11
|
+
self.sign = sign
|
12
|
+
end
|
13
|
+
|
14
|
+
def reset
|
15
|
+
self.sign = EMPTY
|
16
|
+
end
|
17
|
+
|
18
|
+
def sign=(sign_symbol)
|
19
|
+
@sign = sign_symbol
|
20
|
+
self.empty = sign == EMPTY
|
21
|
+
end
|
22
|
+
|
23
|
+
def marked
|
24
|
+
!empty
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Person
|
2
|
+
attr_accessor :country, :country_options
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
self.country_options=["", "Canada", "US", "Mexico"]
|
6
|
+
self.country = "Canada"
|
7
|
+
end
|
8
|
+
|
9
|
+
def reset_country
|
10
|
+
self.country = "Canada"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class HelloCombo
|
15
|
+
include Glimmer
|
16
|
+
def launch
|
17
|
+
person = Person.new
|
18
|
+
shell {
|
19
|
+
composite {
|
20
|
+
combo(:read_only) {
|
21
|
+
selection bind(person, :country)
|
22
|
+
}
|
23
|
+
button {
|
24
|
+
text "Reset"
|
25
|
+
on_widget_selected do
|
26
|
+
person.reset_country
|
27
|
+
end
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}.open
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
HelloCombo.new.launch
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require_relative "hello_computed/contact"
|
2
|
+
|
3
|
+
class HelloComputed
|
4
|
+
include Glimmer
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@contact = Contact.new(
|
8
|
+
first_name: "Barry",
|
9
|
+
last_name: "McKibbin",
|
10
|
+
year_of_birth: 1985
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
def launch
|
15
|
+
shell {
|
16
|
+
text "Hello Computed"
|
17
|
+
composite {
|
18
|
+
grid_layout {
|
19
|
+
num_columns 2
|
20
|
+
make_columns_equal_width true
|
21
|
+
horizontal_spacing 20
|
22
|
+
vertical_spacing 10
|
23
|
+
}
|
24
|
+
label {text "First &Name: "}
|
25
|
+
text {
|
26
|
+
text bind(@contact, :first_name)
|
27
|
+
layout_data {
|
28
|
+
horizontalAlignment :fill
|
29
|
+
grabExcessHorizontalSpace true
|
30
|
+
}
|
31
|
+
}
|
32
|
+
label {text "&Last Name: "}
|
33
|
+
text {
|
34
|
+
text bind(@contact, :last_name)
|
35
|
+
layout_data {
|
36
|
+
horizontalAlignment :fill
|
37
|
+
grabExcessHorizontalSpace true
|
38
|
+
}
|
39
|
+
}
|
40
|
+
label {text "&Year of Birth: "}
|
41
|
+
text {
|
42
|
+
text bind(@contact, :year_of_birth)
|
43
|
+
layout_data {
|
44
|
+
horizontalAlignment :fill
|
45
|
+
grabExcessHorizontalSpace true
|
46
|
+
}
|
47
|
+
}
|
48
|
+
label {text "Name: "}
|
49
|
+
label {
|
50
|
+
text bind(@contact, :name, computed_by: [:first_name, :last_name])
|
51
|
+
layout_data {
|
52
|
+
horizontalAlignment :fill
|
53
|
+
grabExcessHorizontalSpace true
|
54
|
+
}
|
55
|
+
}
|
56
|
+
label {text "Age: "}
|
57
|
+
label {
|
58
|
+
text bind(@contact, :age, on_write: :to_i, computed_by: [:year_of_birth])
|
59
|
+
layout_data {
|
60
|
+
horizontalAlignment :fill
|
61
|
+
grabExcessHorizontalSpace true
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}.open
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
HelloComputed.new.launch
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class HelloComputed
|
2
|
+
class Contact
|
3
|
+
attr_accessor :first_name, :last_name, :year_of_birth
|
4
|
+
|
5
|
+
def initialize(attribute_map)
|
6
|
+
@first_name = attribute_map[:first_name]
|
7
|
+
@last_name = attribute_map[:last_name]
|
8
|
+
@year_of_birth = attribute_map[:year_of_birth]
|
9
|
+
end
|
10
|
+
|
11
|
+
def name
|
12
|
+
"#{last_name}, #{first_name}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def age
|
16
|
+
Time.now.year - year_of_birth.to_i
|
17
|
+
rescue
|
18
|
+
0
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class Person
|
2
|
+
attr_accessor :provinces, :provinces_options
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
self.provinces_options=[
|
6
|
+
"",
|
7
|
+
"Quebec",
|
8
|
+
"Ontario",
|
9
|
+
"Manitoba",
|
10
|
+
"Saskatchewan",
|
11
|
+
"Alberta",
|
12
|
+
"British Columbia",
|
13
|
+
"Nova Skotia",
|
14
|
+
"Newfoundland"
|
15
|
+
]
|
16
|
+
self.provinces = ["Quebec", "Manitoba", "Alberta"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def reset_provinces
|
20
|
+
self.provinces = ["Quebec", "Manitoba", "Alberta"]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class HelloListMultiSelection
|
25
|
+
include Glimmer
|
26
|
+
def launch
|
27
|
+
person = Person.new
|
28
|
+
shell {
|
29
|
+
composite {
|
30
|
+
list(:multi) {
|
31
|
+
selection bind(person, :provinces)
|
32
|
+
}
|
33
|
+
button {
|
34
|
+
text "Reset"
|
35
|
+
on_widget_selected do
|
36
|
+
person.reset_provinces
|
37
|
+
end
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}.open
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
HelloListMultiSelection.new.launch
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Person
|
2
|
+
attr_accessor :country, :country_options
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
self.country_options=["", "Canada", "US", "Mexico"]
|
6
|
+
self.country = "Canada"
|
7
|
+
end
|
8
|
+
|
9
|
+
def reset_country
|
10
|
+
self.country = "Canada"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class HelloListSingleSelection
|
15
|
+
include Glimmer
|
16
|
+
def launch
|
17
|
+
person = Person.new
|
18
|
+
shell {
|
19
|
+
composite {
|
20
|
+
list {
|
21
|
+
selection bind(person, :country)
|
22
|
+
}
|
23
|
+
button {
|
24
|
+
text "Reset"
|
25
|
+
on_widget_selected do
|
26
|
+
person.reset_country
|
27
|
+
end
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}.open
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
HelloListSingleSelection.new.launch
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class HelloTab
|
2
|
+
include Glimmer
|
3
|
+
def launch
|
4
|
+
shell {
|
5
|
+
text "Hello Tab"
|
6
|
+
tab_folder {
|
7
|
+
tab_item {
|
8
|
+
text "English"
|
9
|
+
label {
|
10
|
+
text "Hello, World!"
|
11
|
+
}
|
12
|
+
}
|
13
|
+
tab_item {
|
14
|
+
text "French"
|
15
|
+
label {
|
16
|
+
text "Bonjour Univers!"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}.open
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
HelloTab.new.launch
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Launches all samples
|
2
|
+
export DIR=`echo $0 | sed "s/launch//"`
|
3
|
+
${DIR}../../bin/glimmer \
|
4
|
+
"${DIR}hello_browser.rb" \
|
5
|
+
"${DIR}hello_combo.rb" \
|
6
|
+
"${DIR}hello_computed.rb" \
|
7
|
+
"${DIR}hello_list_multi_selection.rb" \
|
8
|
+
"${DIR}hello_list_single_selection.rb" \
|
9
|
+
"${DIR}hello_tab.rb" \
|
10
|
+
"${DIR}hello_world.rb"
|
data/lib/samples/launch
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-opal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.9.
|
19
|
+
version: 0.9.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.9.
|
26
|
+
version: 0.9.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec-mocks
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,20 +169,53 @@ files:
|
|
169
169
|
- VERSION
|
170
170
|
- lib/glimmer-dsl-opal.rb
|
171
171
|
- lib/glimmer/config.rb
|
172
|
+
- lib/glimmer/data_binding/element_binding.rb
|
173
|
+
- lib/glimmer/data_binding/observable_element.rb
|
172
174
|
- lib/glimmer/dsl/engine.rb
|
173
175
|
- lib/glimmer/dsl/expression.rb
|
174
176
|
- lib/glimmer/dsl/expression_handler.rb
|
177
|
+
- lib/glimmer/dsl/opal/bind_expression.rb
|
178
|
+
- lib/glimmer/dsl/opal/button_expression.rb
|
179
|
+
- lib/glimmer/dsl/opal/combo_expression.rb
|
180
|
+
- lib/glimmer/dsl/opal/combo_selection_data_binding_expression.rb
|
181
|
+
- lib/glimmer/dsl/opal/composite_expression.rb
|
182
|
+
- lib/glimmer/dsl/opal/data_binding_expression.rb
|
175
183
|
- lib/glimmer/dsl/opal/dsl.rb
|
176
184
|
- lib/glimmer/dsl/opal/label_expression.rb
|
177
185
|
- lib/glimmer/dsl/opal/property_expression.rb
|
178
186
|
- lib/glimmer/dsl/opal/shell_expression.rb
|
187
|
+
- lib/glimmer/dsl/opal/widget_listener_expression.rb
|
179
188
|
- lib/glimmer/dsl/parent_expression.rb
|
180
189
|
- lib/glimmer/dsl/static_expression.rb
|
181
190
|
- lib/glimmer/dsl/top_level_expression.rb
|
182
191
|
- lib/glimmer/error.rb
|
183
192
|
- lib/glimmer/invalid_keyword_error.rb
|
184
|
-
- lib/glimmer/opal/
|
185
|
-
- lib/glimmer/opal/
|
193
|
+
- lib/glimmer/opal/div_proxy.rb
|
194
|
+
- lib/glimmer/opal/document_proxy.rb
|
195
|
+
- lib/glimmer/opal/element_proxy.rb
|
196
|
+
- lib/glimmer/opal/event_listener_proxy.rb
|
197
|
+
- lib/glimmer/opal/input_proxy.rb
|
198
|
+
- lib/glimmer/opal/label_proxy.rb
|
199
|
+
- lib/glimmer/opal/select_proxy.rb
|
200
|
+
- lib/samples/elaborate/contact_manager.rb
|
201
|
+
- lib/samples/elaborate/contact_manager/contact.rb
|
202
|
+
- lib/samples/elaborate/contact_manager/contact_manager_presenter.rb
|
203
|
+
- lib/samples/elaborate/contact_manager/contact_repository.rb
|
204
|
+
- lib/samples/elaborate/launch
|
205
|
+
- lib/samples/elaborate/login.rb
|
206
|
+
- lib/samples/elaborate/tic_tac_toe.rb
|
207
|
+
- lib/samples/elaborate/tic_tac_toe/board.rb
|
208
|
+
- lib/samples/elaborate/tic_tac_toe/cell.rb
|
209
|
+
- lib/samples/hello/hello_browser.rb
|
210
|
+
- lib/samples/hello/hello_combo.rb
|
211
|
+
- lib/samples/hello/hello_computed.rb
|
212
|
+
- lib/samples/hello/hello_computed/contact.rb
|
213
|
+
- lib/samples/hello/hello_list_multi_selection.rb
|
214
|
+
- lib/samples/hello/hello_list_single_selection.rb
|
215
|
+
- lib/samples/hello/hello_tab.rb
|
216
|
+
- lib/samples/hello/hello_world.rb
|
217
|
+
- lib/samples/hello/launch
|
218
|
+
- lib/samples/launch
|
186
219
|
homepage: http://github.com/AndyObtiva/glimmer-dsl-opal
|
187
220
|
licenses:
|
188
221
|
- MIT
|
data/lib/glimmer/opal/label.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
module Glimmer
|
2
|
-
module Opal
|
3
|
-
class Label
|
4
|
-
attr_reader :text
|
5
|
-
|
6
|
-
def initialize(parent, args)
|
7
|
-
@parent = parent
|
8
|
-
@args = args
|
9
|
-
@parent.add_child(self)
|
10
|
-
end
|
11
|
-
|
12
|
-
def text=(value)
|
13
|
-
@text = value
|
14
|
-
redraw
|
15
|
-
end
|
16
|
-
|
17
|
-
def redraw
|
18
|
-
old_dom = @dom
|
19
|
-
@dom = nil
|
20
|
-
old_dom.replace dom
|
21
|
-
end
|
22
|
-
|
23
|
-
def dom
|
24
|
-
label_text = @text
|
25
|
-
@dom ||= DOM {
|
26
|
-
label label_text
|
27
|
-
}
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|