serbea 2.0.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +12 -0
- data/lib/serbea/helpers.rb +14 -3
- data/lib/serbea/pipeline.rb +22 -4
- data/lib/version.rb +1 -1
- data/serbea.gemspec +1 -2
- metadata +8 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 328bb1110c02d6c0da3abf6d0f1c26ed1c49d6f0265b82e35dafb945320ca1d5
|
4
|
+
data.tar.gz: 3ec4e316fb6c126a845b22490c944d2eedcd2c91a724a3aa5125866c56b44c53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a657dce3ddf4ca466cffd7e22af1785f026a887b0103d783f9350a60640b518243140229dd140d2c7e6d8ca61e5170f1a2dc98ec8055bfca418a99d1243937b
|
7
|
+
data.tar.gz: 6d604bfc2749f265352cfbd75fdebd1a77be2ff02b78000b9774265f17db53833fe7b515df72531ec1de6f38aaed4ea4676121ba944ec08c40ff0245283581b4
|
data/.github/workflows/ci.yml
CHANGED
@@ -13,7 +13,7 @@ jobs:
|
|
13
13
|
runs-on: ubuntu-latest
|
14
14
|
strategy:
|
15
15
|
matrix:
|
16
|
-
ruby_version: [
|
16
|
+
ruby_version: [3.1.0, 3.2.0, 3.3.0]
|
17
17
|
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
|
18
18
|
# Has to be top level to cache properly
|
19
19
|
env:
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.1.4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 2.2.0
|
4
|
+
|
5
|
+
- Add functionality to purge certain `Object`-based method pollution which interferes with the workings of Serbea's `Pipeline` in pure Ruby.
|
6
|
+
- Ruby 3.1 is now the minimum required version.
|
7
|
+
|
8
|
+
## 2.1.0
|
9
|
+
|
10
|
+
- Remove Active Support as a dependency
|
11
|
+
- This now provides rudimentary support of `html_safe` mechanics. Note that
|
12
|
+
it does NOT handle _any_ additional String methods. It simply allows cloning a string via `html_safe` to mark it safe, and `html_safe?` to query if it's safe.
|
13
|
+
- This _might_ be a breaking change, but likely not if you're using Serbea along with Rails or Bridgetown. To restore previous functionality manually, just install the `activesupport` gem and `require "active_support/core_ext/string/output_safety"` before you require the Serbea gem.
|
14
|
+
|
3
15
|
## 2.0.0
|
4
16
|
|
5
17
|
- Add plain ol' Ruby pipeline functionality
|
data/lib/serbea/helpers.rb
CHANGED
@@ -1,4 +1,15 @@
|
|
1
|
-
|
1
|
+
unless "".respond_to?(:html_safe)
|
2
|
+
# The simplest HTML safety "polyfill" around
|
3
|
+
class String
|
4
|
+
def html_safe
|
5
|
+
self.class.new(self).tap { _1.instance_variable_set(:@html_safe, true) }
|
6
|
+
end
|
7
|
+
|
8
|
+
def html_safe?
|
9
|
+
instance_variable_get(:@html_safe) == true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
2
13
|
|
3
14
|
module Serbea
|
4
15
|
module Helpers
|
@@ -10,7 +21,7 @@ module Serbea
|
|
10
21
|
previous_buffer_state = @_erbout
|
11
22
|
@_erbout = Serbea::OutputBuffer.new
|
12
23
|
result = yield(*args)
|
13
|
-
result = @_erbout.
|
24
|
+
result = @_erbout.empty? ? result : @_erbout
|
14
25
|
@_erbout = previous_buffer_state
|
15
26
|
|
16
27
|
Serbea::OutputBuffer === result ? result.html_safe : result
|
@@ -36,7 +47,7 @@ module Serbea
|
|
36
47
|
end
|
37
48
|
|
38
49
|
def h(input)
|
39
|
-
|
50
|
+
Erubi.h(input.to_s)
|
40
51
|
end
|
41
52
|
alias_method :escape, :h
|
42
53
|
|
data/lib/serbea/pipeline.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
require "set"
|
2
|
-
require "active_support/core_ext/string/output_safety"
|
3
|
-
require "active_support/core_ext/object/blank"
|
4
2
|
|
5
3
|
module Serbea
|
6
4
|
class Pipeline
|
@@ -36,7 +34,7 @@ module Serbea
|
|
36
34
|
full_template = "{{ #{template} | assign_to: :output }}"
|
37
35
|
|
38
36
|
tmpl = Tilt::SerbeaTemplate.new { full_template }
|
39
|
-
tmpl.render(pipeline_obj, locals.
|
37
|
+
tmpl.render(pipeline_obj, locals.empty? ? kwargs : locals)
|
40
38
|
|
41
39
|
pipeline_obj.output
|
42
40
|
end
|
@@ -49,7 +47,7 @@ module Serbea
|
|
49
47
|
# @return [Proc]
|
50
48
|
def self.output_processor
|
51
49
|
@output_processor ||= lambda do |input|
|
52
|
-
(!input.html_safe? && self.autoescape) ?
|
50
|
+
(!input.html_safe? && self.autoescape) ? Erubi.h(input) : input.html_safe
|
53
51
|
end
|
54
52
|
end
|
55
53
|
|
@@ -74,7 +72,27 @@ module Serbea
|
|
74
72
|
@value_methods_denylist ||= Set.new
|
75
73
|
end
|
76
74
|
|
75
|
+
def self.purge_class_pollution
|
76
|
+
@pollution_purged ||= begin
|
77
|
+
polluted_methods_list.each do |name|
|
78
|
+
define_method name do |*args, **kwargs|
|
79
|
+
filter(name, *args, **kwargs)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
true
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.polluted_method(name)
|
88
|
+
polluted_methods_list.merge Array(name)
|
89
|
+
end
|
90
|
+
def self.polluted_methods_list
|
91
|
+
@polluted_methods_list ||= Set.new(%i(select to_json))
|
92
|
+
end
|
93
|
+
|
77
94
|
def initialize(binding, value)
|
95
|
+
self.class.purge_class_pollution
|
78
96
|
@binding = binding
|
79
97
|
@context = binding.receiver
|
80
98
|
@value = value
|
data/lib/version.rb
CHANGED
data/serbea.gemspec
CHANGED
@@ -11,12 +11,11 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.homepage = "https://github.com/bridgetownrb/serbea"
|
12
12
|
spec.license = "MIT"
|
13
13
|
|
14
|
-
spec.required_ruby_version = ">=
|
14
|
+
spec.required_ruby_version = ">= 3.1"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|script|spec|features|docs|serbea-rails)/!) }
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
-
spec.add_runtime_dependency("activesupport", ">= 6.0")
|
20
19
|
spec.add_runtime_dependency("erubi", ">= 1.10")
|
21
20
|
spec.add_runtime_dependency("tilt", "~> 2.0")
|
22
21
|
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serbea
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bridgetown Team
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: activesupport
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '6.0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '6.0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: erubi
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +52,7 @@ dependencies:
|
|
66
52
|
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '13.0'
|
69
|
-
description:
|
55
|
+
description:
|
70
56
|
email: maintainers@bridgetownrb.com
|
71
57
|
executables: []
|
72
58
|
extensions: []
|
@@ -91,7 +77,7 @@ homepage: https://github.com/bridgetownrb/serbea
|
|
91
77
|
licenses:
|
92
78
|
- MIT
|
93
79
|
metadata: {}
|
94
|
-
post_install_message:
|
80
|
+
post_install_message:
|
95
81
|
rdoc_options: []
|
96
82
|
require_paths:
|
97
83
|
- lib
|
@@ -99,15 +85,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
85
|
requirements:
|
100
86
|
- - ">="
|
101
87
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
88
|
+
version: '3.1'
|
103
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
90
|
requirements:
|
105
91
|
- - ">="
|
106
92
|
- !ruby/object:Gem::Version
|
107
93
|
version: '0'
|
108
94
|
requirements: []
|
109
|
-
rubygems_version: 3.
|
110
|
-
signing_key:
|
95
|
+
rubygems_version: 3.3.26
|
96
|
+
signing_key:
|
111
97
|
specification_version: 4
|
112
98
|
summary: Similar to ERB, Except Awesomer
|
113
99
|
test_files: []
|