Skip to content

Commit 2484d5b

Browse files
authored
Update CI (#824)
1 parent 0604701 commit 2484d5b

File tree

8 files changed

+22
-28
lines changed

8 files changed

+22
-28
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ jobs:
1111
matrix:
1212
os: ["ubuntu-latest", "macos-latest"]
1313
ruby-version:
14+
- "3.2"
1415
- "3.3"
1516
- "head"
17+
- "truffleruby"
18+
- "truffleruby-head"
1619

1720
runs-on: ${{ matrix.os }}
1821
steps:
@@ -33,7 +36,7 @@ jobs:
3336
run: bundle exec sus
3437

3538
- name: Quickdraw Tests
36-
run: bundle exec qt
39+
run: bundle exec qt -t 1
3740

3841
rubocop:
3942
runs-on: "ubuntu-latest"

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ inherit_from:
22
- "https://www.goodcop.style/tabs.yml"
33

44
AllCops:
5-
TargetRubyVersion: 3.3.1
5+
TargetRubyVersion: 3.2
66

77
# We need to disable this cop because it’s not compatible with TruffleRuby 23.1, which still needs a `require "set"`
88
Lint/RedundantRequireStatement:

fixtures/sgml_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# frozen_string_literal: true
22

33
module SGMLHelper
4-
def phlex(component = Phlex::HTML, *, **, &)
5-
component.new(*, **).call do |e|
4+
def phlex(component = Phlex::HTML, *a, **k, &)
5+
component.new(*a, **k).call do |e|
66
e.instance_exec(&)
77
end
88
end

lib/phlex.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ module Phlex
2222

2323
Escape = ERB::Escape
2424
ATTRIBUTE_CACHE = FIFO.new
25-
SUPPORTS_FIBER_STORAGE = RUBY_ENGINE == "ruby"
2625
Null = Object.new.freeze
2726

2827
CACHED_FILES = Set.new

lib/phlex/kit.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def const_added(name)
6060
end
6161

6262
define_singleton_method(name) do |*args, **kwargs, &block|
63-
if (component = Fiber[:__phlex_component__])
63+
if (component = Thread.current[:__phlex_component__])
6464
component.instance_exec do
6565
constant = me.const_get(name)
6666
render(constant.new(*args, **kwargs), &block)

lib/phlex/sgml.rb

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def call(...)
1919

2020
# Create a new instance of the component.
2121
# @note The block will not be delegated {#initialize}. Instead, it will be sent to {#template} when rendering.
22-
def new(*, **, &block)
22+
def new(*a, **k, &block)
2323
if block
24-
object = super(*, **, &nil)
24+
object = super(*a, **k, &nil)
2525
object.instance_exec { @_content_block = block }
2626
object
2727
else
@@ -70,10 +70,7 @@ def call(buffer = +"", context: {}, view_context: nil, parent: nil, fragments: n
7070

7171
return "" unless render?
7272

73-
if !parent && Phlex::SUPPORTS_FIBER_STORAGE
74-
original_fiber_storage = Fiber[:__phlex_component__]
75-
Fiber[:__phlex_component__] = self
76-
end
73+
Thread.current[:__phlex_component__] = self
7774

7875
phlex_context.around_render do
7976
before_template(&block)
@@ -96,11 +93,10 @@ def call(buffer = +"", context: {}, view_context: nil, parent: nil, fragments: n
9693
end
9794

9895
unless parent
99-
if Phlex::SUPPORTS_FIBER_STORAGE
100-
Fiber[:__phlex_component__] = original_fiber_storage
101-
end
10296
buffer << phlex_context.buffer
10397
end
98+
ensure
99+
Thread.current[:__phlex_component__] = parent
104100
end
105101

106102
protected def __context__ = @_context
@@ -287,13 +283,13 @@ def __yield_content_with_no_args__
287283
nil
288284
end
289285

290-
def __yield_content_with_args__(*)
286+
def __yield_content_with_args__(*a)
291287
return unless block_given?
292288

293289
buffer = @_context.buffer
294290

295291
original_length = buffer.bytesize
296-
content = yield(*)
292+
content = yield(*a)
297293
__implicit_output__(content) if original_length == buffer.bytesize
298294

299295
nil

phlex.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
1212
spec.description = "A high-performance view framework optimised for fun."
1313
spec.homepage = "https://www.phlex.fun"
1414
spec.license = "MIT"
15-
spec.required_ruby_version = ">= 3.3.1"
15+
spec.required_ruby_version = ">= 3.2"
1616

1717
spec.metadata["homepage_uri"] = spec.homepage
1818
spec.metadata["source_code_uri"] = "https://github.com/phlex-ruby/phlex"

quickdraw/kit.test.rb

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@ def view_template
1111
end
1212
end
1313

14-
# This feature is only supported in Ruby 3.2 or later.
15-
if Phlex::SUPPORTS_FIBER_STORAGE
16-
# this test is flaky
17-
test "raises when you try to render a component outside of a rendering context" do
18-
expect { Components::SayHi() }.to_raise(RuntimeError) do |error|
19-
expect(error.message) == "You can't call `SayHi' outside of a Phlex rendering context."
20-
end
14+
test "raises when you try to render a component outside of a rendering context" do
15+
expect { Components::SayHi("Joel") }.to_raise(RuntimeError) do |error|
16+
expect(error.message) == "You can't call `SayHi' outside of a Phlex rendering context."
2117
end
18+
end
2219

23-
test "defines methods for its components" do
24-
expect(Example.new.call) == %(<article><h1>Hi Joel</h1><h1>Hi Joel</h1>Inside</article><article><h1>Hi Will</h1>Inside</article>)
25-
end
20+
test "defines methods for its components" do
21+
expect(Example.new.call) == %(<article><h1>Hi Joel</h1><h1>Hi Joel</h1>Inside</article><article><h1>Hi Will</h1>Inside</article>)
2622
end

0 commit comments

Comments
 (0)