glimmer-dsl-web 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -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-dsl-web 0.0.5 ruby lib
5
+ # stub: glimmer-dsl-web 0.0.7 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-web".freeze
9
- s.version = "0.0.5".freeze
9
+ s.version = "0.0.7".freeze
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 = ["Andy Maleh".freeze]
14
- s.date = "2023-12-30"
14
+ s.date = "2024-01-02"
15
15
  s.description = "Glimmer DSL for Web (Ruby in the Browser Web GUI Frontend Library) - Enables frontend GUI development with Ruby by adopting a DSL that follows web-like HTML syntax, enabling the transfer of HTML/CSS/JS skills to Ruby frontend development. This library relies on Opal Ruby.".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
17
  s.extra_rdoc_files = [
@@ -31,22 +31,28 @@ Gem::Specification.new do |s|
31
31
  "lib/glimmer-dsl-web/ext/date.rb",
32
32
  "lib/glimmer-dsl-web/ext/exception.rb",
33
33
  "lib/glimmer-dsl-web/samples/hello/hello_button.rb",
34
+ "lib/glimmer-dsl-web/samples/hello/hello_data_binding.rb",
34
35
  "lib/glimmer-dsl-web/samples/hello/hello_form.rb",
36
+ "lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb",
35
37
  "lib/glimmer-dsl-web/samples/hello/hello_world.rb",
36
38
  "lib/glimmer-dsl-web/vendor/jquery.js",
37
39
  "lib/glimmer/config/opal_logger.rb",
38
40
  "lib/glimmer/data_binding/element_binding.rb",
41
+ "lib/glimmer/dsl/web/bind_expression.rb",
42
+ "lib/glimmer/dsl/web/data_binding_expression.rb",
39
43
  "lib/glimmer/dsl/web/dsl.rb",
40
44
  "lib/glimmer/dsl/web/element_expression.rb",
45
+ "lib/glimmer/dsl/web/general_element_expression.rb",
41
46
  "lib/glimmer/dsl/web/listener_expression.rb",
42
47
  "lib/glimmer/dsl/web/p_expression.rb",
43
48
  "lib/glimmer/dsl/web/property_expression.rb",
49
+ "lib/glimmer/dsl/web/select_expression.rb",
50
+ "lib/glimmer/dsl/web/shine_data_binding_expression.rb",
44
51
  "lib/glimmer/util/proc_tracker.rb",
45
52
  "lib/glimmer/web.rb",
46
53
  "lib/glimmer/web/element_proxy.rb",
47
54
  "lib/glimmer/web/event_proxy.rb",
48
- "lib/glimmer/web/listener_proxy.rb",
49
- "lib/glimmer/web/property_owner.rb"
55
+ "lib/glimmer/web/listener_proxy.rb"
50
56
  ]
51
57
  s.homepage = "http://github.com/AndyObtiva/glimmer-dsl-web".freeze
52
58
  s.licenses = ["MIT".freeze]
@@ -60,7 +66,6 @@ Gem::Specification.new do |s|
60
66
  s.add_runtime_dependency(%q<glimmer-dsl-css>.freeze, ["~> 1.2.2".freeze])
61
67
  s.add_runtime_dependency(%q<opal-async>.freeze, ["~> 1.4.0".freeze])
62
68
  s.add_runtime_dependency(%q<to_collection>.freeze, [">= 2.0.1".freeze, "< 3.0.0".freeze])
63
- s.add_runtime_dependency(%q<pure-struct>.freeze, [">= 1.0.2".freeze, "< 2.0.0".freeze])
64
69
  s.add_development_dependency(%q<puts_debuggerer>.freeze, [">= 0".freeze])
65
70
  s.add_development_dependency(%q<rake>.freeze, [">= 10.1.0".freeze, "< 14.0.0".freeze])
66
71
  s.add_development_dependency(%q<rake-tui>.freeze, [">= 0".freeze])
@@ -4,7 +4,6 @@ require 'glimmer/data_binding/observer'
4
4
  module Glimmer
5
5
  module DataBinding
6
6
  class ElementBinding
7
- # TODO consider renaming to WidgetBinding since it's no longer dealing with elements directly yet widgets instead
8
7
  include Glimmer
9
8
  include Observable
10
9
  include Observer
@@ -15,7 +14,8 @@ module Glimmer
15
14
  @property = property
16
15
  @translator = translator || proc {|value| value}
17
16
 
18
- # TODO see if this is needed in Opal
17
+ # TODO implement automatic cleanup upon calling element.remove
18
+ # Alternatively, have this be built into ElementProxy and remove this code
19
19
  # if @element.respond_to?(:dispose)
20
20
  # @element.on_widget_disposed do |dispose_event|
21
21
  # unregister_all_observables
@@ -24,8 +24,8 @@ module Glimmer
24
24
  end
25
25
 
26
26
  def call(value)
27
- converted_value = translated_value = @translator.call(value)
28
- @element.set_attribute(@property, converted_value) unless evaluate_property == converted_value
27
+ converted_value = translated_value = @translator.call(value, evaluate_property)
28
+ @element.send("#{@property}=", converted_value) unless evaluate_property == converted_value
29
29
  end
30
30
 
31
31
  def evaluate_property
@@ -0,0 +1,36 @@
1
+ # Copyright (c) 2023-2024 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/dsl/bind_expression'
24
+ require 'glimmer/data_binding/model_binding'
25
+
26
+ module Glimmer
27
+ module DSL
28
+ module Web
29
+ # Responsible for setting up the return value of the bind keyword (command symbol)
30
+ # as a ModelBinding. It is then used by other data-binding expressions
31
+ class BindExpression < StaticExpression
32
+ include Glimmer::DSL::BindExpression
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,30 @@
1
+ require 'glimmer/dsl/expression'
2
+ require 'glimmer/data_binding/model_binding'
3
+ require 'glimmer/data_binding/element_binding'
4
+
5
+ module Glimmer
6
+ module DSL
7
+ module Web
8
+ # Responsible for wiring two-way data-binding for text and selection properties
9
+ # on Text, Button, and Spinner elements.
10
+ # Does so by using the output of the bind(model, property) command in the form
11
+ # of a ModelBinding, which is then connected to an anonymous element observer
12
+ # (aka element_data_binder as per element_data_binders array)
13
+ #
14
+ # Depends on BindCommandHandler
15
+ class DataBindingExpression < Expression
16
+ def can_interpret?(parent, keyword, *args, &block)
17
+ args.size == 1 and
18
+ args[0].is_a?(DataBinding::ModelBinding) and
19
+ parent.respond_to?(:data_bind)
20
+ end
21
+
22
+ def interpret(parent, keyword, *args, &block)
23
+ model_binding = args[0]
24
+ property = keyword
25
+ parent.data_bind(property, model_binding)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -4,6 +4,10 @@ require 'glimmer/dsl/web/element_expression'
4
4
  require 'glimmer/dsl/web/listener_expression'
5
5
  require 'glimmer/dsl/web/property_expression'
6
6
  require 'glimmer/dsl/web/p_expression'
7
+ require 'glimmer/dsl/web/select_expression'
8
+ require 'glimmer/dsl/web/bind_expression'
9
+ require 'glimmer/dsl/web/data_binding_expression'
10
+ require 'glimmer/dsl/web/shine_data_binding_expression'
7
11
 
8
12
  module Glimmer
9
13
  module DSL
@@ -20,7 +24,9 @@ module Glimmer
20
24
  Web,
21
25
  %w[
22
26
  listener
27
+ data_binding
23
28
  property
29
+ shine_data_binding
24
30
  element
25
31
  ]
26
32
  )
@@ -1,35 +1,17 @@
1
1
  require 'glimmer/dsl/expression'
2
- require 'glimmer/dsl/parent_expression'
3
- require 'glimmer/web/element_proxy'
2
+ require 'glimmer/dsl/web/general_element_expression'
4
3
 
5
4
  module Glimmer
6
5
  module DSL
7
6
  module Web
8
7
  class ElementExpression < Expression
9
- include ParentExpression
8
+ include GeneralElementExpression
10
9
 
11
10
  def can_interpret?(parent, keyword, *args, &block)
12
11
  # TODO automatically pass parent option as element if not passed instead of rejecting elements without a paraent nor root
13
12
  # TODO raise a proper error if root is an element that is not found (maybe do this in model)
14
13
  !keyword.to_s.start_with?('on')
15
14
  end
16
-
17
- def interpret(parent, keyword, *args, &block)
18
- Glimmer::Web::ElementProxy.for(keyword, parent, args, block)
19
- end
20
-
21
- def add_content(parent, keyword, *args, &block)
22
- if parent.rendered? || parent.skip_content_on_render_blocks?
23
- return_value = super(parent, keyword, *args, &block)
24
- if return_value.is_a?(String) && parent.dom_element.text.to_s.empty?
25
- parent.add_text_content(return_value)
26
- end
27
- parent.post_add_content
28
- return_value
29
- else
30
- parent.add_content_on_render(&block)
31
- end
32
- end
33
15
  end
34
16
  end
35
17
  end
@@ -0,0 +1,29 @@
1
+ require 'glimmer/dsl/parent_expression'
2
+ require 'glimmer/web/element_proxy'
3
+
4
+ module Glimmer
5
+ module DSL
6
+ module Web
7
+ module GeneralElementExpression
8
+ include ParentExpression
9
+
10
+ def interpret(parent, keyword, *args, &block)
11
+ Glimmer::Web::ElementProxy.for(keyword, parent, args, block)
12
+ end
13
+
14
+ def add_content(parent, keyword, *args, &block)
15
+ if parent.rendered? || parent.skip_content_on_render_blocks?
16
+ return_value = super(parent, keyword, *args, &block)
17
+ if return_value.is_a?(String) && parent.dom_element.text.to_s.empty?
18
+ parent.add_text_content(return_value)
19
+ end
20
+ parent.post_add_content
21
+ return_value
22
+ else
23
+ parent.add_content_on_render(&block)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,30 +1,11 @@
1
1
  require 'glimmer/dsl/static_expression'
2
- require 'glimmer/dsl/parent_expression'
3
-
4
- require 'glimmer/web/element_proxy'
2
+ require 'glimmer/dsl/web/general_element_expression'
5
3
 
6
4
  module Glimmer
7
5
  module DSL
8
6
  module Web
9
7
  class PExpression < StaticExpression
10
- include ParentExpression
11
-
12
- def interpret(parent, keyword, *args, &block)
13
- Glimmer::Web::ElementProxy.for(keyword, parent, args, block)
14
- end
15
-
16
- def add_content(parent, keyword, *args, &block)
17
- if parent.rendered? || parent.skip_content_on_render_blocks?
18
- return_value = super(parent, keyword, *args, &block)
19
- if return_value.is_a?(String) && parent.dom_element.text.to_s.empty?
20
- parent.add_text_content(return_value)
21
- end
22
- parent.post_add_content
23
- return_value
24
- else
25
- parent.add_content_on_render(&block)
26
- end
27
- end
8
+ include GeneralElementExpression
28
9
  end
29
10
  end
30
11
  end
@@ -0,0 +1,12 @@
1
+ require 'glimmer/dsl/static_expression'
2
+ require 'glimmer/dsl/web/general_element_expression'
3
+
4
+ module Glimmer
5
+ module DSL
6
+ module Web
7
+ class SelectExpression < StaticExpression
8
+ include GeneralElementExpression
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,42 @@
1
+ # Copyright (c) 2020-2022 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/expression'
23
+ require 'glimmer/data_binding/model_binding'
24
+ require 'glimmer/data_binding/shine'
25
+
26
+ module Glimmer
27
+ module DSL
28
+ module Web
29
+ class ShineDataBindingExpression < Expression
30
+ def can_interpret?(parent, keyword, *args, &block)
31
+ args.size == 0 and
32
+ block.nil? and
33
+ (parent.respond_to?("#{keyword}=") and parent.respond_to?(keyword))
34
+ end
35
+
36
+ def interpret(parent, keyword, *args, &block)
37
+ Glimmer::DataBinding::Shine.new(parent, keyword)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 Andy Maleh
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the