ruht 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +11 -0
- data/CODE_OF_CONDUCT.md +4 -1
- data/Gemfile +4 -0
- data/Gemfile.lock +4 -2
- data/lib/ruht/closure_capturing.rb +22 -0
- data/lib/ruht/document.rb +4 -0
- data/lib/ruht/element.rb +1 -1
- data/lib/ruht/fragment.rb +3 -0
- data/lib/ruht/tags.rb +4 -6
- data/lib/ruht/version.rb +1 -1
- data/sig/ruht/closure_capturing.rbs +12 -0
- data/sig/ruht/fragment.rbs +8 -2
- data/sig/ruht/tags.rbs +3 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bbac88061aa6e3ebe5a2d47de160c912f56950dff0cef628598605b464fb03d
|
4
|
+
data.tar.gz: fed1a9e6095c3cbf859d4826eb83d06460575f932f48c9e21e238b5593d1e2a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e126b337abc85c74003a1d56041d6434aeb6b1130110e6b31f365da5f6ddb0ea53e43c2add8a1db40c4653fb6be647faa1f9b27585038e1383c2779c8054609
|
7
|
+
data.tar.gz: 59d058ab1bed600e50112eb45cde4dbc8559799b0b951c624af8cc1e1989da6ed5e19717f58ea5ba8fa236559dfefe8f9f40b16fa99d9f8b779f405be52cc6fa
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.2.
|
1
|
+
3.2.1
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## [0.1.0] - 2023-02-10
|
2
|
+
|
3
|
+
- Capturing variables and methods from the scope
|
4
|
+
|
5
|
+
## [0.0.2] - 2023-02-07
|
6
|
+
|
7
|
+
- Capture methods from closure
|
8
|
+
- Improve types coverage
|
9
|
+
|
1
10
|
## [0.0.1] - 2023-02-05
|
2
11
|
|
3
12
|
- Initial release
|
13
|
+
- Basic HTML rendering
|
14
|
+
- Support all HTML tag names
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -39,7 +39,10 @@ This Code of Conduct applies within all community spaces, and also applies when
|
|
39
39
|
|
40
40
|
## Enforcement
|
41
41
|
|
42
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
43
|
+
reported to the community leaders responsible for enforcement at
|
44
|
+
dmitry.barskov64@gmail.com. All complaints will be reviewed and investigated
|
45
|
+
promptly and fairly.
|
43
46
|
|
44
47
|
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
48
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ruht (0.0
|
4
|
+
ruht (0.1.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -12,6 +12,7 @@ GEM
|
|
12
12
|
minitest (>= 5.1)
|
13
13
|
tzinfo (~> 2.0)
|
14
14
|
ast (2.4.2)
|
15
|
+
byebug (11.1.3)
|
15
16
|
concurrent-ruby (1.2.0)
|
16
17
|
csv (3.2.6)
|
17
18
|
diff-lcs (1.5.0)
|
@@ -101,6 +102,7 @@ PLATFORMS
|
|
101
102
|
x86_64-linux
|
102
103
|
|
103
104
|
DEPENDENCIES
|
105
|
+
byebug
|
104
106
|
rake (~> 13.0)
|
105
107
|
rspec (~> 3.0)
|
106
108
|
rubocop (~> 1.44.1)
|
@@ -111,4 +113,4 @@ DEPENDENCIES
|
|
111
113
|
typeprof
|
112
114
|
|
113
115
|
BUNDLED WITH
|
114
|
-
2.4.
|
116
|
+
2.4.6
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ruht
|
4
|
+
# Delegates method calls to the object who created the given block.
|
5
|
+
module ClosureCapturing
|
6
|
+
def initialize(context)
|
7
|
+
@context = context
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def method_missing(method_name, *args, &block)
|
13
|
+
return super unless respond_to_missing?(method_name)
|
14
|
+
|
15
|
+
@context.send(method_name, *args, &block)
|
16
|
+
end
|
17
|
+
|
18
|
+
def respond_to_missing?(method_name, include_all = false)
|
19
|
+
@context.respond_to?(method_name.to_sym, include_all)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/ruht/document.rb
CHANGED
@@ -18,10 +18,14 @@ module Ruht
|
|
18
18
|
# ...
|
19
19
|
# </html>
|
20
20
|
class Document
|
21
|
+
include ClosureCapturing
|
22
|
+
|
21
23
|
def initialize(&child_block)
|
22
24
|
@doctype = nil
|
23
25
|
@html = nil
|
24
26
|
@child_block = child_block
|
27
|
+
|
28
|
+
super(@child_block&.binding&.receiver)
|
25
29
|
end
|
26
30
|
|
27
31
|
def doctype(*args)
|
data/lib/ruht/element.rb
CHANGED
data/lib/ruht/fragment.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'ruht/closure_capturing'
|
3
4
|
require 'ruht/tags'
|
4
5
|
|
5
6
|
module Ruht
|
@@ -15,12 +16,14 @@ module Ruht
|
|
15
16
|
# <p />
|
16
17
|
# <a />
|
17
18
|
class Fragment
|
19
|
+
include ClosureCapturing
|
18
20
|
include Tags
|
19
21
|
|
20
22
|
def initialize(&child_block)
|
21
23
|
@children = []
|
22
24
|
@evaluated = false
|
23
25
|
@child_block = child_block
|
26
|
+
super(child_block&.binding&.receiver)
|
24
27
|
end
|
25
28
|
|
26
29
|
# Allows to render other fragments / elements inside
|
data/lib/ruht/tags.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'ruht/attributes'
|
4
|
+
require 'ruht/element'
|
5
|
+
require 'ruht/void_element'
|
6
|
+
|
3
7
|
module Ruht
|
4
8
|
# DSL magic here. Including this module will define methods for HTML tags.
|
5
9
|
module Tags
|
@@ -36,10 +40,7 @@ module Ruht
|
|
36
40
|
module ClassMethods
|
37
41
|
def def_tag(tag_name)
|
38
42
|
define_method(tag_name) do |*args, **kwargs, &block|
|
39
|
-
require 'ruht/attributes'
|
40
43
|
attributes = Ruht::Attributes.new(*args, **kwargs)
|
41
|
-
|
42
|
-
require 'ruht/element'
|
43
44
|
element = Ruht::Element.new(tag_name, attributes, &block)
|
44
45
|
render!(element)
|
45
46
|
end
|
@@ -47,10 +48,7 @@ module Ruht
|
|
47
48
|
|
48
49
|
def def_void_tag(tag_name)
|
49
50
|
define_method(tag_name) do |*args, **kwargs|
|
50
|
-
require 'ruht/attributes'
|
51
51
|
attributes = Ruht::Attributes.new(*args, **kwargs)
|
52
|
-
|
53
|
-
require 'ruht/void_element'
|
54
52
|
element = Ruht::VoidElement.new(tag_name, attributes)
|
55
53
|
render!(element)
|
56
54
|
end
|
data/lib/ruht/version.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
module Ruht
|
2
|
+
module ClosureCapturing
|
3
|
+
@context: untyped
|
4
|
+
|
5
|
+
def initialize: (untyped closure) -> void
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def method_missing: (Symbol method_name, *untyped args) -> untyped
|
10
|
+
def respond_to_missing?: (Symbol method_name, ?bool include_all) -> bool
|
11
|
+
end
|
12
|
+
end
|
data/sig/ruht/fragment.rbs
CHANGED
@@ -1,19 +1,25 @@
|
|
1
1
|
module Ruht
|
2
2
|
class Fragment
|
3
3
|
extend Tags::ClassMethods
|
4
|
+
include ClosureCapturing
|
4
5
|
include Tags
|
5
6
|
|
6
7
|
@children: Array[untyped]
|
7
8
|
@evaluated: bool
|
8
9
|
@child_block: (^(self) -> untyped | nil)
|
10
|
+
@context: untyped
|
9
11
|
|
10
|
-
def initialize:
|
11
|
-
|
12
|
+
def initialize: ?{ (self) -> untyped } -> void
|
13
|
+
|
14
|
+
def render!: (untyped child_node) -> Array[untyped]
|
12
15
|
def to_s: -> String
|
13
16
|
|
14
17
|
private
|
15
18
|
|
16
19
|
def eval_children!: -> void
|
17
20
|
def can_render?: (untyped object) -> bool
|
21
|
+
|
22
|
+
def method_missing: (Symbol method_name, *untyped args) -> untyped
|
23
|
+
def respond_to_missing?: (Symbol method_name, *untyped args) -> bool
|
18
24
|
end
|
19
25
|
end
|
data/sig/ruht/tags.rbs
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruht
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Barskov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ruht lets you generate HTML using Ruby syntax
|
14
14
|
email:
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- lib/ruht/attributes/content_attribute.rb
|
36
36
|
- lib/ruht/attributes/data_attributes.rb
|
37
37
|
- lib/ruht/attributes/style_attribute.rb
|
38
|
+
- lib/ruht/closure_capturing.rb
|
38
39
|
- lib/ruht/document.rb
|
39
40
|
- lib/ruht/element.rb
|
40
41
|
- lib/ruht/file.rb
|
@@ -51,6 +52,7 @@ files:
|
|
51
52
|
- sig/ruht/attributes/content_attribute.rbs
|
52
53
|
- sig/ruht/attributes/data_attributes.rbs
|
53
54
|
- sig/ruht/attributes/style_attribute.rbs
|
55
|
+
- sig/ruht/closure_capturing.rbs
|
54
56
|
- sig/ruht/document.rbs
|
55
57
|
- sig/ruht/element.rbs
|
56
58
|
- sig/ruht/file.rbs
|
@@ -83,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
85
|
- !ruby/object:Gem::Version
|
84
86
|
version: '0'
|
85
87
|
requirements: []
|
86
|
-
rubygems_version: 3.4.
|
88
|
+
rubygems_version: 3.4.6
|
87
89
|
signing_key:
|
88
90
|
specification_version: 4
|
89
91
|
summary: DSL for building HTML written in Ruby
|