From dea8fc674cbb284685a227647445374310d55b9b Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Thu, 13 Feb 2025 18:08:42 +0100 Subject: [PATCH 1/3] Revert "Replace `OpenStruct` with `Struct`" This does not work: $ ruby -e 'Struct.new(:foo => "bar")' -e:1:in 'Struct.new': unknown keyword: :foo (ArgumentError) from -e:1:in '
' This reverts commit 1b5f99484b73cd91b2fb76037ad9db6db0be193e. --- lib/foreman/export/base.rb | 3 ++- spec/foreman/process_spec.rb | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/foreman/export/base.rb b/lib/foreman/export/base.rb index cec2676c..010529e6 100644 --- a/lib/foreman/export/base.rb +++ b/lib/foreman/export/base.rb @@ -1,4 +1,5 @@ require "foreman/export" +require "ostruct" require "pathname" require "shellwords" @@ -34,7 +35,7 @@ def template def @engine.procfile Foreman::Export::Base.warn_deprecation! @processes.map do |process| - Struct.new( + OpenStruct.new( :name => @names[process], :process => process ) diff --git a/spec/foreman/process_spec.rb b/spec/foreman/process_spec.rb index 58e21020..d449c956 100644 --- a/spec/foreman/process_spec.rb +++ b/spec/foreman/process_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' require 'foreman/process' +require 'ostruct' require 'timeout' require 'tmpdir' From 2aa65270363a1a49f708459b2419d992f89b0033 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Mon, 16 Sep 2024 11:05:53 +0200 Subject: [PATCH 2/3] Remove unused require in test The OpenStruct library was not used in that test. ostruct raises a warning about not being a shipped-and-bundled-with-Ruby standard library in Ruby 3.5.0. --- spec/foreman/process_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/foreman/process_spec.rb b/spec/foreman/process_spec.rb index d449c956..58e21020 100644 --- a/spec/foreman/process_spec.rb +++ b/spec/foreman/process_spec.rb @@ -1,6 +1,5 @@ require 'spec_helper' require 'foreman/process' -require 'ostruct' require 'timeout' require 'tmpdir' From 299c6f6accbad5308c1d4888b7bbf91328d183e6 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Mon, 16 Sep 2024 11:13:05 +0200 Subject: [PATCH 3/3] Avoid ostruct usage ...in order to avoid Ruby warnings in Ruby 3.5.0 about ostruct not being a built-in library. --- lib/foreman/export/base.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/foreman/export/base.rb b/lib/foreman/export/base.rb index 010529e6..2abb9c05 100644 --- a/lib/foreman/export/base.rb +++ b/lib/foreman/export/base.rb @@ -1,5 +1,4 @@ require "foreman/export" -require "ostruct" require "pathname" require "shellwords" @@ -13,6 +12,9 @@ class Foreman::Export::Base # deprecated attr_reader :port + # deprecated + ProcessStruct = Struct.new(:name, :process) + def initialize(location, engine, options={}) @location = location @engine = engine @@ -35,10 +37,7 @@ def template def @engine.procfile Foreman::Export::Base.warn_deprecation! @processes.map do |process| - OpenStruct.new( - :name => @names[process], - :process => process - ) + ProcessStruct.new(@names[process], process) end end end