-
Notifications
You must be signed in to change notification settings - Fork 216
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
Sort the available Perl version from the newest to the oldest. #565
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In the 'available' command it is annoying to have the available Perl list with the oldest versions on top of the screen and the last on the bottom. Users are going to install newer versions most of the time, so their first choices should be the newest version, and therefore they should be available on the top of list. The problem is oldest version did not follow a coherent version numbering, and therefore it is required to mangle the version number in order to make it comparable. In this implementation I transform a Perl version into a comparable string, so that for instance v5.24.1 becomes 50_024_001, and so it can be sorted quite easily with a Schwartzian-transform. In order to keep 'Perl' separated from 'cperl', the latter version number is translated into a string with no 10 factor multiplier on the major version number.
Created a method to sort the perl versions so that it is easier to refactor other subcommand to present the perl list ordered in the same way. Refactor the available_perls method to use the object oriented interface. Refactor the run_command_available method to return the sorted list of perl instances.
In order to achieve the ordering, the hash of installed perls have now a different key named 'comparable_version' that is the result of the comparable_perl_version method. The ordering of the @Result array is now performed on such version now and not on the orig_version. I left the name comparison untouched since I'm not sure it has to be inverted ($b vs $a).
In the production of a comparable string that represents the perl version, the cperl ones are incremented by 6, making them appearing with a major number of 5+6=11 (mnemonic for the project itself). Moreover, the string is now fully numeric and a numerical comparison has been adopted instead of string comparison.
Fixes #567 |
Merged
2 similar comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the 'available' command it is annoying to have the available Perl list
with the oldest versions on top of the screen and the last on the bottom.
Users are going to install newer versions most of the time, so their first
choices should be the newest version, and therefore they should be available
on the top of list.
The problem is oldest version did not follow a coherent version numbering,
and therefore it is required to mangle the version number in order to make
it comparable.
In this implementation I transform a Perl version into a comparable string,
so that for instance v5.24.1 becomes 50_024_001, and so it can be
sorted quite easily with a Schwartzian-transform.
In order to keep 'Perl' separated from 'cperl', the latter version number
is translated into a string with no 10 factor multiplier on the
major version number.