streamlined 0.3.0 → 0.4.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: c9c83355498ef547dddeb348be536ffa6cc9a469b8fe8004cf18e593586a10d6
4
- data.tar.gz: ca0af7657dc791a511c5b65e1f30bbfd49547203c2c3851d2aed1df93b1ffe83
3
+ metadata.gz: 05f5b1f3f4076db6a1199096cd1da0c78594161b4fadb12bbd5e8777a7d5993f
4
+ data.tar.gz: 1db72d9247ae8d7d5f1b2c49de47c30c8b7341cc50bac7f434386d9ac8eb5555
5
5
  SHA512:
6
- metadata.gz: b4cf6b122586ce5ece9490ff7ca6138d979c5534356ff3f769ffce133a7d9210a17e61cae7aadc08fe36f59a300034bedcea29cd5c9f6ffc037b3fee6946a22e
7
- data.tar.gz: c36e14f2737233f2ea364d797cdd94380f4e9e0318eaa8cddeca77a12e6a94af51ad927e1bcf287b07d12d927a68f785d95a25fba57e1290f113aa809c8cd550
6
+ metadata.gz: 6539b91a92c00001129658a57d139f19672ea07be9ea54a38d1fa04dc2579e7d98d40d439d49a9d24d9a9207228733f03fb8756651fcfefa0e34acc2054d5e42
7
+ data.tar.gz: 045c5edea6a3f743461ae9fa0a5918867daeb8b59e7ac643576bb3c624a16ed3a1d5e360e1280c8514514c66eff91e01664757b464298912ba7abbf465a43322
data/.rubocop.yml CHANGED
@@ -7,7 +7,7 @@ inherit_gem:
7
7
  rubocop-bridgetown: .rubocop.yml
8
8
 
9
9
  AllCops:
10
- TargetRubyVersion: 3.0
10
+ TargetRubyVersion: 3.1
11
11
  NewCops: enable
12
12
 
13
13
  Exclude:
@@ -45,6 +45,9 @@ Metrics/MethodLength:
45
45
  Exclude:
46
46
  - test/**/*.rb
47
47
 
48
+ Naming/BlockForwarding:
49
+ Enabled: false
50
+
48
51
  # Disabled to aid in template readability
49
52
  Style/NestedParenthesizedCalls:
50
53
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.4.0] — 2024-04-04
6
+
7
+ - Provide Roda plugin to mix in Streamlined helpers.
8
+
9
+ ## [0.3.1] - 2023-11-10
10
+
11
+ - Ensure false or nil values for attributes avoid rendering attributes at all
12
+
13
+ ## [0.3.0] - 2023-11-07
14
+
15
+ - Fix escaping bug due to bad test
16
+
5
17
  ## [0.2.0] - 2023-11-07
6
18
 
7
19
  - Back out of more complicated `render_in` mechanics
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- streamlined (0.3.0)
4
+ streamlined (0.4.0)
5
5
  serbea (>= 2.1)
6
6
  zeitwerk (~> 2.5)
7
7
 
@@ -81,7 +81,7 @@ GEM
81
81
  unicode-display_width (>= 2.4.0, < 3.0)
82
82
  rubocop-ast (1.30.0)
83
83
  parser (>= 3.2.1.0)
84
- rubocop-bridgetown (0.4.0)
84
+ rubocop-bridgetown (0.4.1)
85
85
  rubocop (~> 1.23)
86
86
  rubocop-performance (~> 1.12)
87
87
  rubocop-minitest (0.20.1)
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
@@ -44,10 +44,12 @@ module Streamlined
44
44
  # @param prefix_space [Boolean] add a starting space if attributes are present,
45
45
  # useful in tag builders
46
46
  # @return [String]
47
- def html_attributes(options = nil, prefix_space: false, **kwargs)
47
+ def html_attributes(options = nil, prefix_space: false, **kwargs) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
48
48
  options ||= kwargs
49
49
  segments = []
50
50
  options.each do |attr, option|
51
+ next if option == false || option.nil?
52
+
51
53
  attr = dashed(attr)
52
54
  if option.is_a?(Hash)
53
55
  option = option.transform_keys { |key| "#{attr}-#{dashed(key)}" }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Streamlined
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.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.0
4
+ version: 0.4.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-08 00:00:00.000000000 Z
11
+ date: 2024-04-05 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: []