Description
When using inky-rb with Ruby 3.4, deprecation warnings are emitted about frozen string literals.
Warning message
lib/inky/component_factory.rb:137: warning: literal string will be frozen in the future
Environment
- Ruby version: 3.4.x
- inky-rb version: 1.4.2.1
Root cause
In Ruby 3.4, string literals will be frozen by default in the future. The code at line 137 of lib/inky/component_factory.rb modifies a string literal in place, which triggers this deprecation warning.
Suggested fix
Replace in-place string modification with a new string allocation, for example:
- Use string interpolation instead of
prepend/<<
- Use
dup before modifying the string
- Use
+'' to create a mutable copy
This is similar to the fix applied in other gems like marcel (rails/marcel#140).
Description
When using inky-rb with Ruby 3.4, deprecation warnings are emitted about frozen string literals.
Warning message
Environment
Root cause
In Ruby 3.4, string literals will be frozen by default in the future. The code at line 137 of
lib/inky/component_factory.rbmodifies a string literal in place, which triggers this deprecation warning.Suggested fix
Replace in-place string modification with a new string allocation, for example:
prepend/<<dupbefore modifying the string+''to create a mutable copyThis is similar to the fix applied in other gems like marcel (rails/marcel#140).