glimmer-dsl-opal 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/README.md +475 -25
- data/VERSION +1 -1
- data/lib/glimmer-dsl-opal.rb +2 -0
- data/lib/glimmer/data_binding/ext/observable_model.rb +1 -1
- data/lib/glimmer/data_binding/table_items_binding.rb +67 -0
- data/lib/glimmer/dsl/opal/column_properties_expression.rb +22 -0
- data/lib/glimmer/dsl/opal/dsl.rb +5 -0
- data/lib/glimmer/dsl/opal/table_column_expression.rb +17 -0
- data/lib/glimmer/dsl/opal/table_expression.rb +17 -0
- data/lib/glimmer/dsl/opal/table_items_data_binding_expression.rb +29 -0
- data/lib/glimmer/opal/div_proxy.rb +7 -0
- data/lib/glimmer/opal/document_proxy.rb +15 -6
- data/lib/glimmer/opal/element_proxy.rb +2 -3
- data/lib/glimmer/opal/layout_data_proxy.rb +22 -1
- data/lib/glimmer/opal/list_proxy.rb +1 -1
- data/lib/glimmer/opal/tab_folder.rb +9 -2
- data/lib/glimmer/opal/tab_item.rb +1 -1
- data/lib/glimmer/opal/table_column.rb +50 -0
- data/lib/glimmer/opal/table_item.rb +136 -0
- data/lib/glimmer/opal/table_proxy.rb +149 -0
- data/lib/samples/elaborate/contact_manager.rb +1 -2
- metadata +13 -14
- data/lib/glimmer/config.rb +0 -22
- data/lib/glimmer/dsl/engine.rb +0 -193
- data/lib/glimmer/dsl/expression.rb +0 -42
- data/lib/glimmer/dsl/expression_handler.rb +0 -48
- data/lib/glimmer/dsl/parent_expression.rb +0 -12
- data/lib/glimmer/dsl/static_expression.rb +0 -36
- data/lib/glimmer/dsl/top_level_expression.rb +0 -7
- data/lib/glimmer/error.rb +0 -6
- data/lib/glimmer/invalid_keyword_error.rb +0 -6
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'glimmer/error'
|
2
|
-
|
3
|
-
module Glimmer
|
4
|
-
module DSL
|
5
|
-
# Represents a Glimmer DSL expression (e.g. label(:center) { ... })
|
6
|
-
#
|
7
|
-
# An expression object can interpret a keyword, args, and a block into a UI object
|
8
|
-
#
|
9
|
-
# Expressions subclasses follow the convention of using `and` and `or`
|
10
|
-
# english versino of Ruby's boolean operations. This allows easy DSL-like
|
11
|
-
# readability of the rules, and easy tagging with pd when troubleshooting.
|
12
|
-
class Expression
|
13
|
-
class << self
|
14
|
-
def dsl
|
15
|
-
@dsl ||= name.split(/::/)[-2].downcase.to_sym
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
# Checks if it can interpret parameters (subclass must override)
|
20
|
-
def can_interpret?(parent, keyword, *args, &block)
|
21
|
-
raise Error, "#can_interpret? must be implemented by an Expression subclass"
|
22
|
-
end
|
23
|
-
|
24
|
-
# Interprets parameters (subclass must override)
|
25
|
-
def interpret(parent, keyword, *args, &block)
|
26
|
-
raise Error, "#interpret must be implemented by an Expression subclass"
|
27
|
-
end
|
28
|
-
|
29
|
-
# Adds block content to specified parent UI object (Optional)
|
30
|
-
#
|
31
|
-
# Only expressions that receive a content block should implement
|
32
|
-
def add_content(parent, &block)
|
33
|
-
# No Op by default
|
34
|
-
end
|
35
|
-
|
36
|
-
# Checks if object is a Symbol or a String
|
37
|
-
def textual?(object)
|
38
|
-
object.is_a?(Symbol) or object.is_a?(String)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'glimmer/invalid_keyword_error'
|
2
|
-
|
3
|
-
module Glimmer
|
4
|
-
module DSL
|
5
|
-
# Expression handler for a Glimmer DSL specific expression
|
6
|
-
#
|
7
|
-
# Follows the Chain of Responsibility Design Pattern
|
8
|
-
#
|
9
|
-
# Handlers are configured in Glimmer::DSL in the right order
|
10
|
-
# to attempt handling Glimmer DSL interpretation calls
|
11
|
-
#
|
12
|
-
# Each handler knows the next handler in the chain of responsibility.
|
13
|
-
#
|
14
|
-
# If it handles successfully, it returns. Otherwise, it forwards to the next
|
15
|
-
# handler in the chain of responsibility
|
16
|
-
class ExpressionHandler
|
17
|
-
def initialize(expression)
|
18
|
-
@expression = expression
|
19
|
-
end
|
20
|
-
|
21
|
-
# Handles interpretation of Glimmer DSL expression if expression supports it
|
22
|
-
# If it succeeds, it returns the correct Glimmer DSL expression object
|
23
|
-
# Otherwise, it forwards to the next handler configured via `#next=` method
|
24
|
-
# If there is no handler next, then it raises an error
|
25
|
-
def handle(parent, keyword, *args, &block)
|
26
|
-
Glimmer::Config.logger&.debug "Attempting to handle #{keyword} with #{@expression.class.name.split(":").last}"
|
27
|
-
if @expression.can_interpret?(parent, keyword, *args, &block)
|
28
|
-
Glimmer::Config.logger&.debug "#{@expression.class.name} will handle expression keyword #{keyword}"
|
29
|
-
return @expression
|
30
|
-
elsif @next_expression_handler
|
31
|
-
return @next_expression_handler.handle(parent, keyword, *args, &block)
|
32
|
-
else
|
33
|
-
# TODO see if we need a better response here (e.g. dev mode error raising vs production mode silent failure)
|
34
|
-
message = "Glimmer keyword #{keyword} with args #{args} cannot be handled"
|
35
|
-
message += " inside parent #{parent}" if parent
|
36
|
-
message += "! Check the validity of the code."
|
37
|
-
# Glimmer::Config.logger&.error message
|
38
|
-
raise InvalidKeywordError, message
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# Sets the next handler in the expression handler chain of responsibility
|
43
|
-
def next=(next_expression_handler)
|
44
|
-
@next_expression_handler = next_expression_handler
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'glimmer/error'
|
2
|
-
require 'glimmer/dsl/engine'
|
3
|
-
require 'glimmer/dsl/expression'
|
4
|
-
|
5
|
-
module Glimmer
|
6
|
-
module DSL
|
7
|
-
# Represents a StaticExpression for expressions where
|
8
|
-
# the keyword does not vary dynamically. These static keywords are then
|
9
|
-
# predefined as methods in Glimmer instead of needing method_missing
|
10
|
-
#
|
11
|
-
# StaticExpression subclasses may optionally implement `#can_interpret?`
|
12
|
-
# (not needed if it only checks for keyword)
|
13
|
-
#
|
14
|
-
# StaticExpression subclasses must define `#interpret`.
|
15
|
-
#
|
16
|
-
# The direct parent namespace of a StaticExpression subclass must match the DSL name (case-insensitive)
|
17
|
-
# (e.g. Glimmer::DSL::SWT::WidgetExpression has a DSL of :swt)
|
18
|
-
class StaticExpression < Expression
|
19
|
-
class << self
|
20
|
-
def inherited(base)
|
21
|
-
Glimmer::DSL::Engine.add_static_expression(base.new)
|
22
|
-
super
|
23
|
-
end
|
24
|
-
|
25
|
-
def keyword
|
26
|
-
@keyword ||= name.split(/::/).last.sub(/Expression$/, '').underscore
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Subclasses may optionally implement
|
31
|
-
def can_interpret?(parent, keyword, *args, &block)
|
32
|
-
true
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/lib/glimmer/error.rb
DELETED