Suggestion: Add cooldown support to Gem.latest_version_for
#9785
eliotsykes
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Would support for a cooldown argument on
Gem.latest_version_for(or similar) be welcome? For example:The reason for this suggestion relates to brakeman's
--ensure-latestoption. This option can accept a cooldown period and checks if the installed version is up-to-date.The command for a 10-day cooldown period is
brakeman --ensure-latest 10.To support this, brakeman uses
Gem.latest_spec_for('brakeman')and manually checks the release date (source forBrakeman.ensure_latest)This is a little buggy in some scenarios. For example assume:
Running
brakeman --ensure-latest 10will not tell the user to update. The correct behaviour would be to tell the user to update to98.0.0.Another problem is if a larger cooldown is used, say 90 days, then it could be that
brakeman --ensure-latest 90never reports a newer version available, if a new brakeman version is released every 89 days (or less) forever. (This is why brakeman currently limits the max cooldown to 15 days to mitigate this scenario).This is a known bug in brakeman and is unlikely to be fixed with the current rubygems API as it would require brakeman being too tightly coupled to rubygems internals.
However, if rubygems supported a public method accepting the gem name and the cooldown period, then this could be used by brakeman and presumably other projects which have built-in version checks.
Related brakeman discussion: presidentbeef/brakeman#2036
All reactions