ruht 0.0.2 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +15 -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 -12
- data/lib/ruht/tags.rb +4 -6
- data/lib/ruht/version.rb +1 -1
- data/ruht.gemspec +2 -1
- data/sig/ruht/closure_capturing.rbs +12 -0
- data/sig/ruht/fragment.rbs +5 -2
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 760b255532fee07bf3676e53d8dedd952c7b62fc0f52b3e898c668ae4d103796
|
4
|
+
data.tar.gz: ea333cfde23631937ce0ed272870af5c40fa4040e69a02e991c4211416463e74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd6772fa80d38f5124b0a0b31bba9cca76b95e0a2c8b7d2209499ea3a38f3471083f45396c9498313863dcc141a3d354dd6b1de7258e5615a5ef85c239a9025c
|
7
|
+
data.tar.gz: ae6652cff193fd92a858e12815d65cec75465eac2cffe669c268bbfca67ffe6659766330ba0d76b1dbc0283d25990af39be982625019b72ab22eb0e939aa2370
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.2.
|
1
|
+
3.2.1
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
## [0.1.1] - 2023-02-10
|
2
|
+
|
3
|
+
- Update links in .gemspec
|
4
|
+
|
5
|
+
## [0.1.0] - 2023-02-10
|
6
|
+
|
7
|
+
- Capturing variables and methods from the scope
|
8
|
+
|
9
|
+
## [0.0.2] - 2023-02-07
|
10
|
+
|
11
|
+
- Capture methods from closure
|
12
|
+
- Improve types coverage
|
13
|
+
|
1
14
|
## [0.0.1] - 2023-02-05
|
2
15
|
|
3
16
|
- Initial release
|
17
|
+
- Basic HTML rendering
|
18
|
+
- 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.
|
4
|
+
ruht (0.1.1)
|
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
|
@@ -48,17 +51,5 @@ module Ruht
|
|
48
51
|
object.is_a?(simple_class)
|
49
52
|
end
|
50
53
|
end
|
51
|
-
|
52
|
-
def method_missing(method_name, *args, &block)
|
53
|
-
return super unless respond_to_missing?(method_name, *args, &block)
|
54
|
-
|
55
|
-
@child_block.binding.receiver.send(method_name, *args, &block)
|
56
|
-
end
|
57
|
-
|
58
|
-
def respond_to_missing?(method_name, *args)
|
59
|
-
return false unless @child_block
|
60
|
-
|
61
|
-
@child_block.binding.receiver.respond_to?(method_name)
|
62
|
-
end
|
63
54
|
end
|
64
55
|
end
|
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
data/ruht.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
|
11
11
|
spec.summary = 'DSL for building HTML written in Ruby'
|
12
12
|
spec.description = 'Ruht lets you generate HTML using Ruby syntax'
|
13
|
-
spec.homepage = 'https://github.com/
|
13
|
+
spec.homepage = 'https://github.com/ruby-hyper-text/ruht'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
spec.required_ruby_version = '>= 2.7.0'
|
16
16
|
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.metadata['homepage_uri'] = spec.homepage
|
20
20
|
spec.metadata['source_code_uri'] = spec.homepage
|
21
21
|
spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
22
|
+
spec.metadata['github_repo'] = 'ssh://github.com/ruby-hyper-text/ruht'
|
22
23
|
|
23
24
|
# Specify which files should be added to the gem when it is released.
|
24
25
|
# The `git ls-files -z` loads the files in the RubyGem
|
@@ -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,14 +1,17 @@
|
|
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
|
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.
|
4
|
+
version: 0.1.1
|
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
|
@@ -59,14 +61,15 @@ files:
|
|
59
61
|
- sig/ruht/tags.rbs
|
60
62
|
- sig/ruht/version.rbs
|
61
63
|
- sig/ruht/void_element.rbs
|
62
|
-
homepage: https://github.com/
|
64
|
+
homepage: https://github.com/ruby-hyper-text/ruht
|
63
65
|
licenses:
|
64
66
|
- MIT
|
65
67
|
metadata:
|
66
68
|
allowed_push_host: https://rubygems.org
|
67
|
-
homepage_uri: https://github.com/
|
68
|
-
source_code_uri: https://github.com/
|
69
|
-
changelog_uri: https://github.com/
|
69
|
+
homepage_uri: https://github.com/ruby-hyper-text/ruht
|
70
|
+
source_code_uri: https://github.com/ruby-hyper-text/ruht
|
71
|
+
changelog_uri: https://github.com/ruby-hyper-text/ruht/blob/main/CHANGELOG.md
|
72
|
+
github_repo: ssh://github.com/ruby-hyper-text/ruht
|
70
73
|
rubygems_mfa_required: 'true'
|
71
74
|
post_install_message:
|
72
75
|
rdoc_options: []
|
@@ -83,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
86
|
- !ruby/object:Gem::Version
|
84
87
|
version: '0'
|
85
88
|
requirements: []
|
86
|
-
rubygems_version: 3.4.
|
89
|
+
rubygems_version: 3.4.6
|
87
90
|
signing_key:
|
88
91
|
specification_version: 4
|
89
92
|
summary: DSL for building HTML written in Ruby
|