Skip to content

Commit

Permalink
Fix with latest version of yard
Browse files Browse the repository at this point in the history
Monkey patching libraries is a bad idea. Latest version of yard changed
some internal details, which broke bolt.

A workaround was proposed in #3349 but the root cause was not addressed.

Detect if the version of YARD we are using provide the
`YARD::Logger::Severity` class (part of the new interal API) and if so
use its constants to set the log level, otherwise fallback to the
previous way of setting the log level using a Symbol.

While here, revert the workaround that was committed in #3349 and #3350.
  • Loading branch information
smortex committed Oct 31, 2024
1 parent ce9235a commit c34af86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 0 additions & 2 deletions acceptance/setup/common/pre-suite/010_install_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
# public_suffix for win requires Ruby version >= 2.6
# current Ruby 2.5.0 works with public_suffix version 4.0.7
on(bolt, powershell('gem install public_suffix -v 4.0.7'))
on(bolt, powershell('gem install yard -v 0.9.36'))
# current Ruby 2.5.0 works with puppet-strings 2.9.0
on(bolt, powershell('gem install puppet-strings -v 2.9.0'))
# net-ssh 7.x no longer supports ruby 2.5
Expand Down Expand Up @@ -77,7 +76,6 @@
on(bolt, 'gem install public_suffix -v 5.1.1 --no-document')
on(bolt, 'gem install CFPropertyList -v 3.0.6 --no-document')
on(bolt, 'gem install fast_gettext -v 2.4.0')
on(bolt, 'gem install yard -v 0.9.36 --no-document')
# System ruby for osx12 is 2.6, which can only manage puppet-strings 2.9.0
on(bolt, 'gem install puppet-strings -v 2.9.0 --no-document')
# semantic puppet no longer supports ruby < 2.7
Expand Down
7 changes: 6 additions & 1 deletion lib/bolt/pal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,12 @@ def get_plan_info(plan_name, with_mtime: false)
require 'puppet-strings'
require 'puppet-strings/yard'
PuppetStrings::Yard.setup!
YARD::Logger.instance.level = :error
if YARD::Logger.const_defined?(:Severity)
YARD::Logger.instance.level = YARD::Logger::Severity::ERROR
else
# Backward compatility for YARD < 0.9.37
YARD::Logger.instance.level = :error
end
YARD.parse(pp_path)

plan = YARD::Registry.at("puppet_plans::#{plan_name}")
Expand Down

0 comments on commit c34af86

Please sign in to comment.