streamlined 0.3.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +31 -33
- data/README.md +2 -2
- data/lib/roda/plugins/streamlined.rb +27 -0
- data/lib/streamlined/helpers.rb +15 -15
- data/lib/streamlined/renderable.rb +0 -2
- data/lib/streamlined/version.rb +1 -1
- data/lib/streamlined.rb +5 -1
- data/streamlined.gemspec +2 -2
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f6d5e0e63a6f2acc9944f0b703943dc3481e6430cfd19c89df6bd3b68e84a2b
|
4
|
+
data.tar.gz: 1b9c27c5af0cd0cf0dde74aaae73c6cb1add9ebd32a510ca3b2b119749b84994
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 662a0b51ff471acb258b6529c6a9a9b64d1de6062d082301e030f03e4821b82537b050ccdf2ba690426c5441e717f7ba70f6e41e42fa0a28fefd090d4f00b9f6
|
7
|
+
data.tar.gz: 13978e66cd60115cacfeed50d7397c016a04343bad73c862eb6fbd6bd9c21bdd90e1eb3cb292b2b73c73b68822cf90a4f818957e0b33c6cfdf7f855f11912360
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
## [Unreleased]
|
4
4
|
|
5
|
+
## [0.5.0 - 2024-04-06
|
6
|
+
|
7
|
+
- Simplify syntax of pipe procs for text & html
|
8
|
+
|
9
|
+
## [0.4.0] — 2024-04-04
|
10
|
+
|
11
|
+
- Provide Roda plugin to mix in Streamlined helpers.
|
12
|
+
|
5
13
|
## [0.3.1] - 2023-11-10
|
6
14
|
|
7
15
|
- Ensure false or nil values for attributes avoid rendering attributes at all
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
streamlined (0.
|
4
|
+
streamlined (0.5.0)
|
5
5
|
serbea (>= 2.1)
|
6
6
|
zeitwerk (~> 2.5)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (7.1.
|
11
|
+
activesupport (7.1.3.2)
|
12
12
|
base64
|
13
13
|
bigdecimal
|
14
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
@@ -21,39 +21,38 @@ GEM
|
|
21
21
|
ansi (1.5.0)
|
22
22
|
ast (2.4.2)
|
23
23
|
backport (1.2.0)
|
24
|
-
base64 (0.
|
25
|
-
benchmark (0.
|
26
|
-
bigdecimal (3.1.
|
24
|
+
base64 (0.2.0)
|
25
|
+
benchmark (0.3.0)
|
26
|
+
bigdecimal (3.1.7)
|
27
27
|
builder (3.2.4)
|
28
|
-
concurrent-ruby (1.2.
|
28
|
+
concurrent-ruby (1.2.3)
|
29
29
|
connection_pool (2.4.1)
|
30
|
-
diff-lcs (1.5.
|
31
|
-
drb (2.
|
32
|
-
ruby2_keywords
|
30
|
+
diff-lcs (1.5.1)
|
31
|
+
drb (2.2.1)
|
33
32
|
e2mmap (0.1.0)
|
34
33
|
erubi (1.12.0)
|
35
|
-
i18n (1.14.
|
34
|
+
i18n (1.14.4)
|
36
35
|
concurrent-ruby (~> 1.0)
|
37
36
|
jaro_winkler (1.5.6)
|
38
|
-
json (2.
|
37
|
+
json (2.7.2)
|
39
38
|
kramdown (2.4.0)
|
40
39
|
rexml
|
41
40
|
kramdown-parser-gfm (1.1.0)
|
42
41
|
kramdown (~> 2.0)
|
43
42
|
language_server-protocol (3.17.0.3)
|
44
|
-
minitest (5.
|
43
|
+
minitest (5.22.3)
|
45
44
|
minitest-reporters (1.6.1)
|
46
45
|
ansi
|
47
46
|
builder
|
48
47
|
minitest (>= 5.0)
|
49
48
|
ruby-progressbar
|
50
|
-
mutex_m (0.
|
51
|
-
nokogiri (1.
|
49
|
+
mutex_m (0.2.0)
|
50
|
+
nokogiri (1.16.3-arm64-darwin)
|
52
51
|
racc (~> 1.4)
|
53
|
-
nokogiri (1.
|
52
|
+
nokogiri (1.16.3-x86_64-linux)
|
54
53
|
racc (~> 1.4)
|
55
|
-
parallel (1.
|
56
|
-
parser (3.
|
54
|
+
parallel (1.24.0)
|
55
|
+
parser (3.3.0.5)
|
57
56
|
ast (~> 2.4.1)
|
58
57
|
racc
|
59
58
|
racc (1.7.3)
|
@@ -62,41 +61,40 @@ GEM
|
|
62
61
|
minitest
|
63
62
|
nokogiri (>= 1.6)
|
64
63
|
rainbow (3.1.1)
|
65
|
-
rake (13.
|
64
|
+
rake (13.2.0)
|
66
65
|
rbs (2.8.4)
|
67
|
-
regexp_parser (2.
|
66
|
+
regexp_parser (2.9.0)
|
68
67
|
reverse_markdown (2.1.1)
|
69
68
|
nokogiri
|
70
69
|
rexml (3.2.6)
|
71
|
-
rubocop (1.
|
70
|
+
rubocop (1.62.1)
|
72
71
|
json (~> 2.3)
|
73
72
|
language_server-protocol (>= 3.17.0)
|
74
73
|
parallel (~> 1.10)
|
75
|
-
parser (>= 3.
|
74
|
+
parser (>= 3.3.0.2)
|
76
75
|
rainbow (>= 2.2.2, < 4.0)
|
77
76
|
regexp_parser (>= 1.8, < 3.0)
|
78
77
|
rexml (>= 3.2.5, < 4.0)
|
79
|
-
rubocop-ast (>= 1.
|
78
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
80
79
|
ruby-progressbar (~> 1.7)
|
81
80
|
unicode-display_width (>= 2.4.0, < 3.0)
|
82
|
-
rubocop-ast (1.
|
83
|
-
parser (>= 3.
|
81
|
+
rubocop-ast (1.31.2)
|
82
|
+
parser (>= 3.3.0.4)
|
84
83
|
rubocop-bridgetown (0.4.1)
|
85
84
|
rubocop (~> 1.23)
|
86
85
|
rubocop-performance (~> 1.12)
|
87
86
|
rubocop-minitest (0.20.1)
|
88
87
|
rubocop (>= 0.90, < 2.0)
|
89
|
-
rubocop-performance (1.
|
90
|
-
rubocop (>= 1.
|
91
|
-
rubocop-ast (>=
|
88
|
+
rubocop-performance (1.21.0)
|
89
|
+
rubocop (>= 1.48.1, < 2.0)
|
90
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
92
91
|
rubocop-rake (0.6.0)
|
93
92
|
rubocop (~> 1.0)
|
94
93
|
ruby-progressbar (1.13.0)
|
95
|
-
ruby2_keywords (0.0.5)
|
96
94
|
serbea (2.1.0)
|
97
95
|
erubi (>= 1.10)
|
98
96
|
tilt (~> 2.0)
|
99
|
-
solargraph (0.
|
97
|
+
solargraph (0.50.0)
|
100
98
|
backport (~> 1.2)
|
101
99
|
benchmark
|
102
100
|
bundler (~> 2.0)
|
@@ -112,13 +110,13 @@ GEM
|
|
112
110
|
thor (~> 1.0)
|
113
111
|
tilt (~> 2.0)
|
114
112
|
yard (~> 0.9, >= 0.9.24)
|
115
|
-
thor (1.3.
|
113
|
+
thor (1.3.1)
|
116
114
|
tilt (2.3.0)
|
117
115
|
tzinfo (2.0.6)
|
118
116
|
concurrent-ruby (~> 1.0)
|
119
117
|
unicode-display_width (2.5.0)
|
120
|
-
yard (0.9.
|
121
|
-
zeitwerk (2.6.
|
118
|
+
yard (0.9.36)
|
119
|
+
zeitwerk (2.6.13)
|
122
120
|
|
123
121
|
PLATFORMS
|
124
122
|
arm64-darwin-21
|
@@ -133,7 +131,7 @@ DEPENDENCIES
|
|
133
131
|
rubocop-bridgetown (~> 0.4)
|
134
132
|
rubocop-minitest (~> 0.20.0)
|
135
133
|
rubocop-rake (~> 0.6.0)
|
136
|
-
solargraph (~> 0.
|
134
|
+
solargraph (~> 0.50)
|
137
135
|
streamlined!
|
138
136
|
|
139
137
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Streamlined
|
2
2
|
|
3
|
-
|
3
|
+
HTML fragment and component rendering for Ruby using streamlined procs & heredocs with safety checks via RuboCop. Bridgetown, Roda, and Rails all supported.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -10,7 +10,7 @@ Add Streamlined to your application's Gemfile by running:
|
|
10
10
|
bundle add streamlined
|
11
11
|
```
|
12
12
|
|
13
|
-
(If you're using Bridgetown, it's bundled in for Bridgetown
|
13
|
+
(If you're using Bridgetown, it's bundled in for Bridgetown 2.0…coming soon)
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Roda
|
4
|
+
module RodaPlugins
|
5
|
+
module Streamlined
|
6
|
+
module CheckForStreamlined
|
7
|
+
def self.===(other)
|
8
|
+
other.is_a?(Proc) && other.respond_to?(:touched) && other.touched
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module InstanceMethods
|
13
|
+
include ::Streamlined::Helpers
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.load_dependencies(app, _opts = OPTS)
|
17
|
+
app.plugin :custom_block_results
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.configure(app, _opts = OPTS)
|
21
|
+
app.handle_block_result CheckForStreamlined, &:to_s
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
register_plugin :streamlined, Streamlined
|
26
|
+
end
|
27
|
+
end
|
data/lib/streamlined/helpers.rb
CHANGED
@@ -1,19 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "tilt/erubi"
|
4
|
+
|
3
5
|
module Streamlined
|
4
6
|
module Helpers
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
attr_accessor :pipe_block, :touched
|
9
|
-
|
10
|
-
def pipe(&block)
|
11
|
-
return super(self.(), &pipe_block) if pipe_block && !block
|
7
|
+
module TouchableProc
|
8
|
+
attr_accessor :touched
|
12
9
|
|
10
|
+
def touch
|
13
11
|
self.touched = true
|
14
|
-
|
15
|
-
|
16
|
-
tap { _1.pipe_block = block }
|
12
|
+
self
|
17
13
|
end
|
18
14
|
|
19
15
|
def html_safe
|
@@ -36,7 +32,7 @@ module Streamlined
|
|
36
32
|
end
|
37
33
|
end
|
38
34
|
|
39
|
-
::Proc.prepend(
|
35
|
+
::Proc.prepend(TouchableProc)
|
40
36
|
|
41
37
|
# Create a set of attributes from a hash.
|
42
38
|
#
|
@@ -82,16 +78,20 @@ module Streamlined
|
|
82
78
|
"#{attr}=#{value.to_s.encode(xml: :attr)}"
|
83
79
|
end
|
84
80
|
|
85
|
-
def text(callback)
|
86
|
-
|
81
|
+
def text(callback, piping = nil)
|
82
|
+
callback = Serbea::Pipeline.new(binding, callback).tap { _1.instance_exec(&piping) } if piping
|
83
|
+
|
84
|
+
(callback.is_a?(Proc) ? callback.touch : callback).to_s.then do |str|
|
87
85
|
next str if str.html_safe?
|
88
86
|
|
89
87
|
str.encode(xml: :attr).gsub(%r{\A"|"\Z}, "")
|
90
88
|
end
|
91
89
|
end
|
92
90
|
|
93
|
-
def html(callback)
|
94
|
-
callback.
|
91
|
+
def html(callback, piping = nil)
|
92
|
+
callback = Serbea::Pipeline.new(binding, callback).tap { _1.instance_exec(&piping) } if piping
|
93
|
+
|
94
|
+
callback.html_safe.touch
|
95
95
|
end
|
96
96
|
|
97
97
|
def html_map(input, &callback)
|
data/lib/streamlined/version.rb
CHANGED
data/lib/streamlined.rb
CHANGED
@@ -4,6 +4,7 @@ require "serbea/helpers" # primarily just for HTML safety polyfill
|
|
4
4
|
require "serbea/pipeline"
|
5
5
|
require "zeitwerk"
|
6
6
|
loader = Zeitwerk::Loader.for_gem
|
7
|
+
loader.ignore("#{__dir__}/roda")
|
7
8
|
loader.setup
|
8
9
|
|
9
10
|
module Streamlined
|
@@ -11,6 +12,9 @@ module Streamlined
|
|
11
12
|
end
|
12
13
|
|
13
14
|
if defined?(Bridgetown)
|
14
|
-
Bridgetown.initializer :streamlined do
|
15
|
+
Bridgetown.initializer :streamlined do |config|
|
16
|
+
config.roda do |app|
|
17
|
+
app.plugin :streamlined
|
18
|
+
end
|
15
19
|
end
|
16
20
|
end
|
data/streamlined.gemspec
CHANGED
@@ -8,10 +8,10 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.author = "Bridgetown Team"
|
9
9
|
spec.email = "maintainers@bridgetownrb.com"
|
10
10
|
|
11
|
-
spec.summary = "
|
11
|
+
spec.summary = "HTML fragment & component rendering for Ruby using streamlined procs & heredocs."
|
12
12
|
spec.homepage = "https://github.com/bridgetownrb/streamlined"
|
13
13
|
spec.license = "MIT"
|
14
|
-
spec.required_ruby_version = ">= 3.
|
14
|
+
spec.required_ruby_version = ">= 3.1"
|
15
15
|
spec.metadata["rubygems_mfa_required"] = "true"
|
16
16
|
|
17
17
|
# Specify which files should be added to the gem when it is released.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: streamlined
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bridgetown Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: serbea
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- bin/rake
|
58
58
|
- bin/rubocop
|
59
59
|
- bin/setup
|
60
|
+
- lib/roda/plugins/streamlined.rb
|
60
61
|
- lib/streamlined.rb
|
61
62
|
- lib/streamlined/helpers.rb
|
62
63
|
- lib/streamlined/renderable.rb
|
@@ -75,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
76
|
requirements:
|
76
77
|
- - ">="
|
77
78
|
- !ruby/object:Gem::Version
|
78
|
-
version: '3.
|
79
|
+
version: '3.1'
|
79
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
81
|
requirements:
|
81
82
|
- - ">="
|
@@ -85,5 +86,5 @@ requirements: []
|
|
85
86
|
rubygems_version: 3.3.3
|
86
87
|
signing_key:
|
87
88
|
specification_version: 4
|
88
|
-
summary:
|
89
|
+
summary: HTML fragment & component rendering for Ruby using streamlined procs & heredocs.
|
89
90
|
test_files: []
|