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

Sort the available Perl version from the newest to the oldest. #565

Merged
merged 7 commits into from
Oct 10, 2017

Conversation

fluca1978
Copy link
Contributor

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.

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.
@fluca1978
Copy link
Contributor Author

Fixes #567

@fluca1978 fluca1978 mentioned this pull request Oct 5, 2017
@coveralls
Copy link

coveralls commented Oct 5, 2017

Coverage Status

Coverage decreased (-0.03%) to 84.584% when pulling a553732 on fluca1978:sort-availables into 7096e91 on gugod:develop.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 84.584% when pulling a553732 on fluca1978:sort-availables into 7096e91 on gugod:develop.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 84.584% when pulling a553732 on fluca1978:sort-availables into 7096e91 on gugod:develop.

@gugod gugod merged commit c9ec7a5 into gugod:develop Oct 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants