phlex 1.9.1 → 1.9.3

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: 9a0ead9c6e98f79b9f6b71e897a3b7dd2a8be8c68b36c1ead9c4c7ac9d4a93af
4
- data.tar.gz: 51af9dc212b8d5f142c9e607bd0a4a6342cc84b18b59252f4986b394e530f495
3
+ metadata.gz: 9626f57bb65b8406db379a0ec004a4be1328638cf2ae3049189456b1fcf9c84f
4
+ data.tar.gz: 830bb2616cb9fd38dea2e301e2d28eaad7ac17692b69e29dcdcbcd9a3d0e363e
5
5
  SHA512:
6
- metadata.gz: 0703ddfddfca1a573f1883918c8e9f24c928b10c7305d477a8542e5ddac2d1debeb5a38617cfd7d6163a8ee94511395898fad17c78da54222ccdf231c1758fc0
7
- data.tar.gz: 6f2451edb1ecb37979c93e660364bdb3312d145a3a7a961b1c263cf927804ebf9501d5b503b082f1fd9973eba7ddefb55543a0308af328ef3aad987fb15adbdc
6
+ metadata.gz: c53416162addce8669ae69b925859f6be21d2ca4d081e44aa7b0fbba2184f2f58ff543b6032f1c102a0c12bf442df58ce8c46d3000f40563d21dee15449172b3
7
+ data.tar.gz: 0d3b36d039ab0efb7e172633994d8432342759f367ebf2d9e414f3cd99adc8ea2cd6ae0a1579c6945828c5b86ab236ff4f09a062d4670ac71be0e2dbdfe3684c
data/lib/phlex/sgml.rb CHANGED
@@ -384,10 +384,10 @@ module Phlex
384
384
  end
385
385
 
386
386
  lower_name = name.downcase
387
- next if lower_name == "href" && v.start_with?(/\s*javascript:/i)
387
+ next if lower_name == "href" && v.to_s.downcase.tr("^a-z:", "").start_with?("javascript:")
388
388
 
389
389
  # Detect unsafe attribute names. Attribute names are considered unsafe if they match an event attribute or include unsafe characters.
390
- if HTML::EVENT_ATTRIBUTES[lower_name] || name.match?(/[<>&"']/)
390
+ if HTML::EVENT_ATTRIBUTES.include?(lower_name.tr("^a-z-", "")) || name.match?(/[<>&"']/)
391
391
  raise ArgumentError, "Unsafe attribute name detected: #{k}."
392
392
  end
393
393
 
data/lib/phlex/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Phlex
4
- VERSION = "1.9.1"
4
+ VERSION = "1.9.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phlex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 1.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Drapper
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-11 00:00:00.000000000 Z
11
+ date: 2024-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -59,25 +59,8 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - ".editorconfig"
63
- - ".rubocop.yml"
64
- - ".ruby-version"
65
- - ".yardopts"
66
- - CHANGELOG.md
67
- - CODE_OF_CONDUCT.md
68
- - CONTRIBUTING.md
69
- - Gemfile
70
62
  - LICENSE.txt
71
63
  - README.md
72
- - SECURITY.md
73
- - bench.rb
74
- - config/sus.rb
75
- - fixtures/layout.rb
76
- - fixtures/page.rb
77
- - fixtures/view_helper.rb
78
- - gd/phlex/callable.rb
79
- - gd/phlex/sgml/attributes.rb
80
- - gd/support/helper.rb
81
64
  - lib/phlex.rb
82
65
  - lib/phlex/black_hole.rb
83
66
  - lib/phlex/callable.rb
@@ -96,8 +79,6 @@ files:
96
79
  - lib/phlex/testing/view_helper.rb
97
80
  - lib/phlex/unbuffered.rb
98
81
  - lib/phlex/version.rb
99
- - phlex_logo.png
100
- - sig/phlex.rbs
101
82
  homepage: https://www.phlex.fun
102
83
  licenses:
103
84
  - MIT
@@ -122,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
103
  - !ruby/object:Gem::Version
123
104
  version: '0'
124
105
  requirements: []
125
- rubygems_version: 3.4.22
106
+ rubygems_version: 3.5.3
126
107
  signing_key:
127
108
  specification_version: 4
128
109
  summary: A fun framework for building views in Ruby.
data/.editorconfig DELETED
@@ -1,13 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- indent_style = tab
5
- indent_size = 2
6
-
7
- [*.yml]
8
- indent_style = space
9
- indent_size = 2
10
-
11
- [*.erb]
12
- indent_style = space
13
- indent_size = 2
data/.rubocop.yml DELETED
@@ -1,15 +0,0 @@
1
- inherit_from:
2
- - "https://www.goodcop.style/rubocop.yml"
3
- - "https://www.goodcop.style/tabs.yml"
4
-
5
- AllCops:
6
- TargetRubyVersion: 2.7
7
-
8
- Style/ExplicitBlockArgument:
9
- Enabled: false
10
-
11
- Style/MixinUsage:
12
- Enabled: false
13
-
14
- Style/RedundantDoubleSplatHashBraces:
15
- Enabled: false
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.2.2
data/.yardopts DELETED
@@ -1 +0,0 @@
1
- --private --hide-api private --markup markdown
data/CHANGELOG.md DELETED
@@ -1,47 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4
-
5
- ## [1.9.0] 2024-11-24
6
-
7
- - Improved documentation
8
- - Fixed an issue with flushing to the buffer while capturing
9
- - Added `<canvas>` element
10
- - Very minor performance improvements by using `block` instead of `block_given?` where a block has already been captured
11
- - `Integer` objects are now handled by the `format_object` method, which you can override to customise how various objects are rendered
12
- - You can now use `render` with `String` and `Method` objects
13
-
14
- ## [1.8.1] 2023-04-19
15
-
16
- ### Fixed
17
-
18
- - Rendering a component with a false `render?` predicate should return an empty String rather than `nil`.
19
-
20
- ## [1.8.0] 2023-04-19
21
-
22
- ### Changed
23
-
24
- - Support `Integer` and `Float` attribute values, and fall back to calling `to_str` on other objects.
25
-
26
- ## [1.7.0] 2023-04-18
27
-
28
- ### Added
29
-
30
- - Experimental Smart chunking.
31
-
32
- ### Changed
33
-
34
- - Improved YARD documentation, which is now available here https://rubydoc.info/gems/phlex
35
- - `SGML#render` can now render lambdas with zero or one arguments. Previously, it could only render lambdas with exactly one argument, although it could always render Procs with any number of arguments. When an argument is accepted, the `self` of the component rendering it is yielded to the Proc.
36
- - Raise an error when outputting an unknown object using `SGML#plain`.
37
- - Raise an error when using attribute keys that aren't Strings or Symbols.
38
- - Support Array and Set values for HTML/SVG attributes.
39
-
40
- ### Removed
41
-
42
- - Removed the `menuitem` element as it's a deprecated HTML element.
43
- - Removed the `SGML#text` method. This has been replaced with `SGML#plain`.
44
-
45
- ***
46
-
47
- Before this changelog was introduced, changes were logged in the [release notes](https://github.com/phlex-ruby/phlex/releases).
data/CODE_OF_CONDUCT.md DELETED
@@ -1,84 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behavior that contributes to a positive environment for our community include:
12
-
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
18
-
19
- Examples of unacceptable behavior include:
20
-
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
29
-
30
- ## Enforcement Responsibilities
31
-
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
-
36
- ## Scope
37
-
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at joel@drapper.me. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
57
-
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
73
-
74
- ## Attribution
75
-
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
82
-
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/CONTRIBUTING.md DELETED
@@ -1,33 +0,0 @@
1
- # Contributing to Phlex
2
-
3
- ## Priorities
4
-
5
- We’re trying to provide the best possible developer experience for the people using Phlex in their apps and the best possible performance for the users of those apps.
6
-
7
- Phlex is incredibly complex and requires a lot of meta-programming but when you use it, it feels simple. Phlex views feel like plain old Ruby objects. You just subclass and define a couple of methods. That’s it. That’s how it should be.
8
-
9
- ## Setup
10
-
11
- - Install dependencies `bundle install`
12
- - Run the tests `bundle exec sus`
13
- - Run Rubocop and auto-correct `bundle exec rubocop -A`
14
-
15
- ## Tests
16
-
17
- New tests should be written using [GreenDots](https://github.com/joeldrapper/green_dots) and placed in the `gd` folder. You can run these tests with:
18
-
19
- ```
20
- bundle exec gd gd
21
- ```
22
-
23
- Joel maintains GreenDots itself, so if you run into any issues, please reach out to him by creating an issue in the GreenDots repo so he can improve the framework.
24
-
25
- Previously, we used **[Sus](https://github.com/ioquatix/sus)**. Sus tests are in the `test` folder and can be run with:
26
-
27
- ```
28
- bundle exec sus
29
- ```
30
-
31
- ## Documentation
32
-
33
- Documentation is deployed when it’s merged into the `latest` branch with a release. But you can build and preview the docs locally by running `bin/docs`.
data/Gemfile DELETED
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
- git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
-
6
- gemspec
7
-
8
- gem "rubocop"
9
- gem "sus"
10
- gem "benchmark-ips"
11
- gem "yard"
12
- # gem "green_dots", github: "joeldrapper/green_dots"
13
-
14
- group :test do
15
- gem "i18n"
16
- gem "memory_profiler"
17
- end
data/SECURITY.md DELETED
@@ -1,13 +0,0 @@
1
- # Security Policy
2
-
3
- ## Reporting a vulnerability
4
-
5
- If you find a possible security vulnerability, please email security@phlex.fun. Do not create an issue or pull request either demonstrating or fixing the vulnerability.
6
-
7
- ## Bug bounty
8
-
9
- [The Gem Foundation](https://ryanbigg.com/2022/11/the-gem-foundation) has kindly sponsored a $1 bug bounty to discover security vulnerabilities in Phlex.
10
-
11
- ## Sponsoring a bug bounty
12
-
13
- If you wish to sponsor a bug bounty for Phlex, please get in touch with Joel at joel@drapper.me.
data/bench.rb DELETED
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "phlex"
5
- require "benchmark/ips"
6
-
7
- require_relative "fixtures/page"
8
- require_relative "fixtures/layout"
9
-
10
- puts RUBY_DESCRIPTION
11
-
12
- a = Example::Page.new.call
13
- # Example::Page.compile
14
- # Example::LayoutComponent.compile
15
- b = Example::Page.new.call
16
-
17
- raise unless a == b
18
-
19
- Benchmark.ips do |x|
20
- x.report("Page") { Example::Page.new.call }
21
- end
data/config/sus.rb DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "phlex"
4
- require "bundler"
5
-
6
- Bundler.require :test
7
-
8
- require_relative "../fixtures/view_helper"
9
-
10
- Zeitwerk::Loader.eager_load_all
data/fixtures/layout.rb DELETED
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Example
4
- class LayoutComponent < Phlex::HTML
5
- def initialize(title: "Example")
6
- @title = title
7
- end
8
-
9
- def template(&block)
10
- html do
11
- head do
12
- title { @title }
13
- meta name: "viewport", content: "width=device-width,initial-scale=1"
14
- link href: "/assets/tailwind.css", rel: "stylesheet"
15
- end
16
-
17
- body class: "bg-zinc-100" do
18
- nav class: "p-5", id: "main_nav" do
19
- ul do
20
- li(class: "p-5") { a(href: "/") { "Home" } }
21
- li(class: "p-5") { a(href: "/about") { "About" } }
22
- li(class: "p-5") { a(href: "/contact") { "Contact" } }
23
- end
24
- end
25
-
26
- div class: "container mx-auto p-5", &block
27
- end
28
- end
29
- end
30
- end
31
- end
data/fixtures/page.rb DELETED
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Example
4
- class Page < Phlex::HTML
5
- def template
6
- render LayoutComponent.new do
7
- h1 { "Hi" }
8
-
9
- table id: "test", class: "a b c d e f g" do
10
- tr do
11
- td id: "test", class: "a b c d e f g" do
12
- span { "Hi" }
13
- end
14
-
15
- td id: "test", class: "a b c d e f g" do
16
- span { "Hi" }
17
- end
18
-
19
- td id: "test", class: "a b c d e f g" do
20
- span { "Hi" }
21
- end
22
-
23
- td id: "test", class: "a b c d e f g" do
24
- span { "Hi" }
25
- end
26
-
27
- td id: "test", class: "a b c d e f g" do
28
- span { "Hi" }
29
- end
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ViewHelper
4
- def self.extended(parent)
5
- parent.class_exec do
6
- let(:output) { example.call }
7
- let(:example) { view.new }
8
- end
9
- end
10
-
11
- def view(&block)
12
- let :view do
13
- Class.new(Phlex::HTML, &block)
14
- end
15
- end
16
-
17
- def svg_view(&block)
18
- let :view do
19
- Class.new(Phlex::SVG, &block)
20
- end
21
- end
22
- end
data/gd/phlex/callable.rb DELETED
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Example
4
- include Phlex::Callable
5
-
6
- def call
7
- "Hello, world!"
8
- end
9
- end
10
-
11
- def example
12
- Example.new
13
- end
14
-
15
- test "to_proc" do
16
- expect(example.to_proc).to_be_a Proc
17
- expect(example.to_proc.call) == "Hello, world!"
18
- end
@@ -1,79 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- include TestHelper
4
-
5
- class ToStrable
6
- def to_str
7
- "foo"
8
- end
9
- end
10
-
11
- test "with symbol-keyed hash attributes" do
12
- component = build_component_with_template do
13
- div data: { name: { first_name: "Joel" } }
14
- end
15
-
16
- expect(component.new).to_render %(<div data-name-first-name="Joel"></div>)
17
- end
18
-
19
- test "with string-keyed hash attributes" do
20
- component = build_component_with_template do
21
- div data: { "name" => { "first_name" => "Joel" } }
22
- end
23
-
24
- expect(component.new).to_render %(<div data-name-first_name="Joel"></div>)
25
- end
26
-
27
- test "with an array of symbols and strings" do
28
- component = build_component_with_template do
29
- div class: ["bg-red-500", :rounded]
30
- end
31
-
32
- expect(component.new).to_render %(<div class="bg-red-500 rounded"></div>)
33
- end
34
-
35
- test "with a set of symbols and strings" do
36
- component = build_component_with_template do
37
- div class: Set.new(["bg-red-500", :rounded])
38
- end
39
-
40
- expect(component.new).to_render %(<div class="bg-red-500 rounded"></div>)
41
- end
42
-
43
- test "with a to_str-able object" do
44
- component = build_component_with_template do
45
- div class: ToStrable.new
46
- end
47
-
48
- expect(component.new).to_render %(<div class="foo"></div>)
49
- end
50
-
51
- test "with numeric integer/float" do
52
- component = build_component_with_template do
53
- input type: "range", min: 0, max: 10, step: 0.5
54
- end
55
-
56
- expect(component.new).to_render %(<input type="range" min="0" max="10" step="0.5">)
57
- end
58
-
59
- if RUBY_ENGINE == "ruby"
60
- context "with unique tag attributes" do
61
- let def component
62
- build_component_with_template do
63
- div class: SecureRandom.hex
64
- end
65
- end
66
-
67
- let def report
68
- component.call
69
-
70
- MemoryProfiler.report do
71
- 2.times { component.call }
72
- end
73
- end
74
-
75
- test "doesn't leak memory" do
76
- expect(report.total_retained) == 0
77
- end
78
- end
79
- end
data/gd/support/helper.rb DELETED
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "phlex"
4
- require "bundler"
5
-
6
- Bundler.require :test
7
-
8
- module TestHelper
9
- def build_component_with_template(&block)
10
- Class.new(Phlex::HTML) { define_method(:template, &block) }
11
- end
12
- end
13
-
14
- module ToRender
15
- def to_render(expected_output)
16
- output = subject.call
17
- assert(output == expected_output) { "Expected `#{output.inspect}` to equal `#{expected_output.inspect}`." }
18
- end
19
- end
20
-
21
- GreenDots.configure do |config|
22
- config.register_matcher ToRender, Phlex::SGML
23
- end
data/phlex_logo.png DELETED
Binary file
data/sig/phlex.rbs DELETED
@@ -1,4 +0,0 @@
1
- module Phlex
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end