phlex 2.4.0.beta2 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01002f30f11a82c8fce49ec63ce50cd3947c40a50d66c9fd02123c87a89f434c
4
- data.tar.gz: 0b40acfa20d82bf9c7e6bb68c8aeca447731d56436b2876750bfc669e9ba52a4
3
+ metadata.gz: d7204ba8933eeeba6ac827d6a8f965f8a69a5d63245538a882f579881a1a4f3a
4
+ data.tar.gz: c0d11845eb37d6a14cd6c750972a7d898a63ba7062ddcf14f2e024e5785c20fb
5
5
  SHA512:
6
- metadata.gz: 68d5a712386d7da44bb013ee956dde702d6e9f68e1cc237aac8a706a27cbff312dfd81a03405c9330f3109b87e7ff312711cf07a2e022ae1a256d984d60062cb
7
- data.tar.gz: 9dd429c7d0a3d0b962ca1d6b653abd79260134c743f6322e87e90d3af200b188695cf8a2e3a6588ba2d731f6227f0c1ef1bb45b1bfd37f9ae2d6b02764a93d3a
6
+ metadata.gz: 33797f2a30f72abc79d5161e4d3006e38023450c0b4eee03018c19e545307c8344e4e085aeabd590184550ec1f1505e6681e943e1af2ab1bf5faf7f0392abcc1
7
+ data.tar.gz: 6ffe9a663d9be2d87d73992640c803107f26671598e058c843db8786678eee53bab16605e046af350ec0c6c9c0f5c5a5e7fe2860402f43da9727e3d54eee5e7b
@@ -462,7 +462,7 @@ module Phlex::Compiler
462
462
  when Refract::AssocNode
463
463
  (Refract::StringNode === value.key || Refract::SymbolNode === value.key) && static_attribute_value_literal?(value.value)
464
464
  when Refract::CallNode
465
- if value in { receiver: Prism::ConstantReadNode[name: :Set]| Prism::ConstantPathNode[name: :Set, parent: nil], name: :[] }
465
+ if value in { receiver: Prism::ConstantReadNode[name: :Set] | Prism::ConstantPathNode[name: :Set, parent: nil], name: :[] }
466
466
  value.arguments.arguments.all? { |n| static_token_value_literal?(n) }
467
467
  else
468
468
  false
@@ -5,8 +5,6 @@ require "refract"
5
5
 
6
6
  module Phlex::Compiler
7
7
  MAP = {}
8
- DEPENDENCIES = {}
9
-
10
8
  Error = Class.new(StandardError)
11
9
 
12
10
  Concat = Data.define(:node) do
data/lib/phlex/fifo.rb CHANGED
@@ -36,7 +36,7 @@ class Phlex::FIFO
36
36
  @bytesize += value.bytesize
37
37
 
38
38
  while @bytesize > @max_bytesize
39
- k, v = @store.shift
39
+ _k, v = @store.shift
40
40
  @bytesize -= v[1].bytesize
41
41
  end
42
42
  end
data/lib/phlex/kit.rb CHANGED
@@ -63,8 +63,8 @@ module Phlex::Kit
63
63
  end
64
64
 
65
65
  define_singleton_method(name) do |*args, **kwargs, &block|
66
- component, fiber_id = Thread.current[:__phlex_component__]
67
- if (component && fiber_id == Fiber.current.object_id)
66
+ component = Thread.current[:__phlex_component__]
67
+ if component
68
68
  component.instance_exec do
69
69
  constant = me.const_get(name)
70
70
  render(constant.new(*args, **kwargs), &block)
@@ -53,7 +53,11 @@ module Phlex::SGML::Attributes
53
53
  when Phlex::SGML::SafeObject
54
54
  v.to_s.gsub('"', """)
55
55
  else
56
- raise Phlex::ArgumentError.new("Invalid attribute value for #{k}: #{v.inspect}.")
56
+ if v.respond_to?(:to_h)
57
+ generate_nested_attributes(v.to_h, "#{name}-", buffer)
58
+ else
59
+ raise Phlex::ArgumentError.new("Invalid attribute value for #{k}: #{v.inspect}.")
60
+ end
57
61
  end
58
62
 
59
63
  lower_name = name.downcase
data/lib/phlex/sgml.rb CHANGED
@@ -2,17 +2,6 @@
2
2
 
3
3
  # **Standard Generalized Markup Language** for behaviour common to {HTML} and {SVG}.
4
4
  class Phlex::SGML
5
- ERBCompiler = ERB::Compiler.new("<>").tap do |compiler|
6
- compiler.pre_cmd = [""]
7
- compiler.put_cmd = "@_state.buffer.<<"
8
- compiler.insert_cmd = "__implicit_output__"
9
- compiler.post_cmd = ["nil"]
10
-
11
- def compiler.add_insert_cmd(out, content)
12
- out.push("#{@insert_cmd}((#{content}))")
13
- end
14
- end
15
-
16
5
  include Phlex::Helpers
17
6
 
18
7
  class << self
@@ -32,40 +21,6 @@ class Phlex::SGML
32
21
  super
33
22
  end
34
23
  end
35
-
36
- def erb(method_name, erb = nil, locals: nil, &block)
37
- loc = caller_locations(1, 1)[0]
38
- path = loc.path.delete_suffix(".rb")
39
- file = loc.path
40
- line = loc.lineno - 1
41
-
42
- unless erb
43
- method_path = "#{path}/#{method_name}.html.erb"
44
- sidecar_path = "#{path}.html.erb"
45
-
46
- if File.exist?(method_path)
47
- erb = File.read(method_path)
48
- file = method_path
49
- line = 1
50
- elsif method_name == :view_template && File.exist?(sidecar_path)
51
- erb = File.read(sidecar_path)
52
- file = sidecar_path
53
- line = 1
54
- else
55
- raise Phlex::RuntimeError.new(<<~MESSAGE)
56
- No ERB template found for #{method_name}
57
- MESSAGE
58
- end
59
- end
60
-
61
- code, _enc = ERBCompiler.compile(erb)
62
-
63
- class_eval(<<~RUBY, file, line)
64
- def #{method_name} #{locals}
65
- #{code}
66
- end
67
- RUBY
68
- end
69
24
  end
70
25
 
71
26
  def view_template
@@ -105,7 +60,8 @@ class Phlex::SGML
105
60
 
106
61
  block ||= @_content_block
107
62
 
108
- Thread.current[:__phlex_component__] = [self, Fiber.current.object_id].freeze
63
+ previous_phlex_component = Thread.current[:__phlex_component__]
64
+ Thread.current[:__phlex_component__] = self
109
65
 
110
66
  state.around_render(self) do
111
67
  before_template(&block)
@@ -127,7 +83,7 @@ class Phlex::SGML
127
83
  after_template(&block)
128
84
  end
129
85
  ensure
130
- Thread.current[:__phlex_component__] = [parent, Fiber.current.object_id].freeze
86
+ Thread.current[:__phlex_component__] = previous_phlex_component
131
87
  end
132
88
 
133
89
  def context
data/lib/phlex/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Phlex
4
- VERSION = "2.4.0.beta2"
4
+ VERSION = "2.4.0"
5
5
  end
@@ -41,6 +41,8 @@ module RubyLsp
41
41
  RubyIndexer::Entry::BlockParameter.new(name: :content),
42
42
  ]),
43
43
  ], visibility: :public, comments: "Outputs a `<#{tag_name}>` tag.")
44
+ else
45
+ # no-op
44
46
  end
45
47
  end
46
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phlex
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0.beta2
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Drapper
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
101
  requirements: []
102
- rubygems_version: 3.6.7
102
+ rubygems_version: 4.0.3
103
103
  specification_version: 4
104
104
  summary: Object-oriented views in Ruby.
105
105
  test_files: []