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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28c0d44d7cf42201f5c0e9b0b422ddfe9df80ad6f21f2312be0fe33a487b6ddd
4
- data.tar.gz: abb694a7eaa29ca21c6681f4f51590e83f0831fbe1fdf257435bcbe733420a88
3
+ metadata.gz: 2f6d5e0e63a6f2acc9944f0b703943dc3481e6430cfd19c89df6bd3b68e84a2b
4
+ data.tar.gz: 1b9c27c5af0cd0cf0dde74aaae73c6cb1add9ebd32a510ca3b2b119749b84994
5
5
  SHA512:
6
- metadata.gz: 36a0cf9af8a3595d35fb970887ad1ddcfa8ca4a90d052c3f32bc17aee00ab1893365529c20c3f928be87c18cb67fa451fe0f18a1e6540e109681b00849b7f8aa
7
- data.tar.gz: c35f3f75ea443343cc1a4d5c763d4e4be861f8cbdeb95a7b87ddd79818ad1a5929249874684e3953682b5b59b1d6525f2f1a06347cb14146d5114648b08b99fa
6
+ metadata.gz: 662a0b51ff471acb258b6529c6a9a9b64d1de6062d082301e030f03e4821b82537b050ccdf2ba690426c5441e717f7ba70f6e41e42fa0a28fefd090d4f00b9f6
7
+ data.tar.gz: 13978e66cd60115cacfeed50d7397c016a04343bad73c862eb6fbd6bd9c21bdd90e1eb3cb292b2b73c73b68822cf90a4f818957e0b33c6cfdf7f855f11912360
data/.rubocop.yml CHANGED
@@ -48,6 +48,9 @@ Metrics/MethodLength:
48
48
  Naming/BlockForwarding:
49
49
  Enabled: false
50
50
 
51
+ Style/ArgumentsForwarding:
52
+ Enabled: false
53
+
51
54
  # Disabled to aid in template readability
52
55
  Style/NestedParenthesizedCalls:
53
56
  Enabled: false
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
@@ -13,7 +13,7 @@ gem "minitest-reporters", "~> 1.5"
13
13
  gem "rubocop", "~> 1.21"
14
14
  gem "rubocop-bridgetown", "~> 0.4"
15
15
 
16
- gem "solargraph", "~> 0.49.0"
16
+ gem "solargraph", "~> 0.50"
17
17
 
18
18
  gem "rails-dom-testing", "~> 2.0"
19
19
 
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- streamlined (0.3.1)
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.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.1.1)
25
- benchmark (0.2.1)
26
- bigdecimal (3.1.4)
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.2)
28
+ concurrent-ruby (1.2.3)
29
29
  connection_pool (2.4.1)
30
- diff-lcs (1.5.0)
31
- drb (2.1.1)
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.1)
34
+ i18n (1.14.4)
36
35
  concurrent-ruby (~> 1.0)
37
36
  jaro_winkler (1.5.6)
38
- json (2.6.3)
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.20.0)
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.1.2)
51
- nokogiri (1.15.4-arm64-darwin)
49
+ mutex_m (0.2.0)
50
+ nokogiri (1.16.3-arm64-darwin)
52
51
  racc (~> 1.4)
53
- nokogiri (1.15.4-x86_64-linux)
52
+ nokogiri (1.16.3-x86_64-linux)
54
53
  racc (~> 1.4)
55
- parallel (1.23.0)
56
- parser (3.2.2.4)
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.1.0)
64
+ rake (13.2.0)
66
65
  rbs (2.8.4)
67
- regexp_parser (2.8.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.57.2)
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.2.2.4)
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.28.1, < 2.0)
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.30.0)
83
- parser (>= 3.2.1.0)
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.19.1)
90
- rubocop (>= 1.7.0, < 2.0)
91
- rubocop-ast (>= 0.4.0)
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.49.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.0)
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.34)
121
- zeitwerk (2.6.12)
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.49.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
- Component rendering for Ruby using streamlined procs & heredocs. Rails and Bridgetown both supported.
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 1.4…coming soon)
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
@@ -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 PipeableProc
6
- include Serbea::Pipeline::Helper
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
- return self unless block
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(PipeableProc)
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
- (callback.is_a?(Proc) ? callback.pipe : callback).to_s.then do |str|
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.html_safe.pipe
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)
@@ -45,10 +45,8 @@ module Streamlined
45
45
  @_view_context
46
46
  end
47
47
 
48
- # rubocop:disable Style/ArgumentsForwarding
49
48
  def capture(*args, &block)
50
49
  helpers ? helpers.capture(*args, &block) : yield(*args)
51
50
  end
52
- # rubocop:enable Style/ArgumentsForwarding
53
51
  end
54
52
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Streamlined
4
- VERSION = "0.3.1"
4
+ VERSION = "0.5.0"
5
5
  end
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 # |config|
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 = "Component rendering for Ruby using streamlined procs & heredocs."
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.0"
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.3.1
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: 2023-11-11 00:00:00.000000000 Z
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.0'
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: Component rendering for Ruby using streamlined procs & heredocs.
89
+ summary: HTML fragment & component rendering for Ruby using streamlined procs & heredocs.
89
90
  test_files: []