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-840) Add PDK::Util::PuppetVersion.from_module_metadata #461

Merged
merged 5 commits into from
Apr 5, 2018

Conversation

rodjek
Copy link
Contributor

@rodjek rodjek commented Mar 27, 2018

For use when selecting the default Puppet & Ruby version if the user doesn't specify one

@coveralls
Copy link

coveralls commented Mar 27, 2018

Coverage Status

Coverage increased (+0.08%) to 92.413% when pulling 1afd962 on rodjek:pdk-840 into 6832afb on puppetlabs:master.

@rodjek rodjek requested review from scotje and bmjen March 27, 2018 23:25
end

def scan_for_packaged_rubies
{ '2.4.3' => '2.4.0' }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The contents do not match the name of the function. What gives?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that was method was just moved around in the file, I was going to implement it in the next PR.

@@ -24,9 +24,22 @@
shared_context 'is a package install' do
before(:each) do
allow(PDK::Util).to receive(:package_install?).and_return(true)
allow(PDK::Util::RubyVersion).to receive(:versions).and_return('2.1.9' => '2.1.0', '2.4.3' => '2.4.0')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not match actual behaviour of this method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does now (that method was just a stub that was going to be implemented in the next PR).

PDK::Util::RubyVersion.use('2.1.9')
instance219 = PDK::Util::RubyVersion.instance
PDK::Util::RubyVersion.use('2.4.3')
instance243 = PDK::Util::RubyVersion.instance
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it could benefit from a .instance(version), instead of requiring two calls?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

def result(version)
{
gem_version: Gem::Version.new(version),
ruby_version: PDK::Util::RubyVersion.default_ruby_version,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a test of the default_ruby_version, too, or are you using it here only as a shortcut?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PDK::Util::RubyVersion.default_ruby_version will return the details of the running ruby version for non-packaged installs (gem or git clone), so I guess shortcut?

@@ -59,6 +59,36 @@ def from_pe_version(version_str)
find_gem_for(gem_version[:gem_version])
end

def from_module_metadata(metadata)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this parsing be located in the PDK::Module::Metadata class?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it make sense to have it in util, because it validates the metadata object itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could go in either really, but I opted to contain it with all the other puppet version finding logic for clarity (imho). I can move it to be a method of PDK::Module::Metadata if that's the group consensus though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved the validation logic into PDK::Module::Metadata and left the version finding logic in PDK::Util::PuppetVersion

@bmjen bmjen merged commit d459244 into puppetlabs:master Apr 5, 2018
@rodjek rodjek deleted the pdk-840 branch April 8, 2018 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants