Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PDK-1365) Use dynamic ruby detection for default ruby instance #678

Merged
merged 1 commit into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions lib/pdk/util/ruby_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,19 @@ def scan_for_packaged_rubies
end

def default_ruby_version
# For now, the packaged versions will be using default of 2.4.5
# FIXME: make this dynamic
return '2.4.5' if PDK::Util.package_install?

# TODO: may not be a safe assumption that highest available version should be default
latest_ruby_version
@default_ruby_version ||= if PDK::Util.package_install?
# Default to the ruby that supports the latest puppet gem. If you wish to default to a
# specific Puppet Gem version use the following example;
#
# PDK::Util::PuppetVersion.find_gem_for('5.5.10')[:ruby_version]
#
PDK::Util::PuppetVersion.latest_available[:ruby_version]
else
# TODO: may not be a safe assumption that highest available version should be default
# WARNING Do NOT use PDK::Util::PuppetVersion.*** methods as it can recurse into this
rodjek marked this conversation as resolved.
Show resolved Hide resolved
# method and cause Stack Level Too Deep errors.
latest_ruby_version
end
end

def latest_ruby_version
Expand Down
1 change: 1 addition & 0 deletions spec/support/packaged_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
allow(File).to receive(:exist?).with(%r{bundle(\.bat)?$}).and_return(true)
allow(PDK::Util).to receive(:package_cachedir).and_return(package_cachedir)
allow(PDK::Util::RubyVersion).to receive(:versions).and_return('2.4.4' => '2.4.0')
allow(PDK::Util::RubyVersion).to receive(:default_ruby_version).and_return('2.4.4')
end
end

Expand Down